tfukaza / harvest

Simple and intuitive Python framework for algorithmic trading. Easily create bots to live and paper trade stocks, crypto, and options!
https://tfukaza.github.io/harvest-website
MIT License
122 stars 26 forks source link
algorithmic-trading backtesting cryptocurrency options paper-trading python stock trading trading-bot

Header
Harvest is a simple yet flexible Python framework for algorithmic trading. Paper trade and live trade stocks, cryptos, and options![^1][^2] Visit here for tutorials and documentation.


codecov run tests Code style: Black

⚠️WARNING⚠️ Harvest is currently at v0.3. The program is unstable and contains many bugs. Use with caution, and contributions are greatly appreciated.

See for yourself!

The example below is an algorithm to trade Twitter stocks using the moving average crossover strategy.

from harvest.algo import *
from harvest.trader 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()

To paper trade using this algorithm, run the following command:

harvest start -s yahoo -b paper

To live trade using Robinhood, run:

harvest start -s robinhood -b robinhood

With Harvest, the process of testing and deploying your strategies is a piece of cake 🍰

Installation

The only requirement is to have Python 3.9 or newer.

Once you're ready, 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:

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.

Disclaimer

Linter

[^1]: What assets you can trade depends on the broker you are using. [^2]: Backtesting is also available, but it is not supported for options.