Repository navigation
Paper bots: count Binance cash and holdings in bot stats - #5
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.stats()anddashboardStats(): 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_BALANCEmoves toPaperTradingState(re-exported fromScriptBotRunner) soBotServicedoes 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)
OverviewService.allocations(), which is Polymarket-only by design (effectiveAllocation(..., 'polymarket')), so Binance bots still show $0 used.pnl24hFor) is net cash flow (sells − buys), so it shows −$20 right after a buy.Tests
tests/runtime/bot-service-paper-stats.test.ts(Binance-only, Polymarket-only unchanged, dashboard value, positions pricing).maininto the branch:npm run typecheckclean;tests/runtime,tests/server/bot-routes.test.ts,tests/orders/choke-point.test.tspass (257 tests). Full suite left to CI.🤖 Generated with Claude Code