Skip to content

fix(krakenfutures): filter fetchMyTrades by each fill's own market - #30574

Open
rayBastard wants to merge 1 commit into
ccxt:masterfrom
rayBastard:fix/krakenfutures-parse-trade-market
Open

rayBastard wants to merge 1 commit into
ccxt:masterfrom
rayBastard:fix/krakenfutures-parse-trade-market

Conversation

@rayBastard

Copy link
Copy Markdown
Member

/fills returns every contract and ignores symbol, and parseTrades (fills, market) lets safeMarket fall 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; parseTrade is untouched.

Verified live, plus a captured response case (a fill of a contract absent from the static markets) that fails before the fix.

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 carlotestor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: 🟢

Comment thread ts/src/krakenfutures.ts
Comment on lines +2521 to +2523
// 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[];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rayBastard not sure about this one, parseTrades internally runs filterBySymbolSinceLimit so what was wrong with it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants