Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Opening Momentum Algo Help

Hi All,

I am brand new to algorithmic trading. For my first algo, I want to capture the initial opening pricing of a security. If after opening, the price goes up, I will buy and if it goes down, I will sell. Let's say AAPL is up .1% as of 9:31, I will buy. At 9:40, it is up 1.2%. If the price falls more than 10% of that day's gains (so in this case to being up only 1.08%), I will close the position. Basically, I want to capture the initial opening momentum and then once it starts to change, get out for the day.

In the before_trading_start method, I want to get pricing for the securities so I have the starting price for comparison and know when to enter and exit the position. However, I keep getting errors when I add startAppl = data[context.aapl].price to the method. Does anyone have suggestions as why/ how to properly structure my code for this algo idea?

Thank you so much for the help, I really appreciate it.
-Justin