Jump to content

Recommended Posts

Hi,

 

I've had a read through the documentation and am able to get the REST API working fine. The difficulty I'm having is connecting to the streaming API.

 

I'm using the Angular 2 Web Client Demo https://github.com/Lightstreamer/Lightstreamer-example-StockList-client-angular2

 

When I try to connect to https://push.cityindex.com/ I get a "License not valid for this client version" alert.

 

I've tried downgrading my version of the client and also changing my version of Lighstreamer to version 5 as mentioned here http://faq.labs.cityindex.com/index.php?/topic/1072-streaming-api-authentication/#post_id_1877

 

The code that I've created at the moment looks like this:

initStocks(_http) {

        _http.post('https://ciapi.cityindex.com/TradingAPI/session', this.credentials).subscribe(result => {

        	this.sessionData = result.json();
        	
        	let config = {
        		headers: {
        			Username: this.credentials.UserName,
        			Session: this.sessionData.Session
        		}
        	}

        	_http.get('https://ciapi.cityindex.com/TradingAPI/UserAccount/ClientAndTradingAccount', config).subscribe(result => {
        		let res = result.json();
        		this.lsClient = new LightstreamerClient("https://push.cityindex.com/");
        		this.lsClient.connectionDetails.setAdapterSet("STREAMINGALL");
        		this.lsClient.connectionDetails.setUser(res.ClientAccountId);
        		this.lsClient.connectionDetails.setPassword(config.headers.Session);
        		this.lsClient.addListener({
        			onListenStart: function() {
        				console.log('ListenStart');
        			},
        			onStatusChange: function(status) {
        				console.log('Lightstreamer connection status:' + status);
        			}
        		});
        		this.lsClient.connect();
        	},

        	

 		});
    }

Not sure if I'm missing something or if something needs to change but would be grateful for any advice

Share this post


Link to post

Hi Physicsman,

 

Thank you very much for your response.

 

I spoke to someone in Lighstreamer support and he confirmed that the error messages are due to the Lightstreamer server for City Index not supporting the version of the Web Client I'm using. He suggested that I ask you guys what the maximum client version supported by their API servers is?

 

Thanks

Share this post


Link to post

Hello,

 

The page at: http://www.lightstreamer.com/download/#previous shows the client versions supported by Lightstreamer 5.1.2, which is what we are using on our servers. Unfortunately, the AngularJS client isn't on that list. It looks like it is a non-standard LS client as the source you pointed to is on Github rather than on Lighstreamer's site. I suspect it is probably developed for the latest version of  Lightstreamer 6.0.3.

 

Possibly you could convert your code to work with the JavaScript client version supported by LS 5.1.2?

 

Kind Regards,

PM!

Share this post


Link to post

Update - I was able to get the connection working by navigating here http://www.lightstreamer.com/repo/distros/ and downloading the client from this package: Lightstreamer_Moderato_5_0_Colosseo_20120803.zip.

 

It works in HTTP-STREAMING as is the case for Moderato version (from what I understand from the docs). 

 

My only issue now is that when I subscribe to the STREAMINGALL data adapter and choose say "Prices:99500" as an item and "Bid, Offer" as fields I get null output for both. Am I looking up the correct fields?

 

Thanks

Share this post


Link to post

Hi,

 

Yes, those are the correct fields. Not sure why it's not working.

 

Are you able to get prices from any other market? Also, have you tried listening to other streams and such as TRADEMARGIN and do you receive any data from them? NOTE: you'll need to have open positions for data to come through TRADEMARGIN. I assume you are using a demo/test account and a not a LIVE one?

 

Please inform me if you don't have a demo/test account and I can create one for you to use whilst you work on your API development and testing.

 

Kind Regards,

PM!

Share this post


Link to post

Have you tried replacing Prices with PRICES?

There should be a data adapter for the table info or equivalent, which you set to PRICES.

The group is PRICE and then the market id. Maybe give a code snippet of where you subscribe to the stream?

Just a thought.

Share this post


Link to post

Thanks guys - sorry for the delay in getting back to you.

 

It occurred to me yesterday that the CityIndex Lighstreamer server is a Vivace edition so changed my version of the client from Moderato hoping that this might help but no joy.

 

@UKDeveloper99 I tried changing to PRICES but still getting null. I tried a few variations but this is where I'm currently at:

itemNames =  ["PRICES.PRICE.154297"];
fieldNames = ["BID", "OFFER"];

this.subscription = new Subscription("MERGE", this.itemNames, this.fieldNames);
        		this.subscription.setDataAdapter("PRICES");
        		this.subscription.addListener({
        			onItemUpdate: (updateObject) => {
        				var itemName = updateObject.getItemName();
        				updateObject.forEachChangedField((fieldName, fieldPos, val) => {
        					var itemIndex = this.itemNames.indexOf(itemName);
        					var fieldIndex = this.fieldNames.indexOf(fieldName);
        					console.assert(fieldIndex != -1);
        					console.assert(itemIndex != -1);
        					console.log(val);
        					this.stocks[itemIndex][fieldIndex] = val;
        					this.ref.detectChanges();
        				});
        			},
        			onSubscription: function() {
        				console.log('Subscription Start');
        			}
        		});

        		this.lsClient.subscribe(this.subscription);

I get the 'Subscription Start' logged to my console so I know it's connected but think there must be something wrong with the way I'm putting in the itemNames.

 

@Physicsman I'm using a live account and don't have a test account but would be very grateful if you could set one up. I've tried subscribing to news items but still get the same output. Hopefully you guys will be able to spot my error as I'm slightly unsure as to what the correct format is for the strings in the items array.

 

Btw this is the response I'm getting:

/*
window.LS_lastError = {};
window.LS_lastError[1] = null;

*/

Thanks

Share this post


Link to post

Hi,  

 

I'm going to send you a PM on this message board with credentials for a demo/test account.  

 

With regards to the LS connection problem you're encountering, I've asked our developers to look into it and will post a response when I have it. 

 

Kind Regards,

PM!

Share this post


Link to post

Update - was able to get this working with some help from UKDeveloper99 (thanks a lot!).

 

My mistake was not putting all the fields in from the PriceDTO (http://docs.labs.cityindex.com/#Data%20Types/PriceDTO.htm). My item and field arrays now look like this and everything works fine:

itemNames =  ["PRICE.154297"];
fieldNames = ["MarketId", "TickDate", "Bid", "Offer", "Price", "High", "Low", "Change", "Direction", "Delta", "ImpliedVolatility", "AuditId", "StatusSummary"];

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
×