Skip to content

fix(analysis): survive numeric botFunds values in analyze-orders - #13

Open
Impulssi wants to merge 1 commit into
froooze:testfrom
Impulssi:fix/analyze-orders-numeric-botfunds
Open

fix(analysis): survive numeric botFunds values in analyze-orders#13
Impulssi wants to merge 1 commit into
froooze:testfrom
Impulssi:fix/analyze-orders-numeric-botfunds

Conversation

@Impulssi

@Impulssi Impulssi commented Aug 24, 2026

Copy link
Copy Markdown

bots.json documents botFunds as accepting either percentage strings ("90%") or absolute numbers (35 meaning 35 units of the side's asset), and the bot editor writes numbers when a bare value is entered. The "Funds:" display path in analyze-orders called string methods (padEnd/stripColorCodes) directly on the raw config values, so a numeric setting aborted the whole per-bot analysis with
"str.replace is not a function" and the bot was skipped from the report.

Normalize both botFunds sides to strings when the analysis object is built, so every display consumer (width alignment, Funds line) receives a string regardless of the configured type. Percentage strings pass through unchanged.

Testing Notes

  • tests/test_analyze_orders_dynamic_weight.ts: new testAnalyzeOrderFormatsNumericBotFunds covering numeric normalization ("35" -> "35"), percentage passthrough ("35%" unchanged), and that formatAnalysis renders the Funds line without throwing for both forms. Verified the new test fails with the pre-fix analyzer (reproduces the original crash) and passes with the fix.
  • npm run typecheck clean.

Note: I'm new to this codebase and worked through this change with an AI
coding assistant (opencode). The bug was hit on my own live instance and
all measurements / reproduction steps are mine — but please flag anything
in the code that looks off and I'll dig in and follow up.

@Impulssi
Impulssi force-pushed the fix/analyze-orders-numeric-botfunds branch from da44fd9 to c130f63 Compare August 26, 2026 06:03
bots.json documents botFunds as accepting either percentage strings
("90%") or absolute numbers (35 meaning 35 units of the side's asset),
and the bot editor writes numbers when a bare value is entered. The
"Funds:" display path in analyze-orders called string methods
(padEnd/stripColorCodes) directly on the raw config values, so a numeric
setting aborted the whole per-bot analysis with
"str.replace is not a function" and the bot was skipped from the report.

Normalize both botFunds sides to strings when the analysis object is
built, so every display consumer (width alignment, Funds line) receives
a string regardless of the configured type. Percentage strings pass
through unchanged.

## Testing Notes
- tests/test_analyze_orders_dynamic_weight.ts: new
  testAnalyzeOrderFormatsNumericBotFunds covering numeric normalization
  ("35" -> "35"), percentage passthrough ("35%" unchanged), and that
  formatAnalysis renders the Funds line without throwing for both forms.
  Verified the new test fails with the pre-fix analyzer (reproduces the
  original crash) and passes with the fix.
- npm run typecheck clean.
@Impulssi
Impulssi force-pushed the fix/analyze-orders-numeric-botfunds branch from c130f63 to ee9482a Compare August 26, 2026 06:34
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