feat(reconcile): safely seed canonical cost basis

This commit is contained in:
Hermes Agent
2026-07-17 09:57:08 +09:00
parent 18bd8d9f0b
commit 81a853a314
25 changed files with 1689 additions and 66 deletions
+13 -1
View File
@@ -568,7 +568,9 @@ def _cmd_sync(args, cfg, confirm) -> int:
dry_run=dry_run,
)
results.append(res)
if res.get("error") and not res.get("skipped"):
# A skipped result can still be a fail-closed live error (REQ-123).
# Do not let the no-write marker hide a failed sync from automation.
if res.get("error"):
exit_code = 1
if args.json:
@@ -584,6 +586,9 @@ def _cmd_sync(args, cfg, confirm) -> int:
skipped = res.get("skipped", False)
skip_reason = res.get("skip_reason", "")
cleared = res.get("warning_cleared", False)
seeded_avg_price = res.get("seeded_avg_price", False)
cost_basis_source = res.get("cost_basis_source")
cost_basis_reason = res.get("cost_basis_reason")
prefix = "[dry-run] " if dry_run else ""
if skipped:
print(f" {prefix}SKIP slot={sid} symbol={sym} pid={pid} reason={skip_reason}")
@@ -595,6 +600,13 @@ def _cmd_sync(args, cfg, confirm) -> int:
f"qty={after.get('qty')} avg_price={after.get('avg_price')}")
if cleared:
print(" reconcile-warning CLEARED")
if seeded_avg_price is not None:
print(f" cost_basis.seeded={seeded_avg_price}")
if cost_basis_source or cost_basis_reason:
print(f" cost_basis.source={cost_basis_source} reason={cost_basis_reason}")
if res.get("error"):
print(f" error={res.get('error')}")
return exit_code