Public
Binance Futures Testnet bot with CCXT and Telegram
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

πŸ€– Binance Futures Testnet Bot

Automated trading bot for Binance Futures Testnet using CCXT, with hidden divergence detection, liquidity sweep validation, order book analysis, dynamic risk management, and Telegram reporting.

Architecture

Rendering mermaid diagram...

Setup

1. Set Environment Variables

Go to Val Town Settings β†’ Environment Variables and add:

VariableDescription
BINANCE_API_KEYBinance Futures Testnet API key
BINANCE_SECRET_KEYBinance Futures Testnet secret key
TELEGRAM_TOKENTelegram bot token from @BotFather
TELEGRAM_CHAT_IDYour Telegram chat ID
PROXY_URL(Optional) HTTP proxy for geo-blocked regions, e.g. http://user:pass@host:port

2. Configure Cron Schedule

Set main.ts to run every 15 minutes via Val Town's interval settings.

3. Get Testnet Credentials

  1. Go to Binance Futures Testnet
  2. Log in and create API keys
  3. Fund your testnet account with test USDT

Strategy: Hidden Divergence + Liquidity Sweep

Entry Conditions (ALL must be met):

  1. Hidden Divergence Detected (trend continuation):
    • Hidden Bullish: Price makes Higher Low + RSI makes Lower Low β†’ LONG
    • Hidden Bearish: Price makes Lower High + RSI makes Higher High β†’ SHORT
  2. Liquidity Sweep Confirmed: Price wicked into a key S/R zone and rejected
  3. Order Book Imbalance: Bid/Ask volume ratio confirms the direction
  4. Signal Strength β‰₯ 30/100: Combined RSI depth + OB imbalance score

Risk Management:

  • 10% account allocation per trade
  • Dynamic leverage: 10x–20x based on signal strength (linear scale 50–80%)
  • Max 4 concurrent positions
  • 1:1.5 Risk-to-Reward ratio (ATR-based SL/TP)
  • Trailing Stop Loss & Take Profit: Locks profits as trade moves favorably

Proxy / Geo-Block Bypass:

The bot supports HTTP/HTTPS proxy configuration via PROXY_URL env var. This routes all exchange API requests through the proxy to bypass Error 451 (Restricted Location). You must supply your own working proxy β€” free public proxies are unreliable.

Files

FilePurpose
main.tsInterval trigger (entry point)
bot.tsCore bot engine: scan, analyze, trade, report
exchange.tsCCXT exchange setup with proxy, order book, positions
indicators.tsRSI, swing detection, hidden divergence, liquidity sweep
risk.tsLeverage calc, position sizing, SL/TP, trailing logic
storage.tsTrade state persistence via Val Town Blob
telegram.tsTelegram messaging and report formatting
dashboard.tsxHTTP dashboard for monitoring
config.tsAll configurable parameters

⚠️ Disclaimer

This bot is for Testnet only. Never use real funds without extensive backtesting and risk assessment. Trading cryptocurrency futures carries significant risk of loss.