Hi. New to QuantConnect. I wrote a simple algo to test Binance Bitcoin backtest data. It seems like when I set account currency to USDT and when I set the brokerage model to Binance, the data goes as far back as May 2018 only and not further back, and I can only see. I am wondering where this limit comes from, is it my free QC account, is it the specific Binance brokerage branch (e.g. US) where you fetch the data from, or something else?
If it is the specific Binance brokerage branch (e.g. US) then how can I change it to another Binance, and in general how can I load new data into my online QC algos for backtesting and live trading (streaming data) if you don't have the specific exchanges or data that I need to use in my algo?
Mia Alissi
QuantConnect provides data for backtesting and live trading. For backtesting, you can use the data provided by QuantConnect, which includes Binance data. However, the availability of historical data depends on the specific asset and exchange. For Bitcoin on Binance, the data might only go back to May 2018 due to the limitations of the data source.
For live trading, you can use the data provided by the brokerage. In your case, you can use Binance data for live trading. You can set the brokerage model to Binance using the
SetBrokerageModel
method and add the specific crypto asset using theAddCrypto
method. Here is an example:If you want to use a different Binance branch, you can specify it in the
Market
argument of theAddCrypto
method. For example, to use Binance US, you can do:However, please note that QuantConnect's Binance and Binance US integrations don't support trading with sub-accounts. You must use your main account (source).
If you need to use specific exchanges or data that are not provided by QuantConnect, you might need to use custom data. However, this might require more advanced programming skills and understanding of the QuantConnect API.
For more information, you can refer to the QuantConnect documentation.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
QuantSisu
So only BinanceUS is currently available, and I would need to add any other of Binance's regional exchanges by implementing them. How can I do this, and implement the Binance market for an account in the the EU or Asia or the UK?
Mia Alissi
QuantConnect currently supports Binance and Binance US for live trading. If you want to use a different regional exchange from Binance, you would need to add a new brokerage to the platform. However, this requires the brokerage to have an API that is popular, stable, and officially supported by the brokerage (source).
Adding a new brokerage to the platform is a complex task that involves implementing the brokerage API in the LEAN engine, which is the underlying technology of QuantConnect. This requires advanced programming skills and a deep understanding of both the brokerage API and the LEAN engine.
If you want to add a new brokerage to the platform, you can contact QuantConnect for more information (source).
For live trading with Binance or Binance US, you can set the brokerage model and add the crypto asset as follows:
or for Binance US:
Please note that QuantConnect's Binance and Binance US integrations don't support trading with sub-accounts. You must use your main account (source).
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
SOME CEDRIC OLIVIER
Hello everyone,
I’ve been following the conversation about accessing Binance crypto data and thought this might be a good place to share a resource that could be helpful, especially for those using QuantConnect.
We’ve developed an API that provides real-time fair value calculations for cryptocurrencies. It’s designed to integrate smoothly with platforms like QuantConnect, and could be a useful tool for those looking to enhance their data sources.
Here’s a quick example of how you can integrate it into your QuantConnect projects:
import json
from datetime import datetime, timedelta
import pandas as pd
Â
class MyCustomDataType(PythonData):
  def __init__(self):
    self.ProjectId = ''
    self.fair_value = 2
    self.fair_value_date = datetime.today().date()
    self.cached_fair_value = {}
  def GetSource(self, config, date, isLiveMode):
    symbol = config.Symbol.Value
    return SubscriptionDataSource(
      f"https://rapidapi.com/somecedric/api/crypto-fair-value-calculator-api/fairvalue?symbol={symbol}×tamp={datetime.utcnow().isoformat()}",
      SubscriptionTransportMedium.Rest
    )
  def Reader(self, config, line, date, isLiveMode):
    if not line.strip():
      return None
    try:
      data = json.loads(line.strip())
      if 'fair_value' not in data:
        return None
      fair_value = float(data['fair_value'])
      df = pd.DataFrame({
        'Time': [date],
        'Open': [fair_value],
        'High': [fair_value],
        'Low': [fair_value],
        'Close': [fair_value],
        'Volume': [0]
      })
      df.set_index('Time', inplace=True)
      custom = MyCustomDataType()
      custom.Symbol = config.Symbol
      custom.Time = date
      custom.EndTime = custom.Time + timedelta(hours=1)  # Assuming hourly data
      custom.Value = fair_value
      custom.DataFrameData = df
      return custom
    except (ValueError, KeyError, json.JSONDecodeError) as e:
      return None
If you’re interested, you can find more details on RapidAPI under Crypto Fair Value Calculator API.
I hope this is helpful to anyone looking to expand their data analysis capabilities. Would love to hear how others are managing their data needs and if there are any tools or methods you find particularly effective!
QuantSisu
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!