Skip to content

Follow-up to #115/#120: Opinion BUY cap uses wrong units, direct fallback ungated, fallback orders double-recorded to breaker #127

Description

@walt-verweij

Follow-up to #115 / PR #120, reviewed at c930628. Central validation and dry-run now apply to the batch path. Three issues remain, one of them introduced by the fix.

1. Opinion BUY size is validated in the wrong units

Validation computes price * size (https://github.com/alsk1992/CloddsBot/blob/c930628/src/execution/index.ts#L2814) but the batch forwards size unchanged as amount (https://github.com/alsk1992/CloddsBot/blob/c930628/src/execution/index.ts#L3429), and the Opinion adapter treats BUY amount as quote-token spend (https://github.com/alsk1992/CloddsBot/blob/c930628/src/exchanges/opinion/index.ts#L481).

Repro: cap $100, price 0.10, size 1000 passes validation ($100) but submits $1,000 of BUY spend.

2. Direct Opinion fallback still bypasses safety

When tradingContext.executionService is absent, https://github.com/alsk1992/CloddsBot/blob/c930628/src/agents/index.ts#L13225 builds config from env and calls the venue directly at https://github.com/alsk1992/CloddsBot/blob/c930628/src/agents/index.ts#L13233, consulting only env DRY_RUN. No breaker, no size check.

3. Regression: fallback orders are recorded to the circuit breaker twice

The per-order fallback loop calls buyLimit / sellLimit, which already record to the breaker (https://github.com/alsk1992/CloddsBot/blob/c930628/src/execution/index.ts#L2987). The batch then records every result again at https://github.com/alsk1992/CloddsBot/blob/c930628/src/execution/index.ts#L3494.

Repro: one platform: 'betfair' order in a batch produces two breaker records for a single rejection, doubling progress toward the error and daily-count trips. Either only the native batch branch should record, or the fallback loop should skip the second pass.

Verified: tsc --noEmit clean; trading-safety / trading / execution tests 37/37 pass.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions