Overall Statistics
Total Orders
6
Average Win
0.63%
Average Loss
-0.05%
Compounding Annual Return
6.842%
Drawdown
0.300%
Expectancy
6.313
Start Equity
1000000
End Equity
1011434.84
Net Profit
1.143%
Sharpe Ratio
3.074
Sortino Ratio
3.963
Probabilistic Sharpe Ratio
90.341%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
13.63
Alpha
0.039
Beta
-0.027
Annual Standard Deviation
0.012
Annual Variance
0
Information Ratio
-0.171
Tracking Error
0.107
Treynor Ratio
-1.397
Total Fees
$9.12
Estimated Strategy Capacity
$740000000.00
Lowest Capacity Asset
MGC VOFJUCDY9XNH
Portfolio Turnover
0.65%
from AlgorithmImports import *
from QuantConnect.DataSource import *

class USFuturesDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2013, 12, 20) 
        self.set_end_date(2014, 2, 20)
        self.set_cash(1000000) 
        self.universe_settings.asynchronous = True
        # Requesting data
        self.mini_gold = self.add_future(Futures.Metals.GOLD) 
        self.mini_gold.set_filter(0, 90)
        
        self.micro_gold = self.add_future(Futures.Metals.MICRO_GOLD) 
        self.micro_gold.set_filter(0, 90)
        
        self.contract = {self.mini_gold.symbol: None, self.micro_gold.symbol: None}
    
    def on_data(self, slice: Slice) -> None:
        for kvp in slice.future_chains:
            symbol = kvp.Key
            
            if symbol in self.contract:
                chain = kvp.Value
                
                # Select the contract with the greatest open interest
                most_liquid_contract = sorted(chain, key=lambda contract: contract.open_interest, reverse=True)[0]
                
                if self.contract[symbol] is None or most_liquid_contract.symbol != self.contract[symbol].symbol:
                    if self.contract[symbol] is not None:
                        self.liquidate(self.contract[symbol].symbol)
                    self.contract[symbol] = most_liquid_contract
                    
                    if symbol == self.mini_gold.symbol:
                        self.market_order(self.contract[symbol].symbol, 1)
                    elif symbol == self.micro_gold.symbol:
                        self.market_order(self.contract[symbol].symbol, -1)
                
                
    def on_securities_changed(self, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            # Historical data
            history = self.history(security.symbol, 10, Resolution.MINUTE)
            self.debug(f"We got {len(history)} from our history request for {security.symbol}")