README
ΒΆ
Binance Trade Bot
Features
- Auto Trade β Automatically detects market tendency and switches between bull/bear strategies per operation; supports forced strategy mode to wait for a matching tendency
- Bull Trade β Buy-low-sell-high strategy for uptrending markets
- Bear Trade β Sell-high-buy-low strategy for downtrending markets
- Scalp Mode β High-frequency micro-trading using a scoring-based entry system; no longer requires all signals simultaneously
- Top Gainers Monitor β Real-time TUI dashboard of the top 24h movers on Binance
- AI Multi-Agent System β Concurrent analysis from OpenAI, DeepSeek, and Claude with weighted consensus
- Sentiment Analysis β Real-time news headlines and Fear & Greed Index integrated into AI decisions
- Trailing Stop-Loss β Dynamically locks in profits as price moves favorably
- Advanced Indicators β RSI, MACD, DEMA, Bollinger Bands, ADX, ATR, and volume confirmation
- Full OHLCV Analysis β Uses complete candlestick data instead of close-only prices
- Auto-Notional Adjustment β Automatically raises order quantity to meet Binance's minimum notional filter
- Detailed Order Reasoning β Activity Log shows which entry/exit conditions were met (β/β) before each trade
- File Logging β All trade events and errors are written to
binance-bot.logalongside the TUI display
Download
Download Precompiled Binary
You can download the precompiled binary from the repository's release artifacts.
- Visit the Releases page of the repository.
- Download the appropriate binary for your operating system (e.g., Linux, macOS, Windows).
- Make the binary executable (if required):
- On Linux or macOS:
chmod +x binance-bot
- On Linux or macOS:
- Move the binary to a directory in your
$PATHfor global access:- On Linux
sudo mv binance-bot /usr/local/bin/
Usage
[!WARNING] This bot is provided as-is. Use it at your own risk. Trading involves financial risks, and you may incur significant losses. Always test in a safe environment (e.g., a testnet and/or with small amounts) before deploying in live markets. The author is not responsible for any financial outcomes.
Prerequisites
Before using the Binance Trade Bot, you need to configure your environment with the Binance API client credentials. These credentials allow the bot to interact securely with your Binance account. Follow these steps to set up:
-
Obtain your Binance API Key and Secret
- Log in to your Binance account.
- Navigate to the API Management section.
- Create a new API key, choosing HMAC type and providing any label (e.g.,
CLI_Bot). - Save the API Key and Secret Key securely. You will not be able to view the secret again after closing the page.
-
Set Environment Variables Export the API credentials as environment variables in your terminal before executing the binance-bot cli:
export BINANCE_API_KEY=<your-api-key> export BINANCE_SECRET_KEY=<your-secret-key> -
Set AI Provider API Keys (optional) To enable the AI multi-agent system, export one or more of the following API keys. The system works with any combination β you can use 1, 2, or all 3 providers:
export OPENAI_API_KEY=<your-openai-api-key> export DEEPSEEK_API_KEY=<your-deepseek-api-key> export ANTHROPIC_API_KEY=<your-anthropic-api-key>Variable Provider Default Model OPENAI_API_KEYOpenAI gpt-4o-miniDEEPSEEK_API_KEYDeepSeek deepseek-chatANTHROPIC_API_KEYClaude claude-3-5-haiku-20241022If no AI keys are set, the bot runs entirely on technical indicators β AI is fully optional.
-
Create a config file You can specify a custom configuration file to adjust the bot's parameters of trading indicators.
See the sample configuration file.
Now you're ready to use the Binance Trade Bot! π
Run the Bot
Auto Trade (automatic tendency detection)
binance-bot -f binance-config.yml auto-trade -t "BTC/USDT" -a 0.001 -sl 2.0 -tp 2.5 -b 0.9998 -s 1.0003 -rp 2 -ra 5
This example:
- Automatically detects whether
BTC/USDTis trending up or down before each operation. - Enters bull mode (buy low, sell high) when tendency is "up", or bear mode (sell high, buy back low) when tendency is "down".
- Re-detects tendency between every operation, adapting to changing market conditions.
- If tendency flips during entry scanning, the bot dynamically switches mode without waiting.
- The TUI header shows the currently active mode (BULL/BEAR) updated in real-time.
Auto Trade with forced strategy
binance-bot -f binance-config.yml auto-trade -t "DOGE/USDT" -a 100 -sl 2.0 -tp 2.5 -b 0.9998 -s 1.0003 -rp 6 -ra 0 --strategy bull
This example:
- Forces the bot to only enter bull (buy-first) operations β useful when your account only holds USDT.
- The bot monitors the market and waits for an "up" tendency before placing any orders.
- If tendency flips away during scanning, the bot returns to waiting instead of switching to bear.
- Use
--strategy bearto force sell-first operations (when you hold the base coin and want to sell first). - Use
--strategy auto(default) for fully automatic tendency detection.
Bull Trade (uptrending markets)
binance-bot -f binance-config.yml bull-trade -t "XRP/USDT" -a 50 -sl 1.5 -tp 2.0 -b 0.9998 -s 1.0003 -rp 4 -ra 0
This example:
- Trades the pair
XRP/USDTwith an amount of50. - Sets a stop-loss of
1.5%and a take-profit of2%. - Adjusts buy and sell factors for the LIMIT order target price.
- Rounds the price to 4 decimals and the amount to 0 decimals.
Bear Trade (downtrending markets)
binance-bot -f binance-config.yml bear-trade -t "BTC/USDT" -a 0.001 -sl 2.0 -tp 3.0 -b 0.9998 -s 1.0003 -rp 2 -ra 5
This example:
- Sells
0.001 BTCwhen bearish signals are detected. - Sets a stop-loss of
2%(price rises above entry) and take-profit of3%(price drops below entry). - Buys back at a lower price to capture the difference as profit.
Scalp Mode (high-frequency micro-trading)
binance-bot -f sample-scalp-config.yml bull-trade -t "PEPE/USDT" -a 50 --sl 0.6 --tp 1.0 -b 0.9999 -s 1.0001 -rp 8 -ra 0 -o 500
This example:
- Uses 1-minute candles and a scoring-based entry (any 3 of 6 signals bullish).
- Sets tight stop-loss / take-profit suitable for volatile low-cap tokens.
- Runs up to 500 operations with only 5s between them for maximum trade frequency.
- See sample-scalp-config.yml for the full config.
Top Gainers Monitor
binance-bot -f binance-config.yml top-gainers
Launches a real-time TUI listing the top 24h price-change gainers on Binance, filtered by quote asset, minimum volume, and an exclude list. Refreshes on the configured poll-interval. Press q to quit.
Modify these parameters based on your specific trading requirements.
Explanation of Command Arguments
These arguments apply to the auto-trade, bull-trade, and bear-trade commands:
| Option | Short | Description | Default |
|---|---|---|---|
--ticker |
-t |
The trading pair ticker in the format ABC/USD (e.g., BTC/USDT). |
Required |
--amount |
-a |
Amount to trade. | Required |
--stop-loss |
-sl |
Stop-loss percentage (e.g., 1.5 for 1.5%). |
3 |
--take-profit |
-tp |
Take-profit percentage (e.g., 3.0 for 3%). |
2.5 |
--buy-factor |
-b |
Factor to determine the target price for a LIMIT buy order. | 0.9999 |
--sell-factor |
-s |
Factor to determine the target price for a LIMIT sell order. | 1.0001 |
--round-price |
-rp |
Decimal precision for rounding price values. | Required |
--round-amount |
-ra |
Decimal precision for rounding amount values. | Required |
--operations |
-o |
Number of operations to execute during the trading session. | 100 |
--strategy |
-st |
(auto-trade only) Force entry strategy: bull, bear, or auto. |
auto |
--help |
-h |
Show help for the command. | - |
Help Commands
-
For general help on the bot:
binance-bot --helpOutput:
NAME: binance-bot - A program bot to trade in Binance USAGE: binance-bot [global options] command <command args> VERSION: v0.7.0 AUTHOR: Walter Ferreira <wferreirauy@gmail.com> COMMANDS: bull-trade, bt Start a bull trade run bear-trade, brt Start a bear trade run (sell high, buy back low) auto-trade, at Automatically detect market tendency and trade accordingly (bull or bear) top-gainers, tg Monitor top market gainers in real-time help, h Shows a list of commands or help for one command GLOBAL OPTIONS: --config-file FILE, -f FILE Load configuration from FILE (default: $HOME/binance-config.yml) --help, -h show help --version, -v print the version -
For help with the
bull-tradecommand:binance-bot bull-trade --help -
For help with the
bear-tradecommand:binance-bot bear-trade --help -
For help with the
auto-tradecommand:binance-bot auto-trade --help -
For help with the
top-gainerscommand:binance-bot top-gainers --help
TUI Keyboard Shortcuts
While the bot is running, the following keys are available inside the TUI:
| Key | Action |
|---|---|
q / Ctrl+C |
Quit the application |
h |
Toggle the help / keyboard shortcuts popup |
c |
Show loaded configuration popup |
Esc |
Close any open popup |
Configuration
The bot is configured through a YAML file. See sample-binance-config.yml for a complete example.
Indicators Configuration
historical-prices:
period: 100 # number of candlesticks to fetch
interval: "1m" # candlestick interval (1m, 3m, 5m, 15m, 1h, etc.)
tendency:
interval: "3m" # interval for tendency calculation
direction: "up" # expected direction for bull-trade
indicators:
rsi:
interval: "5m"
length: 14
upper-limit: 70 # overbought threshold
middle-limit: 50
lower-limit: 30 # oversold threshold
dema:
length: 9
macd:
fast-length: 12
slow-length: 26
signal-length: 9
bollinger-bands:
length: 20
multiplier: 2.0
atr:
period: 14 # Average True Range for volatility
adx:
period: 14
threshold: 25 # minimum ADX value to confirm trend strength
volume:
ma-period: 20 # volume moving average period
Trailing Stop Configuration
The trailing stop-loss dynamically adjusts to lock in profits as the price moves favorably:
trailing-stop:
enabled: true
activation-pct: 1.5 # activate after price moves 1.5% in your favor
trailing-pct: 1.0 # trail by 1.0% from the peak/trough
- For bull trades: once the price rises by
activation-pctabove buy price, the stop tracks from the highest price and triggers if the price dropstrailing-pctfrom that peak. - For bear trades: once the price drops by
activation-pctbelow sell price, the stop tracks from the lowest price and triggers if the price risestrailing-pctfrom that trough.
Scalp Mode Configuration
Scalp mode is optimized for high-frequency micro-trading on volatile tickers. Instead of requiring all 6 entry signals simultaneously, it scores each signal and enters when min-score are bullish.
scalp-mode:
enabled: true
min-score: 3 # minimum bullish signals out of 6 to trigger entry
post-buy-delay: 5 # seconds to wait after fill before exit monitoring
inter-op-delay: 10 # seconds to wait between completed operations
require-rsi-exit: false # require RSI momentum confirmation before take-profit
Scoring signals (6 total):
| # | Signal | Bullish condition |
|---|---|---|
| 1 | RSI | Below upper limit |
| 2 | MACD | MACD line above signal line |
| 3 | Tendency | Matches configured direction |
| 4 | Bollinger | DEMA closer to lower band than upper band |
| 5 | ADX | Above configured threshold |
| 6 | Volume | Current volume above its moving average |
With min-score: 3 the bot enters if any 3 of 6 signals are bullish. Raise to 4 or 5 for more selective, lower-frequency entries.
See sample-scalp-config.yml for a complete high-frequency configuration tuned for 1-minute candles.
Recommended stop-loss / take-profit for scalping (after 0.2% round-trip fees):
| Scenario | --sl |
--tp |
Net gain/loss |
|---|---|---|---|
| Ultra-tight | 0.4 |
0.7 |
+0.5% / -0.4% |
| Balanced β | 0.6 |
1.0 |
+0.8% / -0.6% |
| Conservative | 1.0 |
1.8 |
+1.6% / -1.0% |
Top Gainers Configuration
top-gainers:
quote-asset: "USDT" # filter pairs ending with this asset
limit: 20 # number of top gainers to display
poll-interval: 60 # seconds between each refresh
min-volume: 1000000 # minimum 24h quote volume to include
exclude-symbols: # symbols to always exclude
- "USDCUSDT"
AI Configuration
The AI multi-agent system is optional. When enabled, it queries multiple LLM providers concurrently with technical indicators and market sentiment data to produce a consensus trading signal.
ai:
enabled: true
providers:
openai:
model: "gpt-4o-mini"
deepseek:
model: "deepseek-chat"
claude:
model: "claude-3-5-haiku-20241022"
min-confidence: 0.5 # minimum consensus confidence to act (0.0 - 1.0)
How it works:
- Each configured provider receives a structured prompt with all technical indicators plus real-time sentiment data.
- Providers are queried concurrently for speed.
- Each agent returns a signal (
BUY,SELL, orHOLD), a confidence score (0.0-1.0), and reasoning. - A weighted consensus algorithm aggregates all votes to produce a final decision.
- The AI must approve (or at least not contradict) technical signals before trades are executed.
Sentiment sources (free, no API key required):
- CryptoCompare β latest news headlines for the traded coin
- Alternative.me Fear & Greed Index β overall crypto market mood
Set
ai.enabled: falseor omit all provider API keys to disable AI and run on technical indicators only.
File Logging
All log levels (orders, info, errors) are automatically written to binance-bot.log in the working directory, alongside the TUI display. Color tags are stripped before writing. The file is opened in append mode so logs accumulate across sessions.
2026-04-07 12:30:00 [INFO] Scalp entry: score 5/6 (min 5)
2026-04-07 12:30:00 [INFO] β RSI 28.4 < 30 (upper limit)
2026-04-07 12:30:00 [INFO] β MACD above signal (0.000012 > 0.000008)
2026-04-07 12:30:00 [INFO] β Tendency up = up
2026-04-07 12:30:00 [INFO] β Closer to lower BB (lower=0.0023, upper=0.0089)
2026-04-07 12:30:00 [INFO] β ADX strong (32.1 > 20)
2026-04-07 12:30:00 [INFO] β Volume confirmed (4200 > avg 5100)
2026-04-07 12:30:01 [ORDER] BUY 50.000000 PEPE @ 0.00001234 USDT = 0.000617 USDT
2026-04-07 12:30:05 [INFO] BUY order filled!
2026-04-07 12:35:10 [INFO] Take-profit triggered: price 0.00001250 >= TP 0.00001246 (buy 0.00001234, TP 1.00%, P&L +1.30%)
2026-04-07 12:35:10 [INFO] β RSI exit ok (RSI declining=true, scalp bypass=false)
Auto-Notional Adjustment
Binance enforces a minimum notional value (price Γ quantity) per symbol β typically 5 USDT. If the configured --amount would produce a notional below this threshold (common with very cheap tokens like PEPE or SHIB), the bot automatically raises the quantity to meet the exchange's NOTIONAL and LOT_SIZE filters before placing the order. A message is logged when an adjustment occurs:
BUY qty adjusted from 50.00000000 to 405210.00000000 to meet exchange filters (minNotional=5.00)
No manual intervention is required β the adjustment is transparent and logged.
Trading Strategy Logic
Bull-Trade
The bull-trade command is designed to operate during bull market trends, leveraging upward momentum to execute profitable trades.
Buy Conditions
In classic mode, the bot places a buy order when all of the following conditions are true simultaneously. In scalp mode, the conditions are scored and entry triggers when min-score out of 6 are bullish (see Scalp Mode Configuration).
- RSI: Value is below the configured
upper-limit(default 70), indicating the market is not overbought. - MACD Crossover: The MACD line crosses above the Signal line (classic) or is above the Signal line (scalp), suggesting upward momentum.
- Tendency Confirmation: The trend direction matches the configured direction (DEMA above EMA = "up").
- DEMA Proximity to Bollinger Bands: The current DEMA is closer to the Lower Band than the Upper Band, suggesting a potential reversal from oversold conditions.
- ADX Trend Strength (if configured): ADX is above the threshold (default 25), confirming a strong trend.
- Volume Confirmation (if configured): Current volume exceeds its moving average, avoiding false breakouts.
- AI Consensus (if enabled): The multi-agent system approves the entry or does not contradict it.
Sell Conditions
The bot will exit a position through one of three mechanisms:
- Trailing Stop-Loss (if enabled): After the price rises by
activation-pctabove buy price, the stop trails from the highest price. Triggers when price drops bytrailing-pctfrom the peak. - Fixed Stop-Loss: The price drops to the stop-loss percentage below buy price. Executes immediately (no AI delay on protective exits).
- Take Profit: The price reaches the take-profit percentage AND RSI is declining (skipped in scalp mode when
require-rsi-exit: false) AND the AI supports the exit (if enabled).
Bear-Trade
The bear-trade command is designed to operate during bear market trends, profiting from downward price movement by selling high and buying back low.
Sell Entry Conditions
In classic mode, all conditions must be met simultaneously. In scalp mode, min-score out of 6 signals must be bearish.
The bot will open a short position (sell) when:
- RSI: Value is above the configured
lower-limit(default 30), indicating the market is not oversold. - MACD Crossover: The MACD line crosses below the Signal line, suggesting downward momentum.
- Tendency: The trend direction is "down" (DEMA below EMA).
- DEMA Proximity to Bollinger Bands: The current DEMA is closer to the Upper Band than the Lower Band, suggesting a potential reversal from overbought conditions.
- ADX Trend Strength (if configured): ADX confirms the trend has strength.
- Volume Confirmation (if configured): Current volume exceeds its moving average.
- AI Consensus (if enabled): The multi-agent system approves the entry.
Buy-Back Exit Conditions
The bot will exit the bear position (buy back) through one of three mechanisms:
- Trailing Stop (if enabled): After the price drops by
activation-pctbelow sell price, the stop trails from the lowest price. Triggers when price rises bytrailing-pctfrom the trough. - Fixed Stop-Loss: The price rises to the stop-loss percentage above sell price. Executes immediately.
- Take Profit: The price drops to the take-profit percentage AND RSI is rising (skipped in scalp mode when
require-rsi-exit: false) AND the AI supports the exit (if enabled).
Auto-Trade (Dynamic Tendency Detection)
The auto-trade command removes the need to manually choose between bull and bear strategies. Before each operation, the bot evaluates the current market tendency using the same DEMA-vs-EMA analysis used by the individual modes.
How It Works
- Strategy Selection: The
--strategyflag determines behavior:auto(default): Detects tendency automatically and trades in whichever direction the market is trending.bull: Forces buy-first operations β the bot waits until tendency is "up" before entering. Ideal when you only hold the quote asset (e.g., USDT).bear: Forces sell-first operations β the bot waits until tendency is "down" before entering. Ideal when you hold the base asset and want to sell first.
- Tendency Detection: At the start of each operation, the bot fetches historical prices on the configured
tendency.intervaland compares DEMA to EMA. If DEMA > EMA the tendency is "up" (bull); otherwise "down" (bear). - Waiting for Match: When a strategy is forced (
bullorbear), the bot continuously monitors tendency and only proceeds when it matches the required direction. The TUI shows the mode with "(waiting)" until tendency aligns. - Mode Selection: Based on the detected/matched tendency, the bot switches to the appropriate strategy β bull (buy low, sell high) or bear (sell high, buy back low).
- Live Re-detection: During entry scanning in
automode, if the tendency flips, the bot immediately adapts and switches to the opposite mode. In forced strategy mode, a tendency flip causes the bot to return to waiting. - Entry & Exit: Once a mode is selected, the exact same entry conditions (classic or scalp scoring) and exit mechanisms (trailing stop, stop-loss, take-profit, AI confirmation) apply as in the standalone
bull-tradeorbear-tradecommands. - Per-Operation Adaptation: After each completed operation (entry + exit), the bot re-detects tendency before the next one.
TUI Display
The TUI header dynamically shows the current mode:
BULL (waiting)orBEAR (waiting)when a forced strategy is waiting for matching tendencyAUTO MODEin cyan at startup (when strategy is auto)- Switches to
BULL MODE(green) orBEAR MODE(red) once tendency is detected/matched - Updates in real-time if tendency flips during scanning
Tip: The
auto-tradecommand uses the same config file and flags asbull-trade/bear-trade. Thetendency.directionconfig field is ignored β the bot determines direction automatically.
AI Multi-Agent Decision Flow
When AI is enabled, the decision flow operates as follows:
Technical Indicators βββ
βββ> AI Agents (concurrent) ββ> Weighted Consensus ββ> Trade Decision
Sentiment Data βββββββββ β β β
OpenAI DeepSeek Claude
- Entry signals: Technical conditions must pass first, then AI must approve (or at least HOLD).
- Stop-loss / trailing-stop exits: Execute immediately without waiting for AI β safety first.
- Take-profit exits: Require AI confirmation to avoid exiting too early in strong trends.
[!WARNING] Always test the bot in a safe environment (e.g., testnet or small amounts) before live trading. Ensure you understand the risks and implications of using automated trading strategies.
Build from Source
To build the binance-bot from the source code, ensure you have the following prerequisites installed:
Prerequisites
-
Go (Golang):
- Install Go from the official website.
- Ensure your Go version is at least 1.19 by running:
go version
-
Git:
- Clone the repository using Git. Install Git from here if you don't already have it.
Steps to Build
-
Clone the repository:
git clone https://github.com/wferreirauy/binance-bot.git cd binance-bot -
Build the project:
go build -o binance-bot -
Verify the executable:
./binance-bot --help
If the build succeeds, you should see the general help menu displayed, indicating that the bot has been built successfully.
References
Binance API documentation
https://binance-docs.github.io/apidocs/spot/en/#general-info
Binance GO library
https://github.com/binance/binance-connector-go
AI Provider APIs
Sentiment Data Sources
- CryptoCompare News API β Free, no API key required
- Alternative.me Fear & Greed Index β Free, no API key required
Documentation
ΒΆ
There is no documentation for this package.