Overall Statistics
Total Orders
7
Average Win
3.88%
Average Loss
0%
Compounding Annual Return
11497.758%
Drawdown
0.100%
Expectancy
0
Start Equity
200000.0
End Equity
230303.94
Net Profit
15.152%
Sharpe Ratio
809.947
Sortino Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
179.874
Beta
0.281
Annual Standard Deviation
0.222
Annual Variance
0.049
Information Ratio
565.804
Tracking Error
0.318
Treynor Ratio
638.899
Total Fees
$380.06
Estimated Strategy Capacity
$24000000.00
Lowest Capacity Asset
BTCBUSD 18R
Portfolio Turnover
46.21%
from AlgorithmImports import *

class BinanceCryptoFutureDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2022, 10, 1)
        self.set_end_date(2022, 10, 10)
        self.set_cash("BUSD", 100000)

        self.set_brokerage_model(BrokerageName.BINANCE_FUTURES, AccountType.MARGIN)

        crypto_future = self.add_crypto_future("BTCBUSD", Resolution.DAILY)
        # perpetual futures does not have a filter function
        self.btcusd = crypto_future.symbol

        # Historical data
        history = self.history(self.btcusd, 10, Resolution.DAILY)
        self.debug(f"We got {len(history)} from our history request for {self.btcusd}")

    def on_data(self, slice: Slice) -> None:

        if self.btcusd in slice.margin_interest_rates:
            interest_rate = slice.margin_interest_rates[self.btcusd].interest_rate
            self.log(f"{self.btcusd} close at {slice.time}: {interest_rate}")        

        if not slice.bars.contains_key(self.btcusd) or not slice.quote_bars.contains_key(self.btcusd):
            return

        quote = slice.quote_bars[self.btcusd]
        price = slice.bars[self.btcusd].price
        
        if price - quote.bid.close > quote.ask.close - price:
            self.set_holdings(self.btcusd, -1)
        else:
            self.set_holdings(self.btcusd, 1)