Coder Social home page Coder Social logo

iqoption-js's Introduction

Install ejtraderIQ

npm install ejtraderiq
const IQOption = require("ejtraderiq")
const {log, sleep} = require("ejtraderiq/utils")

const martinGales = [
	2.22,
	4.88,
	11.90,
	29.05,
	70.89,
	172.97,
	422.05,
	1029.81
]
const candleSize = 60 // MH1 = 60, MH5 = 300
const type = "BINARY" // BINARY OR DIGITAL
const accountType = "PRACTICE" // REAL OR PRACTICE
const active = "EURUSD"

let opering = false

async function operate(API) {
	try {
		opering = true
		log("===============================")

		const candles = await API.getCandles(active, candleSize, 3, Date.now())
		const binaryCandles = candles.map(({open, close}) => open >= close ? 0 : 1)
		const direction = binaryCandles.filter(Boolean).length >= 2 ? "PUT" : "CALL"

		log(`ULTIMAS VELAS: ${binaryCandles}`)
		log(`DIREÇAO: ${direction}`)

		for (let martinGale of martinGales) {
			const martinGaleNumber = martinGales.indexOf(martinGale)
			const isMartinGale = martinGale == martinGales[0]
			martinGale = martinGale.toFixed(2)

			log(isMartinGale ? `ENTRADA: R$ ${martinGale}` : `MG${martinGaleNumber}: R$ ${martinGale}`, false)
			const order = await API.trade({
				active,
				action: direction,
				amount: martinGale,
				type,
				duration: candleSize / 60
			})
			await order.close()
			const result = order.quote.win ? "WIN" : "LOSS"
			const balance = await API.getBalance(accountType)
			
			console.log("", result)
			console.log("", balance.amount)
			if (result == "WIN") break
		}

		opering = false
	} catch (error) {
		console.log(error)
	}
}


IQOption({
	email: "[email protected]",
	password: "mypassword",
}).then(async API => {
	API.accountType(accountType) // REAL OR PRACTICE
	

	const initInterval = setInterval(() => {
		const date = new Date(API.serverTimestamp)
		const nowMinutes = date.getMinutes()
		const nowSeconds = date.getSeconds()
		
		
		if (nowMinutes % 5 == 0) { // delay prevent (nowMinutes % 5 == 4 && nowMinutes % 3 == 2) && nowSeconds == 59
			operate(API)
			setInterval(() => {
				if (!opering) operate(API)
			}, (candleSize * 5) * 1000)
			return clearInterval(initInterval)
		}

		console.clear()
		log(`Aguardando entrada...`)
	}, 20)
}).catch(error => {
	log(error.message)
})

iqoption-js's People

Contributors

sgzuis avatar traderpedroso avatar ejtraderplugins avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.