https://github.com/shirosaidev/stockbot
Alpaca algo stock trading bot
https://github.com/shirosaidev/stockbot
algo-trading algorithmic-trading alpaca alpaca-markets alpaca-trading-api auto-trading nasdaq python stock-market stock-prediction stock-trading stocks trade trading-algorithms
Last synced: 8 months ago
JSON representation
Alpaca algo stock trading bot
- Host: GitHub
- URL: https://github.com/shirosaidev/stockbot
- Owner: shirosaidev
- License: apache-2.0
- Created: 2020-03-27T18:38:21.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-27T04:19:48.000Z (about 4 years ago)
- Last Synced: 2025-08-21T12:49:32.940Z (10 months ago)
- Topics: algo-trading, algorithmic-trading, alpaca, alpaca-markets, alpaca-trading-api, auto-trading, nasdaq, python, stock-market, stock-prediction, stock-trading, stocks, trade, trading-algorithms
- Language: Python
- Homepage:
- Size: 165 KB
- Stars: 185
- Watchers: 9
- Forks: 42
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.MD
- License: LICENSE
Awesome Lists containing this project
README
# stockbot
Alpaca algo stock trading bot
[](./LICENSE)
[](https://github.com/shirosaidev/stockbot/releases/latest)
[](https://www.patreon.com/shirosaidev)
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CLF223XAS4W72)
Get recommended buy and strong buy stocks daily from Nasdaq.com and get prices from Yahoo and determine which stocks moved the most the previous n days, sort those by largest movers (based on open/close $) and buy those stocks if they are going up. When the stock price goes up enough, or at the end of the market day, sell any purchased stocks.
## Options
Trade algo can be set to:
"moved" - uses which stock moved the most in past n days (n days set in config) (default)
"lowtomarket" - uses low price to market price
"lowtohigh" - uses low price to high price
Buy time can bet set to:
"buyatopen" - buy the stocks when market opens and sell when price increases enough or at end of day, whatever comes first
"buyatclose" - buy the stocks before market closes, and hold until next day, if stock price goes up enough sell, or sell at end of next market day
## Slack workspace
Join the conversation, get support, etc on [stocksight Slack](https://join.slack.com/t/stocksightworkspace/shared_invite/enQtNzk1ODI0NjA3MTM4LTA3ZDA0YzllOGNiM2I5ZjAzYWM2MjNmMjI0OTRlY2ZjYTk1NmM5YmEwMmMwOTE2OTNiMGZlNzdjZmZkM2RjM2U).
## Requirements
Uses Alpaca https://alpaca.markets/ for trading. You will need an account with Alpaca to use stockbot.
Set env vars for Alpaca authentication api keys:
```sh
export APCA_API_KEY_ID=
export APCA_API_SECRET_KEY=
export APCA_API_BASE_URL=url
```
url set to:
https://api.alpaca.markets (for live)
https://paper-api.alpaca.markets (for paper)
Install requirements Alpaca python library:
```sh
pip3 install -r requirements.txt
```
### Download
```shell
$ git clone https://github.com/shirosaidev/stockbot.git
$ cd stockbot
```
[Download latest version](https://github.com/shirosaidev/stockbot/releases/latest)
## How to use
Copy sample config:
```sh
cp config.py.sample config.py
```
Edit config.py and adjust settings as needed.
Run stockbot:
```sh
python3 stockbot.py -t -b
```
Stockbot runs in an infinite loop and does daily trading. To stop it, press ctrl+c. Stocks will manually have to be sold on Alpaca web site since stockbot does not keep track of stocks when you exit it.
## Disclaimer
This software is for educational purposes only. USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS. Do not risk money which you are afraid to lose. There might be bugs in the code - this software DOES NOT come with ANY warranty.