0
Q:

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

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

New to Communities?

Join the community