Hey guys,
I´m new in programming with quantopian and I have a problem. I`m trying to place an order on a specific date every month.
My code actually looks like this:
def trading_function(context, data):
open_orders = get_open_orders()
actual_time = get_datetime()
order_time1 = datetime.datetime(2017, 1, 27)
if actual_time == order_time1:
if context.spy not in open_orders and data.can_trade(context.spy):
order_target_percent(context.spy, 1.0, stop_price='price'*0.9)
it tells me the following:
TypeError: can't compare offset-naive and offset-aware datetimes
The problem is in the line "if actual_time == order_time1".
So the problem seems to be that the two datetypes dont match together. Is there any possibility to order on a specific date?
The next problem is, that with this method, I have to manually save all dates for ordering. Like I did at the variable order_time1.
Is there any possibility to always order on the 27th per month without saving all dates manually?
I hope you can help me. Thank you guys.