Overall Statistics
Total Orders
2
Average Win
0%
Average Loss
-21.92%
Compounding Annual Return
-97.287%
Drawdown
40.700%
Expectancy
-1
Start Equity
100000
End Equity
78077.96
Net Profit
-21.922%
Sharpe Ratio
-1.11
Sortino Ratio
-1.746
Probabilistic Sharpe Ratio
11.587%
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-2.465
Beta
5.395
Annual Standard Deviation
0.914
Annual Variance
0.835
Information Ratio
-1.466
Tracking Error
0.875
Treynor Ratio
-0.188
Total Fees
$22.04
Estimated Strategy Capacity
$43000000.00
Lowest Capacity Asset
BTC YFGXKVY5BTVL
Portfolio Turnover
8.07%
# region imports
from AlgorithmImports import *
# endregion

class BasicFutureAlgorithm(QCAlgorithm):
    def initialize(self):
        self.set_start_date(2024,1,1)
        self.universe_settings.asynchronous = True
        self._future = self.add_future(Futures.Currencies.BTC,
            extended_market_hours=True,
            data_mapping_mode=DataMappingMode.LAST_TRADING_DAY,
            data_normalization_mode=DataNormalizationMode.BACKWARDS_RATIO,
            contract_depth_offset=0)
        #self._future.set_filter(0,62)

    def on_data(self, data):
        if self.portfolio.invested:
            return
        continuous_trade_bar = data.bars.get(self._future.symbol)
        mapped_trade_bar = data.bars.get(self._future.mapped)
        self.market_order(self._future.mapped, 1)
   
    # Track events when security changes its ticker allowing algorithm to adapt to these changes.
    def on_symbol_changed_events(self, symbol_changed_events):
        for symbol, changed_event in  symbol_changed_events.items():
            old_symbol = changed_event.old_symbol
            new_symbol = changed_event.new_symbol
            quantity = self.portfolio[old_symbol].quantity

            # Rolling over: to liquidate any position of the old mapped contract and switch to the newly mapped contract
            tag = f"Rollover - Symbol changed at {self.time}: {old_symbol} -> {new_symbol}"
            self.liquidate(old_symbol, tag=tag)
            if quantity: self.market_order(new_symbol, quantity, tag=tag)