Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$37.00
class MultidimensionalNadionCircuit(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 11, 17)  # Set Start Date
        self.SetEndDate(2019, 11, 17)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        # self.AddEquity("SPY", Resolution.Minute)
        
        self.gold = self.AddFuture(Futures.Metals.Gold) 
        self.gold.SetFilter(0, 90)
        
        self.lookback = 3

    def OnData(self, slice):
        for chain in slice.FutureChains:
            self.popularContracts = [contract for contract in chain.Value if contract.OpenInterest > 1000]
  
            if len(self.popularContracts) == 0:
                continue
    
            sortedByOIContracts = sorted(self.popularContracts, key=lambda k : k.OpenInterest, reverse=True)
            self.liquidContract = sortedByOIContracts[0]
            
            if self.Portfolio[self.liquidContract.Symbol].Invested:
                self.mom.Update(slice.Time, self.liquidContract.LastPrice)
                self.Log(f"Current Value: {self.mom.Current.Value}")
                return
        
            self.SetHoldings(self.liquidContract.Symbol, 1)
            
            self.mom = self.MOM(self.liquidContract.Symbol, self.lookback)
            hist = self.History(self.liquidContract.Symbol, self.lookback)['close']
            self.Log(hist.to_string())
            for k, v in hist.items():
                self.mom.Update(k[2], v)
            self.Log(f"Current Value: {self.mom.Current.Value}")
    
    def OnEndOfDay(self):
        pass