/trading-bot

Primary LanguageRustOtherNOASSERTION

Contributors Forks Stargazers Issues project_license LinkedIn


Trading Bot in Rust

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

Main Program Photo

This project combines my personal interest in stocks and trading with my goal of enhancing my skills in Rust. Each step of the development process is documented and shared on YouTube in an easy-to-follow series.

You can follow along with the entire journey here: YouTube Playlist.

(back to top)

Getting Started

This section provides instructions for setting up the project locally. Follow the steps below to get a local copy up and running.

Prerequisites

Ensure you have the following installed on your system:

  • Rust (latest stable version)

  • Cargo (comes with Rust)

  • Git (for cloning the repository)

  • You must have a Finnhub and Alpha Vantage API key, In the format belwow in a .env file in root.

    FINHUB_API_KEY=key
    ALPHA_API_KEY=key
    

Installation

  1. Get a free Finnhub API Key at https://finnhub.io
  2. Get a free Alpha Vantage API Key at https://www.alphavantage.co
  3. Clone the repo
    git clone https://github.com/jacobcorbett/trading-bot.git
  4. Run the project
    cargo run

(back to top)

Usage

Below are examples of how to use the trading bot, along with screenshots showcasing key features.

1. Opening a Trade

Start by opening a new trade using the bot's intuitive command-line interface. Opening a Trade

2. Adding Money

Easily manage your trading balance by adding funds as needed. Adding Money

3. Algorithm Mode

Switch to algorithm mode to let the bot trade automatically based on pre-defined strategies. Algorithm Mode

4. Checking the Status of Trades

View the status of all your trades in real time to stay on top of your portfolio. Status of All Trades

5. Saving and Loading States

Save your current trading state to resume later, or load a previously saved state.

  • Saving State: Saving State
  • Loading State: Loading State

6. Main Program View

Get a clear overview of the main program and its functionality. Main Program Photo

These features make the bot flexible and user-friendly, whether you're trading manually or automating your strategies.

(back to top)

Roadmap

Completed Features

  • Set up the ability to read in historical stock data.
  • Learned how to calculate the moving average.
  • Analyzed stock history data to implement the moving average algorithm.
  • Saved all stock moving averages into a vector for easier data management.
  • Set up the algorithm to run daily, checking for updates automatically.
  • Optimize data fetching to only retrieve new stock data when needed.
  • Calculate moving averages "back in time" to avoid starting fresh with new data.
  • Finish implementing the logic to detect when the moving average crosses the 50-day average and trigger trades accordingly.

Planned Features

  • Add support for cryptocurrency data.
  • Update the algorithm to:
    • Allow auto-save functionality in algorithm mode.
    • Stop operations when the market closes.
  • Enhance the interface with improved graphics and a user-friendly design.
  • Update the save file to include historical moving averages or create a dedicated save file for this data.

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Top contributors:

contrib.rocks image

License

Distributed under the project_license. See LICENSE.txt for more information.

(back to top)

Contact

Your Name - dev@jacobcorbett.com

Project Link: https://github.com/jacobcorbett/trading-bot

(back to top)