Skip to main content

A framework for creating an investment algorithm

Project description

Build Tests Downloads Current Version

Sponsors

Investing Algorithm Framework

:warning: Documentation outdated: We are working hard on releasing v1.0.0. After this release we will update the documentation at the website.

The Investing Algorithm Framework is a python framework for building investment algorithms. It encourages rapid development and clean, pragmatic code design.

The framework provides you with an all the components you need to create an investing algorithm (data providing, portfolio management, order execution, etc..). Also, the algorithm can be controlled with a REST Api that will run in the background.

Example Algorithm for Binance

import os

from investing_algorithm_framework import App, TimeUnit, AlgorithmContext, \
    TradingDataTypes
from investing_algorithm_framework.configuration.constants import BINANCE, \
    BINANCE_API_KEY, BINANCE_SECRET_KEY, TRADING_SYMBOL

# Make the parent dir your resources directory (database, csv storage, snapshots)
dir_path = os.path.abspath(os.path.join(os.path.realpath(__file__), os.pardir))

# Create an application (manages your algorithm, rest api, etc...)
app = App(
    resources_directory=dir_path,
    config={
        BINANCE_API_KEY: "<BINANCE_API_KEY>",
        BINANCE_SECRET_KEY: "<BINANCE_SECRET_KEY>",
        TRADING_SYMBOL: "USDT",
    }
)


# Algorithm strategy that runs every 5 seconds and gets the ticker of BTC from BINANCE
@app.algorithm.strategy(
    time_unit=TimeUnit.SECONDS,
    interval=5,
    data_provider_identifier=BINANCE,
    target_symbol="BTC",
    trading_data_type=TradingDataTypes.TICKER,
)
def perform_strategy(context: AlgorithmContext, ticker):
    # Retrieve unallocated USDT (trading symbol) from the portfolio of the algorithm
    unallocated = context.get_unallocated_size(BINANCE)

    if unallocated > 50000:
        if ticker.ask_price == 50000:
            context.create_limit_buy_order(
                BINANCE, "BTC", price=50000, amount=1, execute=True
            )


if __name__ == "__main__":
    app.start()

NOTE: The framework is in alpha.

The example algorithm makes use of the default data provider, order executor and portfolio manager for BINANCE. However, your can also define your own components for your algorithm making it compatible to any broker of choice.

The goal of the framework is to provide you with a set of components for your algorithm that takes care of a wide variety of operational processes out of the box.

Features

  • Data Providing
  • Order execution
  • Portfolio management
  • Performance tracking
  • Strategy scheduling
  • Resource management
  • Historic portfolio snapshots
  • Order status management
  • Clients (Rest API)

However, we aim to also provide a modular framework where you can write your own components or use third party plugins for the framework.

Further information and the complete documentation can be found at the website

Download

You can download the framework with pypi.

pip install investing-algorithm-framework

Disclaimer

If you use this framework for your investments, do not risk money which you are afraid to lose, until you have clear understanding how the framework works. We can't stress this enough:

BEFORE YOU START USING MONEY WITH THE FRAMEWORK, MAKE SURE THAT YOU TESTED YOUR COMPONENTS THOROUGHLY. USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR INVESTMENT RESULTS.

Also, make sure that you read the source code of any plugin you use or implementation of an algorithm made with this framework.

For further information regarding usage and licensing we recommend going to the licensing page at the website.

Documentation

All the documentation can be found online at the documentation webstie

In most cases, you'll probably never have to change code on this repo directly if you are building your algorithm/bot. But if you do, check out the contributing page at the website.

If you'd like to chat with investing-algorithm-framework users and developers, join us on Slack or join us on reddit

Acknowledgements

We want to thank all contributors to this project. A full list of all the people that contributed to the project can be found here

Bugs / Issues

If you discover a bug in the framework, please search our issue tracker first. If it hasn't been reported, please create a new issue.

Feel like the framework is missing a feature? We welcome your pull requests!

Note before starting any major new feature work, please open an issue describing what you are planning to do. This will ensure that interested parties can give valuable feedback on the feature, and let others know that you are working on it.

Important: Always create your feature or hotfix against the develop branch, not master.

Project details


Release history Release notifications | RSS feed

This version

0.15

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

investing_algorithm_framework-0.15.tar.gz (45.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

investing_algorithm_framework-0.15-py3-none-any.whl (82.3 kB view details)

Uploaded Python 3

File details

Details for the file investing_algorithm_framework-0.15.tar.gz.

File metadata

  • Download URL: investing_algorithm_framework-0.15.tar.gz
  • Upload date:
  • Size: 45.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for investing_algorithm_framework-0.15.tar.gz
Algorithm Hash digest
SHA256 3458e37082400a380fff765d6260fbfae21b194484b397a9416c9701637e32e1
MD5 805f8452584e4b6e6bbe1e57603e81d8
BLAKE2b-256 c729ecbe5e6692b281560c89a657863a2a0e694bb772f392c9e3b83424476a61

See more details on using hashes here.

File details

Details for the file investing_algorithm_framework-0.15-py3-none-any.whl.

File metadata

  • Download URL: investing_algorithm_framework-0.15-py3-none-any.whl
  • Upload date:
  • Size: 82.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for investing_algorithm_framework-0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 dedb63de646bd1d68e4bf3b2ad6add322d246455c5b83aa3df356b2a2bb14c13
MD5 d4d899523ebfdbb5fdac37df8c35ac17
BLAKE2b-256 24a9b66273ade05b44c4e5c936bbaf7cf9bdc3de8b9f53e6aad2a95643b0c5e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page