Forward ledger venue provenance to Portfolio Hub (#99)

Co-authored-by: Hermes Agent <noreply@nousresearch.com>
This commit is contained in:
2026-09-19 19:30:57 +09:00
committed by GitHub
co-authored by Hermes Agent
parent bbdacb121c
commit cd2342f2c6
3 changed files with 38 additions and 3 deletions
@@ -17,11 +17,13 @@ from trex_core.application.ledger_port import (
)
def _trade(asset="PF-1", execution_id="paper:PAPER-000001:10") -> LedgerTrade:
def _trade(asset="PF-1", execution_id="paper:PAPER-000001:10", *,
venue=None, order_venue="KRX") -> LedgerTrade:
return LedgerTrade(
asset_id=asset, order_id="PAPER-000001", execution_id=execution_id,
side="buy", qty=10, price=1000.0, fee=1.5, tax=0.0,
executed_at=datetime(2026, 6, 4, 9, 0, tzinfo=timezone.utc),
venue=venue, order_venue=order_venue,
)
@@ -29,6 +31,20 @@ def _client(handler):
return httpx.Client(transport=httpx.MockTransport(handler))
def test_payload_maps_execution_and_order_venues():
cases = [
(None, "SOR"),
("KRX", "NXT"),
("NXT", "KRX"),
]
for execution_venue, order_venue in cases:
body = PortfolioHubLedger._payload(
_trade(venue=execution_venue, order_venue=order_venue)
)
assert body["execution_venue"] == execution_venue
assert body["order_venue"] == order_venue
def test_post_contract_includes_execution_id_and_path_uses_portfolio_id():
captured = {}