Jump to content
  • 0

Incomplete response from the API


Tomegnon

Question

Hi

I am receiving only incomplete information from my API request. I use VBA and the request is based on the sample. I only get the first market of the watchlist and only few fields such as "expiry" and "epic", but no "bid" or "ask" for instance. If anyone has an idea?

Thanks

Public Function watchlistMarkets(watchlistIdentifier As String) As Collection
 

   Call oXMLHTTP.Open("GET", IG_API_HOST + "/watchlists/" + watchlistIdentifier, False)
    Call oXMLHTTP.SetRequestHeader("X-SECURITY-TOKEN", m_accountToken)
    Call oXMLHTTP.SetRequestHeader("CST", m_clientToken)
    Call oXMLHTTP.SetRequestHeader("X-IG-API-KEY", m_apiKey)
    Call oXMLHTTP.SetRequestHeader("Content-Type", "application/json; charset=utf-8")
    Call oXMLHTTP.SetRequestHeader("Accept", "application/json; charset=utf-8")
    Call oXMLHTTP.send
    If oXMLHTTP.Status = 200 Then
        Dim data As Dictionary
        Set data = JSON.parse(oXMLHTTP.responseText)
        Set watchlistMarkets = data.Item("markets")
    Else
        Set watchlistMarkets = Nothing
    End If
          

End Function

 

Link to comment

8 answers to this question

Recommended Posts

  • 0

Hi I am getting values from the service

image.thumb.png.4d36d60113b16d8be6e3066ce61cddba.png

I wrote a bit of a test in c# at

https://github.com/oneangrytrader/brokerapiclients/blob/master/IG.Csharp.Api.Client/IG.Csharp.Api.Client.Test/WatchListTest.cs

The only difference that I can see is that I pass the endpoint version within the http call as well.

https://github.com/oneangrytrader/brokerapiclients/blob/master/IG.Csharp.Api.Client/IG.Csharp.Api.Client/Rest/IgRestApiClient.cs

image.png.951e625c999774057720625cfceda6ae.png

  • Sad 1
Link to comment
  • 0

Hi, thank you for your response

I've inserted the version it doesn't seem to help. The response include only the first market in the watchlist and only few fields for that market. The API Companion works fine though, I see all the data. I can't see why...

Public Function watchlistMarkets(watchlistIdentifier As String) As Collection

    Dim A_instrumentName As String
    Dim A_expiry As String
    Dim A_epic As String
    Dim A_marketStatus As String
    Dim A_lotSize As String
    Dim A_high As String
    Dim A_low As String
    Dim A_percentageChange As String
    Dim A_netChange As String
    Dim A_bid As String
    Dim A_offer As String
    Dim A_updateTime As String
    Dim A_updateTimeUTC As String
    Dim A_delayTime As String
    Dim A_streamingPricesAvailable As String
    Dim A_scalingFactor As String
    
    Call oXMLHTTP.Open("GET", IG_API_HOST + "/watchlists/" + watchlistIdentifier, False)
    Call oXMLHTTP.SetRequestHeader("X-SECURITY-TOKEN", m_accountToken)
    Call oXMLHTTP.SetRequestHeader("CST", m_clientToken)
    Call oXMLHTTP.SetRequestHeader("Version", "1")
    Call oXMLHTTP.SetRequestHeader("X-IG-API-KEY", m_apiKey)
    Call oXMLHTTP.SetRequestHeader("Content-Type", "application/json; charset=utf-8")
    Call oXMLHTTP.SetRequestHeader("Accept", "application/json; charset=utf-8")
    Call oXMLHTTP.send
    If oXMLHTTP.Status = 200 Then
        Dim data As Dictionary
        Dim market As Dictionary
        Set data = JSON.parse(oXMLHTTP.responseText)
        Set watchlistMarkets = data.Item("markets")
        For Each market In watchlistMarkets
            A_instrumentName = market.Item("instrumentName")
            A_expiry = market.Item("expiry")
            A_epic = market.Item("epic")
            A_marketStatus = market.Item("marketStatus")
            A_lotSize = market.Item("lotSize")
            A_high = market.Item("high")
            A_low = market.Item("low")
            A_percentageChange = market.Item("percentageChange")
            A_netChange = market.Item("netChange")
            A_bid = market.Item("bid")
            A_offer = market.Item("offer")
            A_updateTime = market.Item("updateTime")
            A_updateTimeUTC = market.Item("updateTimeUTC")
            A_delayTime = market.Item("delayTime")
            A_streamingPricesAvailable = market.Item("streamingPricesAvailable")
            A_scalingFactor = market.Item("scalingFactor")
        Next
    Else
        Set watchlistMarkets = Nothing
    End If
        
    Exit Function

End Function

        
    Exit Function

End Function

 

API.thumb.jpg.0105708196e3c10a60f7c432e5c6e3c3.jpg

 

Link to comment
  • 0
52 minutes ago, Tomegnon said:

Ok you're right. The response is complete. It must come to the way I extract the info into my variables then. I used the same as the sample but somehow it is not working property.

API.jpg.c802702a3beb0e9bcef97902a8939b64.jpg

yes, that is why I asked the question, to get rid of one step.

You can tell now that your request and response are correct, so it is down to the way you are parsing the JSON object locally. I use Newtonsoft to parse JSON into objects in C# and it seems that it is working for Visual Basic as well.

https://stackoverflow.com/questions/20079177/deserializing-json-in-visual-basic/20080586

I can't thank enough to the author of that library, it made my development way easier.

 

  • 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

    • Silver Elliott Wave Analysis Function -Counter-Trend Mode - Corrective Structure -Double Zigzag for wave B (circled) Position - Wave (Y) of B Direction - Wave (Y) of B is still in play Details - After violating the last update, we have a new outlook on daily and H4 that better fits the current price action. A lower extension is now expected for Silver. Silver Elliott Wave Analysis: Extended Decline and Bullish Outlook Overview: The decline in Silver that began on May 20th is continuing to extend lower and is expected to persist before finding significant support. Despite this downturn, the year-long trend remains bullish and is anticipated to resume once this corrective phase concludes. The emerging chart pattern suggests a further decline towards $27 in the coming days or weeks.   Daily Chart Analysis: Two key observations can be made on the daily chart: Bullish Yearly Trend: The trend for this year has been bullish, leading to a breakout from a prior 13-month sideways price action. This indicates strong underlying bullish momentum. Corrective Decline: The current decline from April 19th, 2024, is identified as corrective. Therefore, the expectation is that the bullish trend will resume once this corrective structure concludes.   To determine when the corrective structure will finish, it’s important to identify the emerging pattern. Early analysis suggests that the price might be forming a double zigzag Elliott wave corrective structure, labeled as waves (W)-(X)-(Y). Wave (W) and wave (X) completed on June 13th and June 21st, respectively. The price is now breaking down in wave (Y), which could extend to $27 or lower. Meanwhile, the year-long impulse is labeled as wave A (circled) in the primary degree, and the double zigzag pullback should complete the corresponding primary degree wave B (circled). Following this, wave (C) is expected to push the price to a fresh 2024 high.   H4 Chart Analysis: The H4 chart provides a detailed view of the sub-waves within the double zigzag structure. The price is currently in wave A of (Y), which is expected to be followed by a minor corrective bounce for wave B. Afterward, the price should continue lower for wave C, completing wave (Y) of B (circled). This pattern aligns with the broader expectation of a corrective phase before the resumption of the bullish trend.   Summary: Current Decline: Silver’s decline from May 20th is expected to continue towards $27 before finding support. Bullish Yearly Trend: Despite the current downturn, the overall trend for the year remains bullish. Corrective Structure: The decline is forming a double zigzag Elliott wave corrective structure. Daily Chart Insight: The trend is expected to resume higher after the completion of the current wave B. H4 Chart Detail: Sub-waves show a minor bounce expected before a further decline to complete wave (Y) of B. In conclusion, while Silver is currently experiencing a corrective decline, the long-term bullish trend is anticipated to resume once this phase concludes. Traders should watch for a potential bottom around $27 and prepare for a renewed bullish impulse towards new highs in 2024. Technical Analyst : Sanmi Adeagbo Source : Tradinglounge.com get trial here!  
    • Honestly, L2 scaling solution projects are now increasing by the day. Should we worry about that? Absolutely, not. Why? Because it reduce overdependence on one solution and increase adoption. Also, focusing on different aspect of scaling is a good thing; for instance, Blast focus on staking ETH and stablecoin reinforces security on their network and Ethereum mainnet which increases users' confidence in blockchain and crypto.
    • Well, price performances are always a reflection of either of 2 factors: 1. constant hype by influencers/KOLs 2. whale trading activities 3. imrovement of tech or expansion of utility/usecase to accommodate needs of users For BGB, I think it's rather the last 2 basically from the recent expansion of its ecosystem where the token is used for several high-end events like launchpad, poolx etc.
×
×
  • Create New...
us