Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How to get the traded price

Hi

I am pretty new to Quantopian. I have used ProRealtime but want to try the more dynamic Quantopian for automatic trading.
I guess my problem is quite simple to solve. I want to compare the price I paid for a traded stock with the current price. In PRT there is a function called "TradedPrice" but I can't find a similar function.

Grateful for some help.

3 responses

Solved it by saving the current_price in context.traded_price at the actual time I bought the stock.

Inside the context.portfolio.positions object you have a Position object for every security you hold. You can then use Position.cost_basis to know at what price you bought that security

Wonderful! Thank you!