Skip to content

Fix SignalsAPI.stake_get (KeyError on removed totalStake field)#129

Open
lingster wants to merge 1 commit into
numerai:masterfrom
lingster:fix-signals-stake-get
Open

Fix SignalsAPI.stake_get (KeyError on removed totalStake field)#129
lingster wants to merge 1 commit into
numerai:masterfrom
lingster:fix-signals-stake-get

Conversation

@lingster

Copy link
Copy Markdown

Problem

SignalsAPI.stake_get raised KeyError: 'totalStake' on every call:

data = self.public_user_profile(username)
return data['totalStake']

totalStake was once part of the profile query but was dropped when the query
was migrated to v2SignalsProfile and then v3UserProfile. The field no
longer exists on the V3UserProfile type at all, so the lookup always failed.

Fix

Query the current stake field, stakeValue (type Nmr), directly within the
signals tournament and parse it to Decimal, returning None for models with
no stake (instead of raising):

query = '''
  query($model_name: String!, $tournament: Int) {
    v3UserProfile(model_name: $model_name, tournament: $tournament) {
      stakeValue
    }
  }
'''

Testing (red/green TDD)

  • New test_stake_get (asserts stakeValue is queried, totalStake is not,
    and the request is scoped to tournament 11) and test_stake_get_no_stake
    (null stake → None). Written failing first.
  • Full suite: 44 passed (live-API tests deselected); pyflakes clean.
  • Live check: SignalsAPI().stake_get("uuazed") now returns a real
    Decimal instead of raising; an unstaked model returns None.

🤖 Generated with Claude Code

stake_get read `data['totalStake']` from public_user_profile, but that field
was dropped from the profile query during the v2SignalsProfile/v3UserProfile
refactors (commits c4451ec/6a9819f added it; later refactors removed it).
`totalStake` no longer exists on the V3UserProfile type at all, so stake_get
raised KeyError for every call.

Query `stakeValue` (type Nmr) directly within the signals tournament and parse
it to Decimal, returning None when the model has no stake.

Verified against the live API: stake_get("uuazed") now returns the real stake
value instead of raising.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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