refactor: 移除 gate_bot,统一为三所架构并更新文档

删除 crypto_monitor_gate_bot 目录,中控与子代理改为 binance/okx/gate 三账户;
文档与 UI 文案「四所」改为「三所」;新增清库前一次性配置备份脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-04 22:00:08 +08:00
parent be51eee73f
commit 9f67de3677
138 changed files with 26395 additions and 40057 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
"""AI 复盘 journal 文本格式化(所共用)。"""
"""AI 复盘 journal 文本格式化(所共用)。"""
from __future__ import annotations
import sqlite3
+32 -32
View File
@@ -1,32 +1,32 @@
"""子代理持仓:所开仓价字段统一解析。"""
from __future__ import annotations
import sys
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "manual_trading_hub"))
from agent import _position_entry_price # noqa: E402
class TestHubAgentEntryPrice(unittest.TestCase):
def test_binance_entry_price(self):
px = _position_entry_price({"entryPrice": 65851.6, "info": {}})
self.assertAlmostEqual(px, 65851.6)
def test_okx_avg_px(self):
px = _position_entry_price({"info": {"avgPx": "72.731"}})
self.assertAlmostEqual(px, 72.731)
def test_gate_info_entry(self):
px = _position_entry_price({"info": {"entry_price": "0.2232"}})
self.assertAlmostEqual(px, 0.2232)
def test_missing_returns_none(self):
self.assertIsNone(_position_entry_price({"info": {}}))
if __name__ == "__main__":
unittest.main()
"""子代理持仓:所开仓价字段统一解析。"""
from __future__ import annotations
import sys
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "manual_trading_hub"))
from agent import _position_entry_price # noqa: E402
class TestHubAgentEntryPrice(unittest.TestCase):
def test_binance_entry_price(self):
px = _position_entry_price({"entryPrice": 65851.6, "info": {}})
self.assertAlmostEqual(px, 65851.6)
def test_okx_avg_px(self):
px = _position_entry_price({"info": {"avgPx": "72.731"}})
self.assertAlmostEqual(px, 72.731)
def test_gate_info_entry(self):
px = _position_entry_price({"info": {"entry_price": "0.2232"}})
self.assertAlmostEqual(px, 0.2232)
def test_missing_returns_none(self):
self.assertIsNone(_position_entry_price({"info": {}}))
if __name__ == "__main__":
unittest.main()
+1 -1
View File
@@ -1,4 +1,4 @@
"""子代理持仓:所标记价字段统一解析。"""
"""子代理持仓:所标记价字段统一解析。"""
from __future__ import annotations
import sys
+1 -1
View File
@@ -54,7 +54,7 @@ def test_build_fund_overview_skips_unmonitored(tmp_path, monkeypatch):
)
exchanges = [
{"id": "0", "key": "binance", "name": "Binance", "enabled": True},
{"id": "3", "key": "gate_bot", "name": "Gate Bot", "enabled": False},
{"id": "2", "key": "gate", "name": "Gate", "enabled": False},
]
board_rows = [
{
+3 -3
View File
@@ -255,7 +255,7 @@ def test_upsert_forces_sync_exchange_key():
db = Path(td) / "archive.db"
init_db(db)
upsert_trades_cache(
"gate_bot",
"gate",
[
{
"id": 77,
@@ -270,9 +270,9 @@ def test_upsert_forces_sync_exchange_key():
],
db_path=db,
)
rows = load_symbol_trades("gate_bot", "ETH/USDT", db_path=db)
rows = load_symbol_trades("gate", "ETH/USDT", db_path=db)
assert len(rows) == 1
assert rows[0]["exchange_key"] == "gate_bot"
assert rows[0]["exchange_key"] == "gate"
assert "account_exchange_key" not in rows[0]
+1 -1
View File
@@ -1,4 +1,4 @@
"""档案交易:strategy_trade_snapshots 补全 gate_bot 漏记。"""
"""档案交易:strategy_trade_snapshots 补全 gate 漏记。"""
from __future__ import annotations
+1 -1
View File
@@ -86,7 +86,7 @@ class TestTrendDcaEnrichFills(unittest.TestCase):
self.assertLess(dca2["price"], 0.36)
def test_display_price_never_infers_from_target_avg(self):
"""所共用:缺记录时只用网格,不因均价反推离谱触发价。"""
"""所共用:缺记录时只用网格,不因均价反推离谱触发价。"""
plan = self._base_plan(
legs_done=2,
avg_entry_price=0.3507,
+5 -5
View File
@@ -1,4 +1,4 @@
"""趋势计划结束:须写入 trade_records所统一)。"""
"""趋势计划结束:须写入 trade_records所统一)。"""
from __future__ import annotations
import inspect
@@ -15,7 +15,7 @@ from lib.strategy.strategy_trend_register import _call_insert_trade_record # no
class _GateBotLikeModule:
"""模拟 gate_bot:曾有 trend_plan_id 但缺 entry_reason 参数。"""
"""模拟 gate:曾有 trend_plan_id 但缺 entry_reason 参数。"""
@staticmethod
def insert_trade_record(
@@ -80,10 +80,10 @@ class TestTrendFinalizeTradeRecord(unittest.TestCase):
self.assertEqual(row[1], "趋势回调")
self.assertEqual(row[2], 4)
def test_gate_bot_insert_accepts_entry_reason(self):
from crypto_monitor_gate_bot import app as gate_bot_app # noqa: E402
def test_gate_insert_accepts_entry_reason(self):
from crypto_monitor_gate import app as gate_app # noqa: E402
sig = inspect.signature(gate_bot_app.insert_trade_record)
sig = inspect.signature(gate_app.insert_trade_record)
self.assertIn("entry_reason", sig.parameters)
self.assertIn("trend_plan_id", sig.parameters)
+1 -1
View File
@@ -1,4 +1,4 @@
"""所趋势 enrich:实例与中控 monitor 字段一致。"""
"""所趋势 enrich:实例与中控 monitor 字段一致。"""
from __future__ import annotations
import json