Data Feeding: Binance Ingestion

Backfill (REST API)

Syntax & Example
//Here lower_symbol is the symbol whose data we want and in OHLC interval is the interval of the candle

// For live data we use this API
std::string path = "/ws/" + lower_symbol + "@trade";
ws.handshake("stream.binance.com", path);

// For OHLC we use this API
std::string path = "/ws/" + lower_symbol + "@kline_" + interval;
ws.handshake("stream.binance.com", path);

To ensure strategy continuity, NanoVaultDB performs an initial sync. It fetches candlestick (kline) arrays from the Free Binance WebSocket API endpoint up to the current timestamp. The returned records are processed just like normal data fetched through UDP. One thing to note here is this API is free however for trades you have to set your API key first. For more information about this. Kindly look at trades section.

Live Ingestion

Syntax & Example
SET BINANCE DATA FEED LIVE ORDERS ON SYMBOL 3 SYMBOL "BTCUSDT";

Through earlier mentioned API's engine fetches the data in real time. For enabling live binance feed user needs to run this command. Here 3 is symbol defined while creating the HFT tables for more information on this kindly look at creation of HFT tables section.

OHLC candlestick data ingestion

Syntax & Example
SET BINANCE DATA FEED OHLC "1s" ON SYMBOL 2 SYMBOL "BTCUSDT";

For enabling Candlestick data feed user needs to run this command. Here 2 is symbol defined while creating the HFT tables for more information on this kindly look at creation of HFT tables section. and "1s" is the time interval of the candlestick.

Note: In any HFT table you can enable both OHLC data on live orders but reverse can't be done. One table can have both OHLC and live orders as both of their processings are done separately