Overall Statistics
Total Trades
825
Average Win
0.31%
Average Loss
-0.07%
Compounding Annual Return
24.561%
Drawdown
8.800%
Expectancy
0.561
Net Profit
24.524%
Sharpe Ratio
1.69
Probabilistic Sharpe Ratio
71.876%
Loss Rate
70%
Win Rate
30%
Profit-Loss Ratio
4.15
Alpha
0.174
Beta
0.149
Annual Standard Deviation
0.12
Annual Variance
0.014
Information Ratio
0.04
Tracking Error
0.279
Treynor Ratio
1.358
Total Fees
$0.00
class MultidimensionalTachyonFlange(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 1)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        # self.AddEquity("SPY", Resolution.Minute)
        self.vx = self.AddFuture(Futures.Indices.VIX, Resolution.Minute)
        self.vx.SetFilter(timedelta(0), timedelta(100))
        self.vx_contracts = []
        self.es = self.AddCfd("SPX500USD", Resolution.Minute, Market.Oanda)

    def OnData(self, data):
        # Sort VIX contracts
        for chain in data.FutureChains:
            contracts = [contract for contract in chain.Value]
            if len(contracts) == 0:
                return
            else:
                self.vx_contracts = []
                for i in contracts:
                    if Futures.Indices.VIX in str(i):
                        self.vx_contracts.append(i)
        self.vx_contracts = self.ContractSorter(self.vx_contracts)
        if self.Time.minute %10 ==0:
            for i in range(len(self.vx_contracts)):
                self.Debug(f"VX contract {i} is "+str(self.vx_contracts[i].AskPrice))
        # If the second month contract is above the first, contango is true and buy SPX
        if self.vx_contracts[1].AskPrice>self.vx_contracts[0].AskPrice:
            self.contango=True
        else:
            self.contango = False
        
        if self.Portfolio.Invested:
            if self.contango == True:
                return
            else:
                self.Liquidate(self.es.Symbol)
        else:
            if self.contango:
                self.SetHoldings(self.es.Symbol,1)
            else:
                return
        
    def ContractSorter(self,contract_list):
        if len(contract_list)>1.5:
            return sorted(contract_list, key = lambda x: x.Expiry,reverse = False)
        else:
            return contract_list