Harvest algorithmic trading

This revision is from 2024/06/02 09:07. You can Restore it.

cd

mkdir harvest

cd harvest

python3 -m venv ./

source bin/activate

pip install harvest-python[[BROKER]]

Replace BROKER with a brokerage/data source of your choice:

  1. Robinhood
  2. Alpaca
  3. Webull
  4. Kraken
  5. Polygon

pip install harvest-python[[Alpaca]]

Example...

from harvest.algo import *

from harvest.trader import *

class Watch(BaseAlgo):

def config(self):

self.watchlist = ["TSLA"]

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()

  

📝 📜 ⏱️ ⬆️