Closed
Description
Hello,
I am trying to open a long limit order when the time is between 2:55pm and 3pm and only in that timeframe.
In raw python it would look like this, where x is my index column in my dataframe.
def time_in_range(x):
start = time(14, 55)
end = time(15 0)
x = datetime.strptime(x, '%Y-%m-%d %H:%M:%S')
"""Return true if x is in the range [start, end]"""
if start <= end:
return start <= x <= end
else:
return start <= x or x <= end
I am however unsure how I would make it in the backtesting library? How do I open a long limit order when the time is between 2:55pm and 3pm and then close it say 10 minutes later if it hasn't been filled?