I am new to Quantopian and fairly new to Python. My experience if very minimal. I am having a problem with the following code.
import pandas as pd
Put any initialization logic here. The context object will be passed to
the other methods in your algorithm.
def initialize(context):
context.security = sid(24)
Will be called on every trade event for the securities you specify.
def handle_data(context, data):
exchange_time = pd.Timestamp(get_datetime()).tz_convert('US/Eastern')
if exchange_time.hour == 9 and exchange_time.minute == 35:
context.openPrice = data(context.security).open_price
if exchange_time.hour == 10 and exchange_time.minute == 5:
context.lastPrice = data(context.security).price
if context.lastPrice > context.openPrice:
order_target_percent(context.security, 1)
else:
order_target_percent(context.security, -1)
else:
return
return
if exchange_time.hour == 15 and exchange_time.minute == 55:
order_target(context.security, 0)