fix(krakenfutures): filter fetchMyTrades by each fill's own market - #30574
rayBastard wants to merge 1 commit into
Conversation
The fills endpoint returns every contract and ignores the symbol param, so a fill of a contract missing from the markets was stamped with the requested symbol.
carlotestor
left a comment
There was a problem hiding this comment.
Summary
Correct diagnosis: /fills ignores symbol, and passing the requested market into parseTrades lets safeMarket fall back to it for any id missing from markets_by_id — exactly the expired-dated-futures case — so fills of other contracts were mislabelled with the requested symbol. Dropping the market argument and filtering afterwards is the right shape, and this.symbol (symbol) keeps the unknown-symbol throw that this.market (symbol) used to provide.
The added static response case pins the behaviour (a PF_XRPUSD fill dropped from a DOGE/USD:USD query), which is the part that makes this reviewable offline.
One question inline about unresolved ids. Nothing merge-blocking.
Merge gate: 🟢
| // the endpoint returns the fills of every contract, each row resolves its own market | ||
| const trades = this.parseTrades (fills); | ||
| return this.filterBySymbolSinceLimit (trades, symbol, since, limit) as Trade[]; |
There was a problem hiding this comment.
Worth confirming the unresolved-id path: a fill whose contract is no longer in /instruments now parses with safeSymbol returning the raw id (e.g. PF_XRPUSD), so it survives parseTrades but is filtered out whenever symbol is given, and is returned with a non-unified symbol when symbol is undefined. That is strictly better than the old mislabelling, but it does mean fetchMyTrades () with no symbol can now emit raw exchange ids in trade['symbol'] — if that is intended, a one-line comment here would save the next reader the trace.
There was a problem hiding this comment.
Unchanged by this PR - with no symbol the old code also parsed without a market, so an unknown contract already came back with its raw id (checked on master: a PF_XRPUSD fill returns symbol: 'PF_XRPUSD'). That's the base safeMarket contract for unknown ids, so I left it as is.
There was a problem hiding this comment.
@rayBastard not sure about this one, parseTrades internally runs filterBySymbolSinceLimit so what was wrong with it?
There was a problem hiding this comment.
The internal filter takes the symbol only from market, and passing market is the bug itself. For a fill whose contract id is no longer in markets_by_id, safeMarket (marketId, market) falls back to that market, so the row gets the requested symbol before the filter runs and survives it. Parsing without market and filtering by the symbol string is the only way to keep the symbol filter without that fallback.
/fillsreturns every contract and ignoressymbol, andparseTrades (fills, market)letssafeMarketfall back to the requested market for an id missing from the loaded markets — expired dated futures drop out of/instruments, so their fills came back stamped with the requested symbol. Fills now resolve by their own id and are filtered by symbol afterwards;parseTradeis untouched.Verified live, plus a captured response case (a fill of a contract absent from the static markets) that fails before the fix.