Results 1 to 6 of 6
  1. #1

    Looking for a starting point - inbound websocket

    Hello all, for starters, I don't know anything about java, but have been tasked to figure this out none the less.

    I have a websocket feed from a third party that is pushing real-time stock prices. I have been reading all the examples, but am still lost as to where I define my inbound connection. All the stock price ones keep pointing back to the fake stock data and that's where I get loss.

    I have a wss URL to connect to, and the server streams the symbols back in a JSOM format. Up to this point we have been using standard REST API to pull the data, but wanted to give this real-time websocket feeds a try.

    If anyone can just give me a more defined starting point other then here's a page with 100 examples, I would really appreciate it.

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,089
    You are right. We don't provide examples that include a real feed, because there are infinite possible scenarios, hence any concrete example would cover only a few real cases.
    In our Stock List Demo, we only setup a very simple generator of fake stock prices, so that the meaning of the involved data is clear; then we show how to adapt its interface to the Data Adapter interface required by Lightstreamer.
    Real cases will be different in how the data will be received, but the involved data may be similar.

    Here, a starting point could be the identification of your case and the first question is:
    Is your feed interactive, so that you can request to the feed what it should send on the websocket, or does it send everything within a predefined domain?

    Anyway, some coding would be needed. Do you have any preferred language?

  3. #3
    Thank you for the reply. We send a API REST call with the Symbols we want included in the websocket, and it updates the feed accordingly. so Its a very dynamic feed. The goal is that the end user can then subscribe to the light steamer for the individual symbol they need that are parsed from the core feed coming into the server. The feed is provided as real-time data with up to 1500 symbols per websocket connection. We are currently doing it all as REST API calls, but that is not sustainable long term. Our team is made up of Oracle Database guys that know general front end / javascript / php / css kind of stuff with PL/SQL / Oracle backend. More then willing to learn, but more of a reverse engineering kind of a guy that's just lost with all the different examples.

  4. #4
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,089
    If the contents of your feed can be controlled, then the simple StockList demo Adapter example doesn't match well, because in that case our simulated feed sends everything and the Data Adapter extracts the quotes related to the current subscriptions.
    The JMS Adapter example is more similar, since the Adapter receives the subscription requests and forwards the requests to the feed; but it also introduces several complications.
    So, I'm afraid we don't have suitable ready-made code.

    What your Data Adapter should do is quite simple in principle. You should:
    • Upon the invocation of init() from Lightstreamer, open the websocket with the feed and start listening. Since you haven't requested any symbol, I expect that you shouldn't receive anything.
    • Upon an invocation of subscribe(item) from Lightstreamer, send a request to the feed to add the related item (i.e. symbol). From that moment you will receive updates from the websocket for that symbol and you should extract the relevant information and forward them to the Lightstreamer listener.
    • Similarly, upon an invocation of unsubscribe(item) from Lightstreamer, send a request the feed to stop with the related item (i.e. symbol).


    A complication is brought if you also need to handle the "snapshot".
    In practice, when you request your feed to add a symbol, does it immediately send through the websocket the current quotation of the symbol? or does it send events only upon quotation changes?

  5. #5
    When we subscribe, the symbols stay subscribed until we add/remove a symbol from the subscription. The websocket then sends the current stock price when and only when it changes in price. for the first price (if market is closed and no changes) is done with a different API. On page load it gets the current at rest stock price.

  6. #6
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,089
    If you can get the current quotation of a symbol upon page load from your application server and then the page immediately subscribes to the symbol through Lightstreamer Client library to get the updates, this may be enough in most cases.
    There is only the risk of missing an update occurring during this short interval. In this case, until the next update comes, the data on the page would be outdated. In practice, the consequences would be worse for slow symbols, but for them the probability of this to happen would be low.

    If this risk is acceptable, then this would keep the Data Adapter code simple (in particular, the Data Adapter could answer false to the isSnapshotAvailable() callback).
    Otherwise the Data Adapter, upon each subscribe() invocation, should also take care of obtaining from the feed the current stock price. This may involve some REST call, but the frequency of these calls would be much lower than in a polling strategy: it would be needed only upon page load and, whenever many clients should request the same item at the same time, only for the first one.

 

 

Similar Threads

  1. Replies: 1
    Last Post: April 3rd, 2020, 10:03 AM
  2. Replies: 12
    Last Post: December 31st, 2014, 12:18 PM
  3. Replies: 3
    Last Post: September 25th, 2013, 10:24 AM
  4. Replies: 0
    Last Post: March 15th, 2013, 07:24 PM
  5. Lightstreamer Websocket Timout Problem
    By shabbirh in forum Client SDKs
    Replies: 5
    Last Post: November 7th, 2012, 10:26 AM

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 03:01 PM.