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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user