argo-trading-plugin-seed v4.0.1
ARGO-TRADING PLUGIN SEED
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-seedIf 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 installnode_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 startHow to customize the plugin
In lib/custom folder there are the files implementing the name and the
callbacks of the plugin:
name.jsThe registration name of the plugin.
module.exports = "seed";onhearbeat.jsCalled onargo.streamingwith plugin statusloadedorenabled.
function onheartbeat(beat) // beat.timeonload.jsCalled onargo.registercallback.
function onload(name) // plugin nameontick.jsCalled onargo.streamingwith plugin statusenabledfor every tick.
function ontick(tick)
// tick.time
// tick.instrument
// tick.bid
// tick.askonbar.jsCalled onargo.streamingwith plugin statusenabledfor every completed bar.
function onbar(bar)
// bar.time
// bar.instrument
// bar.granularity
// bar.openMid
// bar.highMid
// bar.lowMid
// bar.closeMid
// bar.volumeontransaction.jsCalled onargo.streamingwith plugin statusenabled.
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.tradeReducedonunload.jsCalled onSIGINTcallback.
function onunload(name) // plugin nameYou 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
ema:ema(closes, period, ema0)macd:macd(closes, slowPeriod, fastPeriod, signalPeriod, slowPeriod0, fastPeriod0, signalPeriod0)rsi:rsi(closes, period, close0, avgGain, avgLoss)stoch:stoch(closes, highs, lows, kPeriod, dPeriod)
Scripts
scripts/argo-trading-simulator.jsPrimitive simulator to simulate rates streaming.
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.
argo.registerTold by plugin to register the plugin.argo.unregisterTold by plugin to unregister the plugin.argo.statusTold by Argo to get the plugin status.argo.enableTold by Argo to enable the plugin.argo.disableTold by Argo to disable the plugin.argo.streamingTold by Argo to pass streaming data (heartbeats, ticks and transactions).errorTo catch errors by plugin.SIGINTTo stop the plugin with CTRL-C (or a SIGINT signal).uncaughtExceptionTo catch uncaught exceptions.
Checklist, if you want to publish your plugin
- Rename the project, using the convention
argo-trading-plugin-<myplugin>. - Rename the start script as
bin/argo-trading-plugin-<myplugin>. - Rename the content of
binproperty inpackage.json.
6 years ago
6 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago