Skip to content

TenzinDhonyoe/TradingBot-Using-ML

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎉 Welcome to the MLTrader Project! 🎉

This project is a super cool machine learning-based trading strategy using the lumibot library and Alpaca's trading API. The strategy uses sentiment analysis to make smart trading decisions for the SPY symbol. 🚀

Project Structure 📂

.
├── stonks.py           # Main script containing the MLTrader strategy
├── README.html       # Project README in HTML format
└── utils.py          # Utility functions including sentiment estimation
        

Dependencies 📦

Make sure to install these dependencies before running the project:

pip install lumibot alpaca-trade-api pandas numpy torch transformers
        

Setup 🛠️

To get started with the MLTrader project, follow these steps to set up your environment and get your API credentials from Alpaca:

1. Obtain Alpaca API Credentials 🔑

  1. Sign up for an account at Alpaca.
  2. Log in and navigate to the API section of your dashboard.
  3. Create a new API key. Choose paper trading to test without real money.
  4. Store your API_KEY and API_SECRET securely.

2. Configure Your Environment 💻

It's best to use environment variables or a configuration file to store your API credentials securely. You can set your environment variables as follows:

export ALPACA_API_KEY="your_api_key_here"
export ALPACA_API_SECRET="your_api_secret_here"
        

Alternatively, you can create a config.py file to store these values (not recommended for production).

Usage 🚀

To run the backtesting process, execute the main script:

python stonks.py
        

The backtesting will use historical data to simulate trading based on the MLTrader strategy. Ensure that your utils.py file includes the necessary functions for sentiment analysis, which are essential for the strategy's decision-making process.

Use Case: SPY with 80% Annual Return 📈

Below are the screenshots showing the use case of the program for SPY with an 80% annual return:

Trading performance chart Trading performance statistics

About

This repository contains the code for a trading bot developed using machine learning techniques and Alpaca’s API. The bot is designed to trade the SPY ETF by analyzing sentiment from news articles and making buy or sell decisions based on the analysis.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages