Harvest is a Python based framework providing a simple and intuitive framework for algorithmic trading. Visit Harvest's website for details, tutorials, and documentation.
Comments? Questions? Join our discussion
Example
Below is a minimal example of a crossover strategy for TWTR
implemented with Harvest, tested on historical stock prices.
from harvest.algo import *
from harvest.trader import *
from harvest.api import *
class Watch(BaseAlgo):
def config(self):
self.watchlist = ["TWTR"]
self.interval = "5MIN"
def main(self):
sma_long = self.sma(period=50)
sma_short = self.sma(period=20)
if self.crossover(sma_long, sma_short):
self.buy()
elif self.crossover(sma_short, sma_long):
self.sell()
if __name__ == "__main__":
t = tester.BackTester()
t.set_algo(Watch())
t.start()
If you want to see how this algorithm performs in real life, just change one line to enable paper trading:
- t = tester.BackTester()
+ t = trader.Trader()
Confident in your strategy? Deploy it using a broker of your choice (Currently only supports Robinhood). Again, you just need to change one line:
- t = trader.Trader()
+ t = trader.Trader(robinhood.Robinhood())
With Harvest, the process of testing, simulating, and deploying your strategies is a piece of cake
Installation
There are few prerequisites:
- Python 3.8+
- pip
Once you have them, install via pip:
pip install harvest-python
Next, install the dependencies necessary for the brokerage of your choice:
pip install harvest-python[BROKER]
Replace BROKER
with a brokerage/data source of your choice:
- Robinhood
- Alpaca
- Webull
- Kraken
- Polygon
- Yahoo
Now you're all set!
Contributing
Contributions are greatly appreciated. Check out the CONTRIBUTING document for details, and ABOUT for the long-term goals of this project.
Currently looking for...
- Python devs to code the framework
- Backend devs for the Flask backend
- Frontend devs to make the web GUI based on Svelte
- UX/UI designers for the web GUI
Disclaimer
- Harvest is not officially associated with Robinhood, Alpaca, WebBull, Kraken, Polygon, or Yahoo.
- Many of the brokers were also not designed to be used for algo-trading. Excessive access to their API can result in your account getting locked.
- Tutorials and documentation solely exist to provide technical references of the code. They are not recommendations of any specific securities or strategies.
- Use Harvest at your own responsibility. Developers of Harvest take no responsibility for any financial losses you incur by using Harvest. By using Harvest, you certify you understand that Harvest is a software in early development and may contain bugs and unexpected behaviors.