![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
jsmex-trader-sdk
Advanced tools
[![npm version](https://badgen.now.sh/npm/v/jsmex-trader-sdk)](https://www.npmjs.com/package/jsmex-trader-sdk) [![npm downloads](https://badgen.now.sh/npm/dm/jsmex-trader-sdk)](https://www.npmjs.com/package/jsmex-trader-sdk)
jsmex-trader-sdk
is a library for nodejs which gives you access to jsmex's API interface. This
allows you to create JavaScript strategies which can be deployed in jsmex server and executed in JavaScript environments completely isolated from each other.
JSMEX is the first programmable cryptocurrency exchange! Sign Up Every minute all the uploaded strategies are executed in parallel isolated environments on our servers.
This project requires nodejs LTS version 10.4.0 (or later).
To install this module run npm install jsmex-trader-sdk
.
jsmex-trader-sdk
is a CCXT extension library is used to build strategies for jsmex runtime executor
. It provides quick access to market data for storage, analysis, visualization, indicator development, algorithmic trading, bot programming, and related software engineering.
Trader
[core]This class provide the core interface to ccxt API. Trader instances will inherit all the wrapped ccxt methods and will execute in sequence onInit, onTick and onExit.
Trader.ccxtExchanges.jsmex.ccxtInstance
This is the ccxt instance of the jsmex exchange, if you are not interested in using the wrapper you can directly refer to this reference.
Trader.fetchDepth(options)
options
[object]
symbol
[string] - Trading symbolTrader.fetchOHLCV(options)
options
[object]
symbol
[string] - Trading symbolresolution
[string] - Kline resolutionsince
[number] - Time in millisecondslimit
[number] - Number of klinesTrader.cancelOrder(options)
options
[object]
symbol
[string] - Trading symbolid
[number] - idTrader.cancelAllOrders(options)
Trader.fetchOrders(options)
options
[object]
symbol
[string] - Trading symboloffset
[number] - Offsetlimit
[number] - Limit recordsTrader.fetchTransactions(options)
options
[object]
symbol
[string] - Trading symboloffset
[number] - Offsetlimit
[number] - Limit recordsTrader.putOrder(options)
options
[object]
symbol
[string] - Trading symbolprice
[string] - Priceamount
[string] - Amountside
[string] - Sidetype
[string] - TypeTrader.pipeline(options)
This is restricted API, it allows bulk operations
options
[object]
symbol
[string] - Trading symbolpipeline
[array] - Pipeline arrayTrader.balance(options)
Trader.fetchKeyValueStorage(options)
List key-value storage
Trader.setKeyValueStorage(options)
Set an element in key-value storage
options
[object]
key
[string] - Keyvalue
[string] - ValueTrader.setBulkKeyValueStorage(options)
Bulk set in key-value storage
options
[object]
bulk
[array] - array of key-value object as described in setKeyValueStorageTrader.getKeyValueStorage(options)
Get an element in key-value storage
options
[object]
key
[string] - KeyTrader.deleteKeyValueStorage(options)
Delete an element in key-value storage
options
[object]
key
[string] - KeyTrader.open(index)
index
[number] - Kline indexTrader.high(index)
index
[number] - Kline indexTrader.low(index)
index
[number] - Kline indexTrader.close(index)
index
[number] - Kline indexTrader.volume(index)
index
[number] - Kline indexTrader.balance(index)
Trader.transactions(index)
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 paramsTrader.getPrivateData(fetchOrdersParams, fetchTransactionsParams)
Automatically called in Trader._onInit
, results are parsed in Trader.update
fetchOrdersParams
[object] - ccxt interface paramsfetchTransactionsParams
[object] - ccxt interface paramsBelow is a sample program which shows basic usage of the library.
// file index.js
(async function () {
try {
const PanicCloseStrategy = require('./strategy.js');
await PanicCloseStrategy.start()
} catch (err) {
console.error('err', err)
}
})()
// file strategy.js
global.log = global.log || console.log
global.error = global.error || console.error
// never use console in your program, it doesn't exists in the isolated environment, use global.log in order to receive logs in your account dashboard
module.exports = class extends (global.Trader || require('jsmex-trader-sdk')) {
constructor (options) {
super(options)
this.defaultSymbol = this.options.defaultSymbol
}
/**
* SamplePanicCloseStrategy on init method
*
* @author jsb4ch <jsb4ch@jsmex.io>
* @since 1.1.0
*/
onInit () {
}
/**
* SamplePanicCloseStrategy on tick method
*
* @author jsb4ch <jsb4ch@jsmex.io>
* @since 1.1.0
*/
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)
}
}
/**
* SamplePanicCloseStrategy on tick method
*
* @author jsb4ch <jsb4ch@jsmex.io>
* @since 1.1.0
*/
onExit () {
}
/**
* SamplePanicCloseStrategy static options
*
* @author jsb4ch <jsb4ch@jsmex.io>
* @since 1.1.0
*/
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.
Strategy Editor
Tradingview (test environment)
In our pipeline for 2020 there are really interesting features:
Special thanks to:
FAQs
[![npm version](https://badgen.now.sh/npm/v/jsmex-trader-sdk)](https://www.npmjs.com/package/jsmex-trader-sdk) [![npm downloads](https://badgen.now.sh/npm/dm/jsmex-trader-sdk)](https://www.npmjs.com/package/jsmex-trader-sdk)
We found that jsmex-trader-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.