Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Price and volatility on oil

I think I have this set up so if both USO and OVX (the USO volatility index) are down the previous day, the algo goes long for one day.

2 responses

Hi, You should add a pre_func where you shift the csv data, thats closer to realistic 1day data delay in a live algo (Csv’s are fetched once a day before market opens)

https://www.quantopian.com/posts/shifting-csv-data-simple-question

@Darell Thanks! Just the kind of advice I was looking for

I've attached another backtest where I think I did the pre_func correctly to sort then shift the data back by 1. EDIT: I changed it to df = df.sort(...), but it seems like it returned the same results.

also added some code to make sure there were no open orders that I lifted from here: https://www.quantopian.com/posts/order-target-percent-ordering-too-much#53fe585813eaecd7d7000181 -- dunno if it's necessary or not.