So I am now moving to learn quantopian for futures trading and have ran into a problem where I cannot place a paper trade. The error says that it cannot specify the symbol in the order
method. I am hoping that someone can give me an answer to help me understand what is happening.
def initialize(context):
# Dow Jones E-Mini Continuous Future
context.future = continuous_future('YM')
schedule_function(daily_func, date_rules.every_day(), time_rules.market_open())
def daily_func(context, data):
ym_active = data.history(context.future, 'price', 50, '1m')
log.info(ym_active)
sma_50 = ym_active.mean()
sma_20 = ym_active[-20:].mean()
if sma_20 > sma_50:
#I am running into a problem where it says that I have to specify the contract.
order(context.future, 1, style=MarketOrder)
elif sma_20 < sma_50:
#I am running into a problem here too.
order(context.future, -1, style=MarketOrder)