fix(kevin_bridge): use PositionInfo.ticker + qty*avg_entry for cost basis
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

PositionInfo schema in shared/schemas/trading.py has ticker (not symbol)
and no cost_basis field. Compute cost basis as qty * avg_entry.
Production logs showed AttributeError on every mention process.
This commit is contained in:
Viktor Barzin 2026-05-24 01:22:40 +00:00
parent 06ede26e78
commit 552f5a18f7

View file

@ -158,7 +158,13 @@ class KevinBridge:
async def _snapshot_account(self) -> KevinAccountState:
acct = await self.broker.get_account()
positions = await self.broker.get_positions()
held = {p.symbol: Decimal(str(getattr(p, "cost_basis", 0))) for p in positions}
# PositionInfo schema uses `ticker` + `market_value` (no `cost_basis`).
# Cost basis ≈ qty * avg_entry; this is what the strategy's per-ticker cap compares against.
held = {
p.ticker: Decimal(str(p.qty)) * Decimal(str(p.avg_entry))
for p in positions
if p.qty != 0
}
blocklist = (
await self.blocklist.active_set() if self.blocklist else set()
)