Skip to content

A tensortrade based system to train a model that trades fx, stock, & crypto

License

Notifications You must be signed in to change notification settings

azeemh/alphawicks-ce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alphawicks - Community Edition

A tensortrade based system to train a model that trades fx, stock, & crypto.


This project is a comprehensive trading system built using TensorTrade, which supports real-time data from Bitstamp, Alpaca, and MetaTrader 5, along with custom indicators from TradingView webhooks. It includes a range of technical analysis features from TA-Lib, and a reinforcement learning framework that dynamically learns and adapts to market data.

Features

  • Real-time market data processing from multiple APIs (Bitstamp, Alpaca, MetaTrader 5)
  • Integration with TradingView webhooks for custom indicator signals
  • TA-Lib indicators and candlestick patterns for advanced technical analysis
  • OpenCL or GPU-accelerated preprocessing for fast data handling
  • Reinforcement learning model with a reward function based on profit and loss
  • Support for all order types and trade execution through multiple brokers

Prerequisites

Make sure you have the following installed:

  1. Python 3.7+
  2. Pip (Python package manager)
  3. TA-Lib (Technical analysis library)
  4. TensorTrade
  5. Flask (for receiving TradingView webhook data)
  6. Alpaca API credentials (for Alpaca integration)
  7. MetaTrader 5 installed, with access credentials.
  8. Bitstamp API credentials (for Bitstamp integration)

Installation

Follow the steps below to install and set up the environment.

1. Clone the Repository

git clone https://github.com/azeemh/alphawicks-ce.git
cd alphawicks-ce

2. Create a Python Virtual Environment (optional but recommended)

python -m venv venv
source venv/bin/activate  # On Linux/Mac
venv\Scripts\activate      # On Windows

3. Install the Required Packages

To run the TensorTrade system, ensure you have all the required dependencies installed, including tensortrade, pyopencl, ccxt, alpaca-trade-api, and MetaTrader5.

4. Install TA-Lib

You can install the TA-Lib bindings via pip:

pip install TA-Lib

For TA-Lib to work, you will need the TA-Lib C library installed on your machine. For different operating systems:

  • macOS: brew install ta-lib
  • Linux: Download from TA-Lib.org, extract it, and compile it:
    ./configure --prefix=/usr
    make
    sudo make install
  • Windows: Download the precompiled version of TA-Lib for your Python version and install using pip.

Configuration

1. Set up API Keys

  • Alpaca API: Obtain an API key from Alpaca. You will need the API_KEY and SECRET_KEY in the script for Alpaca.

  • Bitstamp API: Obtain API credentials from Bitstamp. Insert your credentials into the script.

  • MetaTrader 5: Set up MetaTrader 5 and configure API access in the MT5Client connection setup.

2. Configure Flask for TradingView Webhooks

Configure the Flask server to receive TradingView webhook data. The system is set to run on port 5000 by default. If you need to use a different port, update the Flask app.run method accordingly.


Running the System

1. Start Flask Webhook Server

This will listen for webhook alerts from TradingView.

python main.py

You can now set TradingView alerts to trigger the webhook endpoint http://localhost:5000/webhook.

2. Run the Trading System

The system will begin pulling real-time data from your chosen APIs, process the data, and make trading decisions using the reinforcement learning model.

python main.py

3. Real-Time Data Streams

The system will stream real-time data from Bitstamp, Alpaca, and MetaTrader 5. It will also preprocess the data and feed it to the trading model, which will continuously learn and adapt based on the market conditions.


Model Training and Predictions

The system will dynamically train an LSTM-based model on the incoming data stream and make real-time predictions. You can modify the training logic within the train_lstm_realtime function.


Custom Indicators via TradingView Webhook

You can send custom indicator signals from TradingView to the system by setting up alerts with webhook URLs. Use the /webhook endpoint to send custom indicators, which will be integrated into the system for decision-making.


License

This project is GPL-3 Open Source. See the LICENSE file for more details.


Contributing

Feel free to fork the repository, create pull requests, or open issues if you have suggestions for improvement.


Troubleshooting

TA-Lib Installation Issues

  • Ensure you have the correct C library installed on your machine before using pip to install the Python bindings.
  • For Windows, use the precompiled .whl files to avoid build issues.

Real-Time Data Feeds

  • Ensure API credentials are valid and correctly set for Alpaca, MetaTrader 5, and Bitstamp.
  • For TradingView webhooks, ensure your local Flask server is correctly set to the webhook URL.

Model Training

  • The model training is based on the real-time data feed. Adjust the training parameters if the model isn't learning efficiently.

Hopefully this README provides all necessary steps to install, set up, and run the trading system. Adjust the details like your API keys and webhook URL to suit your environment.

Flip The Script!

People always fear that capitalists will replace people with robots...

Replace your local capitalist with a robot...

Perhaps now people will finally contemplate what will we do if AI robots can make money, build houses, grow food, etc?

All this Technology means we should be living in abundance. If we automate a system that can grow food for everyone and deliver it, all of us eat.

About

A tensortrade based system to train a model that trades fx, stock, & crypto

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages