Hey, I am having trouble with my code, I simply don't understand what I am doing wrong with the syntax.
here is the code
def initialize(context):
context.stock =sid(39940)
schedule_function(
myfunc,
date_rules.every_day(),)
schedule_function(
myotherfunc,
date_rules.every_day(),
time_rules.market_close(minutes=2))
total_minutes = 6*60 + 30
for i in range(total_minutes):
# Every 30 minutes run schedule
if i % 30 == 0:
schedule_function(
myfunc
date_rule = date_rules.every_day(),
time_rule=time_rules.market_open(minutes=i),)
total_minutes = 6*60 + 30
for i in range(total_minutes):
# Every 30 minutes run schedule
if i % 30 == 0:
schedule_function(
handle_data
date_rule=date_rules.every_day(),
time_rule=time_rules.market_open(minutes=i),)
def myfunc_(context, data):
open_price= data[context.stock].open_price
order(context.stock, 100, style=StopOrder(open_price))
def handle_data(context, data):
data[context.stock].open_price
curr_bar = data[context.stock].price
open_price= data[context.stock].open_price
if curr_bar > open_price :
order(context.stock, 100, style=StopOrder(open_price))
def myfunc(context, data):
data[context.stock].open_price
curr_bar = data[context.stock].price
open_price= data[context.stock].open_price
if curr_bar <= open_price :
order(context.stock, -100, style=LimitOrder(open_price))
def myotherfunc(context,data):
order(context.stock, -100)