Home

Awesome

ARGO-TRADING PLUGIN SEED

NPM version

This project is a plugin skeleton for Argo, the open source trading platform, connecting directly with OANDA through the powerful API.

You can use it to quickly bootstrap your plugin, especially for your trading strategies.

The seed plugin doesn't do much, just shows how to wire the plugin with Argo.

Getting Started

To get you started you can simply clone the argo-trading-plugin-seed repository and install the dependencies:

Prerequisites

You need git to clone the argo-trading-plugin-seed repository.

We also use a number of Node.js tools to initialize and test argo-trading-plugin-seed.

Clone argo-trading-plugin-seed

Clone the argo-trading-plugin-seed repository using git:

git clone https://github.com/albertosantini/argo-trading-plugin-seed.git
cd argo-trading-plugin-seed

If you only want to have a copy of the repository, without the history, then just delete the .git folder after cloning and then re-initialize the repository:

git clone --depth=1 https://github.com/albertosantini/argo-trading-plugin-seed.git <your-project-name>
cd <your-project-name>
rm -rf .git
git init
git remote add origin https://github.com/myname/<your-project-name>

The depth=1 tells git to only pull down one commit worth of historical data.

Install Dependencies

We get the tools we depend upon via npm, the node package manager.

npm install

node_modules contains the npm packages for the tools we need.

Run the plugin

After starting Argo, the simplest way to start the seed plugin is:

npm start

How to customize the plugin

In lib/custom folder there are the files implementing the name and the callbacks of the plugin:

module.exports = "seed";
function onheartbeat(beat) // beat.time
function onload(name) // plugin name
function ontick(tick)
    // tick.time
    // tick.instrument
    // tick.bid
    // tick.ask
function onbar(bar)
    // bar.time
    // bar.instrument
    // bar.granularity
    // bar.openMid
    // bar.highMid
    // bar.lowMid
    // bar.closeMid
    // bar.volume
function ontransaction(transaction)
    // transaction.id
    // transaction.accountId
    // transaction.time
    // transaction.type
    // transaction.instrument
    // transaction.side
    // transaction.units
    // transaction.price
    // transaction.lowerBound
    // transaction.upperBound
    // transaction.takeProfitPrice
    // transaction.stopLossPrice
    // transaction.trailingStopLossDistance
    // transaction.pl
    // transaction.interest
    // transaction.accountBalance
    // transaction.tradeId
    // transaction.orderId
    // transaction.tradeOpened
    // transaction.tradeReduced
function onunload(name) // plugin name

You need to fill the corresponding functions in those files.

Utils

Inside the callbacks, you may fill orders or request the historical bars.

order.fillOrder(order, callback)

var orderUtil = require("../util/order");

orderUtil.fillOrder({
    instrument: "EUR_USD",
    type: "market",
    side: "buy",
    units: 100
}, console.log);

See OANDA order endpoints for more details about input and output parameters.

bars.getHistBars(barOptions, callback)

var barsUtil = require("../util/bars");

barsUtil.getHistBars({
    instrument: "EUR_USD",
    granularity: "M5"
}, console.log);

Response example:

[ { time: '2015-07-24T12:55:00.000000Z'
    openMid: 0.7285,
    highMid: 0.7285,
    lowMid: 0.7285,
    closeMid: 0.7285,
    volume: 1,
    complete: false },
  { time: '2015-07-24T12:50:00.000000Z',
    openMid: 0.72806,
    highMid: 0.728535,
    lowMid: 0.72797,
    closeMid: 0.728535,
    volume: 42,
    complete: true },
//  ...

Notice bars[0] is the most recent bar, usually not completed.

See OANDA pricing endpoints for more details about input and output parameters.

orderBook.getOrderBook(orderBookOptions, callback)

var orderBook = require("../util/orderbook");

orderBook.getOrderBook({
    instrument: "EUR_USD",
    period: "3600"
}, console.log);

Response example:

{
  "1382042401": {
    "price_points": {
      "1.359": {
        "os": 0.638,
        "ps": 0.2173,
        "pl": 0.67,
        "ol": 0.1535
      },
      "1.3365": {
        "os": 0.0512,
        "ps": 0.4346,
        "pl": 0.0905,
        "ol": 0.4435
      },
      "1.348": {
        "os": 0.0546,
        "ps": 1.8109,
        "pl": 0.1449,
        "ol": 0.3992
      },
      "1.4285": {
        "os": 0.0068,
        "ps": 0,
        "pl": 0,
        "ol": 0.0273
      },
      "1.335": {
        "os": 0.1126,
        "ps": 0.5433,
        "pl": 0.0362,
        "ol": 0.7779
      },
      "1.3705": {
        "os": 0.1126,
        "ps": 0,
        "pl": 0,
        "ol": 0.0614
      },
      "1.317": {
        "os": 0.0444,
        "ps": 0.1992,
        "pl": 0.0724,
        "ol": 0.5664
      }
    },
    "rate": 1.3676
  },
  "1382037600": {
    "price_points": {
      "1.359": {
        "os": 0.638,
        "ps": 0.2173,
        "pl": 0.67,
        "ol": 0.1535
      },
      "1.3365": {
        "os": 0.0512,
        "ps": 0.4346,
        "pl": 0.0905,
        "ol": 0.4435
      },
      "1.348": {
        "os": 0.0546,
        "ps": 1.8109,
        "pl": 0.1449,
        "ol": 0.3992
      },
      "1.381": {
        "os": 0.0614,
        "ps": 0,
        "pl": 0,
        "ol": 0.058
      },
      "1.335": {
        "os": 0.1126,
        "ps": 0.5433,
        "pl": 0.0362,
        "ol": 0.7779
      },
      "1.3705": {
        "os": 0.1126,
        "ps": 0,
        "pl": 0,
        "ol": 0.0614
      },
      "1.317": {
        "os": 0.0444,
        "ps": 0.1992,
        "pl": 0.0724,
        "ol": 0.5664
      }
    },
    "rate": 1.3677
  }
}

See OANDA orderbook for more details about input and output parameters.

Indicators

Scripts

Communication with Argo

The communication with Argo is provided with flic, an inter-process communication via TCP library.

Events

The events are handled in lib/main.js and, usually, the plugin developer should not modify it.

Checklist, if you want to publish your plugin