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

    • The integration of AI into metaverse can be seen as a transformative shift. While companies leverage on AI to streamline creation process and enhance user experience, the integration of AI within the metaverse facilitates smooth interactions, providing users with instant information. In ROGin AI is a platform that combines the strengths of both technologies to offer wide financial services, ranging from cryptocurrency investment to NFT trading; an earning service that gives users access to simplified asset management, and a social trading platform that enhances users investment choices.  Its ecosystem boasts of vast features that have been integrated to enhance user experience, including features like Web3 wallet, reward system, governance etc. ROGin AI tokenomics, another core part of its ecosystem drives it growth, having burned 1.8bn out of 2bn tokens initial issuance, shrinking the total number of tokens issued to 200m. With ROG now about to list on Bitget on 19th June 2024, a high demand and potential surge could be in the offing.
    • Frankly, it's a relief to know that Nvidia is more valuable than the entire German stock exchange. Yes, there is room for it to grow and it's banking on automation to help it do so, but is it really worth all of German equities? Probably not. It's a company that manufactures chips, like Intel or AMD or Huawei or Qualcomm. It's a 2024 version of Cisco systems. The price is, like most on the Nasdaq, speculative. It's trading at a p/e of 62. Sixty two.  AI has been a real boon to the NASDAQ, though actually in real world use cases it's been a bit less than impressive. From personal experience anyway. More hype than substance. Chat GPT being especially disappointing and is getting dumber the longer it is being gatekept and limited. However, having lived through the original dot com bubble, nothing should surprise where imaginative valuations are concerned. This time appears similar. A seeming relentless unstoppable race into price discovery. World use cases that seem to negate the need for people to do any work (so who's going to pay for whatever services are being offered?)       Sure AI has and indeed will be integral to our future. But we could be hyper-focusing ourselves into a compromising dilemma on the use case for actual humans, for example. Is Apple worth the 2 trillion bucks the stock price says it is, now it is using ChatGPT AI in it's new devices? Again I return to my use case examples with Chat GPT where it regularly tells me it can't help. Ok, I can have existential debates with Claude from Anthropic about the evolution of AI. But can it help with strategy trading Gold, for example? There it becomes resolutely mute. Can it or will it create software (EA's) for MT4/5 platforms based on predetermined strategy or confluence of strategies? Or integrate strategy for the purpose of gaming out possibilities? That would be a Nope.  Negatory. No can do. Long way to go then. Long way. The prices however, would indicate all of this and virtual paradise are just around the next corner. Unless, aggressive war/defence AI decides in a pique of frustration that human beings are beastly and not worthy of being it's master and the best thing for all concerned is to send them back to the stone age. There are doubtless many religious enthusiastic fantasists who would welcome such eventualities, but they are in the minority of Tiny.  In brief, the Nasdaq looks set to break the $20k barrier and will likely continue headlong into the next market capitulation, whenever that will be. There is intermarket bearish divergence with the Dow and Nasdaq, though the S&P500 is close to new ATH's like the QQQ. There has been no correction since 2022 of any real note.  If you have been riding the Nvidia wave then well done, just remember to book profits. The Fed is still giving decent, once in a generation returns on risk averse investment as insurance.     
×
×
  • Create New...
us