fix(trend): align hub and four-exchange trend plan display

Unify gate_bot with shared enrich_trend_plan for strategy pages and hub monitor, reconcile DCA avg with live entry price, and fix missing fill price display.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-07 18:05:30 +08:00
parent e5576eaaed
commit 6a4ec69dba
7 changed files with 287 additions and 127 deletions
+16
View File
@@ -62,6 +62,22 @@ class TestTrendDcaEnrichFills(unittest.TestCase):
self.assertEqual(dca2["status"], "pending")
self.assertAlmostEqual(dca2["price"], 0.343, places=4)
def test_missing_dca_fills_align_last_avg_with_header(self):
"""缺补仓成交价时,末档加仓后均价应对齐计划头部 avg_entry_price。"""
plan = self._base_plan(
legs_done=2,
avg_entry_price=0.3507,
order_amount_open=161,
leg_fill_prices_json=json.dumps([0.3436]),
grid_prices_json=json.dumps([0.343, 0.343, 0.3395, 0.336, 0.3325]),
)
enriched = attach_trend_dca_levels(plan)
levels = enriched["dca_levels"]
dca2 = levels[2]
self.assertEqual(dca2["status"], "done")
self.assertAlmostEqual(dca2["avg_entry"], 0.3507, places=4)
self.assertGreater(dca2["price"], 0.343)
if __name__ == "__main__":
unittest.main()