Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mindsdb.com/llms.txt

Use this file to discover all available pages before exploring further.

In this section, we present how to connect Binance to MindsDB. Binance is one of the world’s largest cryptocurrency exchanges. It’s an online platform where you can buy, sell, and trade a wide variety of cryptocurrencies. Binance offers a range of services beyond just trading, including staking, lending, and various financial products related to cryptocurrencies. Binance provides real-time trade data that can be utilized within MindsDB to make real-time forecasts.

Connection

This handler integrates with the Binance API to make aggregate trade (kline) data available to use for model training and predictions. Since there are no parameters required to connect to Binance using MindsDB, you can use the below statement:
CREATE DATABASE my_binance
WITH
  ENGINE = 'binance';

Usage

Select Data

By default, aggregate data (klines) from the latest 1000 trading intervals with a length of one minute (1m) each will be returned.
SELECT *
FROM my_binance.aggregated_trade_data
WHERE symbol = 'BTCUSDT';
Here is the sample output data:
| symbol      | open_time    | open_price  | high_price  | low_price   | close_price | volume      | close_time    | quote_asset_volume | number_of_trades | taker_buy_base_asset_volume | taker_buy_quote_asset_volume |
| ----------- | -----------  | ----------- | ----------- | ----------- | ----------- | ----------- | -----------   | ------------------ | ---------------- | --------------------------- | ---------------------------- |
| BTCUSDT     | 1678338600   | 21752.65000 | 21761.33000 | 21751.53000 | 21756.7000  | 103.8614100 | 1678338659.999| 2259656.20520700   | 3655             | 55.25763000                 | 1202219.60971860             |
where:
  • symbol - Trading pair (BTC to USDT in the above example)
  • open_time - Start time of interval in seconds since the Unix epoch (default interval is 1m)
  • open_price - Price of a base asset at the beginning of a trading interval
  • high_price - The highest price of a base asset during trading interval
  • low_price - Lowest price of a base asset during a trading interval
  • close_price - Price of a base asset at the end of a trading interval
  • volume - Total amount of base asset traded during an interval
  • close_time - End time of interval in seconds since the Unix epoch
  • quote_asset_volume - Total amount of quote asset (USDT in the above case) traded during an interval
  • number_of_trades - Total number of trades made during an interval
  • taker_buy_base_asset_volume - How much of the base asset volume is contributed by taker buy orders
  • taker_buy_quote_asset_volume - How much of the quote asset volume is contributed by taker buy orders
To get a customized response we can pass open_time, close_time, and interval:
SELECT *
FROM my_binance.aggregated_trade_data
WHERE symbol = 'BTCUSDT'
AND open_time > '2023-01-01'
AND close_time < '2023-01-03 08:00:00'
AND interval = '1s'
LIMIT 10000;
Supported intervals are listed here