Jump to content

mf2

Community Member
  • Posts

    19
  • Joined

  • Last visited

Posts posted by mf2

  1. @SergioLage Interestingly, it seems that there is no proper way to post code in this forum – neither as a listing (no appropriate formatting) nor as an attachment (the filetype is not accepted).

    So here is a very minimal C example, which gets you a working connection: http://0x0.st/H_rX.c

    Note however, to subscribe to order status etc. you need to supply the other parameters like LS_user etc. which I wrote in my other post about.

     

  2. You can use these endpoints to iterate over a list of all markets:

    I recommend not doing it though, because you can easily exhaust your API quota. Instead I recommend to use the API companion, it has some sensible defaults for these endpoints and a bit of autocompletion.

  3. Hi,

    that an order is accepted does not mean that it will be filled. As you are aware, after opening a position with the /otc endpoint, you will get a dealReference – described in the API as an "unconfirmed trade".

    With the reference you will have to check if either a confirmation or an error message is available. The recommended way is to use the LightStreamer API, otherwise you can poll the /confirms/ endpoint. See

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

  4. I believe the hourly sentiment is actually what you get at the `/sentiment` endpoint: https://labs.ig.com/rest-trading-api-reference/service-detail?id=655

    But at least for the DE40 it’s not very interesting; over the past couple of trading days, the sentiment was always either 52/48 or 53/47. It would be nice if even more sentiment data would be included, i.e. what you see in the trading interface.

  5. 1 hour ago, charlie303 said:

    @mf2 could you post a create_session.txt file and the complete URL you send it to?

    Fascinating how complicated something supposedly simple as posting code on the IG messageboard is, just because support for proper formatting is missing.

    Anyway, here is  a very minimal example for acessing a LightStreamer API: https://dpaste.com/BGNARUXSS

    Notes:

    • It does not use IG's server, but a public demo server. However, the code is essential the same as I am using in my application.
    • I wrote it under Linux, it might be of limited use to a Windows User. Maybe under WSL it runs.
    • Linux users can compile it via: gcc -lcurl main.c

     

  6. FWIW, the programming language does not really matter and you don’t need any special libraries to access the LightStreamer API. You can send standard HTTP requests and it works, as long as you stick to the protocol. Personally, I prefer this approach as this makes my program independent from any third-party libraries.

    Regarding version 6.0, I meant that the LightStreamer API Companion adds `LS_client_version=6.0` to the request. Note that you don’t need any JavaScript client libraries to access the API via JavaScript, you could use AJAX and/or the .txt endpoint instead of the .js endpoint.

    The issue is just that some details in the specification are left to speculation or interpretation, therefore it requires some experimenting. Furthermore, you need to make sure that you process Chunked requests properly if you don’t use polling.

    Session V3 authentication can be used in your program, you just have to issue another Session V1 REST Api call afterwards to retrieve the CST and XST tokens, as you observed. Also, the documentation is here, you just need to scroll down to V3: https://labs.ig.com/rest-trading-api-reference/service-detail?id=600

    (Note that IG calls this "oauth", but its really not)

    So here is what I am doing:

    1. Authenticate with the REST api via a V3 session call
    2. Issue a V1 session call to get the XST and CST token
    3. Send the following HTTP POST request to the lightstreamer server, at `/lightstreamer/create_session.txt`:

    "LS_cause=new.api&LS_polling=true&LS_polling_millis=0&LS_idle_millis=0&LS_client_version=6.0&LS_user=<IG Account ID>&LS_password=CST-<CST-Token>|XST-<XST-Token>&LS_container=lsc&"

    Some notes:

    1. I use polling, which is not recommended, but its fine for my case.
    2. The `|` in the password needs to be escaped properly.
    • Like 1
  7. So I had the same issue that my self-developed client simply would not connect to the API anymore; after checking out the LightStreamer API companion (it took some hours to remember that it exists) and examining the requests it makes it seems that the API was upgraded to 6.0, which require a little bit different session creation. But then it works with the demo account just fine, even with an old API key.

×
×
  • Create New...
us