npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

myfxbook-api-client

v1.0.4

Published

Myfxbook API client for Node.js

Downloads

10

Readme

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: '[email protected]', password: 'my_password' });

es6 import:

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

const client = new MyfxbookApi({ email: '[email protected]', password: 'my_password' });

Methods

getMyAccounts()

Get list of all trading accounts

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

const client = new MyfxbookApi({ email: '[email protected]', password: 'my_password' });

client
  .getMyAccounts()
  .then(data => {
    console.log(data.accounts);
  })
  .catch(error => {
    console.log('error', error);
  });
{
  "error": false,
  "message": "",
  "accounts": [
    {
      "id": 12345,
      "name": "Holy Grail",
      "description": "Super duper MA+CCI trading system.",
      "accountId": 1013230,
      "gain": 8.92,
      "absGain": 8.92,
      "daily": "0.04",
      "monthly": "1.25",
      "withdrawals": 0,
      "deposits": 10000,
      "interest": 11.1,
      "profit": 892.45,
      "balance": 10892.45,
      "drawdown": 53.53,
      "equity": 10892.45,
      "equityPercent": 100,
      "demo": true,
      "lastUpdateDate": "03/01/2010 10:14",
      "creationDate": "08/06/2009 08:13",
      "firstTradeDate": "04/21/2008 12:18",
      "tracking": 21,
      "views": 549,
      "commission": 0,
      "currency": "USD",
      "profitFactor": 0.3,
      "pips": 81.2,
      "invitationUrl": "http://www.myfxbook.com/members/john101/anyone/347/SDa45X5TSkdIsXg8",
      "server": {
        "name": "Alpari UK"
      }
    }
  ]
}

getWatchedAccounts()

Get list of all watched accounts

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

const client = new MyfxbookApi({ email: '[email protected]', password: 'my_password' });

client
  .getWatchedAccounts()
  .then(data => {
    console.log(data.accounts);
  })
  .catch(error => {
    console.log('error', error);
  });
{
  "error": false,
  "message": "",
  "accounts": [
    {
      "name": "Holy Grail",
      "gain": 8.92,
      "drawdown": 53.53,
      "demo": true,
      "change": 1.53,
    }
  ]
}

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: '[email protected]', password: 'my_password' });

client
  .getOpenOrders(12345)
  .then(data => {
    console.log(data.openOrders);
  })
  .catch(error => {
    console.log('error', error);
  });
{
 "error": false,
 "message": "",
 "openOrders": [
  {
   "openTime": "03/01/2010 13:52",
   "symbol": "GBPUSD",
   "action": "Sell Limit",
   "sizing": {
    "type": "lots",
    "value": "0.08"
   },
   "openPrice": 1.4932,
   "tp": 1.4882,
   "sl": 0,
   "comment":"Best trade ever"
  }
 ]
}

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: '[email protected]', password: 'my_password' });

client
  .getOpenTrades(12345)
  .then(data => {
    console.log(data.openTrades);
  })
  .catch(error => {
    console.log('error', error);
  });
{
 "error": false,
 "message": "",
 "openTrades": [
    {
      "openTime": "03/01/2010 13:39",
      "symbol": "GBPUSD",
      "action": "Sell",
      "sizing":    {
        "type": "lots",
        "value": "0.01"
      },
      "openPrice": 1.4802,
      "tp": 1.4832,
      "sl": 0,
      "comment":"best trade ever",
      "profit": -10.8,
      "pips": -108,
      "swap": 0,
      "magic": 24129962
    }
  ]
}

getHistory(id)

Get history of all trades for a given account

Arguments:

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

const client = new MyfxbookApi({ email: '[email protected]', password: 'my_password' });

client
  .getHistory(12345)
  .then(data => {
    console.log(data.history);
  })
  .catch(error => {
    console.log('error', error)}
  );
{
 "error": false,
 "message": "",
 "history": [
  {
   "openTime": "03/01/2010 14:13",
   "closeTime": "03/01/2010 15:26",
   "symbol": "GBPUSD",
   "action": "Buy Limit",
   "sizing": {
    "type": "lots",
    "value": "0.04"
   },
   "openPrice": 1.4831,
   "closePrice": 1.4934,
   "tp": 1.4881,
   "sl": 0,
   "comment":"best trade ever",
   "pips": 0,
   "profit": 0,
   "interest": 12.1,
   "commission": 0
  }
 ]
}

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: '[email protected]', password: 'my_password' });

client
  .getDailyGain(12345, '2019-02-01', '2019-02-07')
  .then(data => {
    console.log(data.dailyGain);
  })
  .catch(error => {
    console.log('error', error);
  });
{
 "error": false,
 "message": "",
 "dailyGain": [
  [{
   "date": "02/01/2010",
   "value": 0.07,
   "profit": 0.03
  }]
 ]
}

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: '[email protected]', password: 'my_password' });

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

getCommunityOutlook()

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

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

const client = new MyfxbookApi({ email: '[email protected]', password: 'my_password' });

client
  .getCommunityOutlook()
  .then(data => {
    console.log(data.symbols);
    console.log(data.general);
  })
  .catch(error => {
    console.log('error', error);
  });
{
 "error": false,
 "message": "",
 "symbols": [
  {
   "name": "EURUSD",
   "shortPercentage": 55,
   "longPercentage": 44,
   "shortVolume": 1142.58,
   "longVolume": 905.47,
   "longPositions": 2932,
   "shortPositions": 3888,
   "totalPositions": 2048,
   "avgShortPrice":1.3808,
   "avgLongPrice":1.4097
  }
 ],
 "general": {
  "demoAccountsPercentage": 43,
  "realAccountsPercentage": 56,
  "profitablePercentage": 54,
  "nonProfitablePercentage": 45,
  "fundsWon": "6,819,251.63",
  "fundsLost": "-8,740,646.15",
  "averageDeposit": "21,740.16",
  "averageAccountProfit": "4,127.88",
  "averageAccountLoss": "-5,290.95",
  "totalFunds": "35,914,737.56"
 }
}

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: '[email protected]', password: 'my_password' });

client
  .getCommunityOutlookByCountry('eurusd')
  .then(data => {
    console.log(data.countries);
  })
  .catch(error => {
    console.log('error', error);
  });
{
 "error": false,
 "message": "",
 "countries": [
  {
   "name": "GERMANY",
   "code": "DE",
   "longVolume": 13.71,
   "shortVolume": 35.76,
   "longPositions": 111,
   "shortPositions": 489
  }
 ]
}

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: '[email protected]', password: 'my_password' });

client
  .getDailyData(12345, '2019-02-01', '2019-02-07')
  .then(data => {
    console.log(data.dataDaily);
  })
  .catch(error => {
    console.log('error', error);
  });
{
 "error": false,
 "message": "",
 "dataDaily":[
  [{
   "date": "02/01/2010",
   "balance": 25083.56,
   "pips": 83.30,
   "lots": 0.41,
   "floatingPL": -500.00,
   "profit": 84.7400,
   "growthEquity": -4.15,
   "floatingPips": 1.00
  }]
 ]
}