撤单状态暂不可读时仍停止父任务新增
This commit is contained in:
parent
c72556901e
commit
6702090264
|
|
@ -267,11 +267,18 @@ def cancel(*, instruction_id: str, dispatch_ref=None) -> dict:
|
|||
try:
|
||||
cancel_id = wsc.new_cancel_id(int(datetime.now().strftime("%Y%m%d")))
|
||||
n = qmt_repo.request_cancel(parent_id=instruction_id, cancel_id=cancel_id)
|
||||
pending = any(o.get('status') in qmt_repo.LIVE
|
||||
for o in qmt_repo.orders_for_parent(instruction_id))
|
||||
except Exception as e:
|
||||
logger.exception("撤单请求落表失败 %s", instruction_id)
|
||||
return {"ok": False, "mode": m, "error": f"{type(e).__name__}: {e}"}
|
||||
pending = bool(n)
|
||||
if not pending:
|
||||
try:
|
||||
pending = any(o.get('status') in qmt_repo.LIVE
|
||||
for o in qmt_repo.orders_for_parent(instruction_id))
|
||||
except Exception:
|
||||
# 撤销意图已写入。展示核验失败不能使父任务继续新增或恢复续单。
|
||||
pending = True
|
||||
logger.warning('撤单请求已登记,子委托状态暂不可核实 %s', instruction_id)
|
||||
if not n:
|
||||
return {"ok": True, "mode": m, "cancelled": 0, "cancel_pending": pending,
|
||||
"note": "撤单已在处理中,等待QMT终态" if pending else "该指令名下没有在途子单, 仅本地置撤销"}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
运行: docker compose run --rm pms-web python scripts/run_tests.py
|
||||
|
||||
包含 (例数按 2026-10-26 隔离回归实跑校正):
|
||||
test_batch52_units.py 当日限价、撤单拒绝、迟到成交、发送恢复与真实SQL状态保护 (21例)
|
||||
test_batch52_units.py 当日限价、撤单拒绝、迟到成交、发送恢复与真实SQL状态保护 (22例)
|
||||
test_batch51_units.py 跨日决策复核、撤单回报、数量约束、人工确认与真实SQL事务及完整选股接线 (36例)
|
||||
test_batch50_units.py QMT限价等待、价格来源故障、用户暂停、配额防重和试算隔离 (14例)
|
||||
test_batch49_units.py 持仓分组、同名股票与批次归属、未迁移及缺数展示 (8例)
|
||||
|
|
|
|||
|
|
@ -154,6 +154,13 @@ class DeadlineTest(unittest.TestCase):
|
|||
result = dispatcher.cancel(instruction_id='P')
|
||||
self.assertTrue(result['ok']); self.assertTrue(result['cancel_pending'])
|
||||
|
||||
def test_cancel_intent_survives_status_read_failure(self):
|
||||
with patch.object(dispatcher, 'mode', return_value='ws'), \
|
||||
patch.object(qmt_repo, 'request_cancel', return_value=0), \
|
||||
patch.object(qmt_repo, 'orders_for_parent', side_effect=RuntimeError('temporarily unavailable')):
|
||||
result = dispatcher.cancel(instruction_id='P')
|
||||
self.assertTrue(result['ok']); self.assertTrue(result['cancel_pending'])
|
||||
|
||||
|
||||
class SqlTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue