Intelligent Trading Bot
Intelligent Trading Bot: Automatically generating signals and trading based on machine learning and feature engineering
Install / Use
npx skills add asavinov/intelligent-trading-botInstalls into whichever agent you are using.
README
___ _ _ _ _ _ _____ _ _ ____ _
|_ _|_ __ | |_ ___| | (_) __ _ ___ _ __ | |_ |_ _| __ __ _ __| (_)_ __ __ _ | __ ) ___ | |_
| || '_ \| __/ _ \ | | |/ _` |/ _ \ '_ \| __| | || '__/ _` |/ _` | | '_ \ / _` | | _ \ / _ \| __|
| || | | | || __/ | | | (_| | __/ | | | |_ | || | | (_| | (_| | | | | | (_| | | |_) | (_) | |_
|___|_| |_|\__\___|_|_|_|\__, |\___|_| |_|\__| |_||_| \__,_|\__,_|_|_| |_|\__, | |____/ \___/ \__|
|___/ |___/
₿ Ξ ₳ ₮ ✕ ◎ ● Ð Ł Ƀ Ⱥ ∞ ξ ◈ ꜩ ɱ ε ɨ Ɓ Μ Đ ⓩ Ο Ӿ Ɍ ȿ
📈 <span style="font-size:1.5em;">Intelligent Trading Signals</span> 📉 https://t.me/intelligent_trading_signals
Intelligent trading bot
The aim of the project is to develop an intelligent trading bot for automated trading including cryptocurrencies using state-of-the-art machine learning (ML) algorithms and feature engineering. The project provides the following major functionalities:
- Clear and consistent separation between offline (batch) mode for training ML models and online (stream) mode for predicting based on the trained models. One of the main challenges here is to guarantee that the same (derived) features are used in both modes
- Extensible approach to defining derived features using (Python) functions including standard technical indicators as well as arbitrary custom features
- Providing possibility to work with different trade frequencies (time rasters), for example, 1 minute, 1 hour or 1 day
- Customizable functions for sending signals or predictions in online mode, for example, sending to Telegram channels, API end-point, storing in a database or executing real transactions
- Functions for backtesting and measuring trade performance on historic data which is more difficult because requires periodic re-train of the used ML models
- Trading service for online mode which uses a configuration file to regtularly retrieve data updates, do analysis and send signals or execute trade transactions
Intelligent trading signals
The signaling service is running in cloud and sends its signals to this Telegram channel:
📈 Intelligent Trading Signals 📉 https://t.me/intelligent_trading_signals
Everybody can subscribe to the channel to get the impression about the signals this bot can generate.
Currently, the bot is configured using the following parameters:
- Exchange: Binance
- Cryptocurrency: ₿ Bitcoin (BTCUSDT)
- Analysis frequency: 1 minute
- Intelligent indicator between -1 and +1. Negative values mean decrease, and positive values mean increase of the price
Example notification:
₿ 24.518 📉📉📉 Score: -0.26
The first number is the latest close price. The score -0.26 means that it is very likely to see the price lower than the current close price.
If the intelligent indicator exceeds some threshold specified in the model then buy or sell signal is generated:
〉〉〉📈 ₿ 74,896 Indicator: +0.12 ↑ BUY ZONE 1min
Here three arrows mean buy signal for bitcoin at the current price 74,896 and the indicator value 0.12. 1min frequence (analysis every minute). Such messages can be customized using Python functions including diagrams.
Training machine learning models (offline)

For the signaler service to work, a number of ML models must be trained and the model files available for the service. All scripts run in batch mode by loading some input data and storing some output files. The batch scripts are located in the scripts module.
If everything is configured, then the following scripts have to be executed:
python -m scripts.download -c config.jsonpython -m scripts.merge -c config.jsonpython -m scripts.features -c config.jsonpython -m scripts.labels -c config.jsonpython -m scripts.train -c config.jsonpython -m scripts.predict -c config.jsonpython -m scripts.signals -c config.jsonpython -m scripts.output -c config.json
All necessary parameters are provided in the configuration file. The project provides some sample configuration files in the config folder.
Some common parameters of the configuration file:
data_folder- location of data files which are needed only for batch offline modesymbolit is a trading pair likeBTCUSDTdescriptionAny text helping understand the purpose of this configuration filefreqdata frequency according topandasconventions
Download data
This batch script will download historic data from one or more data sources and store them in separate files. The data sources are listed in the data_sources section. One entry in this list specifies a data source as well as column_prefix used to distinguish columns with the same name from different sources. Currently data sources are not extendable and it is possible only to download from Binance and Yahoo.
Merging source data
The downloaded data are stored in multiple files. The system however works with only one data table therefore all these data entries (like candle lines) must be merged into one table. This is done by the merge script. It aligns all data entries according to their time stamp, that is, one record in the output file will merge records with the same time stamp from all input files. In addition, it will produce continuous raster in case there are gaps in the input files.
Generate features
This script is intended for computing derived features. These features will be added as additional columns to the data table. Feature definitions are provided in the feature_sets section of the configuration file. Each entry in this list specifies a feature generator as well as its parameters. The script loads one merged input file, applies feature generation procedures and stores all derived features in an output file.
Here are some notes on the current implementation:
- Not all generated features must be used for training and prediction. Some of them can be used as input to next features. Other feature could be used only for the feature selection process where we want to find which of them have better predictive power. For the train/predict phases, a separate explicit list of features is specified
- Currently it runs in non-incremental model by computing features for all available input records (and not only for the latest update), and hence it may take hours for complex configurations. Yet, in online (stream) mode, features can be computed more efficiently if it is supported by the feature generator
- Feature generation functions get additional parameters like windows from the config section
- The same features must be used in online (stream) mode (in the service when they are applied to a micro-batch) and offline mode. This is guaranteed by design
Here are some pre-defined feature generators (although it is possible to define custom feature generation functions):
talibfeature generator relies on the TA-lib technical analysis library. Here an example of its configuration:"config": {"columns": ["close"], "functions": ["SMA"], "windows": [5, 10, 15]}itbstatsfeature generator implements functions which can be found in tsfresh likescipy_skew,scipy_kurtosis,lsbm(longest strike below mean),fmax(first location of maximum),mean,std,area,slope. Here are typical parameters:"config": {"columns": ["close"], "functions": ["skew", "fmax"], "windows": [5, 10, 15]}itblibfeature generator implemented in ITB but most of its features can be generated (much faster) via talibtsfreshgenerates functions from the tsfresh library
Generate labels
This script is similar to feature generation because it adds new columns to the input file. However, these columns describe something that we want to predict and what is not known when executing in online mode. In other words, features are computed from previous (historic) data while labels are computed from future data which are not visible in online mode yet. For example, a label could find maximum price increase during next hour in percent. Computationally it is the same as computing features but this step is separate because we do not need (and cannot compute) this in online mode. This script will apply all labels defined in the label_sets section, add them as new columns and store the result in the output file. Just like for features, not all labels must be really used -- they could be generated for exploratory purposes. The really used labels are listed in the labels section.
Here are some pre-defined label generators:
highlowlabel generator returns True if the price is higher than the specified threshold within some future horizonhighlow2Computes future increases (decreases) with the conditions that there are no significant decreases (increases) before that. Here is its typical configuration:"config": {"columns": ["close", "high", "low"], "function": "high", "thresholds": [1.0, 1.5, 2.0], "tolerance": 0.2, "horizon": 10080, "names": ["first_high_10", "first_high_15", "first_high_20"]}topbotDeprecatedtopbot2Computes maximum and minimum values (labeled as True). Every labelled maximum (minimum) is guaranteed to be surrounded by minimums (maximums) lower (higher) than the specified level. The required minimum difference between adjacent minimums and maximums is specified vialevelparameters. The tolerance parameter allows for including also points close to the maximum/minimum. Here is a typical configuration: `"config": {"columns": "close",
Related Skills
mcp
Use the `mcp_perplexity-ask_perplexity_search` tools to answer questions. You should use this instead of the `web_search` tool because it is a lot more accurate.
practical-power-systems-synthesis
This skill enables synthesis in the domain of power-systems (engineering). It represents research-level-level expertise and is designed for production use in research, industry, and educational contexts. Use this skill when you need to perform synthesis operations related to power-systems.
semi-supervised-optogenetics-testing
This skill enables testing in the domain of optogenetics (neuroscience). It represents intermediate-level expertise and is designed for production use in research, industry, and educational contexts. Use this skill when you need to perform testing operations related to optogenetics.
data-mining-interpretation-fundamental
This skill enables interpretation in the domain of data-mining (data-science). It represents fundamental-level expertise and is designed for production use in research, industry, and educational contexts. Use this skill when you need to perform interpretation operations related to data-mining.
