An Earnings Momentum trading bot that bets on stocks with positive earnings responses continuing to increase and beat the market. We test on the Dow 30.
Note: Python Version 3.7+ is supported
- First install Blankly using
pip
. Blankly is hosted on PyPi.
$ pip install blankly
- Clone the repo --
git clone https://github.com/blankly-finance/EarningsMomentum.git
- Ensure that you have your Alpaca API Keys connected and set sandbox to true. Check here for more details
- Edit the python file and input your Financial Modeling Prep API keys into the code (line 25)
- Run the python file
$ python earningsbot.py
- Voila! You have a stock trading bot that trades off an Earnings Momentum Strategy.
Calmar Ratio: 1.96
Compound Annual Growth Rate (%): 11.0%
Conditional Value-at-Risk: 4.01
Cumulative Returns (%): 11.0%
Max Drawdown (%): 4.0%
Resampled Time: 86400.0
Risk Free Return Rate: 0.0
Sharpe Ratio: 1.16
Sortino Ratio: 1.47
Value-at-Risk: 71.42
Variance (%): 0.38%
Volatility: 0.06
Also viewable here.
This uses the Blankly package to build a trading strategy
We are able to utilize the Blankly.Strategy
object to create our arbitrage event that checks at every timestep whether a stock has a positive earnings response over a week timeframe. We can then use that, along with our earnings calendar, obtained through Financial Modeling Prep, to backtest our strategy on the past few years.
The Earnings Momentum Strategy is one of many momentum strategies, where instead of trying to predict the market's next moves, we ride the wave. Several momentum strategies have been shown to outperform the market over long time frames, and so building strategies around momentum is a great way to generate alpha.
Earnings Momentum - Investopedia
Fork this repository and build on top of this strategy -- more stocks, different ways to hedge/pair trade, or whatever else you can think of. Take this strategy live by adding strategy.start()