Skip to content

btcccorp/dax-trade-sdk-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BTCC DAX trade SDK

All place/cancel order request should have a zero RC(Error Code) property

To use DAX trade SDK

npm i -s @btcc_exchange/dax-trade-sdk

Create trader from SDK

const Trader = require('@btcc_exchange/dax-trade-sdk')

const trader = new Trader({
  accessKeyId: '01234567-0123-0123-0123-0123456789ab',
  secretAccessKey: '0123456789abcdef0123456789abcdef0123456789abcdef'
})

Get balance

<<create-trader>>

trader.getAccountInfo().then((res) => {
  // Do something with axios response
  console.log(res.data)
})

Create simplified ETC_BTC market from trader (ETH_BTC the same)

<<create-trader>>

const etcMarket = trader.getMarket('ETC_BTC')

Get my open orders

<<create-etc-market>>

etcMarket.list().then((res) => {
  // Do something with axios response
  console.log(res.data)
})

Buy

<<create-etc-market>>

// amount, price
etcMarket.buy('0.01', '0.1').then((res) => {
  // Do something with axios response
  console.log(res.data)
})

Sell

<<create-etc-market>>

// amount, price
etcMarket.sell('0.02', '0.1').then((res) => {
  // Do something with axios response
  console.log(res.data)
})

Cancel order

<<create-etc-market>>

// order id
etcMarket.cancel('0123456789abcdef0123456789abcdef').then((res) => {
  // Do something with axios response
  console.log(res.data)
})

To get a signed axios

const Trader = require('@btcc_exchange/dax-trade-sdk')

const axios = Trader.signAxios({
  accessKeyId: '01234567-0123-0123-0123-0123456789ab',
  secretAccessKey: '0123456789abcdef0123456789abcdef0123456789abcdef'
})

BTCC DAX Public Websocket API

npm i -s ws uuid
const WebSocket = require('ws')
const uuidv4 = require('uuid/v4')

const ws = new WebSocket('wss://ws-dax.btcc.com/ws/pub')

ws.on('open', () => {
  ws.send(JSON.stringify({
    MsgType: "QuoteRequest",
    CRID: uuidv4(),
    Symbol: "ETC_BTC",
    QuoteType: 2,
  }))
})

ws.on('message', (data) => {
  // Do something with GlobalTicker, OrderBook and ExecTradeBase
  console.log(data)
  ws.close() // Or remove this line to listen increment trade
})