[Promise]
Trader.fetchKeyValueStorage(options)
List key-value storage
Trader.setKeyValueStorage(options)
Set an element in key-value storage
options
[object]
key
[string] - Keyvalue
[string] - Value
- return an [object]
Trader.setBulkKeyValueStorage(options)
Bulk set in key-value storage
options
[object]
bulk
[array] - array of key-value object as described in setKeyValueStorage
- return an [object]
Trader.getKeyValueStorage(options)
Get an element in key-value storage
options
[object]
- return an [object]
Trader.deleteKeyValueStorage(options)
Delete an element in key-value storage
options
[object]
- return an [object]
Trader.open(index)
index
[number] - Kline index- return a [BigNumber]
Trader.high(index)
index
[number] - Kline index- return a [BigNumber]
Trader.low(index)
index
[number] - Kline index- return a [BigNumber]
Trader.close(index)
index
[number] - Kline index- return a [BigNumber]
Trader.volume(index)
index
[number] - Kline index- return a [BigNumber]
Trader.balance(index)
Trader.transactions(index)
- return a [TransactionDTO]
Trader.orders(index)
Trader.getPublicData(fetchDepthParams, fetchOHLCVParams)
Automatically called in Trader._onInit
, results are parsed in Trader.update
fetchDepthParams
[object] - ccxt interface paramsfetchOHLCVParams
[object] - ccxt interface params- return a [Promise]
Trader.getPrivateData(fetchOrdersParams, fetchTransactionsParams)
Automatically called in Trader._onInit
, results are parsed in Trader.update
fetchOrdersParams
[object] - ccxt interface paramsfetchTransactionsParams
[object] - ccxt interface params- return a [Promise]
EXAMPLES
Below is a sample program which shows basic usage of the library.
(async function () {
try {
const PanicCloseStrategy = require('./strategy.js');
await PanicCloseStrategy.start()
} catch (err) {
console.error('err', err)
}
})()
global.log = global.log || console.log
global.error = global.error || console.error
module.exports = class extends (global.Trader || require('jsmex-trader-sdk')) {
constructor (options) {
super(options)
this.defaultSymbol = this.options.defaultSymbol
}
onInit () {
}
async onTick () {
try {
let close = this.close()
let yesterdayOpen = this.open(24)
let rate = (
close.minus(yesterdayOpen)
).div(yesterdayOpen)
if (rate.lte(-0.2)) {
return this.cancelAllOrders()
} else {
global.log(rate.toNumber())
}
} catch (err) {
global.error(err)
}
}
onExit () {
}
static get options () {
return {
...this.defaultOptions,
defaultSymbol: 'BTC/USDT',
exchanges: {
jsmex: {
wwwDomain: 'jsmex.io',
apiDomain: 'api.jsmex.io'
}
},
ccxt: {
fetchOHLCV: {
resolution: '10m',
limit: 500
}
}
}
}
}
For othe examples, like how to use key-value storage, check out examples
directory.
SCREENSHOTS
Strategy Editor
Tradingview (test environment)
PIPELINE
In our pipeline for 2020 there are really interesting features:
- Q1 Strategy performance ranking
- Q2 Strategy Copy Trading
THANKS
Special thanks to:
- CCXT Team
- Hapi for Joi
- MikeMcl for bignumber.js
CONTACT US
jsb4ch@jsmex.io
NEWS
https://t.me/jsmexio
https://twitter.com/jsmexchange