迭代16: 交易关联驱动持仓份额动态调整(R-018)
This commit is contained in:
@@ -66,8 +66,11 @@ try {
|
||||
db.prepare(
|
||||
"INSERT INTO trade_orders (order_id, trade_date, code, name, direction, insert_ts, fetched_at) VALUES (?,?,?,?,?,?,?)"
|
||||
).run('T-001', '20260907', '600719.SH', '大连热电', 'sell', Date.now(), Date.now());
|
||||
// 归属到 s1 的历史行
|
||||
db.prepare('UPDATE trade_orders SET holding_id=? WHERE order_id=?').run(week[0].holdingId, 'T-001');
|
||||
// 归属到 s1 的历史行(R-018:真相源 = 段表 —— 段 + 冗余列镜像)
|
||||
db.prepare(
|
||||
"INSERT INTO trade_order_attributions (order_id, strategy_id, holding_id, code, direction, volume, created_at) VALUES (?,?,?,?,?,?,?)"
|
||||
).run('T-001', 's1', week[0].holdingId, '600719.SH', 'sell', 100, Date.now());
|
||||
db.prepare('UPDATE trade_orders SET strategy_id=?, holding_id=? WHERE order_id=?').run('s1', week[0].holdingId, 'T-001');
|
||||
const apiWeek = await handleStrategy('strategy-holdings/history', { strategyId: 's1', range: 'week' }, runtime);
|
||||
assert(apiWeek.length === 1 && apiWeek[0].code === '600719.SH', '端点近一周返回 1 行');
|
||||
assert(apiWeek[0].name === '大连热电', 'name 兜底取关联委托 name');
|
||||
|
||||
Reference in New Issue
Block a user