This project is a Python-based stock trading bot that uses the Supertrend strategy. It uses the Alpaca Paper Trading API and Yahoo Finance API (yfinance) to gather data and make trades.
- Uses the supertrend strategy to determine when to buy and sell stocks.
- Runs only during market hours to ensure accurate and up-to-date information.
- Implements stop loss orders to minimize losses in case of unfavorable market conditions.
- Prints out all relevant data to keep users informed of the bot's activity.
To install the required packages, use pip: pip install alpaca-trade-api yfinance
Before using the bot, you need to set up an Alpaca Paper Trading account and get your API keys. You can find more information on how to do that at https://alpaca.markets/learn/start-paper-trading/.
Once you have your API keys, open the bot.py
file and replace API_KEY
and SECRET_KEY
with your actual keys.
To run the bot, simply run the bot.py
script. You can customize the stockN
and alpacaName
variables to the stock you wish to trade.
Since this bot dowloads live market data on a certain timeframe it is highly suggested to run it on a cloud platform such as PythonAnywhere.
To run the bot on PythonAnywhere, follow these steps:
- Create a PythonAnywhere account and log in.
- In the dashboard, go to the "Files" tab and click "New file".
- Name the file
bot.py
and copy the contents ofbot.py
into it. - Save the file and return to the dashboard.
- Open a new console and navigate to the directory where
bot.py
is located. - Run the command
python bot.py
to start the bot.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License.
This bot is provided for educational and informational purposes only. It is not intended to be used as a financial or investment advice. The user assumes all responsibility and risk associated with the use of this bot.