1.1.50 • Published 4 years ago

jsmex-trader-sdk v1.1.50

Weekly downloads
16
License
MIT
Repository
-
Last release
4 years ago

npm version npm downloads

jsmex-trader-sdk -- JSMEX Trader SDK

ALT JSMEX LOGO NPM

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

JSMEX is the first programmable cryptocurrency exchange! Sign Up Every minute all the uploaded strategies are executed in parallel isolated environments on our servers.

REQUIREMENTS

This project requires nodejs LTS version 10.4.0 (or later).

To install this module run npm install jsmex-trader-sdk.

API DOCUMENTATION

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.

Class: 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)
Trader.fetchOHLCV(options)
Trader.cancelOrder(options)
Trader.cancelAllOrders(options)
Trader.fetchOrders(options)
Trader.fetchTransactions(options)
Trader.putOrder(options)
Trader.pipeline(options)

This is restricted API, it allows bulk operations

Trader.balance(options)
Trader.fetchKeyValueStorage(options)

List key-value storage

Trader.setKeyValueStorage(options)

Set an element in key-value storage

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

Trader.deleteKeyValueStorage(options)

Delete an element in key-value storage

Trader.open(index)
Trader.high(index)
Trader.low(index)
Trader.close(index)
Trader.volume(index)
Trader.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 params
  • fetchOHLCVParams 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 params
  • fetchTransactionsParams object - ccxt interface params
  • return a Promise

EXAMPLES

Below 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.

SCREENSHOTS

Strategy Editor ALT JSMEX SCREENSHOT

Tradingview (test environment) ALT JSMEX SCREENSHOT

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

TWITTER

https://twitter.com/jsmexchange

algorithmicalgotradingaltcoinaltcoinsapiarbitragebacktestbacktestingbitcoinbotbtccnycoincoinscryptocryptocurrencycrypto currencycrypto marketcurrencycurrenciesdarkcoindashdigital currencydogedogecoine-commerceetcethetherethereumexchangeexchangeseurframeworkinvestinvestinginvestorlibrarylightlitecoinltcmarketmarket datamarketsmerchandisemerchantminimalohlcvorderorderbookorder bookpriceprice datapricefeedprivatepublicripplestrategytickertickerstoolkittradetradertradingusdvolumexbtxrpzeczerocoin1Broker1BTCXEACXacx.ioallcoinallcoin.comANXANXProbiboxbibox.comBinancebinance.combit2c.co.ilBit2CBitBayBitBaysbitcoincoidBitcoin.co.idBitfinexbitFLyerbitflyer.jpbithumbbithumb.combitlishBitMarketBitMEXBitsoBitstampBittrexBL3PBleutradebleutrade.comBlinkTradebraziliexbraziliex.comBtcBoxbtcbox.co.jpBTCCBTCChinaBTC-eBTCeBTCExchangebtcexchange.phBTC Marketsbtcmarketsbtcmarkets.netBTCTraderbtctrader.combtc-trade.com.uaBTC Trade UABTCTurkbtcturk.comBTCXbtc-xbterBter.comBX.in.thccexC-CEXcexCEX.IOCHBTCChileBitchilebit.netcoincheckCoinExchangecoinexchange.iocoingicoingi.comCoinMarketCapCoinMateCoinsecureCoinSpotcoinspot.com.auCrypto Capitalcryptocapital.coDSXdsx.ukEXMOflowBTCflowbtc.comFoxBitfoxbit.exchangeFYB-SEFYB-SGGatecoinGDAXGeminiHitBTCHuobiHuobiPROhuobi.proIndependent Reserveindependentreserve.comitBitjubi.comKrakenKucoinKunaLakeBTClakebtc.comLiveCoinLiquiliqui.iolunomercadoMercadoBitcoinmercadobitcoin.brmixcoinsmixcoins.comnovanovaexchangenovaexchange.comOKCoinOKCoin.comOKCoin.cnOKEXokex.comPaymiumPoloniexQuadrigaCXQryptosQUOINEXSouthxchangeSurBitcoinsurbitcoin.comTidextidex.comTheRockTradingUrduBiturdubit.comVaultoroVBTCvbtc.exchangevbtc.vnVirWoXWEXwex.nzxBTCexbtce.comYoBityobit.netYUNBIZaifZB1btcxe.comAllcoinanxpro.comanybits.comAnybitsbcex.topBCEXBiboxbig.oneBigONEbitbank.ccbitbankbitbay.netbitfinex.combitFlyerbitforex.comBitforexBithumbbitibu.comBitibubitkk.combitkkbitlish.comBitlishbitmarket.plbitmarket.netbitmex.combitsane.comBitsanebitso.combitstamp.netbittrex.combit-z.comBit-Zbl3p.eubitonic.nlBraziliexbtc-alpha.comBTC-Alphabtcchina.combtctrade.imBtcTrade.imbuda.comBudabx.in.thc-cex.comcex.iotrade.chbtc.comcobinhood.comCOBINHOODcoinbase.comCoinbaseprime.coinbase.comCoinbase Primepro.coinbase.comCoinbase Procoincheck.comcoinegg.comCoinEggcoinex.comCoinExcoinfalcon.comCoinFalconcoinfloor.co.ukcoinfloorCoingicoinmarketcap.comcoinmate.iocoinnest.co.krcoinnestcoinone.co.krCoinOnecointiger.proCoinTigercoolcoin.comCoolCoincoss.ioCOSScrex24.comCREX24cryptonbtc.comCryptonderibit.comDeribitethfinex.comEthfinexexmo.meexx.comEXXfcoin.comFCointrader.flowbtc.comfybse.sefybsg.comgatecoin.comgate.ioGate.iogdax.comgemini.comgetbtc.orgGetBTChadax.comHADAXhitbtc.comHuobi Prohuobi.com.ruHuobi Russiaice3x.comice3x.co.zaICE3Xindodax.comINDODAXitbit.comkkex.comKKEXkraken.comkucoin.comKuCoinkuna.iolbank.infoLBankliquid.comLiquidlivecoin.netluno.comlykke.comLykkemercadobitcoin.com.brMercado BitcoinMixCoinsnegociecoins.com.brNegocieCoinsNovaexchangeokcoin.cnOKCoin CNYokcoin.comOKCoin USDpaymium.compoloniex.comquadrigacx.comrightbtc.comRightBTCsouthxchange.comSouthXchangestronghold.coStrongholdtheocean.tradeThe Oceantherocktrading.comtidebit.comTideBituex.comUEXupbit.comUpbitvaultoro.comvirwox.comyunbi.comzaif.jpzb.comfcoinjp.comFCoinJPbinance.jeBinance Jerseybequant.ioBequantmandalaex.comMandaladx.exchangeDX.Exchangeoceanex.pro.comOceanExflowbtc.com.brfoxbit.com.brlatoken.comLatokenbitmart.comBitMartdigifinex.vipDigiFinexidex.marketIDEXadara.ioAdarabinance.usBinance USwhitebit.comWhiteBitbitmax.ioBitMaxbytetrade.comByteTradeftx.comFTX{hostname}bw.comstex.comSTEXBWtimex.ioTimeXbitz.com
1.1.50

4 years ago

1.1.49

4 years ago

1.1.45

4 years ago

1.1.47

4 years ago

1.1.43

4 years ago

1.1.36

4 years ago

1.1.34

4 years ago

1.1.33

4 years ago

1.1.32

4 years ago

1.1.26

4 years ago