Back to Posts
Listen to Thread

Anyone have any advice on building a time based algo?

For example, if the return of SPY is positive since the previous day's close, short at 3:30pm and cover at 3:59pm. If the return of the SPY is negative since the previous day's close, buy spy at 3:30pm and sell at 3:59pm.

first, you can store closing data that you load separately (the minute-by-minute bars don't include the actual official close) in a dictionary in the context variable.
then, keep checking the timestamps on your SPY data as it comes in and act accordingly (at 330, put on the position, at 359, take it off).

Log in to reply to this thread.
Not a member? Sign up!