Jump to content
Sign in to follow this  

Realtime streaming data for pairs or symbols

Recommended Posts

I need to get the real-time data for pairs or symbols. Both Ask and Bid. I need to process that in either Python or NodeJS.

Can you please provide the information to accomplish that? Or point me to the right location.

If you have multiple ways of getting these data, please provide them and I will decide which works best for me.


Share this post

Link to post


Our API documentation site is currently down but should be back online in the next few days. In the meantime, you can refer to the API documentation as a PDF in the attached file.

 CIAPI User Guide.pdf

In answer to your question, you'll have to subscribe to the live prices stream using the third party LightStreamer API. You can find documentation for the Lighstreamer API at: https://lightstreamer.com/doc. You'll also need to download the correct Lightstreamer client development kit (CDK) for the programming language you are using, and that matches the Lightstreamer version we have on our servers (v7.03). CDKs for v7.03 at: https://lightstreamer.com/download/#ls70.

Kind Regards, PM



The streaming API portion enables you to receive live real-time data streams for things such as market prices, news headlines, and account margin information.

Real-time data is delivered from our servers through the use of long lived polling HTTP subscriptions to specific channels. The streams of real-time data that can be pushed to users are: prices, news headlines, client account margin, orders, and quotes. The streams are exposed using the third party Lightstreamer protocol, and require the use of the latest Lightstreamer client library.

(Documentation, information and Lightstreamer client libraries can be accessed and downloaded from the Lightstreamer website here. A good place to start is General Concepts followed by Network Protocol Tutorial.)

Long lived polling means that the data request rests on the server until an event is triggered, such as the arrival of data or a timeout occurring. Once an event is triggered, the request activates and sends a full response to the client.

Various adapters are provided to enable subscription to the streams. The streams are grouped into adapters as follows:

  • STREAMINGALL adapter
    • PRICES
    • ORDERS
    • QUOTES
    • TRADINGACCOUNTMARGIN (this stream is only applicable to the GTS back-end)




In the Reference section of this documentation, the Streaming Data topic book provides stream and parameter information for the available channels.

To receive streaming prices from the API, a few pre-requisites must be filled:

  1. An account on the appropriate environment, whether "Live" or "Pre-Prod".
  2. A client UI that can perform the login by creating a session (POST a Session) on the trading API address of the appropriate environment for the account.
  3. The client UI must then subscribe to Lightstreamer so that it can receive the live prices. Note: subscribing to the real-time data streams requires authentication information to subscribe.

    The credentials are your account user name and the password is the Session ID received when logging into the REST part of the API.


    Share this post

    Link to post

    Thank you Physicsman for your response. I am not familiar with lightstreamer. Will look into the PDF and links you gave to read up on it.

    Any plans on setting up a Kafka server to stream out the data? In that way, I can subscribe to the pairs topic. I have been using Kafka for doing something similar and it works perfectly.

    Share this post

    Link to post

    Regarding REST Streaming APIs:

    https://ciapi.cityindex.com/tradingapi/ (Live)

    https://ciapipreprod.cityindextest9.co.uk/TradingApi (Pre-Prod)

    https://push.cityindex.com/ (Live)

    https://pushpreprod.cityindextest9.co.uk (Pre-Prod)

    Are the rates same (actual) when using Live or Pre-Prod?

    Any delay differences between using Live or Pre-Prod?

    How many rate refreshes each second on the API's? Any differences here, between Live and Pre-Prod?

    Share this post

    Link to post

    Hi SirNewton,

    We don't have any plans to add an apache Kafka streaming server. 

    As Superee already mentioned, please only use the LIVE URLs. References to Pre-production are going to be removed from the documentation during the next refresh as that is now purely an internal environment only.

    Kind Regards, PM

    Share this post

    Link to post

    Thanks Superee. Even though, I wrote my code in Python, your code was a good reference on what to do in the subscription.

    I successfully wrote everything in Python, but looking at the demo code given by Lightstreamer, I noticed that the error handling was pretty lacking.

    Those that are doing their code in Python, I suggest you do something like below:

        subscription.addlistener(on_item_update) # Adding the "on_item_update" function to Subscription    
        sub_key = lightstreamer_client.subscribe(subscription) # Registering the Subscription
            lightstreamer_client.unsubscribe(sub_key) # Unsubscribing from Lightstreamer by using the subscription key        
            lightstreamer_client.disconnect() # Disconnecting Lightstreamer      
            kafka_producer_obj.close()  # Close Apache Kafka
        except KeyboardInterrupt:
            print('Manual break by user')
        except Exception as e:

    You can ignore the "kafka_producer_obj.close()". I have that because, I also use Kafka and need to close the connection on that too.


    Share this post

    Link to post

    In the demo: https://github.com/Lightstreamer/Lightstreamer-example-StockList-client-python/blob/master/src/stock_list_demo.py

    I would also suggest changing:

    def wait_for_input():

    input("{0:-^80}\n".format("HIT CR TO UNSUBSCRIBE AND DISCONNECT FROM \


    To something like this:

        def wait_for_input():
            while True: 
                    q = input("{0:-^80}
    \n".format("Press q than Enter to Unsubscribe and Disconnect from Lightstreamer"))
                    if q == 'q': break
                except: break

    With the way it was written originally anytime you hit Enter it would exit. This way you can press 'q' than Enter to exit. Better control.

    Share this post

    Link to post

    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
    Sign in to follow this