1

因此,我现在开始学习期货交易的 Quantopian,但遇到了无法进行纸面交易的问题。该错误表示它无法在order方法中指定符号。我希望有人能给我一个答案,以帮助我了解正在发生的事情。

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) 
4

0 回答 0