Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% 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 $0.00 |
from clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Common") from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Securities import * from datetime import timedelta import decimal as d import numpy as np from datetime import datetime import decimal class FutureTimeOffsetBug(QCAlgorithm): def Initialize(self): self.SetStartDate(2018, 1, 16) self.SetEndDate(2018, 1, 16) self.SetCash(100000) self.SetWarmUp(30); #setup scheduler for all USA traded ETF funds self.equity = self.AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute) self.future = self.AddFuture( Futures.Indices.SP500EMini ) self.future.SetFilter(timedelta(0), timedelta(180)) def OnData(self,slice): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.''' if self.IsWarmingUp: return chain = None contracts = None contract = None for chain in slice.FuturesChains: # find the front contract expiring no earlier than in 90 days contracts = filter(lambda x: x.Expiry > self.Time + timedelta(15), chain.Value) # if there is any contract, trade the front contract if len(contracts) == 0: continue contract = sorted(contracts, key = lambda x: x.Expiry, reverse=False)[0] self.Log("SPY slice date: {0} price: {1} contract symbol: {2} slice date: {3} price: {4}".format(self.equity.LocalTime, self.equity.Price, contract.Symbol.Value, contract.Time, contract.LastPrice)) # self.Log("contract symbol: {0} slice date: {1} price: {2}".format(contract.Symbol.Value, contract.Time, contract.LastPrice))