socalwill 1 Report post Posted October 17, 2015 Hi there, for my very limited development purposes (running scripts for download of recent prices for one single currency pair of choice and then placing a trade) I see different approaches for a simple solution of the streaming part of the API. After exploring different resources in an attempt to avoid reinventing the wheel, it seems to me that a simple python client such as https://github.com/Lightstreamer/Lightstreamer-example-StockList-client-python which is discussed at http://forums.lightstreamer.com/showthread.php?4737 would be a perfect starting point but I thought I post here before getting started: Does anyone know of an implementation along the lines of the code referenced above for Cityindex? Thanks so much! William 1 ShannonChumb reacted to this Share this post Link to post
Physicsman 25 Report post Posted October 19, 2015 Hi William, Unfortunately, not that I am aware of - although it would be marvellous if someone does know of something and posts it in this thread! Kind Regards, PM! Share this post Link to post
socalwill 1 Report post Posted October 19, 2015 Hi there PM! I will definitely post the code once I have it working. In the meantime, I received a response on the lightstreamer forum that is a good basis to get started. Here is one thing for which your input would be incredibly helpful: If you have a chance, please take a look at post #24 in http://forums.lightstreamer.com/showthread.php?4737-Python-client-for-lightstreamer . Here is a copy of the two pieces of code there: lightstreamer_client = LSClient(base_url="https://push.cityindex.com/", user="<your user name>", password="<your security token>", adapter_set="CITYINDEXSTREAMINGDEFAULTPRICES") and # Making a new Subscription to "PRICES" Data Adapter subscription = Subscription( adapter="PRICES" mode="MERGE", items=["AC2347"], fields=["MarketId", "TickDate", "Bid", "Offer", "Price"] ) # A simple function acting as a Subscription listener def on_item_update(item_update): print("{MarketId}, {TickDate}, {Bid}, {Offer}, {Price}".format(**item_update["values"])) # Adding the "on_item_update" function to Subscription subscription.addlistener(on_item_update) What I had before was pretty close, but I was getting an error message because I didn't have the fields in the subscription right. Now I can connect and disconnect, but I don't see any prices printed to my screen. I use the session_id of a valid session as password. Should the adapter be set to CITYINDEXSTREAMINGDEFAULTPRICES or to STREAMINGALL? Also, I changed the items value to the market_id of EURUSD, which is 154290. Thanks much for your help - I may be missing some parts of the documentation where the above questions are answered, if so, it would be great if you could provide pointers. Best, William Share this post Link to post
Physicsman 25 Report post Posted October 20, 2015 Hello, As a client, STREAMINGALL is the adapter set to use. You should be able to see streaming prices using this adapter set. Kind Regards, PM! Share this post Link to post
socalwill 1 Report post Posted October 20, 2015 Hello PM, I believe I am getting close. For the subscription, I am getting an error message if I choose meaningless values for adapter or mode. If I set those to PRICES and MERGE, respectively, it seems like I can subscribe and unsubscribe, but there is something that seems suspicious...I can choose some random value for item, say "mycurrencyid" and still "subscribe" and unsubscribe and get no error message. I will see if the lightstreamer forum might help with this. Thanks! Share this post Link to post
socalwill 1 Report post Posted October 22, 2015 Hi there - making progress and having fun. With the help of support from the lightstreamer side, i got both, a bare-bones command line version as well as a modified python script working for streaming data from Cityindex. Please see http://forums.lightstreamer.com/showthread.php?4737-Python-client-for-lightstreamer/page4 . Of course I have a question related to trades now as I am moving on, but I will post that on a different thread or start a new one. Thanks! Share this post Link to post
Garstonman 0 Report post Posted March 2, 2017 Hello Physcisman, Socalwill, Just wondering if there was a python library available now for streaming City Index prices? Or if its best to use the Lightstreamer stock-list demo and edit it? Share this post Link to post
Physicsman 25 Report post Posted March 3, 2017 Hello Garstonman, There isn't a Python library that I'm aware of unfortunately - we've not been working on one. It's probably easiest to modify / edit the Lighstreamer one and go from there. Cordially, PM! Share this post Link to post