-
Notifications
You must be signed in to change notification settings - Fork 215
Open
Description
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
dealIdno longer appears in open positions) - At that point I want to determine the
closeLeveland whether the position closed via TP or SL
What I’ve observed
- There is no endpoint that allows a direct lookup
dealId -> closeLevel closeLevelis available in Transaction History (/history/transactions)- However, the transaction
referencedoes not match:- the position
dealId - nor the
dealReferenceused when opening the position
- the position
- Account Activity (
/history/activity) is not fully reliable for mapping closes:- close-related entries are not always present
dealReferencedoes not clearly map to transactionreference
Current workaround
I match the correct transaction heuristically using:
- price proximity (
openLevelvs entry price) - time proximity (
dateUtcvs local close detection time) - closeness of
closeLevelto 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.
Metadata
Metadata
Assignees
Labels
No labels