I tried and tried but I can't figure out the issue. Need help, thanks.
def initialize(context):
context.csco = sid(1900)
schedule_function(when_to_sell, date_rules.every_day(), time_rules.market_open(minutes=1))
schedule_function(buy_shares, date_rules.every_day(), time_rules.market_open(minutes=1))
schedule_function(sell_shares, date_rules.every_day(), time_rules.market_open(minutes=1))
def buy_shares(context, data):
order_target_percent(context.csco, 0.50)
def when_to_sell(context, data):
hist = data.history(context.csco, 'price', 15, '1m')
lego = hist.mean()
stop_price = lego + (lego*0.005)
stock_price = data.current(context.csco, 'price')
try:
if stock_price > stop_price
order_target_percent(context.csco, 0)