Skip to content

Paper bots: count Binance cash and holdings in bot stats - #5

Merged
markb-1 merged 2 commits into
mainfrom
claude/paper-binance-stats
Nov 1, 2026
Merged

markb-1 merged 2 commits into
mainfrom
claude/paper-binance-stats

Conversation

@markb-1

@markb-1 markb-1 commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Summary

A paper bot has two simulated pots seeded with the same starting balance: Polymarket USDC (balance) and Binance (binanceBalances). The bot Overview (stats()), the dashboard Bot Overview (dashboardStats()) and Open Positions only read the Polymarket pot, so a paper bot holding $20 of ETH showed cash $100, positions $0, P&L $0 and no value for the position.

  • One paper valuation helper for stats() and dashboardStats(): cash = Polymarket cash + the Binance USDT change from the seed; positions = Gamma-priced Polymarket positions + each Binance asset at its USDT price. Exact for single-exchange bots; unpriced assets are left out as before.
  • positions() now prices Binance rows (currentPrice / currentValue).
  • BotServiceDeps.binancePrice (default: the public /api/v3/ticker/price) so tests inject prices.
  • DEFAULT_PAPER_BALANCE moves to PaperTradingState (re-exported from ScriptBotRunner) so BotService does not import the worker runtime.

Found while taking README screenshots: the demo ETH bot's stored state was {"balance":100,"binanceBalances":{"USDT":80,"ETH":0.0088}}.

Not changed (separate follow-ups)

  • Allocation used (bot page, Bots list) comes from OverviewService.allocations(), which is Polymarket-only by design (effectiveAllocation(..., 'polymarket')), so Binance bots still show $0 used.
  • 24h P&L (pnl24hFor) is net cash flow (sells − buys), so it shows −$20 right after a buy.

Tests

  • New tests/runtime/bot-service-paper-stats.test.ts (Binance-only, Polymarket-only unchanged, dashboard value, positions pricing).
  • After merging current main into the branch: npm run typecheck clean; tests/runtime, tests/server/bot-routes.test.ts, tests/orders/choke-point.test.ts pass (257 tests). Full suite left to CI.

🤖 Generated with Claude Code

markb-1 and others added 2 commits November 1, 2026 15:30
A paper bot has two simulated pots seeded with the same starting balance:
Polymarket USDC (`balance`) and Binance (`binanceBalances`). The bot
Overview (stats), the dashboard Bot Overview (dashboardStats) and Open
Positions only read the Polymarket pot, so a bot holding $20 of paper ETH
showed cash $100, positions $0 and no value for the position.

- One paper valuation helper for stats() and dashboardStats(): cash is the
  Polymarket cash plus the Binance USDT change from the seed; positions add
  each Binance asset at its USDT price to the Gamma-priced Polymarket ones.
  Exact for single-exchange bots; unpriced assets are left out as before.
- positions() prices Binance rows.
- BotServiceDeps.binancePrice (default: the public ticker) for tests.
- DEFAULT_PAPER_BALANCE moves to PaperTradingState (re-exported from
  ScriptBotRunner) so BotService does not import the worker runtime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@markb-1
markb-1 merged commit d2a22f1 into main Nov 1, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant