| 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 datetime import timedelta
from collections import deque
class TestAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2017, 8, 2)
self.SetEndDate(2017, 8, 3)
self.SetCash(25000)
# Subscribe and set our expiry filter fr the futures chain
# get contracts expring in 15 to 180 days
self.soybeans = self.AddFuture(Futures.Grains.Soybeans, Resolution.Hour)
self.soybeans.SetFilter(timedelta(15), timedelta(180))
def OnData(self, slice):
# only print out data for settlement (which occurs at 2:15 PM ET)
if not (self.Time.hour == 14 and self.Time.minute == 15):
return
data = dict()
# iterate over each futures chain we are getting data for
for chain in slice.FutureChains:
# sort the contracts by open interest (highest to lowest, so reverse the default sort order)
# get the first contract in the sorted list to get the month we want data on
front = sorted(chain.Value, key = lambda x: x.OpenInterest, reverse=True)[0]
self.Log(str(self.History(front.Symbol, 5, Resolution.Hour)))