SDK Guide

Only available for Node.js and Python. (To be supported language : Java)

1. Setup Import

  • Import ProBit SDK module into the project.
    • Node : npm install probit-socket-sdk
    • Python : pip install probit_socket_sdk

2. Basic Information

3. Create Instance / Class

  • Create new instance of ProBitSdk using client ID and Secret Key as arguments.

4. Connect to WebSocket

Market Data

  • Subscribe Request-connectMarketData(market_id, filter)/ connect_market_data(market_id, filter)
typestringmust be 'subscribe'
market_idstringMarket ID that you want subscribe.
filterstring[]Required parameters are one or more of the values ​​below.

ticker,
recent_trades,
order_books_l0,
order_books_l1,
order_books_l2,
order_books_l3,
order_books_l4
  • Responses (When subscribe, and on going)
paramtypedescription
tickerObjectReturns if you put 'ticker' in your "filter" parameter.
Ticker made with 24 hours since last trade occurs.

TICKER Object:

- base_volume: Trade volume of base currency
- change: Price difference over 24 hours ago
- high: highest price in 24 hours.
- last: last price of lastest trade.
- low: : lowest price in 24 hours.
- quote_volume: Trade volume of quote currency
- time: when ticker last calculated
recent_tradesRECENT_TRADES[]Returns if you put 'recent_trades' in your "filter" parameter.
It will return last 100 trades of the market.
Old trade will be first, New trade will be last.

RECENT_TRADES:

- price: a closed price,
- quantity: traded quantity,
- time: the time the deal was made,
- side: 'buy' or 'sell',
- tick_direction:
An indicator of whether the transaction amount has risen or gone down compared to the previous transaction.
It will be 'up' | 'down' | 'zero' | 'zeroup' | 'zerodown',
order_books_l0
order_books_l1
order_books_l2
order_books_l3
order_books_l4
ORDER_BOOK[]Returns if you put 'order_books_l0' or 'order_books_l1' or 'order_books_l2' or 'order_books_l3' or 'order_books_l4' in your "filter" parameter.

It sends differ of order_book.
{
side: "buy",
price: "0.00004477",
quantity: "1789410.140359",
}

order_books_l0
order_books_l1
order_books_l2
order_books_l3
order_books_l4:
Sends orderbook grouped by 10^(ceil(log10(tick size))+[LEVEL]). Other than this everything is the same as order_books.

My Balance

  • Subscribe Request-connectMyBalance()/ connect_my_balance()
  • Responses (When subscribe, and on going)
paramtypedescription
BALANCEobject[]See below.
columntypedescription
currency_idstringCurrency ID
availablestringAvailable amount of currency.
totalstringTotal amount of currency.

Open Order

  • Subscribe Request-connectOpenOrder()/ connect_open_order()
  • Responses (When subscribe, and on going)
paramtypedescription
OPEN_ORDERobject[]See below.
columntypemeaning
idstringspecific id for the new order
user_idstringuser id of the user who makes the order
market_idstringrequested market_id
typestring"limit" or "market"
sidestring"buy" or "sell"
quantitystringquantity
limit_pricestringIf type is limit, then order's price.
time_in_forcestringselected time_in_force.
filled_coststringThe amount of filled cost. It is for market.
filled_quantitystringThe amount of filled quantity.
open_quantitystringThe amount of open quantity.
cancelled_quantitystringThe amount of cancelled quantity.
statusstringshould be 'open'.
timeDateOrder time.
client_order_idstringclient_order_id.

5. Read Data

  • Use getCachedData(channel, market_id?, filter?)
    / get_cached_data(channel, market_id?, filter?)to read the received data from the server.
channelargumentvalue
Market Datachannelmarketdata
market_id${market id}
filterPick one from below.
ticker, recent_trades, order_books_l0, order_books_l1,
order_books_l2, order_books_l3, order_books_l4
My Balancechannelbalance
Open Orderchannelopen_order

Example)

// 1.Setup Import
import { ProBitSDK } from "probit-socket-sdk";


async function main() {
  // 2.Basic Information
  const id = 'YOUR_CLIENT_ID_VALUE';
  const key = 'YOUR_SECRET_KEY_VALUE';

  // 3.Create Instance / Class
  const sdk = await ProBitSDK.createInstance(id, key);

  // 4.Connect WebSocket
  const connect = await sdk.connect();
  console.log(`connect: ${connect}`);
  await sdk.connectMarketData("BTC-USDT", ["order_books_l0", "order_books_l4", "recent_trades", "ticker"]);
  await sdk.connectMyBalance();
  await sdk.connectOpenOrder();

  // 5.Read Data
  console.log("\nMarketData-order_books_l0: " + JSON.stringify(sdk.getCachedData("marketdata", "BTC-USDT", "order_books_l0")));
  console.log("\nMarketData-order_books_l4: " + JSON.stringify(sdk.getCachedData("marketdata", "BTC-USDT", "order_books_l4")));
  console.log("\nMarketData-recent_trades: " + JSON.stringify(sdk.getCachedData("marketdata", "BTC-USDT", "recent_trades")));  
  console.log("\nMarketData-ticker: " + JSON.stringify(sdk.getCachedData("marketdata", "BTC-USDT", "ticker"))); 
  console.log("\nBalance : " + JSON.stringify(sdk.getCachedData("balance")));
  console.log("\nOpenOrder : " + JSON.stringify(sdk.getCachedData("open_order")));
}

main().catch((e) => {
  console.log(e);
});

# Setup Import
from probit_socket_sdk import ProBitSdk
from probit_socket_sdk.constant.channel_type import CHANNEL_TYPE
from probit_socket_sdk.constant.filter_type import FILTER_TYPE

# Basic Information
id = "YOUR_CLIENT_ID_VALUE"
secret = "YOUR_SECRET_KEY_VALUE"

# Create Instance / Class
sdk = ProBitSdk(id, secret)
                
# Connect to WebSocket
sdk.connect_market_data("BTC-USDT", [FILTER_TYPE.order_books_l0.name, FILTER_TYPE.order_books_l4.name,
                                    FILTER_TYPE.recent_trades.name, FILTER_TYPE.ticker.name])
sdk.connect_my_balance()
sdk.connect_open_order()

# Read Data
print(f"order_books_l0: {sdk.get_cached_data(CHANNEL_TYPE.MARKET_DATA.value, "BTC-USDT", FILTER_TYPE.order_books_l0.name)}")
print(f"order_books_l0: {sdk.get_cached_data(CHANNEL_TYPE.MARKET_DATA.value, "BTC-USDT", FILTER_TYPE.order_books_l4.name)}")
print(f"ticker: {sdk.get_cached_data(CHANNEL_TYPE.MARKET_DATA.value, "BTC-USDT", FILTER_TYPE.ticker.name)}")
print(f"recent_trade: {sdk.get_cached_data(CHANNEL_TYPE.MARKET_DATA.value, "BTC-USDT", FILTER_TYPE.recent_trades.name)}")
print(f"balance: {sdk.get_cached_data(CHANNEL_TYPE.BALANCE.value)}")
print(f"open_order: {sdk.get_cached_data(CHANNEL_TYPE.OPEN_ORDER.value)}")