1.0.4 • Published 5 years ago

myfxbook-api-client v1.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

A Node.js client for working with Myfxbook API - https://www.myfxbook.com/api

Installation

via npm:

npm install myfxbook-api-client --save

via yarn:

yarn add myfxbook-api-client

Usage

email and password are credentials to your myfxbook.com account

require:

const { MyfxbookApi } = require('myfxbook-api-client');

const client = new MyfxbookApi({ email: 'my@email.com', password: 'my_password' });

es6 import:

import { MyfxbookApi } from 'myfxbook-api-client';

const client = new MyfxbookApi({ email: 'my@email.com', password: 'my_password' });

Methods

getMyAccounts()

Get list of all trading accounts

const { MyfxbookApi } = require('myfxbook-api-client');

const client = new MyfxbookApi({ email: 'my@email.com', password: 'my_password' });

client
  .getMyAccounts()
  .then(data => {
    console.log(data.accounts);
  })
  .catch(error => {
    console.log('error', error);
  });

getWatchedAccounts()

Get list of all watched accounts

const { MyfxbookApi } = require('myfxbook-api-client');

const client = new MyfxbookApi({ email: 'my@email.com', password: 'my_password' });

client
  .getWatchedAccounts()
  .then(data => {
    console.log(data.accounts);
  })
  .catch(error => {
    console.log('error', error);
  });

getOpenOrders(id)

Get all open orders for a given account

Arguments:

  • id - id of a trading account
const { MyfxbookApi } = require('myfxbook-api-client');

const client = new MyfxbookApi({ email: 'my@email.com', password: 'my_password' });

client
  .getOpenOrders(12345)
  .then(data => {
    console.log(data.openOrders);
  })
  .catch(error => {
    console.log('error', error);
  });

getOpenTrades(id)

Get all open trades for a given account

Arguments:

  • id - id of a trading account
const { MyfxbookApi } = require('myfxbook-api-client');

const client = new MyfxbookApi({ email: 'my@email.com', password: 'my_password' });

client
  .getOpenTrades(12345)
  .then(data => {
    console.log(data.openTrades);
  })
  .catch(error => {
    console.log('error', error);
  });
</p>
</details>

---

### **`getHistory(id)`**

Get history of all trades for a given account

Arguments:

- `id` - _id of a trading account_

```javascript
const { MyfxbookApi } = require('myfxbook-api-client');

const client = new MyfxbookApi({ email: 'my@email.com', password: 'my_password' });

client
  .getHistory(12345)
  .then(data => {
    console.log(data.history);
  })
  .catch(error => {
    console.log('error', error)}
  );

getDailyGain(id, start, end)

Get daily breakdown of all gains for a given account within time range

Arguments:

  • id - id of a trading account
  • start - start date, format : yyyy-MM-dd
  • end - end date, format : yyyy-MM-dd
const { MyfxbookApi } = require('myfxbook-api-client');

const client = new MyfxbookApi({ email: 'my@email.com', password: 'my_password' });

client
  .getDailyGain(12345, '2019-02-01', '2019-02-07')
  .then(data => {
    console.log(data.dailyGain);
  })
  .catch(error => {
    console.log('error', error);
  });

getGain(id, start, end)

Get total gain for a given account within time range

Arguments:

  • id - id of a trading account
  • start - start date, format : yyyy-MM-dd
  • end - end date, format : yyyy-MM-dd
const { MyfxbookApi } = require('myfxbook-api-client');

const client = new MyfxbookApi({ email: 'my@email.com', password: 'my_password' });

client
  .getGain(12345, '2019-02-01', '2019-02-07')
  .then(data => {
    console.log(data.value);
  })
  .catch(error => {
    console.log('error', error);
  });

getCommunityOutlook()

Get Myfxbook Community Outlook data (https://www.myfxbook.com/community/outlook)

const { MyfxbookApi } = require('myfxbook-api-client');

const client = new MyfxbookApi({ email: 'my@email.com', password: 'my_password' });

client
  .getCommunityOutlook()
  .then(data => {
    console.log(data.symbols);
    console.log(data.general);
  })
  .catch(error => {
    console.log('error', error);
  });

getCommunityOutlookByCountry(symbol)

Get community outlook data broken down by a country for provided symbol

Arguments:

  • symbol - a trading instrument (currency pair)
const { MyfxbookApi } = require('myfxbook-api-client');

const client = new MyfxbookApi({ email: 'my@email.com', password: 'my_password' });

client
  .getCommunityOutlookByCountry('eurusd')
  .then(data => {
    console.log(data.countries);
  })
  .catch(error => {
    console.log('error', error);
  });

getDailyData(id, start, end)

Get daily breakdown of all account data within time range

Arguments:

  • id - id of a trading account
  • start - start date, format : yyyy-MM-dd
  • end - end date, format : yyyy-MM-dd
const { MyfxbookApi } = require('myfxbook-api-client');

const client = new MyfxbookApi({ email: 'my@email.com', password: 'my_password' });

client
  .getDailyData(12345, '2019-02-01', '2019-02-07')
  .then(data => {
    console.log(data.dataDaily);
  })
  .catch(error => {
    console.log('error', error);
  });
1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago