Skip to content

libretrading/libre-engine

Repository files navigation

Multi-Strategy Multi-Account Trade Execution Engine

This project is a multi-strategy, multi-account trade execution engine designed to work with Alpaca. The engine is capable of executing various trading strategies across multiple accounts and can be expanded to support other brokers in the future. It is developed to be easily deployed to a linux server.

Table of Contents

Project Structure

Directories and Files

  • alpaca_api/: Contains the Alpaca API integration functions.
  • historical_data/: Manages historical data fetching and updating.
  • postgresql/: Contains the Flask application, database models, and PostgreSQL management scripts.
  • schedulers/: Scheduler scripts for different trading strategies.
  • systems/: Implementation of various trading strategies.
  • crontab: Crontab configuration for scheduling tasks.
  • maintenance.sh: Script for system maintenance.
  • run_schedulers.sh: Script to run all schedulers.
  • requirements.txt: Python dependencies.

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/yourrepository.git
    cd yourrepository
  2. Create a virtual environment and activate it:

    python3 -m venv venv
    source venv/bin/activate
  3. Install the required dependencies:

    pip install -r requirements.txt
  4. Set up the environment variables:

Configuration

Alpaca API

  • Configure your Alpaca API keys in .env:
    API_PUBLIC=your_public_key
    API_SECRET=your_secret_key

PostgreSQL

  • Configure your PostgreSQL database in .env:
    DB_USER=your_db_user
    DB_PASSWORD=your_db_password
    DB_HOST=your_db_host
    DB_PORT=your_db_port
    DB_NAME=your_db_name

Usage

Running the Flask Application

  1. Navigate to the postgresql directory:

    cd postgresql
  2. Run the Flask application:

    python flaskapp.py

Running the Schedulers

  1. Run the run_schedulers.sh script to start all schedulers:
    bash run_schedulers.sh

Maintenance

  1. Run the maintenance.sh script for system maintenance:
    bash maintenance.sh

Scripts

This script starts all the scheduler scripts in separate tmux sessions.

This script performs system maintenance tasks such as terminating tmux sessions, cleaning up the system, and rebooting.

APIs

Flask Application

The Flask application provides an interface to manage user accounts and their API keys.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

License

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

About

Multi Strategy, Multi Account Trade Execution Engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published