Jump to content
  • 0

Level not working in API limit order


wki

Question

Hi, I am trying to do a trade through the API (either Python or the API Companion).  I can do a MARKET trade successfully but now I want to do a LIMIT trade, where the trade is executed when a specific price point is reached but I cannot get this to work. I can place the limit order with the level through the IG Trading Dashboard though. Through the API, the LEVEL seems to be completely ignored and so it bypasses the limit and goes straight to market. Here is my Python script for GBPUSD:

epic = "CS.D.GBPUSD.TODAY.IP"
direction = "BUY"
stopDistance = 15
limitDistance = 15
size = 0.5
level = 13130 #(current price is 13125)
expiry="DBF"
orderType="LIMIT"
guaranteedStop=False
stopLevel=None
trailingStopIncrement=None
trailingStop=False
forceOpen=True
limitLevel=None
quoteId=None
currencyCode="GBP"

response = ig_service.create_open_position(currencyCode, direction, epic,
                            expiry, forceOpen, guaranteedStop, level, limitDistance,
                            limitLevel, orderType, quoteId, size, stopDistance, stopLevel,
                            trailingStop, trailingStopIncrement, None)

 
Edited by wki
Link to comment

6 answers to this question

Recommended Posts

  • 1
7 hours ago, wki said:

Can you get the API Companion working for a limit resting order with a level, the same as what is possible through the main UI dashboard (see attached)?  Thanks again for your help!

Hi, the picture helped. Now I understand what you are trying to do. You are pointing your code to the wrong endpoint, you don't need the Open Position Request, you need the Create Working Order Request.

Quote

Endpoint: /gateway/deal/workingorders/otc

The type of order that you are looking for is a Resting Working Order, the API companion has a menu option for it. It is at "Trading Working Orders"

https://labs.ig.com/rest-trading-api-reference/service-detail?id=533

I sent a test to get the json parameters, here is the request:

Quote

{
    "epic": "CS.D.GBPUSD.TODAY.IP",
    "expiry": "DFB",
    "direction": "BUY",
    "size": "0.5",
    "level": "13300",
    "forceOpen": "true",
    "type": "LIMIT",
    "currencyCode": "GBP",
    "timeInForce": "GOOD_TILL_CANCELLED",
    "goodTillDate": null,
    "guaranteedStop": "false",
    "stopLevel": null,
    "stopDistance": null,
    "limitLevel": null,
    "limitDistance": null
}

You can amend stop and limit levels to match your picture.

That gets a response with a deal reference. Querying the "Trade Confirm" endpoint that we discussed earlier you will get a response like:

Quote

{
    "date": "2020-08-29T04:54:56.582",
    "status": "OPEN",
    "reason": "SUCCESS",
    "dealStatus": "ACCEPTED",
    "epic": "CS.D.GBPUSD.TODAY.IP",
    "expiry": "DFB",
    "dealReference": "L2LEBWUUNQN44S3",
    "dealId": "DIAAAAEASUXMMA3",
    "affectedDeals": [{
        "dealId": "DIAAAAEASUXMMA3",
        "status": "OPENED"
    }],
    "level": 13300.0,
    "size": 0.5,
    "direction": "BUY",
    "stopLevel": null,
    "limitLevel": null,
    "stopDistance": null,
    "limitDistance": null,
    "guaranteedStop": false,
    "trailingStop": false,
    "profit": null,
    "profitCurrency": null
}

 

  • Sad 1
Link to comment
  • 0

Hi, thanks @jlzfor your reply but I can't see anything in your C# code that indicates where I have gone wrong.  As mentioned, I can't even get this working via the API Companion, let alone through Python.  I'll contact IG directly. 👍

Link to comment
  • 0
38 minutes ago, wki said:

Hi, thanks @jlzfor your reply but I can't see anything in your C# code that indicates where I have gone wrong.  As mentioned, I can't even get this working via the API Companion, let alone through Python.  I'll contact IG directly. 👍

When you send a Create Position Request you always get a deal reference as a result.

If the request didn't go through you can query the "Trade Confirm" endpoint with that reference.

This is a result from a wrong request that I sent as a test:

    "date": "2020-08-28T16:56:11.906",
    "status": null,
    "reason": "LIMIT_ORDER_WRONG_SIDE_OF_MARKET",
    "dealStatus": "REJECTED",
    "epic": "IX.D.FTSE.DAILY.IP",
    "expiry": null,
    "dealReference": "RBHDM9LUQYU44S3",
    "dealId": "DIAAAAEASE5RTA3",
    "affectedDeals": [],
    "level": null,
    "size": null,
    "direction": "BUY",
    "stopLevel": null,
    "limitLevel": null,
    "stopDistance": null,
    "limitDistance": null,
    "guaranteedStop": false,
    "trailingStop": false,
    "profit": null,
    "profitCurrency": null
}
  • Sad 1
Link to comment
  • 0

Hi, thanks again for your response and top tip. I am indeed getting the "LIMIT_ORDER_WRONG_SIDE_OF_MARKET" error. I have realised that I am looking to do a resting order as opposed to an immediate order as explained here: https://labs.ig.com/apiorders

Can you get the API Companion working for a limit resting order with a level, the same as what is possible through the main UI dashboard (see attached)?  Thanks again for your help!

IG.jpg

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

    • USD/CHF Elliott Wave Analysis Trading Lounge Day Chart,     U.S.Dollar/Swiss Franc (USD/CHF) Day Chart   USD/CHF Elliott Wave Technical Analysis DXY Elliott Wave Technical Analysis                           FUNCTION: Trend                           MODE: impulsive                         STRUCTURE: blue wave 5                         POSITION: black wave 1                       DIRECTION NEXT LOWER   DEGREES: black wave 2                       DETAILS:blue wave 4 of 1 looking  completed at 0.90085,now  blue wave 5 of 1 is in play   . Wave Cancel invalid level: 0.88948   The USD/CHF Elliott Wave Analysis for the day chart provides insights into the potential price movements of the U.S. Dollar against the Swiss Franc, utilizing Elliott Wave principles for technical analysis.   Identified as a "Trend," the analysis suggests that the prevailing market direction aligns with the broader trend, indicating potential opportunities for traders to participate in the direction of the trend.   Described as "Impulsive" in mode, the analysis indicates that the current market movement exhibits characteristics of an impulsive wave pattern. This implies that the price is likely advancing in the direction of the trend with strong momentum, potentially offering trading opportunities for trend-following strategies.   The "STRUCTURE" is labeled as "blue wave 5," providing clarity on the current phase of the Elliott Wave cycle. This helps traders understand the stage of the trend and anticipate potential reversal points or continuation patterns.   Positioned as "black wave 1," the analysis highlights the specific phase of the Elliott Wave cycle within the current trend. This indicates that the market has completed a wave cycle and is potentially starting a new wave cycle in the direction of the trend.   In the "DIRECTION NEXT LOWER DEGREES" section, the analysis mentions "black wave 2," suggesting the potential direction for the next lower-degree wave within the Elliott Wave cycle. This implies that the market may experience a corrective wave before continuing its upward movement.   The "DETAILS" section notes that "blue wave 4 of 1 looking completed at 0.90085, now blue wave 5 of 1 is in play." This suggests that the corrective wave within the current wave cycle has potentially ended, and the market is now resuming its upward movement. Additionally, the wave cancel level is identified at 0.88948, providing a reference point for invalidating the wave count. Traders can utilize this information to assess potential trading opportunities and manage risk effectively.       USD/CHF Elliott Wave Analysis Trading Lounge 4 Hour Chart,     U.S.Dollar/Swiss Franc (USD/CHF) 4 Hour Chart   USD/CHF Elliott Wave Technical Analysis DXY Elliott Wave Technical Analysis                           FUNCTION: Trend                           MODE: impulsive                         STRUCTURE: blue wave 5                         POSITION: black wave 1                       DIRECTION NEXT HIGHER   DEGREES:blue wave 5(may started)                         DETAILS:blue wave 4 of 1 looking  completed at 0.90085,now  blue wave 5 of 1 is in play   . Wave Cancel invalid level: 0.88948   The USD/CHF Elliott Wave Analysis for the 4-hour chart provides insights into the potential price movements of the U.S. Dollar against the Swiss Franc, employing Elliott Wave principles for technical analysis.   Identified as a "Trend," the analysis suggests that the prevailing market direction aligns with the broader trend, indicating potential opportunities for traders to participate in the direction of the trend.   Described as "Impulsive" in mode, the analysis indicates that the current market movement exhibits characteristics of an impulsive wave pattern. This implies that the price is likely advancing in the direction of the trend with strong momentum, potentially offering trading opportunities for trend-following strategies.   The "STRUCTURE" is labeled as "blue wave 5," providing clarity on the current phase of the Elliott Wave cycle. This helps traders understand the stage of the trend and anticipate potential reversal points or continuation patterns.   Positioned as "black wave 1," the analysis highlights the specific phase of the Elliott Wave cycle within the current trend. This indicates that the market has completed a wave cycle and is potentially starting a new wave cycle in the direction of the trend.   In the "DIRECTION NEXT HIGHER DEGREES" section, the analysis mentions "blue wave 5 (may have started)," suggesting the potential direction for the next higher-degree wave within the Elliott Wave cycle. This implies that the market may continue its upward movement, supporting the overall bullish trend.   The "DETAILS" section notes that "blue wave 4 of 1 looking completed at 0.90085, now blue wave 5 of 1 is in play." This suggests that the corrective wave within the current wave cycle has potentially ended, and the market is now resuming its upward movement. Additionally, the wave cancel level is identified at 0.88948, providing a reference point for invalidating the wave count. Traders can utilize this information to assess potential trading opportunities and manage risk effectively.   Technical Analyst : Malik Awais   Source : Tradinglounge.com get trial here!      
    • ASX: NATIONAL AUSTRALIA BANK LIMITED - NAB Elliott Elliott Wave Technical Analysis TradingLounge (1D Chart) Greetings, Our Elliott Wave analysis today updates the Australian Stock Exchange (ASX) with NATIONAL AUSTRALIA BANK LIMITED - NAB. In our Top 50 ASX Stocks forecasting service, NAB's price decline was accurately forecast, significantly reducing risk for investors. We are currently closely monitoring NAB for a further trading opportunity. ASX: NATIONAL AUSTRALIA BANK LIMITED - NAB Elliott Wave Technical Analysis   ASX: NATIONAL AUSTRALIA BANK LIMITED - NAB 1D Chart (Semilog Scale) Analysis Function: Major trend (Minute degree, green) Mode: Motive Structure: Impulse Position: Wave (c)-purple of Wave ((iv))-green Details: The short-term outlook describes that waves ((i))-green through ((iii))-green have concluded, and wave ((iv))-green is now unfolding. A common retracement target for wave 4 is at the 0.382 level, so I anticipate that wave ((iv)) will continue to decline to lower levels, while prices consistently remain below 36.11, which would increase confidence in this perspective. Invalidation point: 29.84       ASX: NATIONAL AUSTRALIA BANK LIMITED - NAB Elliott Wave Technical Analysis TradingLounge (4-Hour Chart) ASX: NATIONAL AUSTRALIA BANK LIMITED - NAB Elliott Wave Technical Analysis ASX: NATIONAL AUSTRALIA BANK LIMITED - NAB 4-Hour Chart Analysis Function: Counter trend (Minuette degree, purple) Mode: Corrective Structure: Regular Flat Position: Wave v-blue of Wave (c)-purple   Details: The short-term outlook suggests that the ((iv))-green wave is unfolding with higher detail. This could potentially be a Flat Correction (3-3-5) pattern, with waves (a) and (b)-purple already completed. Now, wave (c)-purple is likely to unfold, pushing lower. It is subdividing into five smaller waves, with at least waves i-blue to iv-blue identified. This implies that wave v-blue is completing its role. Following this, we may see the return of the ((v))-green wave pushing higher. Invalidation point: 33.67       Conclusion:   Our analysis, forecast of contextual trends, and short-term outlook for ASX: NATIONAL AUSTRALIA BANK LIMITED - NAB aim to provide readers with insights into the current market trends and how to capitalize on them effectively. We offer specific price points that act as validation or invalidation signals for our wave count, enhancing the confidence in our perspective. By combining these factors, we strive to offer readers the most objective and professional perspective on market trends. Technical Analyst: Hua (Shane) Cuong, CEWA-M (Master’s Designation). Source : Tradinglounge.com get trial here!  
    • Hi @Nate,  Unfortunately, purchasing Gold on IG isn't available, even if it's digital gold that you can buy, hold, and later sell for updated rates. However, with IG, you can trade Gold on our CFD and Spreadbet platforms using Leverage/Margin and capitalize on price differences. You have the option for spot trading or trading futures, holding positions as long as you have sufficient funds to cover your Margin. It's important to note that with spot trading, you'll incur daily interest fees for the leverage used, whereas futures trading doesn't involve additional interest fees as they are covered within our spread.  I agree that storing gold like Smaug isn't always ideal. You have to constantly worry about Dwarves, Elves, or even Hobbits! Jokes aside, you can research how to trade commodities on our platform with leverage and decide what suits you best. All the best, AshishIG
×
×
  • Create New...
us