Hi,
I have only spent a few hours toying with Quantopian and I am predictably stuck. I wanted to do a buy-and-hold test.
For example, buy a set of securities on March 15, 2002 and hold on until now.
Just one transaction per security for all time. I started from the trading example that rebalances an equally weighted
portfolio of 9 sector ETFs.
I either get an invalid syntax error or if it runs, no trade happens.
if exchange_time.date() == datetime.date(2002,3,15): <--- this results in no trades
if exchange_time.date() == datetime.datetime(2002,3,15,0,0,tzinfo=): <--- this results in invalid syntax.
if exchange_time.date() == '2002-03-15': <--- this results in no trades
# Do nothing if there are open orders:
if has_orders(context):
print('has open orders - doing nothing!')
return
rebalance(context, data, exchange_time)
Clearly the date condition is not met. How can I trade only on a specific date? (or date/time for that matter)
Thank you