Page 6 of 8 FirstFirst ... 45678 LastLast
Results 51 to 60 of 80
  1. #51
    Power Member
    Join Date
    Feb 2008
    Location
    Siracusa
    Posts
    161
    Hi strangecarr,

    here a recap of the basic steps required to start a streaming session with IG platform:

    1. Generate a new API key for the selected account (demo or live), as per instructions you can find here
    2. Login to the chosen environment by using the session API (see the POST method, version 3). Please consider that you can accomplish this task even by using the API Companion, which offers you a web-based form.
    3. Login to the IG platform by using the Python API, providing the required information as per instructions you can find here; basically you have to provide data returned by the session API response, which includes the the Lightstreamer endpoint to contact, and the updated security tokens, as follows:

      where <password> has to be in the form CST-<cst_token>|XST-<x_security_token>, with <cst_token> and <x_security_token> as provided by the session API response.


    Hope this helps, but please have a look at the IG documentation for getting more information.
    Thanks and Regards
    Gianluca

  2. #52
    Quote Originally Posted by epep View Post
    You're right !

    It seems that IG changed something about the persistence of authentication tokens, my script get stuck trying to reconnect with invalid password … I need more intelligence here. I'll let you know as soon as I have done something good.
    Hello epep, I'm trying to get the IG Streaming API up and running but I'm having the same problem as you. Did you finally manage to solve the problem? Thanks!

  3. #53
    Hi Gianluca,

    First of all, thank you very much for the code, it has been really useful for me. I'm also using it to connect to the IG Streaming API and it has work just fine, the only problem that I'm having is the reconnect issue as stated by IG:

    The Lightstreamer client should also have the ability to reconnect in the event of a connection failure or if instructed by the Lightstreamer server (e.g. due to a LOOP rebind message). A re-connection attempt can fail if the CST and X-SECURITY-TOKEN tokens have expired in which case it will be necessary to re-authenticate to obtain new security tokens.
    I was thinking on adding a Timer to the LSClient class, connecting the timeout (after 2 seconds for example) to a new method that unsubscribes, disconnects and reconnects and resubscribe. Obviously I will have to end the session with the rest api and start a new one to get new session tokens.
    What do you think of this approach?

    Thanks in advance!

  4. #54
    Power Member
    Join Date
    Feb 2008
    Location
    Siracusa
    Posts
    161
    Hi Mamoa,
    it can certainly work, but the LSClient should be left as a general purpose Lightstreamer Client, hence I believe that your proposed logic should be put somewhere else, because it catches a specific use case.

    Reconnection is a feature handled by other official Lightstreamer Client, by it is supposed that credentials do not change or, if they do, you have to write some custom logic to provide updated values.

    Please let me know if your reconnection proposal also involves handling of new session tokens.

    Thanks, Gianluca

  5. #55
    Quote Originally Posted by gianluca.finocchiaro View Post
    Hi Mamoa,
    it can certainly work, but the LSClient should be left as a general purpose Lightstreamer Client, hence I believe that your proposed logic should be put somewhere else, because it catches a specific use case.

    Reconnection is a feature handled by other official Lightstreamer Client, by it is supposed that credentials do not change or, if they do, you have to write some custom logic to provide updated values.

    Please let me know if your reconnection proposal also involves handling of new session tokens.

    Thanks, Gianluca
    Hi Gianluca,

    Thanks for the reply. I have been very busy lately and I'm sorry that I didn't get back to you sooner. As you said, my case is really specific to my situation so it shouldn't be added to your lightstreamer client.
    To answer your question, yes, my logic requires handling new session tokens so actually I had to use another api client (Rest API from IG) to get reconnected and getting new sessions tokens.
    Finally I got it running (with a few custom modifications) but I'm having problems with a special case.

    IG Streaming API (https://labs.ig.com/streaming-api-reference) has a special case where you have a DISTINCT Mode subscription , with 1 Item (TRADE) and 1 Field (OPU) but within that field you have various elements. When I subscribe to this trade I see the following message printed by the LightStreamer Client:

    Code:
    Received update message ---> <1,1|{"stopLevel":1.74014,"trailingStopDistance":0,"limitLevel":null,"trailingStep":0,"currency":"CAD","expiry":"-",
    "guaranteedStop":false,"dealIdOrigin":"DIAAAABBHRQJLBA","direction":"SELL","epic":"CS.D.GBPCAD.MINI.IP",
    "dealId":"DIAAAABBHRQJLBA","dealReference":"GCMJXRBVSFD44TD","level":1.73414,"status":"OPEN","size":1,
    "channel":"PublicRestOTC","timestamp":"2017-05-26T07:23:21.000","dealStatus":"ACCEPTED"}>
    but in the table listener I get this message:

    Code:
    {'values': {'OPU': u'{"stopLevel":1.74014'}, 'pos': 1, 'name': 'TRADE:MCMVD'}
    As you can see, I only received the first element of the dict in the listener. I could make an adaptation for this case but I thought it could be positive to add this feature (multiple elements within the field) to your lightstreamer client. What do you think?

    Thanks again,
    Mamoa

  6. #56
    Power Member
    Join Date
    Feb 2008
    Location
    Siracusa
    Posts
    161
    Hi Mamoa,

    thank you very much for this post, as you helped me find out a bug in the demo.
    Actually, the 'values' dict should have been looked like the following:

    Code:
    {'values': {'OPU':u'{"stopLevel":1.74014,"trailingStopDistance":0,"limitLevel":null,"trailingStep":0,"currency":"CAD","expiry":"-","guaranteedStop":false,"dealIdOrigin":"DIAAAABBHRQJLBA","direction":"SELL","epic":"CS.D.GBPCAD.MINI.IP","dealId":"DIAAAABBHRQJLBA","dealReference":"GCMJXRBVSFD44TD","level":1.73414,"status":"OPEN","size":1,"channel":"PublicRestOC","timestamp":"2017-05-26T07:23:21.000","dealStatus":"ACCEPTED"}', 'pos': 1, 'name': 'TRADE:MCMVD'}
    where the value associated with the 'OPU' key is a json string to be processed by your custom logic.
    I've just fixed the client on our github repository.

    Please let me know wheter it helps.

    Thanks and Regards.
    Gianluca

  7. #57
    Hi GianLuca,

    I tested the fixed client and now is working perfectly. Thank you very much!

    Regards,
    Mamoa

  8. #58
    Hello guys

    I have the following issue reoccurring somewhat randomly, like after 4, 10, 24 hours etc.

    All of the sudden the streamer just stops receiving messages and this is the last one:

    Waiting for a new message
    Received message ---> <1,1||||||||||||||1|>
    Received update message ---> <1,1||||||||||||||1|>

    I've downloaded the python LSClient from your Github examples, so the rebind = True function is available. Previously I was using an old version from the pip repository and that always closed the connection after around one hour. Where the rebinding didn't even occur!

    Please advise on how to debug this.


  9. #59
    Power Member
    Join Date
    Feb 2008
    Location
    Siracusa
    Posts
    161
    Hi majestrooo,

    let me first clarify that the Lightstreamer Client Python package actually available from the pip repository is not provided by our company.

    Could you provide us with a server side log excerpt of the issue?

    Thanks,
    Gianluca

  10. #60
    Quote Originally Posted by gianluca.finocchiaro View Post
    Hi majestrooo,

    let me first clarify that the Lightstreamer Client Python package actually available from the pip repository is not provided by our company.

    Could you provide us with a server side log excerpt of the issue?

    Thanks,
    Gianluca
    Hello Gianluca

    I am using the lightstreamer code from this URL https://github.com/Lightstreamer/Lig...k_list_demo.py

    The only part I removed is the stuff in the end for the demo.

    What server side log do you need? I only have those of the ls_streamer. Otherwise please advise if there's a way to turn on more logging.

 

 

Similar Threads

  1. Python Client Library for Lightstreamer
    By Alessandro in forum Client SDKs
    Replies: 1
    Last Post: December 18th, 2014, 06:15 PM
  2. how to comunicate lightstreamer server by python
    By keyan in forum Client SDKs
    Replies: 4
    Last Post: December 18th, 2014, 06:12 PM
  3. Replies: 2
    Last Post: January 5th, 2012, 09:53 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 09:47 AM.