Binance DCA — Professional Dollar-Cost Averaging Tool
Systematic crypto accumulation made simple.
Plan, execute, and track DCA strategies on Binance with confidence.
What is DCA?
Dollar-Cost Averaging (DCA) is an investment strategy where you buy a fixed dollar amount of an asset at regular intervals, regardless of price. This approach:
- - ✅ Reduces timing risk — no need to predict market tops/bottoms
- ✅ Smooths volatility — averages out price fluctuations over time
- ✅ Removes emotion — systematic buying, no panic or FOMO
- ✅ Builds discipline — consistent accumulation, perfect for long-term holders
This tool helps you plan, automate, and track your DCA strategy on Binance spot markets.
Features
- - 📊 DCA Plan Projections — scenario analysis showing potential outcomes at different price levels
- 💰 Market & Limit Orders — flexible execution options
- 📈 Trade History — track your accumulation progress
- 🔒 Secure — credentials via environment variables only, zero hardcoded secrets
- 🧪 Testnet Support — practice on Binance testnet before going live
- 🤖 OpenClaw Integration — automate DCA buys via cron jobs with alerts
- 🛡️ Risk Management — conservative defaults, validation before execution
Setup
1. Get Binance API Keys
- 1. Log in to binance.com
- Go to Account → API Management
- Create a new API key:
-
Label: OpenClaw-DCA (or similar)
-
Restrictions: Enable
Spot & Margin Trading only
-
IP Whitelist: Add your server IP for security (optional but recommended)
- 4. Save your API Key and Secret Key securely
⚠️ Security tips:
- - Never share your secret key
- Enable IP whitelist if your server has a static IP
- Use a separate API key for DCA (easier to revoke if needed)
- Start with small amounts to test
2. Set Environment Variables
Never hardcode credentials. Always use environment variables:
CODEBLOCK0
Make them permanent (optional, add to ~/.bashrc or ~/.zshrc):
CODEBLOCK1
For testnet (recommended for first-time users):
CODEBLOCK2
Get testnet API keys at: testnet.binance.vision
3. Verify Setup
CODEBLOCK3
If you see prices/balances, you're ready!
Quick Start Examples
Example 1: Check Current Price
CODEBLOCK4
Works for any pair:
CODEBLOCK5
Example 2: Check Your Balance
CODEBLOCK6
Check any asset:
CODEBLOCK7
Example 3: Plan a DCA Strategy
Scenario: You want to invest $600 over 3 months in BTC.
CODEBLOCK8
Output:
CODEBLOCK9
What this tells you:
- - If BTC stays flat → break even
- If BTC averages -20% during your buys → you're down ~21% (but you own more BTC)
- If BTC averages +50% → you're up ~63%
Use this to set realistic expectations before committing.
Example 4: Execute Your First DCA Buy
Market order (instant execution):
CODEBLOCK10
Output:
CODEBLOCK11
Limit order (wait for your price):
CODEBLOCK12
Output:
CODEBLOCK13
(Order will fill when price hits $94,000)
Example 5: Check Your Trade History
CODEBLOCK14
Output:
Last 10 trades for BTCUSDT:
---
1738752000 | BUY | qty=0.00052500 | price=95238.10 | fee=0.00000053 BNB
1738665600 | BUY | qty=0.00051234 | price=97567.20 | fee=0.00000051 BNB
...
Complete Action Reference
price [SYMBOL]
Get current spot price for a trading pair.
CODEBLOCK16
Default: BTCUSDT if symbol is omitted.
balance [ASSET]
Check free and locked balance for an asset.
CODEBLOCK17
Output format: INLINECODE6
Default: USDT if asset is omitted.
Use case: Check how much capital you have available before placing orders.
buy SYMBOL AMOUNT [TYPE] [PRICE]
Place a buy order.
Arguments:
- -
SYMBOL — Trading pair (e.g., BTCUSDT, ETHUSDT) - INLINECODE12 — Amount in quote currency (USDT). The tool calculates how much BTC/ETH you get.
- INLINECODE13 —
MARKET (default) or INLINECODE15 - INLINECODE16 — Required for
LIMIT orders
Market order examples:
CODEBLOCK18
Limit order examples:
CODEBLOCK19
Safety features:
- - Amount validation (must be a number)
- API key check before execution
- Order status confirmation in output
history [SYMBOL] [LIMIT]
Show recent trade history.
CODEBLOCK20
Defaults: BTCUSDT, limit INLINECODE20
Output includes:
- - Timestamp (Unix seconds)
- Side (BUY/SELL)
- Quantity purchased
- Execution price
- Fees paid (and fee asset)
Use case: Track your DCA progress over time, calculate average entry price.
plan [AMOUNT] [FREQ_DAYS] [NUM_BUYS] [SYMBOL]
Project a DCA plan with scenario analysis.
Arguments:
- -
AMOUNT — Dollar amount per buy (default: 50) - INLINECODE24 — Days between buys (default:
7) - INLINECODE26 — Number of buys (default:
12) - INLINECODE28 — Trading pair (default:
BTCUSDT)
Examples:
CODEBLOCK21
What you get:
- - Total investment amount
- BTC/ETH you'd own at current price
- Time span (days + months)
- Scenario analysis: PnL at -30%, -20%, -10%, 0%, +10%, +20%, +50%, +100% average prices
Use this to:
- - Decide on a comfortable budget and frequency
- Understand risk/reward before starting
- Show the math to justify DCA vs. lump sum
DCA Strategy Guide
When to Use DCA
✅ Good for:
- - Long-term accumulation (6+ months)
- High-volatility assets (BTC, ETH, altcoins)
- Building positions without timing stress
- Removing emotional decision-making
❌ Not ideal for:
- - Short-term trading (use manual buys)
- Assets you want to flip quickly
- Low-volatility stablecoins (just buy once)
Best Practices
- 1. Start small — Test with 1-2% of your budget first
- Use testnet — Practice on
https://testnet.binance.vision before going live - Set a timeline — DCA works best over 3-12+ months
- Stick to the plan — Resist urge to stop during dips (that's when DCA shines)
- Track progress — Use
history to see your average entry price - Adjust if needed — Life changes, budgets change — recalculate with
plan and adapt
Position Sizing Recommendations
Conservative (1-2% per buy):
- - Portfolio: $10,000 → DCA $100-$200 per buy
- Lower risk, slower accumulation
Moderate (3-5% per buy):
- - Portfolio: $10,000 → DCA $300-$500 per buy
- Balanced approach, standard for most users
Aggressive (5-10% per buy):
- - Portfolio: $10,000 → DCA $500-$1,000 per buy
- Higher risk, faster accumulation, requires strong conviction
Never go above 10% per buy — leaves no room for unexpected dips or expenses.
Frequency Guidelines
- - Daily — For very active traders, high time commitment
- Every 3 days — Aggressive, good for short DCA periods (1-3 months)
- Weekly — Most popular, good balance (Mondays are common)
- Bi-weekly — Aligns with paychecks, moderate pace
- Monthly — Long-term HODLers, lowest effort
Pro tip: Match DCA frequency to your income schedule (weekly paycheck → weekly DCA).
Automation with OpenClaw
Manual Cron (Basic)
Run DCA buys automatically via system cron:
CODEBLOCK22
Limitations:
- - No alerts if it fails
- No confirmations
- Silent execution
OpenClaw Cron (Recommended)
Use OpenClaw for intelligent DCA automation with alerts:
Example: Weekly BTC DCA with Telegram notifications
CODEBLOCK23
Benefits:
- - ✅ Execution confirmations sent to you
- ✅ Failure alerts
- ✅ Can ask agent to analyze history and report progress
- ✅ Easy to pause/resume via
openclaw cron commands
Setup:
CODEBLOCK24
Troubleshooting
Error: BINANCE_API_KEY not set
Fix: Set environment variables before running:
CODEBLOCK25
Error: Timestamp for this request is outside of the recvWindow
Cause: Your system clock is out of sync with Binance servers.
Fix (Linux/macOS):
CODEBLOCK26
Fix (Docker):
Add --cap-add SYS_TIME when running container, or sync host clock.
Error: Signature for this request is not valid
Causes:
- - Wrong INLINECODE38
- API key restrictions (IP whitelist mismatch, disabled Spot Trading)
Fix:
- 1. Double-check your secret key (copy-paste from Binance)
- Verify API key has Spot & Margin Trading enabled
- If using IP whitelist, confirm your server IP is allowed
- Regenerate API key if uncertain
Error: API request failed
Causes:
- - Network issues
- Wrong INLINECODE40
- Binance API maintenance
Fix:
- 1. Test network: INLINECODE41
- Check Binance status: binance.com/en/support/announcement
- If using testnet, confirm: INLINECODE42
Error: Account has insufficient balance for requested action
Cause: Not enough USDT in your spot account.
Fix:
- 1. Check balance: INLINECODE44
- Deposit USDT to your spot account
- Reduce DCA amount to match available balance
Order shows NEW status (limit order not filling)
This is normal for limit orders. Status means:
- -
NEW — Order placed, waiting for price - INLINECODE47 — Order executed
- INLINECODE48 — Partial execution
- INLINECODE49 — You or system canceled it
Check order status:
CODEBLOCK27
Cancel pending limit orders:
Use Binance web/app → Orders → Open Orders → Cancel.
FAQ
Q: Can I DCA into altcoins (not just BTC)?
A: Yes! Use any Binance spot pair:
CODEBLOCK28
Just replace BTCUSDT with your desired pair.
Q: What's the minimum buy amount?
A: Binance sets minimums per pair (usually $10-$20). Check Binance docs or test with a small amount on testnet first.
Q: Does this work with Binance.US?
A: Not directly. Binance.US has a separate API (https://api.binance.us). You'd need to change BINANCE_BASE_URL and test. Not officially supported.
Q: Can I sell with this tool?
A: Not currently. This is DCA (accumulation) only. For selling, use Binance web/app or modify the script (change side=BUY to side=SELL).
Q: Is my data stored anywhere?
A: No. Zero data storage. All credentials are environment variables. The script makes direct API calls to Binance and exits.
Q: Can I use this on multiple machines?
A: Yes, but set up API keys separately on each. Consider using IP whitelist on your API key for security.
Q: What if I want to change my DCA amount mid-strategy?
A: Just adjust the amount in your next manual/cron execution. DCA is flexible — no commitment to fixed amounts.
Example: Week 1-4 use $50, Week 5+ use $100.
Q: How do I calculate my average entry price?
Run history and average the price column:
CODEBLOCK29
Or use a spreadsheet: export history, paste prices, =AVERAGE().
Security Best Practices
🔒 API Key Safety:
- - Use dedicated API key for DCA (label it
DCA-Only) - Enable Spot Trading only (no Futures, Margin, Withdrawals)
- Set IP whitelist if your server has static IP
- Rotate keys every 3-6 months
- Revoke immediately if compromised
🔒 Credential Management:
- - Never commit
.env files with keys to Git - Use environment variables, not hardcoded strings
- On shared servers, restrict file permissions: INLINECODE60
🔒 Testnet First:
- - Always test new strategies on testnet before using real funds
- Testnet keys: testnet.binance.vision
- Set: INLINECODE61
🔒 Start Small:
- - First live DCA: use 10-20% of planned amount
- Verify execution, fees, and confirmations
- Scale up once confident
Advanced Usage
Dynamic DCA (Market Conditions)
Adjust buy amounts based on price:
Buy more when BTC dips:
CODEBLOCK30
Use limit orders to "buy the dip":
CODEBLOCK31
Multi-Asset DCA
DCA into multiple coins:
CODEBLOCK32
Logging for Analysis
Track all DCA buys to a log file:
CODEBLOCK33
Then analyze with:
CODEBLOCK34
Contributing
Found a bug? Have a feature idea? Want to add support for other exchanges?
- - GitHub: (if public repo exists, link here)
- Issues: Report via GitHub Issues
- Pull Requests: Welcome! Follow existing code style.
License
MIT License — Free to use, modify, and distribute.
Disclaimer: This tool is provided as-is. Use at your own risk. The authors are not responsible for trading losses, API issues, or incorrect usage. Always test on testnet first and never invest more than you can afford to lose.
Changelog
v1.2.0 (2026-02-05)
- - 📚 Comprehensive documentation overhaul
- 📋 Added real-world examples for all actions
- 🎓 DCA strategy guide with best practices
- 🔧 Troubleshooting section
- ❓ FAQ with common questions
- 🔒 Security best practices guide
- 🚀 Advanced usage examples
- 🤖 OpenClaw automation guide
v1.1.0 (2026-02-05)
- - Initial public release
- Core DCA functionality: plan, buy, history, price, balance
- Testnet support
- Market and limit orders
Built with ❤️ for long-term crypto accumulation.
Questions? Feedback? Tag @fpsjago on ClawHub or OpenClaw Discord.
Binance DCA — 专业定投工具
系统化加密货币积累,简单易行。
在币安上自信地规划、执行和追踪定投策略。
什么是DCA?
定投(Dollar-Cost Averaging, DCA) 是一种投资策略,即定期以固定金额买入资产,无论价格如何。这种方法:
- - ✅ 降低择时风险 — 无需预测市场顶部/底部
- ✅ 平滑波动 — 长期平均价格波动
- ✅ 消除情绪影响 — 系统化买入,不恐慌或FOMO
- ✅ 培养纪律 — 持续积累,适合长期持有者
本工具 帮助你在币安现货市场规划、自动化并追踪你的定投策略。
功能特点
- - 📊 定投计划预测 — 情景分析,展示不同价格水平下的潜在结果
- 💰 市价与限价单 — 灵活的执行选项
- 📈 交易历史 — 追踪你的积累进度
- 🔒 安全可靠 — 仅通过环境变量传递凭证,无硬编码密钥
- 🧪 测试网支持 — 上线前在币安测试网练习
- 🤖 OpenClaw集成 — 通过定时任务自动执行定投并发送提醒
- 🛡️ 风险管理 — 保守默认设置,执行前验证
设置指南
1. 获取币安API密钥
- 1. 登录 binance.com
- 进入 账户 → API管理
- 创建新的API密钥:
-
标签: OpenClaw-DCA(或类似名称)
-
权限: 仅启用
现货及杠杆交易
-
IP白名单: 添加你的服务器IP以增强安全性(可选但推荐)
- 4. 安全保存你的 API密钥 和 密钥
⚠️ 安全提示:
- - 切勿分享你的密钥
- 如果你的服务器有静态IP,请启用IP白名单
- 为DCA使用单独的API密钥(需要时更容易撤销)
- 从小额开始测试
2. 设置环境变量
切勿硬编码凭证。 始终使用环境变量:
bash
export BINANCEAPIKEY=你的-api-密钥
export BINANCESECRETKEY=你的-密钥
使其永久生效(可选,添加到 ~/.bashrc 或 ~/.zshrc):
bash
echo export BINANCEAPIKEY=你的-api-密钥 >> ~/.bashrc
echo export BINANCESECRETKEY=你的-密钥 >> ~/.bashrc
source ~/.bashrc
对于测试网(推荐首次用户使用):
bash
export BINANCEBASEURL=https://testnet.binance.vision
在 testnet.binance.vision 获取测试网API密钥。
3. 验证设置
bash
检查余额(应无错误)
bash scripts/dca.sh balance USDT
检查BTC价格
bash scripts/dca.sh price BTCUSDT
如果能看到价格/余额,说明设置成功!
快速入门示例
示例1:查看当前价格
bash
bash scripts/dca.sh price BTCUSDT
输出:BTCUSDT = 95234.50
适用于任何交易对:
bash
bash scripts/dca.sh price ETHUSDT
bash scripts/dca.sh price SOLUSDT
示例2:查看你的余额
bash
bash scripts/dca.sh balance USDT
输出:USDT: free=1000.00000000, locked=0.00000000
查看任何资产:
bash
bash scripts/dca.sh balance BTC
bash scripts/dca.sh balance ETH
示例3:规划定投策略
场景: 你想在3个月内投资600美元购买BTC。
bash
每周50美元,持续12周
bash scripts/dca.sh plan 50 7 12 BTCUSDT
输出:
DCA Plan: BTCUSDT
==========================
买入金额: 每次50美元
频率: 每7天
持续时间: 12次买入
当前价格: 95234.50
==========================
总投资: 600.00美元
当前价格:0.00630245 BTC
时间跨度:84天(约2.8个月)
情景分析(假设期间平均价格为):
-30% -> 均价 $66,664.15 -> 0.00900000 BTC -> 盈亏:-$186.00 (-31.0%)
-20% -> 均价 $76,187.60 -> 0.00787500 BTC -> 盈亏:-$126.00 (-21.0%)
-10% -> 均价 $85,711.05 -> 0.00700000 BTC -> 盈亏:-$63.00 (-10.5%)
+0% -> 均价 $95,234.50 -> 0.00630245 BTC -> 盈亏:+$0.00 (+0.0%)
+10% -> 均价 $104,757.95 -> 0.00572727 BTC -> 盈亏:+$63.00 (+10.5%)
+20% -> 均价 $114,281.40 -> 0.00525000 BTC -> 盈亏:+$126.00 (+21.0%)
+50% -> 均价 $142,851.75 -> 0.00420000 BTC -> 盈亏:+$378.00 (+63.0%)
+100% -> 均价 $190,469.00 -> 0.00315122 BTC -> 盈亏:+$630.00 (+105.0%)
这告诉你什么:
- - 如果BTC保持平稳 → 盈亏平衡
- 如果BTC在你买入期间均价下跌20% → 你亏损约21%(但你拥有更多BTC)
- 如果BTC均价上涨50% → 你盈利约63%
在投入前使用此功能 设定合理预期。
示例4:执行首次定投买入
市价单(立即执行):
bash
以当前市价买入50美元BTC
bash scripts/dca.sh buy BTCUSDT 50
输出:
正在下达市价买入:BTCUSDT,金额50 USDT...
订单 #123456789:已成交
成交数量:0.00052500 BTC
限价单(等待你的价格):
bash
仅当BTC跌至94,000美元时买入
bash scripts/dca.sh buy BTCUSDT 50 LIMIT 94000
输出:
正在下达限价买入:BTCUSDT,金额50 USDT...
订单 #123456790:新建
成交数量:0.00000000 BTC
(当价格触及94,000美元时订单将成交)
示例5:查看交易历史
bash
BTCUSDT最近10笔交易
bash scripts/dca.sh history BTCUSDT 10
输出:
BTCUSDT最近10笔交易:
1738752000 | 买入 | 数量=0.00052500 | 价格=95238.10 | 手续费=0.00000053 BNB
1738665600 | 买入 | 数量=0.00051234 | 价格=97567.20 | 手续费=0.00000051 BNB
...
完整操作参考
price [交易对]
获取交易对当前现货价格。
bash
bash scripts/dca.sh price BTCUSDT
bash scripts/dca.sh price ETHUSDT
bash scripts/dca.sh price SOLUSDT
默认值: 省略交易对时默认为 BTCUSDT。
balance [资产]
检查资产的可用和锁定余额。
bash
bash scripts/dca.sh balance USDT
bash scripts/dca.sh balance BTC
bash scripts/dca.sh balance ETH
输出格式: ASSET: free=X.XXXXXXXX, locked=Y.YYYYYYYY
默认值: 省略资产时默认为 USDT。
用途: 在下单前检查可用资金。
buy 交易对 金额 [类型] [价格]
下达买入订单。
参数:
- - 交易对 — 交易对(例如 BTCUSDT、ETHUSDT)
- 金额 — 以 计价货币(USDT)计价的金额。工具会自动计算你能获得多少BTC/ETH。
- 类型 — MARKET(默认)或 LIMIT
- 价格 — 限价单必需
市价单示例:
bash
立即买入50美元BTC
bash scripts/dca.sh buy BTCUSDT 50
立即买入100美元ETH
bash scripts/dca.sh buy ETHUSDT 100
限价单示例:
bash
仅当BTC