What is Boot Camp?
Boot Camp is a great way to improve your skills and learn the QuantConnect API in easily digestible portions.
Don't have an account? Join QuantConnect Today
We are dedicated to providing investors with a cutting-edge platform for rapidly creating quant investment strategies. Founded in 2012, we've empowered more than 250,000 quants and engineers to create and trade their ideas.
Quickly and easily started with our API to build your strategy. The learning center lessons are interactive, step-by-step guides to make you productive as fast as possible.
Focus your efforts on driving alpha, not parsing CSV files. Our cloud offers hundreds of terabytes of traditional and alternative data preformatted, cleaned, and instantly accessible by our API.
Coordinate teamwork, control access permissions, and your shared cloud resources. Grow your trading organization safely and efficiently on top of our cloud architecture.
A selection of streaming live-trading strategies written by QuantConnect, and top highlights from the community available to follow and clone. Peer into detailed real-time positions to gain insight for your own trading.
What is Boot Camp?
Boot Camp is a great way to improve your skills and learn the QuantConnect API in easily digestible portions.
A collection of courses from independent educators to improve your quant skill base and create better strategies.
Solidify and expand your quant skill base with courses at QuantConnect
Learn algorithmic trading with python for US Equities. Guided strategy development in easily digestible portions.
Author: QuantConnect
Free | 95,883 People Enrolled
Learn algorithmic trading with python for FX. Guided strategy development in easily digestible portions.
Author: QuantConnect
Free | 20,555 People Enrolled
Learn algorithmic trading with python for Futures. Guided strategy development in easily digestible portions.
Author: QuantConnect
Free | 7,412 People Enrolled
In this algorithmic trading tutorial series you will learn everything you need to know to start writing your own trading bots using Python and the QuantConnect quantitative trading platform.
Author: Louis
Free | 28,715 People Enrolled
Master algorithmic trading on QuantConnect; backtest and live trade Stocks, Options, Futures, Forex, and Crypto.
Author: Cheng Li
Paid | Enroll on Udemy
Learn to use Python, Pandas, Matplotlib, and the QuantConnect Lean Engine to perform financial analysis and trading.
Author: Jose Portilla, Pierian Training
Paid | Enroll on Udemy
Learn to write programs that algorithmically trade cryptocurrencies using QuantConnect (C#).
Author: Eric Summers
Paid | Enroll on Udemy
Organization Notes
Get Started with Algorithm Lab
New Research
Optimizing a Gold-SPY Portfolio Using Hidden Markov Models for Market Downtime
Gold-SPY portfolio optimization using Hidden Markov Models for minimizing market downturn risk....
ReadAlgorithm Lab is your playground for developing and refining trading algorithms with QuantConnect. Utilize advanced tools, historical data, and robust backtesting to enhance your trading strategies. Transform your ideas into actionable insights and optimize your trading approach with ease.
Sign Up for FreeAlready have an account Log In.
This account is protected by two-factor authentication.
Request Token Information Reset My TokenCreated | Last Time Used | Agent | |
---|---|---|---|
No entries found |
To continue please enter your email:
(No google account required)
To verify that everything goes well please enter the 6 digit verification code generated by the authenticator application
Algorithm Lab is your playground for developing and refining trading algorithms with QuantConnect. Utilize advanced tools, historical data, and robust backtesting to enhance your trading strategies. Transform your ideas into actionable insights and optimize your trading approach with ease.
Sign Up for FreeAlready have an account Log In.
Please stop one of the following coding sessions, or upgrade your account.
NAME | ORGANIZATION |
---|
QuantConnect Datasets
Explore free and paid datasets available on QuantConnect covering fundamentals, pricing, and alternative options.
Datasets >
Dashboard
A transparent, community reporting system. Report suspected issues with our cloud data to be investigated by the QuantConnect Team.
Issue List
Loading...
Data Explorer Issues are a way to report and track data problems. They give the QuantConnect community a way to discuss potential solutions and be notified when they are resolved. If you think you have found a data problem please check the existing open and closed issues first; often another user may have already reported your problem.
Does your issue match any of the already listed issues?
Thank you for your contribution! Our team is currently working on resolving these issues, please subscribe to them to receive updates.
Datasets >
Bybit Crypto Future Price Data
Dataset by CoinAPI
The Bybit Crypto Future Price Data by CoinAPI is for Cryptocurrency Futures price and volume data points. The data covers 433 Cryptocurrency pairs, starts in August 2020, and is delivered on any frequency from tick to daily. This dataset is created by monitoring the trading activity on Bybit.
The Bybit Crypto Future Margin Rate Data dataset provides margin interest rate data to model margin costs.
CoinAPI was founded by Artur Pietrzyk in 2016 with the goal of providing real-time and historical cryptocurrency market data, collected from hundreds of exchanges. CoinAPI provides access to Cryptocurrencies for traders, market makers, and developers building third-party applications.
The following snippet demonstrates how to request data from the Bybit Crypto Future Price dataset:
def initialize(self) -> None:
self.set_brokerage_model(BrokerageName.BYBIT, AccountType.MARGIN)
self.crypto_future_symbol = self.add_crypto_future("BTCUSDT", Resolution.MINUTE).symbol
private Symbol _cryptoFutureSymbol;
public override void Initialize
{
SetBrokerageModel(BrokerageName.Bybit, AccountType.Margin);
_cryptoFutureSymbol = AddCryptoFuture("BTCUSDT", Resolution.Minute).Symbol;
}
The following table describes the dataset properties:
Property | Value |
---|---|
Start Date | October 2019 |
Asset Coverage | 433 Crypto Futures Pairs |
Data Density | Dense |
Resolution | Tick, Second, Minute, Hourly, & Daily |
Timezone | UTC |
Market Hours | Always Open |
The Bybit Crypto Future Price dataset enables you to accurately design strategies for Crypto Futures with term structure. Examples include the following strategies:
For more example algorithms, see Examples.
The Bybit Crypto Future Price dataset provides TradeBar, QuoteBar, and Tick objects.
TradeBar objects have the following attributes:
QuoteBar objects have the following attributes:
Tick objects have the following attributes:
The following table shows the available Crypto Future pairs:
Pairs Available (433) | |||||
---|---|---|---|---|---|
1CATUSDT | 1INCHUSDT | A8USDT | AAVEUSDT | ACEUSDT | ACHUSDT |
ADAUSD | ADAUSDT | AERGOUSDT | AEROUSDT | AEVOUSDT | AGIUSDT |
AGIXUSDT | AGLDUSDT | AIDOGEUSDT | AIOZUSDT | AIUSDT | AKROUSDT |
AKTUSDT | ALGOUSDT | ALICEUSDT | ALPACAUSDT | ALPHAUSDT | ALTUSDT |
AMBUSDT | ANKRUSDT | ANTUSDT | APEUSDT | API3USDT | APTUSDT |
APUUSDT | ARBUSDT | ARKMUSDT | ARKUSDT | ARPAUSDT | ARUSDT |
ASTRUSDT | ATAUSDT | ATHUSDT | ATOMUSDT | AUCTIONUSDT | AUDIOUSDT |
AVAILUSDT | AVAXUSDT | AXLUSDT | AXSUSDT | BABYDOGEUSDT | BADGERUSDT |
BAKEUSDT | BALUSDT | BANANAUSDT | BANDUSDT | BATUSDT | BBUSDT |
BCHUSDT | BEAMUSDT | BEERUSDT | BELUSDT | BENDOGUSDT | BICOUSDT |
BIGTIMEUSDT | BLASTUSDT | BLURUSDT | BLZUSDT | BNBUSDT | BNTUSDT |
BNXUSDT | BOBAUSDT | BOMEUSDT | BONDUSDT | BONKUSDT | BRETTUSDT |
BSVUSDT | BSWUSDT | BTCUSD | BTCUSDT | BTTUSDT | BUSDUSDT |
C98USDT | CAKEUSDT | CEEKUSDT | CELOUSDT | CELRUSDT | CETUSUSDT |
CFXUSDT | CHRUSDT | CHZUSDT | CKBUSDT | CLOUDUSDT | COMBOUSDT |
COMPUSDT | COQUSDT | COREUSDT | COSUSDT | COTIUSDT | COVALUSDT |
CROUSDT | CRVUSDT | CTCUSDT | CTKUSDT | CTSIUSDT | CVCUSDT |
CVXUSDT | CYBERUSDT | DAOUSDT | DARUSDT | DASHUSDT | DATAUSDT |
DEGENUSDT | DENTUSDT | DEXEUSDT | DGBUSDT | DODOUSDT | DOGEUSDT |
DOGSUSDT | DOGUSDT | DOP1USDT | DOTUSD | DOTUSDT | DRIFTUSDT |
DUSKUSDT | DYDXUSDT | DYMUSDT | EDUUSDT | EGLDUSDT | ENAUSDT |
ENJUSDT | ENSUSDT | EOSUSD | EOSUSDT | ETCUSDT | ETHBTCUSDT |
ETHFIUSDT | ETHUSD | ETHUSDT | ETHWUSDT | FDUSDUSDT | FETUSDT |
FILUSDT | FIREUSDT | FITFIUSDT | FLMUSDT | FLOKIUSDT | FLOWUSDT |
FLRUSDT | FORTHUSDT | FOXYUSDT | FRONTUSDT | FTMUSDT | FTNUSDT |
FUNUSDT | FXSUSDT | GALAUSDT | GALUSDT | GASUSDT | GFTUSDT |
GLMRUSDT | GLMUSDT | GMEUSDT | GMTUSDT | GMXUSDT | GNOUSDT |
GODSUSDT | GPTUSDT | GRTUSDT | GTCUSDT | GUSDT | HBARUSDT |
HFTUSDT | HIFIUSDT | HIGHUSDT | HNTUSDT | HOOKUSDT | HOTUSDT |
ICPUSDT | ICXUSDT | IDEXUSDT | IDUSDT | ILVUSDT | IMXUSDT |
INJUSDT | IOSTUSDT | IOTAUSDT | IOTXUSDT | IOUSDT | IQ50USDT |
JASMYUSDT | JOEUSDT | JSTUSDT | JTOUSDT | JUPUSDT | KASUSDT |
KAVAUSDT | KDAUSDT | KEYUSDT | KLAYUSDT | KNCUSDT | KSMUSDT |
L3USDT | LADYSUSDT | LAIUSDT | LDOUSDT | LEVERUSDT | LINAUSDT |
LINKUSDT | LISTAUSDT | LITUSDT | LOOKSUSDT | LOOMUSDT | LPTUSDT |
LQTYUSDT | LRCUSDT | LSKUSDT | LTCUSD | LTCUSDT | LTOUSDT |
LUNA2USDT | LUNCUSDT | MAGICUSDT | MANAUSD | MANAUSDT | MANEKIUSDT |
MANTAUSDT | MAPOUSDT | MASAUSDT | MASKUSDT | MATICUSDT | MAVIAUSDT |
MAVUSDT | MAXUSDT | MBLUSDT | MBOXUSDT | MCUSDT | MDTUSDT |
MEMEUSDT | MERLUSDT | METISUSDT | MEWUSDT | MINAUSDT | MKRUSDT |
MNTUSDT | MOBILEUSDT | MOCAUSDT | MOGUSDT | MONUSDT | MOTHERUSDT |
MOVRUSDT | MTLUSDT | MULTIUSDT | MYRIAUSDT | MYROUSDT | NEARUSDT |
NEIROETHUSDT | NEOUSDT | NFPUSDT | NFTUSDT | NKNUSDT | NMRUSDT |
NOTUSDT | NTRNUSDT | NULSUSDT | NYANUSDT | OCEANUSDT | OGNUSDT |
OGUSDT | OMGUSDT | OMNIUSDT | OMUSDT | ONDOUSDT | ONEUSDT |
ONGUSDT | ONTUSDT | OPUSDT | ORBSUSDT | ORCAUSDT | ORDERUSDT |
ORDIUSDT | ORNUSDT | OSMOUSDT | OXTUSDT | PAXGUSDT | PEIPEIUSDT |
PENDLEUSDT | PENGUSDT | PEOPLEUSDT | PEPEUSDT | PERPUSDT | PHAUSDT |
PHBUSDT | PIRATEUSDT | PIXELUSDT | PIXFIUSDT | POLYXUSDT | PONKEUSDT |
POPCATUSDT | PORTALUSDT | POWRUSDT | PRCLUSDT | PROMUSDT | PUNDUUSDT |
PYTHUSDT | QIUSDT | QNTUSDT | QTUMUSDT | RADUSDT | RAREUSDT |
RATSUSDT | RAYDIUMUSDT | RAYUSDT | RDNTUSDT | REEFUSDT | RENDERUSDT |
RENUSDT | REQUSDT | REZUSDT | RIFUSDT | RLCUSDT | RNDRUSDT |
RONUSDT | ROSEUSDT | RPLUSDT | RSRUSDT | RSS3USDT | RUNEUSDT |
RVNUSDT | SAFEUSDT | SAGAUSDT | SANDUSDT | SATSUSDT | SCAUSDT |
SCRTUSDT | SCUSDT | SEIUSDT | SFPUSDT | SHIB1000USDT | SILLYUSDT |
SKLUSDT | SLERFUSDT | SLPUSDT | SNTUSDT | SNXUSDT | SOLUSD |
SOLUSDT | SPECUSDT | SPELLUSDT | SSVUSDT | STARLUSDT | STEEMUSDT |
STGUSDT | STMXUSDT | STORJUSDT | STPTUSDT | STRAXUSDT | STRKUSDT |
STXUSDT | SUIUSDT | SUNDOGUSDT | SUNUSDT | SUPERUSDT | SUSHIUSDT |
SWEATUSDT | SXPUSDT | SYNUSDT | SYSUSDT | TAIKOUSDT | TAOUSDT |
THETAUSDT | TIAUSDT | TLMUSDT | TNSRUSDT | TOKENUSDT | TOMIUSDT |
TOMOUSDT | TONUSDT | TRBUSDT | TRUUSDT | TRXUSDT | TURBOUSDT |
TUSDT | TWTUSDT | UMAUSDT | UNFIUSDT | UNIUSDT | USDCUSDT |
USDEUSDT | USTCUSDT | UXLINKUSDT | VANRYUSDT | VELOUSDT | VETUSDT |
VGXUSDT | VIDTUSDT | VINUUSDT | VOXELUSDT | VRAUSDT | VTHOUSDT |
WAVESUSDT | WAXPUSDT | WENUSDT | WIFUSDT | WLDUSDT | WOOUSDT |
WSMUSDT | WUSDT | XAIUSDT | XCHUSDT | XCNUSDT | XECUSDT |
XEMUSDT | XLMUSDT | XMRUSDT | XNOUSDT | XRDUSDT | XRPUSD |
XRPUSDT | XTZUSDT | XVGUSDT | XVSUSDT | YFIIUSDT | YFIUSDT |
YGGUSDT | ZBCNUSDT | ZCXUSDT | ZECUSDT | ZENUSDT | ZETAUSDT |
ZEUSUSDT | ZILUSDT | ZKFUSDT | ZKJUSDT | ZKUSDT | ZROUSDT |
ZRXUSDT |
To add Bybit Crypto Future Price data to your algorithm, call the AddCryptoFutureadd_crypto_future method. Save a reference to the Crypto Future Symbol so you can access the data later in your algorithm.
class CoinAPIDataAlgorithm(QCAlgorithm):
def initialize(self) -> None:
self.set_start_date(2020, 6, 1)
self.set_end_date(2021, 6, 1)
# Set Account Currency to Tether
self.set_account_currency("USDT", 100000)
self.set_brokerage_model(BrokerageName.BYBIT, AccountType.MARGIN)
crypto_future = self.add_crypto_future("BTCUSDT", Resolution.MINUTE)
self.btcusdt = crypto_future.symbol
namespace QuantConnect
{
public class CoinAPIDataAlgorithm : QCAlgorithm
{
private Symbol _symbol;
public override void Initialize()
{
SetStartDate(2020, 6, 1);
SetEndDate(2021, 6, 1);
// Set Account Currency to Tether
SetAccountCurrency("USDT", 100000);
SetBrokerageModel(BrokerageName.Bybit, AccountType.Margin);
var cryptoFuture = AddCryptoFuture("BTCUSDT", Resolution.Minute);
_symbol = cryptoFuture.Symbol;
}
}
}
For more information about creating Crypto Future subscriptions, see Requesting Data.
To get the current Bybit Crypto Future Price data, index the Barsbars, QuoteBarsquote_bars, or Ticksticks properties of the current Slice with the Crypto Future Symbol. Slice objects deliver unique events to your algorithm as they happen, but the Slice may not contain data for your security at every time step. To avoid issues, check if the Slice contains the data you want before you index it.
def on_data(self, slice: Slice) -> None:
if self.btcusdt in slice.bars:
trade_bar = slice.bars[self.btcusdt]
self.log(f"{self.btcusdt} close at {slice.time}: {trade_bar.close}")
if self.btcusdt in slice.quote_bars:
quote_bar = slice.quote_bars[self.btcusdt]
self.log(f"{self.btcusdt} bid at {slice.time}: {quote_bar.bid.close}")
if self.btcusdt in slice.ticks:
ticks = slice.ticks[self.btcusdt]
for tick in ticks:
self.log(f"{self.btcusdt} price at {slice.time}: {tick.price}")
public override void OnData(Slice slice)
{
if (slice.Bars.ContainsKey(_symbol))
{
var tradeBar = slice.Bars[_symbol];
Log($"{_symbol} price at {slice.Time}: {tradeBar.Close}");
}
if (slice.QuoteBars.ContainsKey(_symbol))
{
var quoteBar = slice.QuoteBars[_symbol];
Log($"{_symbol} bid at {slice.Time}: {quoteBar.Bid.Close}");
}
if (slice.Ticks.ContainsKey(_symbol))
{
var ticks = slice.Ticks[_symbol];
foreach (var tick in ticks)
{
Log($"{_symbol} price at {slice.Time}: {tick.Price}");
}
}
}
You can also iterate through all of the data objects in the current Slice.
def on_data(self, slice: Slice) -> None:
for symbol, trade_bar in slice.bars.items():
self.log(f"{symbol} close at {slice.time}: {trade_bar.close}")
for symbol, quote_bar in slice.quote_bars.items():
self.log(f"{symbol} bid at {slice.time}: {quote_bar.bid.close}")
for symbol, ticks in slice.ticks.items():
for tick in ticks:
self.log(f"{symbol} price at {slice.time}: {tick.price}")
public override void OnData(Slice slice)
{
foreach (var kvp in slice.Bars)
{
var symbol = kvp.Key;
var tradeBar = kvp.Value;
Log($"{symbol} price at {slice.Time}: {tradeBar.Close}");
}
foreach (var kvp in slice.QuoteBars)
{
var symbol = kvp.Key;
var quoteBar = kvp.Value;
Log($"{symbol} bid at {slice.Time}: {quoteBar.Bid.Close}");
}
foreach (var kvp in slice.Ticks)
{
var symbol = kvp.Key;
var ticks = kvp.Value;
foreach (var tick in ticks)
{
Log($"{symbol} price at {slice.Time}: {tick.Price}");
}
}
}
For more information about accessing Crypto Future data, see Handling Data.
To get historical Bybit Crypto Future Price data, call the Historyhistory method with the Crypto Future Symbol. If there is no data in the period you request, the history result is empty.
# DataFrame
history_df = self.history(self.btcusdt, 100, Resolution.DAILY)
# TradeBar objects
history_trade_bars = self.history[TradeBar](self.btcusdt, 100, Resolution.MINUTE)
# QuoteBar objects
history_quote_bars = self.history[QuoteBar](self.btcusdt, 100, Resolution.MINUTE)
# Tick objects
history_ticks = self.history[Tick](self.btcusdt, timedelta(seconds=10), Resolution.TICK)
// TradeBar objects
var historyTradeBars = History(_symbol, 100, Resolution.Daily);
// QuoteBar objects
var historyQuoteBars = History<QuoteBar>(_symbol, 100, Resolution.Minute);
// Tick objects
var historyTicks = History<Tick>(_symbol, TimeSpan.FromSeconds(10), Resolution.Tick);
For more information about historical data, see History Requests.
To unsubscribe from a Crypto Future contract that you added with the AddCryptoFutureadd_crypto_future method, call the RemoveSecurityremove_security method.
self.remove_security(self.btcusdt)
RemoveSecurity(_symbol);
The RemoveSecurityremove_security method cancels your open orders for the security and liquidates your Crypto Future holdings.
The Bybit Crypto Future Price dataset provides TradeBar, QuoteBar, and Tick objects.
TradeBar objects have the following attributes:
QuoteBar objects have the following attributes:
Tick objects have the following attributes:
The following example algorithm buys BTCUSDT perpetual future contract if the last day's close price was close to ask close price than bid close price, sells short of that in opposite, through the Bybit exchange:
from AlgorithmImports import *
class BybitCryptoFutureDataAlgorithm(QCAlgorithm):
def initialize(self) -> None:
self.set_start_date(2022, 10, 1)
self.set_end_date(2022, 10, 10)
# Set Account Currency to Tether, since USD and USDT will not auto-convert and USD cannot be used to trade
self.set_account_currency("USDT", 100000)
# Bybit accepts both Cash and Margin account types, select the one you need for the best reality modeling.
self.set_brokerage_model(BrokerageName.BYBIT, AccountType.MARGIN)
# Requesting data, we only trade on BTCUSDT Future in Bybit exchange
crypto_future = self.add_crypto_future("BTCUSDT", Resolution.DAILY)
# perpetual futures does not have a filter function
self.btcusdt = crypto_future.symbol
# Historical data
history = self.history(self.btcusdt, 10, Resolution.DAILY)
self.debug(f"We got {len(history)} from our history request for {self.btcusdt}")
def on_data(self, slice: Slice) -> None:
# Note that you may want to access the margin interest of the crypto future to calculate if it would impact a trade's PnL
if self.btcusdt in slice.margin_interest_rates:
interest_rate = slice.margin_interest_rates[self.btcusdt].interest_rate
self.log(f"{self.btcusdt} close at {slice.time}: {interest_rate}")
# Trade only based on updated price data
if not slice.bars.contains_key(self.btcusdt) or not slice.quote_bars.contains_key(self.btcusdt):
return
quote = slice.quote_bars[self.btcusdt]
price = slice.bars[self.btcusdt].price
# Scalp-trade the bid-ask spread based on the supply-demand strength
if price - quote.bid.close > quote.ask.close - price:
self.set_holdings(self.btcusdt, -1)
else:
self.set_holdings(self.btcusdt, 1)
using System.Linq;
using QuantConnect.Data;
using QuantConnect.Brokerages;
namespace QuantConnect.Algorithm.CSharp
{
public class BybitCryptoFutureDataAlgorithm : QCAlgorithm
{
public Symbol _symbol;
public override void Initialize()
{
SetStartDate(2022, 1, 1);
SetEndDate(2023, 1, 1);
// Set Account Currency to Tether, since USD and USDT will not auto-convert and USD cannot be used to trade
SetAccountCurrency("USDT", 100000);
// Bybit accepts both Cash and Margin account types, select the one you need for the best reality modeling.
SetBrokerageModel(BrokerageName.Bybit, AccountType.Margin);
// Requesting data, we only trade on BTCUSDT Future in Bybit exchange
var cryptoFuture = AddCryptoFuture("BTCUSDT", Resolution.Daily);
// perpetual futures does not have a filter function
_symbol = cryptoFuture.Symbol;
// Historical data
var history = History(_symbol, 10, Resolution.Daily);
Debug($"We got {history.Count()} from our history request for {_symbol}");
}
public override void OnData(Slice slice)
{
// Note that you may want to access the margin interest of the crypto future to calculate if it would impact a trade's PnL
if (slice.MarginInterestRates.ContainsKey(_symbol))
{
var interestRate = slice.MarginInterestRates[_symbol].InterestRate;
Log($"{_symbol} price at {slice.Time}: {interestRate}");
}
// Trade only based on updated price data
if (!slice.QuoteBars.TryGet(_symbol, out var quote) || !slice.Bars.ContainsKey(_symbol))
{
return;
}
var price = slice.Bars[_symbol].Price;
// Scalp-trade the bid-ask spread based on the supply-demand strength
if (price - quote.Bid.Close > quote.Ask.Close - price)
{
SetHoldings(_symbol, -1m);
}
else
{
SetHoldings(_symbol, 1m);
}
}
}
}
The following example algorithm hold a 100% long BTCUST future portfolio if the last day's close price was close to ask close price than bid close price, while hold short of that in opposite, through the Bybit exchange using the algorithm framework implementation:
from AlgorithmImports import *
class BybitCryptoFutureDataAlgorithm(QCAlgorithm):
def initialize(self) -> None:
self.set_start_date(2022, 10, 1)
self.set_end_date(2022, 10, 10)
# Set Account Currency to Tether, since USD and USDT will not auto-convert and USD cannot be used to trade
self.set_account_currency("USDT", 100000)
# Bybit accepts both Cash and Margin account types, select the one you need for the best reality modeling.
self.set_brokerage_model(BrokerageName.BYBIT, AccountType.MARGIN)
self.universe_settings.resolution = Resolution.DAILY
self.universe_settings.leverage = 2
# We only trade on BTCUSDT Future in Bybit exchange
symbols = [Symbol.create("BTCUSDT", SecurityType.CRYPTO_FUTURE, Market.BYBIT)]
self.add_universe_selection(ManualUniverseSelectionModel(symbols))
# Custom alpha model to emit insights based on the Crypto Future price data
self.add_alpha(CryptoFutureAlphaModel())
# Equally invest to evenly dissipate the capital concentration risk of inidividual crypto pair
self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())
self.set_execution(ImmediateExecutionModel())
class CryptoFutureAlphaModel(AlphaModel):
def __init__(self) -> None:
self.symbols = []
def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]:
insights = []
for symbol in self.symbols:
# Note that you may want to access the margin interest of the crypto future to calculate if it would impact a trade's PnL
if symbol in slice.margin_interest_rates:
interest_rate = slice.margin_interest_rates[symbol].interest_rate
algorithm.log(f"{symbol} close at {slice.time}: {interest_rate}")
# Trade only based on updated price data
if not slice.bars.contains_key(symbol) or not slice.quote_bars.contains_key(symbol):
continue
quote = slice.quote_bars[symbol]
price = slice.bars[symbol].price
# Scalp-trade the bid-ask spread based on the supply-demand strength
if price - quote.bid.close > quote.ask.close - price:
insights.append(Insight.price(symbol, timedelta(1), InsightDirection.DOWN))
else:
insights.append(Insight.price(symbol, timedelta(1), InsightDirection.UP))
return insights
def on_securities_changed(self, algorithm: QCAlgorithm, changes: SecurityChanges) -> None:
for security in changes.added_securities:
symbol = security.symbol
self.symbols.append(symbol)
# Historical data
history = algorithm.history(symbol, 10, Resolution.DAILY)
algorithm.debug(f"We got {len(history)} from our history request for {symbol}")
for security in changes.removed_securities:
symbol = security.symbol
if symbol in self.symbols:
self.symbols.remove(symbol)
using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Brokerages;
using QuantConnect.Data;
using QuantConnect.Data.UniverseSelection;
using QuantConnect.Algorithm.Framework.Selection;
using QuantConnect.Algorithm.Framework.Alphas;
using QuantConnect.Algorithm.Framework.Portfolio;
using QuantConnect.Algorithm.Framework.Execution;
namespace QuantConnect.Algorithm.CSharp
{
public class BybitCryptoFutureDataAlgorithm : QCAlgorithm
{
public Symbol _symbol;
public override void Initialize()
{
SetStartDate(2022, 10, 1);
SetEndDate(2022, 10, 10);
// Set Account Currency to Tether, since USD and USDT will not auto-convert and USD cannot be used to trade
SetAccountCurrency("USDT", 100000);
// Bybit accepts both Cash and Margin account types, select the one you need for the best reality modeling.
SetBrokerageModel(BrokerageName.Bybit, AccountType.Margin);
UniverseSettings.Resolution = Resolution.Daily;
UniverseSettings.Leverage = 2;
// We only trade on BTCUSDT Future in Bybit exchange
var symbols = new []{
QuantConnect.Symbol.Create("BTCUSDT", SecurityType.CryptoFuture, Market.Bybit)
};
AddUniverseSelection(new ManualUniverseSelectionModel(symbols));
// Custom alpha model to emit insights based on the Crypto Future price data
AddAlpha(new CryptoFutureAlphaModel());
// Equally invest to evenly dissipate the capital concentration risk of inidividual crypto pair
SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel());
SetExecution(new ImmediateExecutionModel());
}
}
public class CryptoFutureAlphaModel : AlphaModel
{
private List<Symbol> _symbols = new();
public override List<Insight> Update(QCAlgorithm algorithm, Slice slice)
{
var insights = new List<Insight>();
foreach (var symbol in _symbols)
{
// Note that you may want to access the margin interest of the crypto future to calculate if it would impact a trade's PnL
if (slice.MarginInterestRates.ContainsKey(symbol))
{
var interestRate = slice.MarginInterestRates[symbol].InterestRate;
algorithm.Log($"{symbol} price at {slice.Time}: {interestRate}");
}
// Trade only based on updated price data
if (!slice.Bars.ContainsKey(symbol) || !slice.QuoteBars.TryGet(symbol, out var qoute))
{
continue;
}
var price = slice.Bars[symbol].Price;
// Scalp-trade the bid-ask spread based on the supply-demand strength
if (price - quote.Bid.Close > quote.Ask.Close - price)
{
insights.Add(
Insight.Price(symbol, TimeSpan.FromDays(1), InsightDirection.Down)
);
}
else
{
insights.Add(
Insight.Price(symbol, TimeSpan.FromDays(1), InsightDirection.Up)
);
}
}
return insights;
}
public override void OnSecuritiesChanged(QCAlgorithm algorithm, SecurityChanges changes)
{
foreach (var security in changes.AddedSecurities)
{
var symbol = security.Symbol;
_symbols.Add(symbol);
// Historical data
var history = algorithm.History(symbol, 10, Resolution.Daily);
algorithm.Debug($"We got {history.Count()} from our history request for {symbol}");
}
foreach (var security in changes.RemovedSecurities)
{
_symbols.Remove(security.Symbol);
}
}
}
}
Bybit Crypto Future Price Data is allowed to be used in the cloud for personal and commercial projects for free. The data is permissioned for use within the licensed organization only
Free | Documentation
Bybit Crypto Future Price Data can be downloaded on premise with the LEAN CLI, for a charge per file downloaded. This download is for the licensed organization's internal LEAN use only and cannot be redistributed or converted in any format.
Starting at 5 QCC/file | Learn More
LEAN CLI is a cross-platform wrapper on the QuantConnect algorithmic trading engine called LEAN. The CLI makes using LEAN incredibly easy, reducing most of the pain points of developing and managing an algorithmic trading strategy to a few lines of bash.
Using the CLI you can download the same data QuantConnect hosts in the cloud for a small fee. These fees are per file downloaded, and are paid for in QuantConnect-Credits (QCC). We recommend purchasing credits to enable downloading.
The CLI command generator is a helpful tool to generate a copy-paste command to download this dataset from the form below.
lean data download \
--dataset "Bybit Crypto Future Price Data" \
--data-type "trade" \
--ticker "BTCUSDT, ETHUSDT" \
--resolution "second" \
--start "20240328" \
--end "20250328"
lean data download `
--dataset "Bybit Crypto Future Price Data" `
--data-type "trade" `
--ticker "BTCUSDT, ETHUSDT" `
--resolution "second" `
--start "20240328" `
--end "20250328"
Free access to Bybit Crypto Future margin rate data from Bybit via the QuantConnect Cloud platform for your backtesting and research.
Crypto-futures Tick resolution archives in LEAN format for on premise backtesting and research. One file per ticker/day
Crypto-futures Second resolution archives in LEAN format for on premise backtesting and research. One file per ticker/day
Crypto-futures Minute resolution archives in LEAN format for on premise backtesting and research. One file per ticker/day
Crypto-futures Hour resolution archives in LEAN format for on premise backtesting and research. One file per ticker.
Crypto-futures Daily resolution archives in LEAN format for on premise backtesting and research. One file per ticker.
What people are saying about this
This product has not received any reviews yet, be the first to post one!
Rate the Module:
Provider offers 6 licensing options
Explore free and paid datasets available on QuantConnect covering fundamentals, pricing, and alternative options.
Dataset Status from to
No Runs
OK
Degraded
Failure
Explore free and paid datasets available on QuantConnect covering fundamentals, pricing, and alternative options.
Lorem ipsum dolor sit amet conjectura lorem ipsum dolor sit amet conjectura lorem ipsum
Configuration Keys
Environment Variables
Lorem ipsum dolor sit amet conjectura lorem ipsum dolor sit amet conjectura lorem ipsum
File Link
Lorem ipsum dolor sit amet conjectura lorem ipsum dolor sit amet conjectura lorem ipsum
Lorem ipsum dolor sit amet conjectura lorem ipsum dolor sit amet conjectura lorem ipsum
Upload a manually created tar or zip file to all cloud data systems.
Add a link and click the Sync Dataset button to upload the dataset
Upload Destinations
The dataset synchronizer is an internal tool for the QuantConnect team to upload data to the
cloud data storage environments. It supports TAR files which are extracted in the root directory
of the cloud data environments.
Take extreme care to carefully structure your data TAR package with
the same folders as the LEAN data folder. Ensure all folders and file names are lowercase as Linux is case-sensitive.
Support
Algorithm Lab is your playground for developing and refining trading algorithms with QuantConnect. Utilize advanced tools, historical data, and robust backtesting to enhance your trading strategies. Transform your ideas into actionable insights and optimize your trading approach with ease.
Sign Up for FreeAlready have an account Log In.
â‘
â‘
â‘
â‘
â‘
Hover and click over the stars to rate us.
It looks like you are not fully satisfied with your experience on QuantConnect, please take a moment to let us know how we can improve our services for you:
If you have a minute to spare, please leave us a review on Trustpilot.
Stories like yours help others see the full potential of QuantConnect.
Organization Name |
---|
Upgrade to Team plan or higher to enable custom invoicing
Changes will be applied to future invoices.
Users will be able to join by following the link in the invitation email.
You’ve been invited by Jared Broad to join his G-Force Organization.
Would you like to accept the invitation?
Are you sure you want to delete the encryption key "undefined"?
Caution: We will not be able to decrypt encrypted projects without the original key.
Drag & Drop or
Keys are added to the local storage in your web browser and not uploaded to QuantConnect. To use an encrypted project on another computer you will need to bring a copy of the key.
This project is encrypted using the key .
This project will be encrypted using the key .