A framework for creating an investment algorithm
Project description
Sponsors
Investing Algorithm Framework
The Investing Algorithm Framework is a Python tool that enables swift and elegant development of investment algorithms and trading bots. It comes with all the necessary components for creating algorithms, including data provisioning, portfolio management, and order execution.
Example
The following algorithm connects to binance and buys BTC every 5 seconds. It also exposes an REST API that allows you to interact with the algorithm.
import pathlib
from datetime import datetime, timedelta
from investing_algorithm_framework import create_app, PortfolioConfiguration, \
RESOURCE_DIRECTORY, TimeUnit, TradingTimeFrame, TradingDataType, OrderSide
app = create_app({RESOURCE_DIRECTORY: pathlib.Path(__file__).parent.resolve()})
app.add_portfolio_configuration(
PortfolioConfiguration(
market="binance",
api_key="xxxxxx",
secret_key="xxxxxx",
trading_symbol="USDT"
)
)
@app.strategy(
time_unit=TimeUnit.SECOND, # Algorithm will be executed every 5 seconds
interval=5,
market="binance", # Will retrieve trading data from binance
symbols=["BTC/USDT", "ETH/USDT", ["DOT/USDT"]], # Symbols must be in the format of TARGET/TRADE symbol (e.g. BTC/USDT)
trading_data_types=[TradingDataType.OHLCV, TradingDataType.TICKER, TradingDataType.ORDER_BOOK],
trading_time_frame_start_date=datetime.utcnow() - timedelta(days=1), # Will retrieve data from the last 24 hours
trading_time_frame=TradingTimeFrame.ONE_MINUTE # Will retrieve data on 1m interval (OHLCV)
)
def perform_strategy(algorithm, market_data):
print(algorithm.get_allocated())
print(algorithm.get_unallocated())
print(market_data)
algorithm.create_limit_order(
target_symbol="BTC",
side=OrderSide.BUY,
price=market_data["TICKER"]["BTC/USDT"]["BID"],
amount_target_symbol=0.00001
)
if __name__ == "__main__":
app.run()
You can find more examples here folder.
Broker/Exchange configuration
The framework has by default support for ccxt. This should allow you to connect to a lot of brokers/exchanges.
from investing_algorithm_framework import App, PortfolioConfiguration
app = App()
app.add_portfolio_configuration(
PortfolioConfiguration(
market="bitvavo",
api_key="xxxx",
secret_key="xxxx",
track_from="01/01/2022",
trading_symbol="EUR"
)
)
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for investing_algorithm_framework-1.4.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7ed1d202b098aaf458e859b570afbe2baacc55e0cff3ee5e66e5fff5bbe3bbd |
|
MD5 | cc0552cef821375801bb29b018e0f8cc |
|
BLAKE2b-256 | a2e39a7c835464cf8790466b974c5295f540fbfe7f38f67208b21e63b9220ff7 |
Hashes for investing_algorithm_framework-1.4.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3017f7208beb0163fcb9bf50af58af0046b1bc4b32665811c64272a6d74dbb0b |
|
MD5 | 35534d069bcade557fa2420a738ec241 |
|
BLAKE2b-256 | 5236086f317e167487c623685c5abb6e46ef23bbec28d06a5f8e86bfdd9f6400 |