SirNewton 3 Report post Posted January 27 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. Thanks. Share this post Link to post
Physicsman 26 Report post Posted January 27 Hello, 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 Quote 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 NEWSHEADLINES CLIENTACCOUNTMARGIN TRADEMARGIN ORDERS QUOTES TRADINGACCOUNTMARGIN (this stream is only applicable to the GTS back-end) CITYINDEXSTREAMINGDEFAULTPRICES adapter DEFAULTPRICES 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: An account on the appropriate environment, whether "Live" or "Pre-Prod". 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. https://ciapi.cityindex.com/tradingapi/ (Live). https://ciapipreprod.cityindextest9.co.uk/TradingApi (Pre-Prod). 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. https://push.cityindex.com/ (Live). https://pushpreprod.cityindextest9.co.uk (Pre-Prod). Share this post Link to post
SirNewton 3 Report post Posted January 27 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
SirNewton 3 Report post Posted January 27 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
SupereeDuperee 6 Report post Posted January 27 I have created a C# .NET Console app that collects streaming rates (and saves to database). If you are interested I can share my code. Share this post Link to post
SupereeDuperee 6 Report post Posted January 27 Also DO NOT USE the Pre-Prod URL - that has been deprecated. Use the LIVE Url for both DEMO and Live accounts. Share this post Link to post
Physicsman 26 Report post Posted January 28 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
SirNewton 3 Report post Posted January 28 Thanks for the info @Physicsman. I will use the Live URL. Hello @SupereeDuperee, Yes, please share your code. Would really appreciate that. Share this post Link to post
SupereeDuperee 6 Report post Posted January 29 I hope this link works. Visual Studio 2017/19 Solution Folder Ziipped . https://drive.google.com/file/d/1SavnJe6f_NRFE5-LYV9arewd893d7AdP/view?usp=sharing I created a Class to hold the rate info, and a List of that Rate Info Class - which keeps latest rate info , along with showing rates on the screen. 1 Physicsman reacted to this Share this post Link to post
SirNewton 3 Report post Posted February 1 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 try: wait_for_input() 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: lightstreamer_client.unsubscribe(sub_key) lightstreamer_client.disconnect() kafka_producer_obj.close() print('Manual break by user') except Exception as e: lightstreamer_client.unsubscribe(sub_key) lightstreamer_client.disconnect() kafka_producer_obj.close() print(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. 1 Physicsman reacted to this Share this post Link to post
SirNewton 3 Report post Posted February 1 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 \ LIGHTSTREAMER")) To something like this: def wait_for_input(): while True: try: 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. 1 Physicsman reacted to this Share this post Link to post