Jump to content
  • 0

Unable to close position via Restful API


TradingJ

Question

I have the following positions in my demo account

image.thumb.png.f841286ed3ff10baa099bb635979504a.png

Quote
{
    "positions": [{
        "position": {
            "contractSize": 1.0,
            "createdDate": "2022/08/30 19:10:42:000",
            "createdDateUTC": "2022-08-30T09:10:42",
            "dealId": "DIAAAAKFXB2DHA6",
            "dealReference": "MMWQAMB83JQTYN7",
            "size": 0.3,
            "direction": "BUY",
            "limitLevel": 7273.1,
            "level": 7263.1,
            "currency": "USD",
            "controlledRisk": true,
            "stopLevel": 6536.1,
            "trailingStep": null,
            "trailingStopDistance": null,
            "limitedRiskPremium": 27.0
        },
        "market": {
            "instrumentName": "Crypto 10 Index",
            "expiry": "-",
            "epic": "CS.D.CRYPTOB10.CFD.IP",
            "instrumentType": "CURRENCIES",
            "lotSize": 1.0,
            "high": 7313.1,
            "low": 6984.0,
            "percentageChange": 2.08,
            "netChange": 147.06,
            "bid": 7148.63,
            "offer": 7268.63,
            "updateTime": "13:15:47",
            "updateTimeUTC": "12:15:47",
            "delayTime": 0,
            "streamingPricesAvailable": true,
            "marketStatus": "TRADEABLE",
            "scalingFactor": 1
        }
    }, {
        "position": {
            "contractSize": 1.0,
            "createdDate": "2022/08/30 19:13:08:000",
            "createdDateUTC": "2022-08-30T09:13:08",
            "dealId": "DIAAAAKFXBFHYAW",
            "dealReference": "WG8WMPYEY4TYN7",
            "size": 0.3,
            "direction": "BUY",
            "limitLevel": 7275.26,
            "level": 7265.26,
            "currency": "USD",
            "controlledRisk": true,
            "stopLevel": 6538.26,
            "trailingStep": null,
            "trailingStopDistance": null,
            "limitedRiskPremium": 27.0
        },
        "market": {
            "instrumentName": "Crypto 10 Index",
            "expiry": "-",
            "epic": "CS.D.CRYPTOB10.CFD.IP",
            "instrumentType": "CURRENCIES",
            "lotSize": 1.0,
            "high": 7313.1,
            "low": 6984.0,
            "percentageChange": 2.08,
            "netChange": 147.06,
            "bid": 7148.63,
            "offer": 7268.63,
            "updateTime": "13:15:47",
            "updateTimeUTC": "12:15:47",
            "delayTime": 0,
            "streamingPricesAvailable": true,
            "marketStatus": "TRADEABLE",
            "scalingFactor": 1
        }
    }]
}

 

I'm making the following close position request in the API Companion

Quote

{
    "dealId": null,
    "epic": "CS.D.CRYPTOB10.CFD.IP",
    "expiry": "DFB",
    "direction": "SELL",
    "size": "0.3",
    "level": null,
    "orderType": "MARKET",
    "timeInForce": "FILL_OR_KILL",
    "quoteId": null
}

 

and I get HTTP 400 error as following:

{
    "errorCode": "unable to aggregate close positions - no compatible position found"
}

 

Any ideas why this is happening?

Link to comment

4 answers to this question

Recommended Posts

  • 0
On 19/12/2022 at 00:01, roarkrearden said:

Hi TradingJ, 

Did you solve your problem ? I made the same observation and fell back to "editing" the existing position to reajust the limit at the current bid - but I'm wondering maybe you found a better solution ?

Hi @roarkrearden

Thank you for reaching out. Please email websupportapi@ig.com for more assistance. All the best, OfentseIG

  • Sad 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...
us