Interface layer: Defines trigger conditions, analysis framework, output specification, and error strategy, independent of any specific exchange. For each exchange's API endpoints and request formats, see the
impl/directory:
impl/binance.md— Binance implementationimpl/okx.md— OKX implementationTo add a new exchange, simply add the corresponding
impl/{exchange}.md, and this file needs no modification.
Overview
Monitor cryptocurrency market data in real time, calculate technical indicators, and generate trading signals.
Trigger conditions
- User asks about market conditions or prices
- Scheduled polling (configurable interval)
- Price reaches a preset alert line
Input parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| pair | string | Yes | Trading pair, in BASE/QUOTE format (e.g., BTC/USDT) |
| exchange | string | No | Target exchange id (see impl/ directory), default binance |
| interval | string | No | K-line interval (1m / 5m / 15m / 1h / 4h / 1d), default 1h |
| limit | number | No | Number of K-lines, default 100 |
Execution flow
1. 根据 exchange 参数加载对应 impl/{exchange}.md
2. 调用实现层获取 24h 行情和 K 线数据
3. 基于 K 线数据计算技术指标
4. 按信号规则生成交易信号
5. 返回标准输出格式
Technical indicators (exchange-independent)
- Moving averages: MA7, MA25, MA99
- RSI (period 14)
- MACD(12, 26, 9)
- Bollinger Bands (20, 2)
- Volume analysis
Signal generation rules
| Signal | Trigger condition |
|---|---|
strong_buy |
RSI < 30 and MACD golden cross and price touches the lower Bollinger Band |
buy |
RSI < 40 and MA7 crosses above MA25 |
neutral |
30 ≤ RSI ≤ 70 and no clear trend |
sell |
RSI > 60 and MA7 crosses below MA25 |
strong_sell |
RSI > 70 and MACD death cross and price touches the upper Bollinger Band |
Output format
{
"pair": "BTC/USDT",
"exchange": "binance",
"interval": "1h",
"timestamp": "ISO8601",
"price": 0.0,
"change24h": 0.0,
"volume24h": 0.0,
"indicators": {
"rsi14": 0.0,
"macd": { "line": 0.0, "signal": 0.0, "histogram": 0.0 },
"ma": { "ma7": 0.0, "ma25": 0.0, "ma99": 0.0 },
"bollinger": { "upper": 0.0, "mid": 0.0, "lower": 0.0 }
},
"signal": "strong_buy | buy | neutral | sell | strong_sell",
"confidence": 0.0,
"keyLevels": { "support": [], "resistance": [] }
}
Error handling strategy
| Error type | Handling method |
|---|---|
| Rate limiting (429) | Wait 60s and retry, up to 3 times |
| Invalid parameter (400) | Prompt the user to correct the trading pair or parameter |
| Service unavailable (5xx) | Tell the user to retry later |
| Network timeout | Log the error and inform the user |
Security constraints
- Read-only operations, do not trigger any orders
- Only access whitelisted domains defined in impl/
- All API calls are recorded by the gateway to the audit log