binance-spot-trade
Skill0 starsChanged 15 days agoMITView on GitHub
Place and manage crypto SPOT orders with hard risk caps, exchange filters, and dry-run/testnet support. Reference implementation targets Binance Spot REST; keep adapters swappable for other spot venues. Use when buying/selling spot, checking balances or positions, implementing trade.py, or wiring order flow after a judge decision. Trigger phrases: "spot buy", "spot sell", "place order", "check positions", "dry-run trade", "trade.py".
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- backtestSkill
- crypto-news-collectSkill
- daily-trading-runSkill
- news-judgeSkill
- security-checkSkill
- trade-reportSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 43
Verify symbol status is tradable for spot (Binance: status=TRADING, spot permission).
- Distinctive: line 44
Read filters (Binance names.
- Distinctive: line 63
Only sell quantity tracked (or available) for that spot position.
- Very specific: line 85
If PnL % ≥ risk.take_profit_pct → sell (per rules)
- Very specific: line 86
If PnL % ≤ risk.stop_loss_pct → sell
- Very specific: line 87
If held ≥ risk.max_hold_hours → sell or alert (per your explicit policy in config comments)
- Distinctive: line 124
Prefer marketable spot orders for news-driven flow unless config says otherwise
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Spot trade (Binance reference)
Overview
Implement a spot-only trading module that reads keys from keychain/env, enforces risk.* and entry.* from config.yaml, respects venue filters, and records positions/logs. Wording below is venue-agnostic where possible; Binance-specific endpoints and filters are called out as the reference adapter.
When to use
- Executing a
BUY/SELLfromnews-judge - Periodic TP / SL / max-hold checks
- Implementing or auditing the order path
Instructions
1. Safety gates (before any signed call)
- Confirm
exchange.testnet/exchange.dry_runper config and AGENTS.md stage rules. - Load API key + secret from OS keychain or env (
exchange.keychain/ documented env names). Never print them. - Permission check: query API key / account permissions. If withdraw, transfer, futures, or margin are enabled → refuse, notify via
notifications, stop. - Allow-list HTTP methods+paths in code. Reference Binance Spot allow-list pattern:
GET /api/v3/timeGET /api/v3/ticker/priceGET /api/v3/exchangeInfoGET /api/v3/accountPOST /api/v3/order(live)POST /api/v3/order/test(dry-run)- Reject everything else (no withdraw, margin, futures, transfer).
2. Symbol + filters
- Resolve
SYMBOL= base +exchange.quote_asset(e.g.BTC+USDT). - Verify symbol status is tradable for spot (Binance:
status=TRADING, spot permission). - Read filters (Binance names; map equivalents on other venues):
LOT_SIZE/MARKET_LOT_SIZE— step size, min/max qtyMIN_NOTIONALorNOTIONAL— min quote- price tick size if using limit orders
- Round quantities down to step size; ensure quote notional ≥ max(config
risk.min_buy_quote, venue min).
3. Risk caps (code)
Before buy:
- Quote amount ≤
risk.max_buy_quote - Amount equals
entry.probe.size_quoteorentry.normal.size_quotefor the judgetier(or explicit CLI amount that still respects caps) - Judge confidence already met
entry.min_confidenceand the tier'smin_confidence; impact met tiermin_impact; risk ≤ tiermax_risk(trade module may re-check) - Open bot cost basis + new buy ≤
risk.max_total_cost_quote - Positions on symbol <
risk.max_positions_per_symbol - Symbol in universe (include/exclude/stables rules)
Before sell:
- Only sell quantity tracked (or available) for that spot position; no naked short
- News-driven sells: confidence ≥
entry.sell_min_confidencewhen that key is set;entry.allow_sell_existingmust be true - TP/SL/max-hold exits use
risk.*and do not requiresell_min_confidence
4. Order flow
judge/CLI intent
→ validate config + permissions + universe
→ compute quote/qty in code
→ apply filters (LOT_SIZE, MIN_NOTIONAL)
→ acquire process lock
→ dry_run ? order-test / simulate : create market (or configured) order
→ update positions file + append trades log
→ release lock → JSON result on stdout
→ optional notification (no secrets)5. Exit checks
On a schedule (schedule.position_check_minutes) or CLI check:
- If PnL % ≥
risk.take_profit_pct→ sell (per rules) - If PnL % ≤
risk.stop_loss_pct→ sell - If held ≥
risk.max_hold_hours→ sell or alert (per your explicit policy in config comments)
Suggested CLI
python trade.py balance
python trade.py price SYMBOL
python trade.py buy SYMBOL --tier probe|normal [--dry-run]
python trade.py sell SYMBOL [all|QTY] [--dry-run]
python trade.py positions
python trade.py check [--dry-run]Project paths
| Path | Role |
config.yaml | exchange, risk, entry |
trade.py | orders + checks |
data/positions.json | open bot positions |
data/trades.log | append-only log |
Input / output schema
Buy input: symbol, tier or quote amount, dry-run flag.
Output: JSON with ok, symbol, side, qty, quote, order_id (or dry_run), ts.
Refuse: JSON with ok: false, error, non-zero exit.
Failure handling
- Insufficient balance / filter reject → no retry loop that escalates size
- Lock busy → exit cleanly
- Network error mid-order → query open orders / fills before retry; use client order id for idempotency
Guidelines
- Spot only; refuse futures/margin wording in CLI
- Prefer marketable spot orders for news-driven flow unless config says otherwise
- Other venues: keep the same caps and lock/log pattern behind an adapter interface
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

