-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Are trades based on signals lagged? #541
-
My forecasted price and my open price are both in the same dataframe. When I run the backtest, it doesn't buy when the buy condition (forecasted price > open price) is fulfilled, yet it buys the next day despite the sell condition being fulfilled (forecasted price < open price) I've repeatedly checked my code and checked the csv the dataframe is reading, and nothing is suggesting that I formatted the data incorrectly. If someone could follow up with this I'd be grateful.
Beta Was this translation helpful? Give feedback.
All reactions
IIUC, have you tried with trade_on_close=True
?
Replies: 2 comments 2 replies
-
Just tested it on another ticker, and yes, trade signals are lagged. This is incredibly confusing, especially compounded with the fact that the backtesting model always sells on the last candle...
Beta Was this translation helpful? Give feedback.
All reactions
-
IIUC, have you tried with trade_on_close=True
?
Beta Was this translation helpful? Give feedback.
All reactions
-
Apologies, I should have read the documentation where it states that when buy/sell condition is met, a buy order will be placed on next days open. And if trade_on_close=True, it will buy on close on the same candle. Is it possible to make orders on open of the same candle?
Beta Was this translation helpful? Give feedback.
All reactions
-
When is it that you are going to be deciding upon your trade then? Do you often place your market order for 8 AM at 11 AM? 🤨 If you need more timely precision, use more fine-grained data. It's all in the tutorial. 😛
Beta Was this translation helpful? Give feedback.