Filling at an extreme price - way above the high of the bar?
Getting an entry way above the high of the bar. What 's it happening there?
How must I deal with it? Makes my backtest invalid if it is a common error in the database.
Please look at chart in dropbox link
https://www.dropbox.com/s/3t5wpdah84vt7o5/Captura de pantalla 2018-04-12 14.55.12.png?dl=0
Comments
You didnt give us a symbol or a date, but looking at the chart, the time is 9:31.
Is it possible you are attempting to trade before the open (or even at the open without an opening auction order)?
If you place any order at any time and the bid or ask is "way out" the sim will fill you based on the bid/ask at the time.
If there is no bid or ask then they can often be set by default to 0 and 199999.99 and you will be filled at these prices.
Depending on the type of model you are writing it is often good practice to ensure the spread is not too large
md.L1.ask-md.L1.bid<md.stat.prev_close*0.01 # spread is less than 1% of the close price.
You do not want to get into the habit of loosely sending out market orders without checking bid, ask and spread, particularly with HFT algo's around!
Run the code below to see all symbols on a particular day that still have not opened after 9:31 with a spread of more than 5% of the previous close...
Sample Output