___ _ _ _ _ _ _____ _ _ ____ _
|_ _|_ __ | |_ ___| | (_) __ _ ___ _ __ | |_ |_ _| __ __ _ __| (_)_ __ __ _ | __ ) ___ | |_
| || '_ \| __/ _ \ | | |/ _` |/ _ \ '_ \| __| | || '__/ _` |/ _` | | '_ \ / _` | | _ \ / _ \| __|
| || | | | || __/ | | | (_| | __/ | | | |_ | || | | (_| | (_| | | | | | (_| | | |_) | (_) | |_
|___|_| |_|\__\___|_|_|_|\__, |\___|_| |_|\__| |_||_| \__,_|\__,_|_|_| |_|\__, | |____/ \___/ \__|
|___/ |___/
₿ Ξ ₳ ₮ ✕ ◎ ● Ð Ł Ƀ Ⱥ ∞ ξ ◈ ꜩ ɱ ε ɨ Ɓ Μ Đ ⓩ Ο Ӿ Ɍ ȿ
📈 Intelligent Trading Signals 📉 https://t.me/intelligent_trading_signals
Intelligent trading bot
The aim of the project is to develop a generic forecasting framework that combines machine learning (ML) and feature engineering (FE). It can be applied to almost any kind of time series and domain, including cryptocurrencies, classical stock markets, futures trading, energy markets, and others. The essential requirements are that sufficient historic data is available to train ML models (such as ARIMA or neural networks) and that domain knowledge can be encoded in custom features via feature engineering (similar to moving averages but adapted to the specifics of the problem domain).
The project provides the following major functionalities:
-
Principled separation between two modes: Offline (or batch) and Online (or stream). The challenge is to avoid duplication of artifacts by defining elements only once while ensuring correct and consistent behavior when switching between modes.
-
Offline mode is intended for automatically extracting knowledge from historic data, particularly for training ML models or determining statistical parameters.
-
Online mode is intended for making forecasts based on the knowledge (models) extracted from historic data as well as (expert) knowledge encoded in domain-specific features via feature engineering.
-
-
Extensible design that provides an easy way to define and use derived features via (Python) functions. This includes both standard technical indicators and arbitrary custom features. Features can be encoded and parameterized by both expert domain-specific knowledge and knowledge extracted from historic data. The feature-engineering layer relies on the column-oriented approach, where new features are defined in terms of previously defined features, so that all features form a directed acyclic graph (DAG) of definitions.
-
Support for different trade frequencies (time rasters or sample rates). For example, it is possible to develop a trading bot for 1-minute, 1-hour, or daily analysis.
-
Integration with the external environment through input and output adapters:
- Input data is provided via custom data collectors that fetch data from an external data source in online mode or download historic data in offline mode.
- Output results are sent to consumers via custom functions that deliver forecasts (such as signals or predictions in online mode) to external consumers, for example Telegram channels, API endpoints, databases, or systems that execute real transactions.
-
Scripts for backtesting and measuring trade performance on historic data. In particular, walk-forward prediction can be performed by regularly re-training ML models and thereby changing the behavior of the system.
-
A trading service for online mode that uses a configuration file to regularly retrieve data updates, perform analysis, and send signals or execute trade transactions.
Offline mode
The diagram below shows the main steps executed in offline (batch) mode by the corresponding scripts. The main purpose of this data-processing pipeline is to train (forecasting) machine-learning models under the assumption that the features consumed by a model, the features produced by a model, and the labels used to train them are all custom features.
All scripts implementing these steps run in batch mode by loading input data and storing output files. These batch scripts are located in the itb.scripts package. To execute all the steps, the scripts should be run in the following sequence:
python -m itb.scripts.download -c config.jsonpython -m itb.scripts.merge -c config.jsonpython -m itb.scripts.features -c config.jsonpython -m itb.scripts.labels -c config.jsonpython -m itb.scripts.train -c config.jsonpython -m itb.scripts.predict -c config.jsonpython -m itb.scripts.signals -c config.jsonpython -m itb.scripts.output -c config.json
All necessary parameters are provided in the configuration file. Sample configuration files can be found in the configs folder. Common parameters include:
data_folder— location of data files required only for batch offline modesymbol— trading pair, for exampleBTCUSDTfreq— data frequency according topandasconventions
More details about the configuration can be found in the documentation.
The main steps of the batch data-processing pipeline are:
-
Download data. This batch script downloads historic data from one or more data sources and stores them in separate files. The data sources are listed in the
data_sourcessection. Each entry specifies a data source together with acolumn_prefixused to distinguish columns that share the same name across different sources. -
Merge source data. The downloaded data are stored in multiple files. The system, however, works with a single data table, so all data rows (typically candle lines) must be merged into one table. This is performed by the
mergescript. It aligns all data entries according to their timestamps, so that one record in the output file combines records with the same timestamp from all input files. In addition, it produces a continuous raster when gaps exist in the input files. -
Generate features. This script computes derived features, which are added as additional columns to the main data table. Feature definitions are provided in the
feature_setssection of the configuration file. Each entry specifies a feature generator together with its parameters. The script loads one merged input file, applies the feature-generation procedures, and stores all derived features in an output file.- Not all generated features need to be used for training and prediction. Some may serve as inputs to subsequent features; others may be used only during feature selection to identify those with better predictive power. For the train/predict phases, a separate explicit list of features is specified.
- Currently the script runs in non-incremental mode, computing features for all available input records (not only the latest update). Consequently it may take significant time for complex configurations. In online (stream) mode, features can be computed more efficiently when supported by the feature generator.
- Feature-generation functions receive additional parameters (such as windows) from their configuration section.
- The same features must be used in both online (stream) mode (when the service applies them to a micro-batch) and offline mode. This consistency is guaranteed by design.
-
Generate labels. This script is similar to feature generation in that it adds new columns to the input file. These columns, however, describe quantities that we want to predict and that are not known when running in online mode. In other words, features are computed from previous (historic) data while labels are computed from future data. For example, a label might measure the maximum price increase during the next hour. Computationally the process is the same as defining features, but the step is kept separate because labels are neither needed nor computable in online mode. The script applies all labels defined in the
label_setssection, adds them as new columns, and stores the result in the output file. As with features, not all labels need to be used in production; they may be generated for exploratory purposes. The labels that are actually used are listed in thelabelssection. -
Train prediction models. The purpose of this step is to analyze historic data and produce ML models as output files. These models store, in condensed form, knowledge about the time series and are later used in online (stream) mode for forecasting. More specifically, one ML model is trained to predict a given label based on the generated features. When the model is applied to the latest data in online mode, it predicts the value of that label, which is normally used to make a trade decision. The parameters for the train script are specified in the
train_feature_setssection. Classification and regression algorithms are currently supported; they can automatically scale input features when specified in the configuration. The trained models are applied to the training data set and the prediction scores are stored in the fileprediction-metrics.txt. -
Post-processing. After ML models have been applied and predictions generated as new columns, additional computations based on those predictions may be required. This is similar to ordinary feature generation except that it occurs after prediction. For example, predictions produced by ML algorithms for different labels can be aggregated into a single intelligent indicator intended for trade decisions. These computations follow the parameters in the
signal_setssection, which has the same structure as the feature generators. The result is one or more new columns. -
Output signal generation and output adapters. Each preceding step adds new columns to the data table (historic data in batch mode or the latest data in stream mode). Functions are still required for interaction with external systems—for example, sending messages, storing signals in a database, or executing real transactions (buying or selling assets). This behavior is configured in the
output_setssection. Each entry specifies a function that interacts with an external system. For example, the generatorscore_notification_modelsends a message to the configured Telegram channel.
Backtesting
When training ML models it is necessary to find the best hyper-parameters. This is typically performed by conventional methods and is not explicitly supported by the present framework. Even good hyper-parameters, however, do not guarantee good trade performance. The ultimate criterion for choosing among features, labels, ML algorithms, and their hyper-parameters is trade performance. Computing realistic trade performance is supported by the following two scripts that work with historic data and help estimate the trade performance of the entire pipeline.
The predict_rolling script applies prediction to data (similar to the predict script) but does so by regularly re-training the ML models. This produces more realistic predictions because the models are applied only to unseen data (data that was not used for training) while still being re-trained whenever enough new data has been collected. This is precisely the procedure used in a real system; the script simply applies it to historic data. It implements rolling walk-forward splits by training models on preceding data and applying them to the subsequent prediction interval.
The simulate script applies a (pre-defined) trading logic to historic data that includes everything expected in online mode. It scans the historic data, applies the trade rules, and produces buy-sell transactions that are then aggregated.
Online service
This script starts a service:
python -m itb.service.server -c config.json
The service periodically (for example, every minute) executes the following tasks:
- Retrieve the latest data from the server and update the current data window, which includes a history whose length is defined by a configuration parameter.
- Compute derived features based on the nearest history (which now includes the latest data). The features to be computed are described in the configuration file and are exactly the same as those used in batch mode during model training.
- Apply several previously trained ML models to predict the values of the labels, which are themselves treated as more complex derived features. Trained models are loaded from the
MODELSfolder specified in the configuration file.
- Aggregate the forecasting results produced by the different ML models and compute a final signal score that reflects the strength of the upward or downward trend. Multiple previously computed scores serve as inputs to derive a single output score.
- Execute functions that interact with external systems, for example by sending notifications to a Telegram channel. It is also possible to configure a real trader that executes buy or sell transactions.
Intelligent trading signals
This is a cloud signaling service that demonstrates how the project can be used. It regularly sends signals to the following Telegram channel:
📈 Intelligent Trading Signals 📉 https://t.me/intelligent_trading_signals
Anyone can subscribe to the channel to gain an impression of how the project can be applied. Configurations may change, but the service normally transmits an intelligent indicator ranging between −1 and +1. Positive values are interpreted as future growth; negative values indicate that the price is likely to fall.
Example notification:
₿ 24.518 📉📉📉 Score: -0.26
When the intelligent indicator exceeds a threshold specified in the model, a buy or sell signal is generated:
〉〉〉📈 ₿ 74,896 Indicator: +0.12 ↑ BUY ZONE 1min
Three arrows indicate a buy signal for Bitcoin at the current price of 74,896 with an indicator value of 0.12. The 1min suffix denotes the analysis frequency (every minute). Such messages can be customized via Python functions and may include diagrams.
Install the project
Option 1 — Install from source (recommended for development)
git clone https://github.com/asavinov/intelligent-trading-bot.git
cd intelligent-trading-bot
# Create and activate a virtual environment (strongly recommended)
python -m venv .venv
source .venv/bin/activate # Linux / macOS
# .venv\Scripts\activate # Windows
# Install the package in editable mode together with its dependencies
pip install -e .
Option 2 — Install from PyPI
pip install intelligent-trading-bot
Note that you will still need a local configuration file and (for offline mode) a data folder. Cloning the repository is usually more convenient because it also provides sample configuration files.
Metadata
Release files for intelligent-trading-bot 0.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| intelligent_trading_bot-0.8.1.tar.gz | 101.2 kB | Without provenance | Details for intelligent_trading_bot-0.8.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| intelligent_trading_bot-0.8.1-py3-none-any.whl | Python 3 | none | any | Details for intelligent_trading_bot-0.8.1-py3-none-any.whl |
Total release size: 229.4 kB
Release files / intelligent_trading_bot-0.8.1.tar.gz
| Download URL | intelligent_trading_bot-0.8.1.tar.gz |
|---|---|
| Size | 101.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff337d41f35b250a899cf96b8a06e5130201afe5d56b63519e7fa3baeed57cc2
|
|
BLAKE2b-256 checksum How to use checksums |
998d6b374ea21ca5462f82b254d4ae1630a8e8eb6cfc1ed7df52d26e4783e022
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / intelligent_trading_bot-0.8.1-py3-none-any.whl
| Download URL | intelligent_trading_bot-0.8.1-py3-none-any.whl |
|---|---|
| Size | 128.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c539dd655912445e92e38fe643a5bba3de642ead9f42cbf0ba3855ff4573559
|
|
BLAKE2b-256 checksum How to use checksums |
6d9b16dfca03e781626229e13f60ec883b07d48d4323be89b8aee020c625a696
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Security for intelligent-trading-bot 0.8.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.