If I were to want to check some data or order a security at a specific time of day how would I do that? Below is an example that I have been trying to just order aapl at 10:30am and then sell after 6hrs. But no orders ever get executed.
from pytz import timezone
# Put any initialization logic here. The context object will be passed to
# the other methods in your algorithm.
def initialize(context):
#myfunc will be called every day 60min after market open
schedule_function(
openfunc,
date_rules.every_day(),
time_rules.market_open(hours=1, minutes=0)
)
schedule_function(
closefunc,
date_rules.every_day(),
time_rules.market_open(hours=6, minutes=0)
)
# Will be called on every trade event for the securities you specify.
def handle_data(context, data):
pass
def openfunc(context, data):
order(sid(24), 50)
def closefunc(context, data):
order_target(sid(24), 0)