修复删对冲后持仓接口 NameError:恢复 tgt_map/profit_exit_map 赋值。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1340,6 +1340,9 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
try:
|
||||
from lib.options.options_target_lib import targets_by_inst
|
||||
from lib.options.options_profit_exit_lib import profit_exit_by_inst
|
||||
|
||||
tgt_map = targets_by_inst(conn)
|
||||
profit_exit_map = profit_exit_by_inst(conn)
|
||||
rows = []
|
||||
for p in raw:
|
||||
inst = str(p.get("instId") or "").strip()
|
||||
|
||||
@@ -56,6 +56,17 @@ class RemoveHedgeSmokeTests(unittest.TestCase):
|
||||
self.assertFalse(tab_allowed("hedge_plan"))
|
||||
self.assertNotIn("hedge_plan", EMBED_TABS)
|
||||
|
||||
def test_positions_api_still_builds_target_maps(self):
|
||||
"""删对冲时勿再漏掉 tgt_map / profit_exit_map 赋值,否则有仓时接口 500、前端暂无持仓."""
|
||||
import inspect
|
||||
from lib.options import options_register
|
||||
|
||||
src = inspect.getsource(options_register.register_options_routes)
|
||||
self.assertIn("tgt_map = targets_by_inst(conn)", src)
|
||||
self.assertIn("profit_exit_map = profit_exit_by_inst(conn)", src)
|
||||
self.assertNotIn("hedge_target_map", src)
|
||||
self.assertNotIn("hedge_plan_target", src)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user