Hi, I have a question about retrieving the closeLevel for a closed position.
Context
- Positions are opened via
POST /positions/otc
- I store the returned
dealId
- Later I detect that the position is closed (the
dealId no longer appears in open positions)
- At that point I want to determine the
closeLevel and whether the position closed via TP or SL
What I’ve observed
- There is no endpoint that allows a direct lookup
dealId -> closeLevel
closeLevel is available in Transaction History (/history/transactions)
- However, the transaction
reference does not match:
- the position
dealId
- nor the
dealReference used when opening the position
- Account Activity (
/history/activity) is not fully reliable for mapping closes:
- close-related entries are not always present
dealReference does not clearly map to transaction reference
Current workaround
I match the correct transaction heuristically using:
- price proximity (
openLevel vs entry price)
- time proximity (
dateUtc vs local close detection time)
- closeness of
closeLevel to known TP / SL levels
This works in practice, but feels like a workaround rather than an intended solution.
Question
Is there an official or deterministic way in the IG API to map a closed dealId to its closeLevel?
Or is heuristic matching (price + time proximity) the expected approach?
Thanks in advance, and thanks for maintaining the library.
Hi, I have a question about retrieving the closeLevel for a closed position.
Context
POST /positions/otcdealIddealIdno longer appears in open positions)closeLeveland whether the position closed via TP or SLWhat I’ve observed
dealId -> closeLevelcloseLevelis available in Transaction History (/history/transactions)referencedoes not match:dealIddealReferenceused when opening the position/history/activity) is not fully reliable for mapping closes:dealReferencedoes not clearly map to transactionreferenceCurrent workaround
I match the correct transaction heuristically using:
openLevelvs entry price)dateUtcvs local close detection time)closeLevelto known TP / SL levelsThis works in practice, but feels like a workaround rather than an intended solution.
Question
Is there an official or deterministic way in the IG API to map a closed
dealIdto itscloseLevel?Or is heuristic matching (price + time proximity) the expected approach?
Thanks in advance, and thanks for maintaining the library.