Overall Statistics |
Total Trades 28 Average Win 0.00% Average Loss 0.00% Compounding Annual Return -0.001% Drawdown 0.000% Expectancy -0.753 Net Profit -0.010% Sharpe Ratio -0.335 Probabilistic Sharpe Ratio 0.000% Loss Rate 79% Win Rate 21% Profit-Loss Ratio 0.15 Alpha -0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -0.662 Tracking Error 0.154 Treynor Ratio -3.083 Total Fees $51.80 Estimated Strategy Capacity $2900000.00 Lowest Capacity Asset ZW YEALCV7W1CTH |
from AlgorithmImports import * class QAFutureSpreader(QCAlgorithm): # ================================================================================== # Reserved for future comments # ================================================================================== def Initialize(self): self.SetStartDate(2015, 8, 29) self.SetCash(100000000) self.corn = self.AddFuture(Futures.Grains.Corn, Resolution.Daily) self.symbolcorn = self.corn.Symbol self.corn.SetFilter(lambda x: x.ExpirationCycle([1, 12])) self.wheat = self.AddFuture(Futures.Grains.Wheat, Resolution.Daily) self.symbolwheat = self.wheat.Symbol self.wheat.SetFilter(lambda x: x.ExpirationCycle([1,12])) self.SetWarmup(21) self.traded_thismonth = False self.n_days = 12 self.ticket= None def OnData(self, slice: Slice) -> None: chain = slice.FuturesChains.get(self.symbolcorn) chain2 = slice.FutureChains.get(self.symbolwheat) if chain and chain2: contract = sorted(chain, key=lambda contract: contract.Expiry, reverse=True)[0] contract2 = sorted(chain2, key =lambda contract: contract.Expiry, reverse=True)[0] if self.ticket is not None and self.UtcTime >= self.ticket.Time + timedelta(days=self.n_days): self.Liquidate() self.ticket = None if self.Time.month == 9 and self.Time.day < self.n_days: if not self.Portfolio.Invested: self.ticket = self.MarketOrder(contract.Symbol, 1) self.MarketOrder(contract2.Symbol, -1)