Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
cost_basis and amount are split adjusted

I just realized that the cost_basis and amount properties in context.portfolio[my_stock].positions are automagically adjusted for splits. Maybe this was evident to others but I had to test it to verify it's true (maybe note this in the documentation? https://www.quantopian.com/help#api-position this isn't a feature request just a doc update request). It makes complete sense that this would be required.

Specifically, I was looking to place a limit order to sell at a certain profit percent. This can easily be done with

price = context.portfolio.positions[my_stock].cost_basis * (1 + desired_profit)

Look at the logs in the attached backtest. HNR had a 4:1 split on 11/4/2016. The positions properties are correctly adjusted.