Add swing trading strategy with RSI signals and Binance integration

- Introduced a new swing trading strategy utilizing the RSI indicator on the ETHBTC pair from Binance.
- Implemented the `SwingEngine` to manage trading logic, including entry and exit conditions based on RSI thresholds.
- Added configuration options for swing direction, trade amount, and RSI parameters in `config.ts`.
- Created new documentation for the swing strategy, detailing its behavior and configuration.
- Enhanced CLI to support the new swing strategy option.
- Added tests for swing logic to ensure correct behavior under various market conditions.
This commit is contained in:
discountry
2026-01-31 16:15:07 +08:00
parent 1d88ddefb5
commit c4559cb0d7
16 changed files with 2369 additions and 5 deletions
+49
View File
@@ -25,6 +25,11 @@ const translations: Record<string, TranslationEntry> = {
zh: "监控均线信号,自动进出场并维护止损/止盈",
en: "Monitors SMA signals, automates entries/exits, maintains stops.",
},
"app.strategy.swing.label": { zh: "Swing 策略 (RSI14/4h)", en: "Swing (RSI14/4h)" },
"app.strategy.swing.desc": {
zh: "使用 Binance ETHBTC 4h RSI 信号,主动开平仓并维护止损",
en: "Uses Binance ETHBTC 4h RSI signals to actively trade and maintain stops.",
},
"app.strategy.guardian.label": { zh: "Guardian 防守策略", en: "Guardian Protection" },
"app.strategy.guardian.desc": {
zh: "不主动开仓,只为现有仓位补挂/移动止损,防止裸奔",
@@ -132,6 +137,50 @@ const translations: Record<string, TranslationEntry> = {
"trend.label.long": { zh: "做多", en: "Long" },
"trend.label.short": { zh: "做空", en: "Short" },
"trend.label.none": { zh: "无信号", en: "No signal" },
"swing.name": { zh: "Swing 策略", en: "swing strategy" },
"swing.title": { zh: "Swing 策略仪表盘", en: "Swing Strategy Dashboard" },
"swing.readyMessage": { zh: "正在等待交易所/RSI 信号…", en: "Waiting for exchange feeds / RSI signal..." },
"swing.headerLine": {
zh: "交易所: {exchange} 交易对: {symbol} 方向: {direction} 最近价格: {lastPrice} 状态: {phase}",
en: "Exchange: {exchange} | Symbol: {symbol} | Mode: {direction} | Last: {lastPrice} | Phase: {phase}",
},
"swing.signalLine": {
zh: "信号源: Binance {binanceSymbol} 价格: {binancePrice} RSI: {rsi} ({zone}) 连接: {connection}",
en: "Signal: Binance {binanceSymbol} | Price: {binancePrice} | RSI: {rsi} ({zone}) | Conn: {connection}",
},
"swing.statusLine": {
zh: "状态: {status} 按 Esc 返回策略选择",
en: "Status: {status} | Press Esc to return to menu.",
},
"swing.zone.overbought": { zh: "超买", en: "Overbought" },
"swing.zone.oversold": { zh: "超卖", en: "Oversold" },
"swing.zone.neutral": { zh: "正常区间", en: "Neutral" },
"swing.zone.unknown": { zh: "未知", en: "Unknown" },
"swing.phase.disabled": { zh: "已禁用", en: "Disabled" },
"swing.phase.initializing": { zh: "初始化/同步中", en: "Initializing" },
"swing.phase.observing": { zh: "观察", en: "Observing" },
"swing.phase.waitingOpenShort": { zh: "等待开空", en: "Waiting to open short" },
"swing.phase.waitingCloseShort": { zh: "等待平空", en: "Waiting to close short" },
"swing.phase.waitingOpenLong": { zh: "等待开多", en: "Waiting to open long" },
"swing.phase.waitingCloseLong": { zh: "等待平多", en: "Waiting to close long" },
"swing.positionLine": {
zh: "方向: {direction} 数量: {qty} 开仓价: {entry}",
en: "Direction: {direction} | Size: {qty} | Entry: {entry}",
},
"swing.pnlLine": {
zh: "浮动盈亏: {pnl} USDT 账户未实现盈亏: {unrealized} USDT",
en: "Floating PnL: {pnl} USDT | Account Unrealized: {unrealized} USDT",
},
"swing.stopLine": {
zh: "止损目标价: {stop}",
en: "Stop target: {stop}",
},
"swing.stateTitle": { zh: "策略状态", en: "Strategy State" },
"swing.armedLine": {
zh: "Armed: SE={se} SX={sx} LE={le} LX={lx}",
en: "Armed: SE={se} SX={sx} | LE={le} LX={lx}",
},
"swing.volumeLine": { zh: "累计成交量: {volume} USDT", en: "Total volume: {volume} USDT" },
"guardian.name": { zh: "Guardian 策略", en: "Guardian strategy" },
"guardian.title": { zh: "Guardian 策略仪表盘", en: "Guardian Strategy Dashboard" },
"guardian.readyMessage": { zh: "正在等待行情/账户推送…", en: "Waiting for market/account feeds..." },