This project implements an Exponential Moving Average (EMA) crossover trading strategy using Python. The bot fetches historical stock data, calculates EMA crossovers, and logs trades into an Excel file.
- Retrieves historical stock data using the Yahoo Finance API.
- Calculates short-term and long-term EMAs.
- Identifies EMA crossovers for trade signals.
- Logs trade details to an Excel file without overwriting previous data.
- Python 3.7 or higher
yfinancelibrarypandaslibrarynumpylibrary
- Clone the repository:
git clone https://github.com/SoorajR-ai/Algo_Trader.git - Install the required dependencies:
pip install yfinance pandas numpy
Run the trading bot script:
python trading_bot.pyThe bot will fetch stock data, calculate EMA crossovers, and log trades to trading_log.xlsx.
The main script, trading_bot.py, contains the following key functions:
calculate_ema_angle(ema_series): Calculates the angle of an EMA line.main(): Main loop for running the strategy.EMA_cross_scanner(stock, index): Scans for EMA crossovers and logs trades.write_to_excel(): Writes the trade log to an Excel file.
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or issues, please open an issue in the GitHub repository>your.email@example.com.