Samson

How to backtest with Adjusted Price?

Programming


Hey everyone!

I was running a backtest for AAPL, and noticed the market price suddenly dropped by over 90%. I think this happened because of a stock split. Does anyone know how I can backtest using adjusted prices instead? Would really appreciate any tips!

Thanks!

 
Darius
you can't backtest with adjusted price, the system is using original price
 
Darius
Original Posted by - Darius: you can't backtest with adjusted price, the system is using original price
as an alternative, if you have the adjusted prices, you can follow this to import to the system for backtest
 
tony lam
For reference, here the general system behavior to handle corporate events: 

  • The data steam under on_marketdatafeed and on_bulkdatafeed are the original price observed in the market. It is a system design to simulate the actual data feed when deploying the algo in real market. 
  • If there is outstanding position before stock split, the system will auto adjust the position/ avg entry price/ tp/ sl on the split date. (eg. doubling the position if it is a 1-to-2 split) 
  • You can always use the getSystemOrders function to get the latest order and position details reflecting the effect of corporate events. 
  • The result from the getHistoricalBar function is adjusted for corporate events. 

If you implement dynamic logic for monitoring close order conditions, you may need to handle properly to cater for sudden price gaps due to those split events.