Skip to content

kathirsci41/ML-trading-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ML-trading-Bot

Certainly! Here’s a concise and detailed description for your GitHub repository:


ML Trading Bot

This repository contains a Python-based machine learning trading bot that uses Alpaca API for executing trades. The bot leverages sentiment analysis of news headlines to inform its trading decisions, targeting the SPY stock. It features position sizing based on available cash and a risk-free rate fetched from Yahoo Finance.

Features

  • Sentiment Analysis: The bot fetches recent news headlines and estimates sentiment to decide on trades.
  • Automated Trading: Integrates with Alpaca API for seamless trading operations including buying and selling stocks.
  • Risk Management: Calculates position sizes based on available cash and predefined risk tolerance.
  • Daily Iterations: Runs trading logic in daily intervals, adjusting positions based on updated sentiment.

Prerequisites

  • Python 3.7+
  • Alpaca API keys (set as environment variables)
  • Required Python packages listed in requirements.txt

Setup

  1. Clone the repository:

    git clone https://github.com/yourusername/ml-trading-bot.git
    cd ml-trading-bot
  2. Install dependencies:

    pip install -r requirements.txt
  3. Set up environment variables: Create a .env file in the project root with the following content:

    ALPACA_API_KEY=your_api_key
    ALPACA_API_SECRET=your_api_secret
    
  4. Run the bot:

    python tradingbot.py

Usage

The bot is designed to be run continuously, making trading decisions based on the latest available data and sentiment analysis. Ensure the environment variables are set and the Alpaca API keys are valid before running the script.

Customization

  • Symbol: Change the trading symbol by modifying the symbol parameter in the initialize method.
  • Cash at Risk: Adjust the risk tolerance by modifying the cash_at_risk parameter.
  • Sentiment Analysis: Integrate your own sentiment analysis model by customizing the estimate_sentiment function.

Contributing

Feel free to submit issues and pull requests. Contributions are welcome!

License

This project is licensed under the MIT License. See the LICENSE file for details.


You can adjust the URLs and placeholders (yourusername, your_api_key, your_api_secret) as needed. This description provides an overview of the project, setup instructions, usage details, and customization options.

About

Python-based ML trading bot using Alpaca API. Executes trades on SPY based on sentiment analysis of news headlines. Features automated trading, risk management, and daily iterations. Requires Python 3.7+, Alpaca API keys, and dependencies in `requirements.txt`. Customize symbol and risk tolerance as needed.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages