I am having an issue. I am trying to implement the algorithm found at:
http://www.reddit.com/r/investing/comments/1fr0z8/analysis_of_a_trading_strategy_buy_the_10_day_low/
The algorithm has as an exit signal, sell if you have been holding a stock for 10 days. I saw that context.portfolio.positions exists but it doesn't seem to include a date for any given stock. Can someone please help me find a way to keep track of how long I have held a stock for? I could maybe do something like
elif buy_signal(context, data) and notional < context.max_notional:
order(context.stock,+100)
date = #get date somehow
context.portfolio.positions[context.stock].date = date
Thanks for checking this post out.