fix(kevin_bridge): use PositionInfo.ticker + qty*avg_entry for cost basis
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
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:
parent
06ede26e78
commit
552f5a18f7
1 changed files with 7 additions and 1 deletions
|
|
@ -158,7 +158,13 @@ class KevinBridge:
|
||||||
async def _snapshot_account(self) -> KevinAccountState:
|
async def _snapshot_account(self) -> KevinAccountState:
|
||||||
acct = await self.broker.get_account()
|
acct = await self.broker.get_account()
|
||||||
positions = await self.broker.get_positions()
|
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 = (
|
blocklist = (
|
||||||
await self.blocklist.active_set() if self.blocklist else set()
|
await self.blocklist.active_set() if self.blocklist else set()
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue