📜  if sma_20 > sma_50: if context.aapl not in open_orders order_target_percent(context.aapl,1.0)#order_target_percent(card,% of profoil)''' - 任何代码示例

📅  最后修改于: 2022-03-11 14:54:57.453000             🧑  作者: Mango

代码示例1
hist = data.history(context.aapl,'price', 50, '1d')
    
    sma_50 = hist.mean()
    sma_20 = hist[-20:].mean()
    
    open_orders = get_open_orders()
    
    if sma_20 > sma_50:
        if context.aapl not in open_orders:
            order_target_percent(context.aapl, 1.0)
    elif sma_20 < sma_50:
        if context.aapl not in open_orders:
            order_target_percent(context.aapl, -1.0)