Hi,
Newbie here. Seems like my log and the transaction is off by 1 minute. Why is that? And it seems that I have to run the full back test to get my results. Thanks in advance!
import datetime
from pytz import timezone
def initialize(context):
context.qqq = sid(19920)
def handle_data(context, data):
dt = data[context.qqq].datetime.astimezone(timezone('US/Pacific'))
if dt.year == 2012 and dt.month == 1 and dt.day == 5:
if dt.hour == 10 and dt.minute == 0:
log.info("Ordered 50 on %s" % dt.ctime())
order(context.qqq, 50)
log.info("%s" % data[context.qqq].price)
Log Output:
2012-01-05handle_data:14INFOOrdered 50 on Thu Jan 5 10:00:00 2012
2012-01-05handle_data:16INFO57.43
End of logs.
Transactions List
1 - 1 of 1 PreviousNext
DATE SECURITY TRANSACTION
SHARES
PRICE
$ AMOUNT
2012-01-05 10:01:00 QQQ BUY 50 $57.44 $2,872.00