fix(critical): remove dead manifold.get_probability() from legacy scan and fix BUY_NO payout calculation
CI/CD / build-and-push (push) Successful in 29s
CI/CD / build-and-push (push) Successful in 29s
- Legacy scan called ManifoldClient.get_probability(), removed in the v3
matcher migration, causing AttributeError when positions had changed
family keys. The block used Manifold to escalate positions to
CLOSE_RECOMMENDED (inversion detection) — a trading decision forbidden
under MANIFOLD_SIGNAL_ENABLED=false — so the dependency is removed
entirely; the scan keeps family re-keying and sibling-conflict logic.
- PaperExecutor.close_position() computed cash += position_cost * resolution,
ignoring direction: a winning BUY_NO (resolution=0.0) paid out $0 and
reported a loss. Now settles per trade:
BUY_YES: payout = shares * resolution
BUY_NO: payout = shares * (1 - resolution)
with pnl = payout - net_cost; Telegram win/loss keys off pnl > 0.
Adds read-only Database.get_open_trades_for_market().
- tests/test_paper_close.py covers the 4 deterministic payout cases;
tests/conftest.py shims datetime.UTC for local Python 3.10 (prod is 3.11).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
3a353c7e5b
commit
340c8523cf
@@ -152,6 +152,20 @@ class Database:
|
||||
""")
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
async def get_open_trades_for_market(self, market_id: str) -> list[dict]:
|
||||
"""Return direction, shares and net_cost for each open trade in a market.
|
||||
|
||||
Used by PaperExecutor.close_position() to compute the settlement
|
||||
payout per direction (BUY_NO pays out when resolution = 0.0).
|
||||
"""
|
||||
async with self._pool.acquire() as conn:
|
||||
rows = await conn.fetch(
|
||||
"SELECT direction, shares, net_cost FROM trades "
|
||||
"WHERE market_id = $1 AND closed_at IS NULL",
|
||||
market_id,
|
||||
)
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
async def close_paper_position(
|
||||
self, market_id: str, reason: str = "", resolution: Optional[float] = None
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user