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
  • image.png

  • Posts

    • Elliott Wave Analysis TradingLounge Daily Chart, Cadarno/ U.S. dollar(ADAUSD) ADAUSD Elliott Wave Technical Analysis  Function: Counter Trend Mode: Corrective Structure: Flat Position: Wave C Direction Next higher Degrees: wave (II) of Impulse Wave Cancel invalid level:  Details: Wave II Is equal to 61.8% of Wave I at 0.358 Cadarno/ U.S. dollar(ADAUSD)Trading Strategy: The second wave correction in the Expanded Flat pattern, where we are in the middle of a decline in Wave C, will have five extended internal sub-waves. But we still have one more decline left for Wave C to complete. So wait for the correction to complete to rejoin the trend. Cardano/ U.S. dollar(ADAUSD)Technical Indicators: The price is below the MA200 indicating a Dow trend, The Wave Oscillator is a Bearish Momentum.       Elliott Wave Analysis TradingLounge H4 Chart, Cadarno/ U.S. dollar(ADAUSD) ADAUSD Elliott Wave Technical Analysis  Function: Follow Trend Mode: Motive Structure: Impulse Position: Wave 4 Direction Next higher Degrees: wave C of Flat Wave Cancel invalid level:  Details: A short-term pullback in wave 4 before falling again in wave 5. Cardano/ U.S. dollar(ADAUSD)Trading Strategy: The second wave correction in the Expanded Flat pattern, where we are in the middle of a decline in Wave C, will have five extended internal sub-waves. But we still have one more decline left for Wave C to complete. So wait for the correction to complete to rejoin the trend. Cardano/ U.S. dollar(ADAUSD)Technical Indicators: The price is below the MA200 indicating a Dow trend, The Wave Oscillator is a Bearish Momentum. Technical Analyst : Kittiampon Somboonsod Source : Tradinglounge.com get trial here!    
×
×
  • Create New...
us