ig-python / trading-ig

A lightweight Python wrapper for the IG Markets API
https://trading-ig.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
313 stars 197 forks source link

Workaround for IG `/confirms` bug #320

Open bug-or-feature opened 8 months ago

bug-or-feature commented 8 months ago

There is a bug in IG's implementation of their

/confirms/{dealReference}

endpoint, when you close a position. The method in this project is IGService.fetch_deal_by_deal_reference(). This is the request you make after opening/updating/closing a position or working order. It responds with the status of your request, and a unique ID for the transaction, if it was successful.

The bug is this: when closing a position, fetch_deal_by_deal_reference() responds with the ID of the opening transaction, not closing. There is a discussion about it on the IG community forum here.

This a real pain. Especially as IG don't even acknowledge that there is anything wrong. It makes it hard to associate opening and closing trades, and therefore get P&L information.

There is a workaround, as outlined in the forum chat. I propose to add built-in support for the workaround in the code. Optional of course.

The same bug exists whether you request the confirms information via the REST or Streaming API