The Binance Java Bot is an automated trading bot designed to interact with the Binance cryptocurrency exchange and execute trades based on advanced technical analysis strategies. The bot utilizes key technical indicators such as the ZigZag pattern and Fibonacci retracement levels to determine optimal buy and sell points. This integration also includes a Telegram bot, allowing users to interact with the bot and receive trade signals directly via Telegram.
NOT: development still in progress ✔️
- Automatic trading execution using Binance API
- Detection of ZigZag patterns in market data
- Fibonacci retracement level calculation for buy and sell signals
- Telegram bot integration for receiving trading signals and selecting strategies
- Configurable investment and scheduling parameters
- Comprehensive test suite with coverage reporting
The ZigZag pattern is a technical analysis tool used to filter out market noise and highlight key trends in price movements. It identifies significant peaks (highs) and troughs (lows) by filtering out price changes below a specified percentage.
The ZigZag pattern is particularly useful for:
- Highlighting key market trends
- Reducing market noise
- Helping traders spot reversals and continuation patterns
The bot detects significant price movements using the ZigZag pattern and then applies Fibonacci retracement levels to determine optimal trading points.
Fibonacci retracement levels are used to identify potential reversal points in an asset's price by calculating retracement levels based on the Fibonacci sequence (e.g., 23.6%, 38.2%, 50%, 61.8%, and 100%). These levels are crucial in determining where prices are likely to find support or resistance, which are important for making trading decisions.
The bot calculates the following Fibonacci retracement levels based on the highest and lowest ZigZag points:
- 23.6% (0.236)
- 38.2% (0.382)
- 50% (0.500)
- 61.8% (0.618)
- 76.4% (0.764)
- 100% (1.000)
These levels are used to determine entry points, take-profit targets, and stop-loss levels in the generated trading signals.
The trading signals generated by the bot include the following components:
- Symbol: The cryptocurrency pair being traded (e.g., BTCUSDT).
- Trending Status: Whether the signal indicates a BUY or SELL trade.
- Entry Start: The lower boundary of the buy entry range, based on the 23.6% Fibonacci level.
- Entry End: The upper boundary of the buy entry range, based on the 38.2% Fibonacci level.
- Take Profit Levels: A series of levels (50%, 61.8%, 76.4%, etc.) indicating potential profit-taking points.
- Stop Loss: The stop-loss level based on the 100% Fibonacci retracement level, protecting against unfavorable market movements.
- Close Price: The current closing price of the asset.
- High Price: The highest price observed during the relevant period.
- Low Price: The lowest price observed during the relevant period.
MDTBTC
TRENDING STATUS: BUY
ENTRY_START: 0.00000125
ENTRY_END: 0.00000150
TP1: 0.00000181
TP2: 0.00000195
TP3: 0.00000214
TP4: 0.00000245
TP5: 0.00000266
TP6: 0.00000300
TP7: 0.00000353
TP8: 0.00000400
STOP: 0.00000120
This format clearly defines the trending status (BUY or SELL), entry points, take-profit levels, and stop-loss level, allowing the trader to execute the trade efficiently.
- Java 21
- Maven
- Binance account
- Telegram account
- Clone the repo:
git clone https://github.com/ozgen/binance-java-bot.git
- Navigate to the directory:
cd binance-java-bot
- Build with Maven:
mvn clean install
Configure the application using environment variables or a .env
file. Here are the key variables you need to set:
DB_USER=user
DB_PASSWORD=password
DB_NAME=app
DB_HOST=localhost
DB_PORT=5432
BINANCE_API_SECRET=<secret>
BINANCE_API_KEY=<key>
TELEGRAM_TOKEN=<token>
TELEGRAM_USERNAME=<bot-name>
TELEGRAM_BOT_ENABLED=true
TRADING_BOT_ENABLED=true
app.bot.investment.currency
: Investment currency (e.g.,BTC
)app.bot.investment.amount
: Total investment amountapp.bot.investment.perAmount
: Amount per tradeapp.bot.investment.currencyRate
: Currency rate for conversion (e.g.,BTCUSD
)app.bot.investment.percentageInc
: Percentage increase for buyingapp.bot.investment.profitPercentage
: Profit percentage targetapp.bot.investment.zigzagPercentage
: The percentage movement required to trigger ZigZag pattern detection (e.g.,0.01
for 1%)
app.bot.schedule.buyError
: Schedule interval for buy error in msapp.bot.schedule.sellError
: Schedule interval for sell error in msapp.bot.schedule.insufficient
: Schedule interval for insufficient balance in msapp.bot.schedule.notInRange
: Schedule interval for not in range status in msapp.bot.schedule.tradingSignal
: Schedule interval for trading signals in msapp.bot.schedule.openSellOrder
: Schedule interval for open sell orders in msapp.bot.schedule.openBuyOrder
: Schedule interval for open buy orders in msapp.bot.schedule.monthBefore
: Number of months before for date calculations
bot.telegram.enabled
: Set totrue
to enable the Telegram bot.bot.trading.enabled
: Set totrue
to enable trading bot in Binance.
Start the bot with:
java -jar target/binance-telegram-bot-0.0.1-SNAPSHOT.jar
- Create a Telegram Bot: Follow the instructions on Telegram's official documentation to create a new bot.
- Generate a Bot Token: Use this guide to generate a token for your Telegram bot.
Here's an example of how the bot works when a user enters a symbol and selects a trading strategy:
- The user enters a trading pair (e.g.,
btcusdt
). - The bot asks the user to choose a trading strategy.
- After selecting a strategy, the bot processes the signal and provides a response with the trading signal details.
Execute the test suite using Maven:
mvn test
After running the tests, generate a coverage report using JaCoCo (Java Code Coverage Library):
mvn jacoco:report
The coverage report can be found in target/site/jacoco/index.html
. Open it in a web browser to view detailed coverage statistics.
This project is licensed under the MIT License - see LICENSE.md for details.
- Binance API
- Telegram API