Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Pair Trade - Exxon and Chevron

I'm rather new to both trading and this website. This is my first algorithm and I tried implementing a basic pair trading strategy. The idea is that when the current ratio of two highly correlated stocks like Exxon and Chevron diverts from the 30 day average of the ratio, the algorithm increases the shares for the undervalued stock and decreases the shares of the overvalued stock. The shares go back to an even amount once the current ratio crosses back over the 30 day average. The algorithm seems to have moderate success. Any input to improve the algorithm would be greatly appreciated.