Overview
Automated Trading Alert System with Telegram Integration
The goal of this project is to create a service that automatically monitors coins based on screener settings, analyzes key market data (such as price changes and key levels), and sends actionable alerts to a Telegram channel. This service will not execute trades but will notify channel when a coin meets the specified trading criteria.
Recent Changes
March 15, 2025
ALPHA
- Fixed an issue with the alert ready check query, and updated the default config values. node-service-event (v0.10.3)
WHISTLER (new)
- Initial features test branch released which alert is based on RSI value. node-service-event (v0.11.1)
March 12, 2025
ALPHA
- Fixed an issue with the ATR value when chart candles are too short after a new symbol is added by exchange, and support for override
KLINE_MIN_COUNT,STAR_RATE_1_NVF_USD_MINandSCREENSHOT_CHART_INTERVAL. node-service-event (v0.10.2)
March 11, 2025
ALPHA
- Fixed an issue with premature alert triggers caused by minimum quote volume and updated the ignored alert log level from
infotoverbose. node-service-event (v0.10.1)
March 10, 2025
ALPHA
- Fixed an issue where new exchange symbols were detected but their corresponding data wasn't updated in the cache and improve the handling of the supported exchange constructor. node-stream-exchange (v0.5.0)
- Improved screenshot consistency by capturing the chart prior to calculating the entry price. Additionally, enforced stricter trigger retest conditions and include missed alerts into CloudWatch due to cooldown periods. node-service-event (v0.10.0)
- Removed the handling of screenshots from the Telegram service. node-telegram-server (v0.8.0)
March 03, 2025
ALPHA
- Initial Alpha Release Candidate.
Installation
The application uses Redis for local caching and channels for real-time communication between microservices. It utilizes Docker to simplify deployment and updates, ensuring consistent and seamless maintenance. Additionally, it uses multiple cloud services, including AWS DynamoDB with AppSync for database, Lambda as a proxy to bypass rate limits, CloudWatch for log management, and CHART-IMG API for capturing TradingView charts.
For optimal performance, it is recommended to use compute optimized EC2 instances with a minimum of 8 GB of RAM. Keep in mind that the application tracks every trade for each symbol supported by both Binance Spot & Futures markets. Depending on market activity, it uses about 500 - 800 GB of downstream data monthly. To safeguard against system overloads during market surges, it is advisable to provision additional resources.
Docker
Docker is used to simplify the deployment process and manage application updates. The private registry provides the latest images to ensure seamless updates and efficient maintenance of the application.
Redis
/etc/redis/redis.conf
# disable all data persistence
appendonly no
save ""
# skip auth
protected-mode no
/etc/sysctl.conf
# enable memory overcommit
vm.overcommit_memory=1
Redis should be part of the Docker container. However, when running Dockerized Redis for extended periods with continuous real-time data streams, delays may occur. To resolve this issue, it is recommended to deploy Redis outside the Docker container. Furthermore, ensure that all data persistence options are disabled in the configuration to optimize performance.
Quick Start
Login to private registry
$ docker login registry.example.com
Username: example
Password: ********
Pull the Latest Image
$ docker compose pull
Start the application (detached mode)
$ docker compose up -d
Log output
$ docker compose logs
End the application
$ docker compose down
After login to private registry, you only need two file .env and docker-compose.yml, to pull the latest image and run the application with a single command docker compose up -d. The file config.json is optional and can be used to override the default configuration values.
The required files, along with the login credentials and domain address for the private registry, should have been provided to run the application.
Environment Variable
.env
ENV=prod
REDIS_HOST=127.0.0.1
CHART_IMG_API_KEY=API_KEY_HERE
TELEGRAM_API_TOKEN=API_TOKEN_HERE
TELEGRAM_ALERT_CHAT_ID=CHANNEL_CHAT_ID_HERE
LAMBDA_PROXY_URL=https://example.lambda-url.ca-central-1.on.aws
LAMBDA_PROXY_ACCESS_KEY=ACCESS_KEY_HERE
APP_ASYNC_API_URL=https://example.appsync-api.ca-central-1.amazonaws.com/graphql
APP_ASYNC_API_KEY=API_KEY_HERE
AWS_ACCESS_KEY_ID=ACCESS_KEY_ID_HERE
AWS_SECRET_ACCESS_KEY=SECRET_ACCESS_KEY_HERE
.env file should have been provided for each environment of the application.
| Parameter | Required | Default | Description |
|---|---|---|---|
| ENV | Yes | - | Environment name for the application eg. prod, staging |
| LOG_LEVEL | No | info |
Console log output level [error, warn, info, verbose, debug] |
| REDIS_HOST | No | 127.0.0.1 |
Redis host server IP address |
| HOST_DOMAIN | No | - | Host domain name to set Telegram callback URL |
| HOST_PORT | No | 3000 |
Telegram callback server port, which should be behind HTTPS proxy |
| TELEGRAM_API_TOKEN | Yes | - | Telegram API Token |
| TELEGRAM_ALERT_CHAT_ID | Yes | - | Telegram Channel Chat ID for the alerts |
| TELEGRAM_WEBHOOK_UPDATE | No | false |
Update Telegram Callback URL to HOST_DOMAIN/path when starting Telegram Server |
| CHART_IMG_API_KEY | Yes | - | API KEY for CHART-IMG API |
| CHART_IMG_LAYOUT_ID | No | - | Override default CHART-IMG API Shared Layout ID |
| LAMBDA_PROXY_URL | Yes | - | AWS Lambda Proxy URL |
| LAMBDA_PROXY_ACCESS_KEY | Yes | - | AWS Lambda Proxy Access Key |
| APP_ASYNC_API_URL | Yes | - | AWS AppSync API URL |
| APP_ASYNC_API_KEY | Yes | - | AWS AppSync API key |
| AWS_ACCESS_KEY_ID | Yes | - | AWS API Access Key for CloudWatch |
| AWS_SECRET_ACCESS_KEY | Yes | - | AWS API Access Secret Key for CloudWatch |
Docker Composer
docker-compose.yml
services:
stream-exchange-binance:
image: registry.example.com/stream-exchange:latest
network_mode: 'host' # to access host redis-server
command: npm run start -- -e binance
restart: always
init: true
volumes:
- ./logs/stream-exchange-binance:/logs
environment:
- LOG_SETUP=docker
- LOG_LEVEL
- REDIS_HOST
- LAMBDA_PROXY_URL
- LAMBDA_PROXY_ACCESS_KEY
stream-exchange-binancefutures:
image: registry.example.com/stream-exchange:latest
network_mode: 'host' # to access host redis-server
command: npm run start -- -e binancefutures
restart: always
init: true
volumes:
- ./logs/stream-exchange-binancefutures:/logs
environment:
- LOG_SETUP=docker
- LOG_LEVEL
- REDIS_HOST
- LAMBDA_PROXY_URL
- LAMBDA_PROXY_ACCESS_KEY
service-net-flow-binance:
image: registry.example.com/service-net-flow:latest
network_mode: 'host' # to access host redis-server
command: npm run start -- -e binance
restart: always
init: true
volumes:
- ./logs/service-net-flow-binance:/logs
environment:
- LOG_SETUP=docker
- LOG_LEVEL
- REDIS_HOST
service-net-flow-binancefutures:
image: registry.example.com/service-net-flow:latest
network_mode: 'host' # to access host redis-server
command: npm run start -- -e binancefutures
restart: always
init: true
volumes:
- ./logs/service-net-flow-binancefutures:/logs
environment:
- LOG_SETUP=docker
- LOG_LEVEL
- REDIS_HOST
service-event:
image: registry.example.com/service-event:latest
network_mode: 'host' # to access host redis-server
restart: always
init: true
volumes:
- ./config.json:/config.json # to override the default values
- ./logs/node-service-event:/logs
environment:
- ENV
- LOG_SETUP=docker
- LOG_LEVEL
- REDIS_HOST
- AWS_REGION
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- LAMBDA_PROXY_URL
- LAMBDA_PROXY_ACCESS_KEY
- APP_ASYNC_API_URL
- APP_ASYNC_API_KEY
- CHART_IMG_API_KEY
- CHART_IMG_LAYOUT_ID
- BYPASS_INTERVAL_RESET_DELAY
telegram-server:
image: registry.example.com/telegram-server:latest
network_mode: 'host' # to access host redis-server
restart: always
init: true
volumes:
- ./logs/telegram-server:/logs
environment:
- ENV
- LOG_SETUP=docker
- LOG_LEVEL
- REDIS_HOST
- HOST_DOMAIN
- HOST_PORT
- APP_ASYNC_API_URL
- APP_ASYNC_API_KEY
- TELEGRAM_API_TOKEN
- TELEGRAM_ALERT_CHAT_ID
- TELEGRAM_WEBHOOK_UPDATE
docker-compose.yml file should have been provided for each environment of the application. If network_mode is set to host, ensure that unnecessary ports are protected from public access.
Release
| Name | Description | env | stream-exchange | service-net-flow | service-event | telegram-server |
|---|---|---|---|---|---|---|
| WHISTLER | RSI Test Branch | whistler |
latest |
latest |
0.11.1* |
0.8.0 |
| ALPHA | Alpha Release | alpha |
latest |
latest |
0.10.3 |
0.8.0 |
Supported Image Tags
| Service | Tags |
|---|---|
| stream-exchange | latest |
| service-net-flow | latest |
| service-event | latest, 0.11.1*, 0.10.0-3, 0.9.1 |
| telegram-server | latest, 0.8.0,0.7.1 |
Configuration (Optional)
config.json
{
"trigger": {
"PRICE_CHANGE_PERCENT": 4
},
"process": {
"TICKER_24H_QUOTE_VOL_MIN": "5m",
"OI_MIN_PERCENT_CHANGE": 4,
"ALERT_COOLDOWN_MINUTE": 1440
}
}
To enable the override, make sure service-event volume ./config.json:/config.json is included in the docker-compose.yml file. Then include config.json file with key-value you wish to override.
trigger
| Key | Default | Description |
|---|---|---|
| PRICE_CHANGE_PERCENT | 4 |
Minimum percentage change in hourly interval to trigger an event |
| RETEST_MAX_COUNT | 10 |
After first alert, retest briefly to validate additonal alert conditions |
| RETEST_DELAY_SECOND | 3 |
A delay between each retest in seconds |
process
| Key | Default | Description |
|---|---|---|
| NVF_TIMEFRAME | 5m |
Last net volume flow time frame |
| OI_LAST_COUNT | 10 |
Last uptrend open interest value count |
| OI_MIN_PERCENT_CHANGE | 5.0 |
Last uptrend minium open interest percentage change |
| ATR_RISK_RATIO | 1.5 |
ATR risk ratio based on volatility of the chart |
| ATR_REWARD_RATIO_1 | 3 |
ATR reward ratio #1 based on volatility of the chart |
| ATR_REWARD_RATIO_2 | 4 |
... #2 |
| ATR_REWARD_RATIO_3 | 6 |
... #3 |
| STAR_RATE_5_NVF_USD_MIN | 6000000 |
Minimum net volume flow in timeframe |
| STAR_RATE_5_VOL_QUOTE_MIN | 300000000 |
Minimum 24h ticker quote volume |
| STAR_RATE_4_NVF_USD_MIN | 3000000 |
... |
| STAR_RATE_4_VOL_QUOTE_MIN | 200000000 |
... |
| STAR_RATE_3_NVF_USD_MIN | 1500000 |
... |
| STAR_RATE_3_VOL_QUOTE_MIN | 150000000 |
... |
| STAR_RATE_2_NVF_USD_MIN | 500000 |
... |
| STAR_RATE_2_VOL_QUOTE_MIN | 100000000 |
... |
| STAR_RATE_1_NVF_USD_MIN | 200000 |
... |
| STAR_RATE_1_VOL_QUOTE_MIN | 100000000 |
... |
| SCREENSHOT_CHART_INTERVAL | 5m |
TradingView screenshot interval |
| ALERT_COOLDOWN_MINUTE | 10080 |
Minimum alert cooldown minute for each direction LONG/SHORT |
| KLINE_MIN_COUNT | 150 |
Minimum required candle validation based on SCREENSHOT_CHART_INTERVAL interval |
Microservices
These microservices are independent applications, each designed to perform a specific function. They work together to process data and trigger alerts in real-time.
node-stream-exchange
This service processes WebSocket streams from the exchange by establishing real-time connections. It continuously receives updates, such as ticker prices, trades, and candlestick data. The service ensures accurate data reception and efficiently forwards it to the appropriate channels for use by other services.
v0.5.0
- Fixed when new exchange symbols were detected but the symbol data was not updated in the cache.
- Updated the handling of the supported exchange constructor.
v0.4.5
- Initial Alpha Release
node-service-net-flow
This service processes Net Volume Flow data received through WebSocket streams, enabling real-time analysis of market flow.
v0.2.2
- Initial Alpha Release
node-service-event
This service analyzes the data received from WebSocket streams to identify key market indicators. When specific conditions or patterns are met, it triggers alert events based on predefined rules.
v0.11.1* TEST BRANCH
Database is not compatible with v0.10.x
- Forked new features branch that handles alert based on RSI value.
v0.10.3
- Fixed an issue with alert ready check query.
- Updated default config values.
v0.10.2
- Fixed an issue with the ATR value when chart candles are too short after a new symbol is added by exchange.
- Add config override support for
KLINE_MIN_COUNT,STAR_RATE_1_NVF_USD_MINandSCREENSHOT_CHART_INTERVAL.
v0.10.1
- Fixed an issue with premature alert triggers after exceeding the minimum quote volume and other conditions.
- Updated CloudWatch logs for alerts not triggered due to cooldown level, changing the log level from
infotoverbose.
v0.10.0
- Updated to capture the chart screenshot first, followed by calculating the entry price, to minimize latency between the screenshot and the entry price calculation.
- Enforced strict trigger retest percentage conditions with a shorter delay.
- Included CloudWatch logs for alerts that were not triggered due to cooldown.
v0.9.1
- Initial Alpha Release
node-telegram-server
This service manages interactions with Telegram, primarily focused on sending alerts to designated channels for alert notifications.
v0.8.0
- Removed screenshot handling, and process included the screenshot image in the event payload.
v0.7.1
- Initial Alpha Release