Skip to content

Commit

Permalink
Merge e4230b4 into 2fd8ccf
Browse files Browse the repository at this point in the history
  • Loading branch information
andredezzy committed May 13, 2021
2 parents 2fd8ccf + e4230b4 commit da0615e
Show file tree
Hide file tree
Showing 60 changed files with 3,009 additions and 116 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
],
"alphabetize": { "order": "asc", "ignoreCase": true }
}
],
"@typescript-eslint/no-unused-vars": [
"error",
{ "varsIgnorePattern": "[iI]gnored" }
]
}
}
14 changes: 10 additions & 4 deletions examples/iqoption/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ This folder contains Hemes for IQ Option examples for different types of actions
them were tested and may work properly. You can also customize them for your
needs.

| Name | Link |
| ----------- | ------------------------------------------------------------------------- |
| Log in | [JavaScript](./logIn.js) - [TypeScript](./typescript/logIn.tsx) |
| Get profile | [JavaScript](./getProfile.js) - [TypeScript](./typescript/getProfile.tsx) |
| Name | Link |
| ----------------------- | ----------------------------------------------------------------------------------------------- |
| Log in | [JavaScript](./logIn.js) - [TypeScript](./typescript/logIn.tsx) |
| Get initialization data | [JavaScript](./getInitializationData.js) - [TypeScript](./typescript/getInitializationData.tsx) |
| Get profile | [JavaScript](./getProfile.js) - [TypeScript](./typescript/getProfile.tsx) |
| Get underlying list | [JavaScript](./getUnderlyingList.js) - [TypeScript](./typescript/getUnderlyingList.tsx) |
| Get instruments | [JavaScript](./getInstruments.js) - [TypeScript](./typescript/getInstruments.tsx) |
| Place digital option | [JavaScript](./placeDigitalOption.js) - [TypeScript](./typescript/placeDigitalOption.tsx) |
| Open binary option | [JavaScript](./openBinaryOption.js) - [TypeScript](./typescript/openBinaryOption.tsx) |
| Get position | [JavaScript](./getPosition.js) - [TypeScript](./typescript/getPosition.tsx) |

## Add an example

Expand Down
23 changes: 23 additions & 0 deletions examples/iqoption/getActiveProfit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import '../../loadEnv'

import { Hemes } from '@hemes/core'
import { IQOptionProvider } from '@hemes/iqoption'

async function run() {
const hemes = new Hemes(IQOptionProvider).getProvider()

const account = await hemes.logIn({
email: String(process.env.TEST_IQOPTION_ACCOUNT_EMAIL),
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

const profit = await account.getActiveProfit(
'EURUSD-OTC',
'binary-option',
'm1'
)

console.log('\n', 'Active profit:', profit, '\n')
}

run()
26 changes: 26 additions & 0 deletions examples/iqoption/getPosition.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import '../../loadEnv'

import { Hemes } from '@hemes/core'
import { IQOptionProvider } from '@hemes/iqoption'

async function run() {
const hemes = new Hemes(IQOptionProvider).getProvider()

const account = await hemes.logIn({
email: String(process.env.TEST_IQOPTION_ACCOUNT_EMAIL),
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

const placedPosition = await account.placeDigitalOption({
active: 'EURUSD',
direction: 'call',
expiration_period: 'm1',
price: 1,
})

const position = await account.getPosition(placedPosition.id)

console.log('\n', 'Position:', JSON.stringify(position), '\n')
}

run()
6 changes: 2 additions & 4 deletions examples/iqoption/getProfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../../loadEnv'

import { Hemes, sleep } from '@hemes/core'
import { Hemes } from '@hemes/core'
import { IQOptionProvider } from '@hemes/iqoption'

async function run() {
Expand All @@ -11,11 +11,9 @@ async function run() {
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

await sleep(5000)

const profile = await account.getProfile()

console.log('Has received profile ->', !!profile)
console.log('\n', 'Has received profile:', !!profile, '\n')
}

run()
23 changes: 23 additions & 0 deletions examples/iqoption/isActiveEnabled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import '../../loadEnv'

import { Hemes } from '@hemes/core'
import { IQOptionProvider } from '@hemes/iqoption'

async function run() {
const hemes = new Hemes(IQOptionProvider).getProvider()

const account = await hemes.logIn({
email: String(process.env.TEST_IQOPTION_ACCOUNT_EMAIL),
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

const isEnabled = await account.isActiveEnabled(
'EURUSD',
'binary-option',
'm1'
)

console.log('\n', 'Is active enabled:', isEnabled, '\n')
}

run()
24 changes: 24 additions & 0 deletions examples/iqoption/openBinaryOption.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import '../../loadEnv'

import { Hemes } from '@hemes/core'
import { IQOptionProvider } from '@hemes/iqoption'

async function run() {
const hemes = new Hemes(IQOptionProvider).getProvider()

const account = await hemes.logIn({
email: String(process.env.TEST_IQOPTION_ACCOUNT_EMAIL),
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

const position = await account.openBinaryOption({
active: 'EURUSD',
direction: 'call',
expiration_period: 'm5',
price: 1,
})

console.log('\n', 'Position:', JSON.stringify(position), '\n')
}

run()
24 changes: 24 additions & 0 deletions examples/iqoption/placeDigitalOption.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import '../../loadEnv'

import { Hemes } from '@hemes/core'
import { IQOptionProvider } from '@hemes/iqoption'

async function run() {
const hemes = new Hemes(IQOptionProvider).getProvider()

const account = await hemes.logIn({
email: String(process.env.TEST_IQOPTION_ACCOUNT_EMAIL),
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

const position = await account.placeDigitalOption({
active: 'EURUSD',
direction: 'call',
expiration_period: 'm15',
price: 1,
})

console.log('\n', 'Position:', JSON.stringify(position), '\n')
}

run()
23 changes: 23 additions & 0 deletions examples/iqoption/setBalanceMode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import '../../loadEnv'

import { Hemes } from '@hemes/core'
import { IQOptionProvider } from '@hemes/iqoption'

async function run() {
const hemes = new Hemes(IQOptionProvider).getProvider()

const account = await hemes.logIn({
email: String(process.env.TEST_IQOPTION_ACCOUNT_EMAIL),
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

await account.setBalanceMode('practice')

const profile = await account.getProfile()

console.log('\n', 'Balance:', profile.balance)
console.log('Balance ID:', profile.balance_id, profile.balance_type)
console.log('Balance type:', profile.balance_type, '\n')
}

run()
23 changes: 23 additions & 0 deletions examples/iqoption/typescript/getActiveProfit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import '../../loadEnv'

import { Hemes } from '@hemes/core'
import { IQOptionProvider, BaseIQOptionProvider } from '@hemes/iqoption'

async function run() {
const hemes = new Hemes(IQOptionProvider).getProvider<BaseIQOptionProvider>()

const account = await hemes.logIn({
email: String(process.env.TEST_IQOPTION_ACCOUNT_EMAIL),
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

const profit = await account.getActiveProfit(
'EURUSD-OTC',
'binary-option',
'm1'
)

console.log('\n', 'Active profit:', profit, '\n')
}

run()
28 changes: 28 additions & 0 deletions examples/iqoption/typescript/getPosition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import '../../loadEnv'

import { Hemes, sleep } from '@hemes/core'
import { IQOptionProvider, BaseIQOptionProvider } from '@hemes/iqoption'

async function run() {
const hemes = new Hemes(IQOptionProvider).getProvider<BaseIQOptionProvider>()

const account = await hemes.logIn({
email: String(process.env.TEST_IQOPTION_ACCOUNT_EMAIL),
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

const placedPosition = await account.placeDigitalOption({
active: 'EURUSD',
direction: 'call',
expiration_period: 'm1',
price: 1,
})

await sleep(100000)

const position = await account.getPosition(placedPosition.id)

console.log('\n', 'Position:', JSON.stringify(position), '\n')
}

run()
6 changes: 2 additions & 4 deletions examples/iqoption/typescript/getProfile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../../loadEnv'

import { Hemes, sleep } from '@hemes/core'
import { Hemes } from '@hemes/core'
import { IQOptionProvider, BaseIQOptionProvider } from '@hemes/iqoption'

async function run() {
Expand All @@ -11,11 +11,9 @@ async function run() {
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

await sleep(5000)

const profile = await account.getProfile()

console.log('Has received profile ->', !!profile)
console.log('\n', 'Has received profile:', !!profile, '\n')
}

run()
23 changes: 23 additions & 0 deletions examples/iqoption/typescript/isActiveEnabled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import '../../loadEnv'

import { Hemes } from '@hemes/core'
import { IQOptionProvider, BaseIQOptionProvider } from '@hemes/iqoption'

async function run() {
const hemes = new Hemes(IQOptionProvider).getProvider<BaseIQOptionProvider>()

const account = await hemes.logIn({
email: String(process.env.TEST_IQOPTION_ACCOUNT_EMAIL),
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

const isEnabled = await account.isActiveEnabled(
'EURUSD',
'binary-option',
'm1'
)

console.log('\n', 'Is active enabled:', isEnabled, '\n')
}

run()
24 changes: 24 additions & 0 deletions examples/iqoption/typescript/openBinaryOption.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import '../../loadEnv'

import { Hemes } from '@hemes/core'
import { IQOptionProvider, BaseIQOptionProvider } from '@hemes/iqoption'

async function run() {
const hemes = new Hemes(IQOptionProvider).getProvider<BaseIQOptionProvider>()

const account = await hemes.logIn({
email: String(process.env.TEST_IQOPTION_ACCOUNT_EMAIL),
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

const position = await account.openBinaryOption({
active: 'EURUSD',
direction: 'call',
expiration_period: 'm5',
price: 1,
})

console.log('\n', 'Position:', JSON.stringify(position), '\n')
}

run()
24 changes: 24 additions & 0 deletions examples/iqoption/typescript/placeDigitalOption.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import '../../loadEnv'

import { Hemes } from '@hemes/core'
import { IQOptionProvider, BaseIQOptionProvider } from '@hemes/iqoption'

async function run() {
const hemes = new Hemes(IQOptionProvider).getProvider<BaseIQOptionProvider>()

const account = await hemes.logIn({
email: String(process.env.TEST_IQOPTION_ACCOUNT_EMAIL),
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

const position = await account.placeDigitalOption({
active: 'EURUSD',
direction: 'call',
expiration_period: 'm15',
price: 1,
})

console.log('\n', 'Position:', JSON.stringify(position), '\n')
}

run()
23 changes: 23 additions & 0 deletions examples/iqoption/typescript/setBalanceMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import '../../loadEnv'

import { Hemes } from '@hemes/core'
import { IQOptionProvider, BaseIQOptionProvider } from '@hemes/iqoption'

async function run() {
const hemes = new Hemes(IQOptionProvider).getProvider<BaseIQOptionProvider>()

const account = await hemes.logIn({
email: String(process.env.TEST_IQOPTION_ACCOUNT_EMAIL),
password: String(process.env.TEST_IQOPTION_ACCOUNT_PASSWORD),
})

await account.setBalanceMode('practice')

const profile = await account.getProfile()

console.log('\n', 'Balance:', profile.balance)
console.log('Balance ID:', profile.balance_id, profile.balance_type)
console.log('Balance type:', profile.balance_type, '\n')
}

run()
3 changes: 2 additions & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"update": "cd .. && yarn --force && yarn build && cd examples && yarn --force",
"prestart": "yarn update",
"start": "yarn ts-node"
"start": "yarn ts-node",
"start-noupdate": "yarn ts-node"
},
"dependencies": {
"@hemes/core": "../packages/core",
Expand Down
Loading

0 comments on commit da0615e

Please sign in to comment.