adam.connelly
Hi,
I've written a data adapter that is used to provide exchange rate data to a client. Currently I just assume that there is only ever one rate per currency, per update. In reality, for each rate update, there may be multiple bands of rate, depending on the amount of currency you're buying.
What I want to know is, is there any built in functionality to support this in lightstreamer, or do I have to write something myself.
The scenario is something like (bearing in mind that the numbers are completely contrived):
Code Bid Offer Limit
GBPUSD 1.2 1.3 1000
GBPUSD 1.1 1.2 5000
Basically, I want someone to be able to subscribe to GBPUSD and receive all the rate bands for that currency pair in one update. I could write something myself to just pack and then extract this information, but obviously if there's something built in I won't.
Cheers,
Adam
Alessandro Alinone
Hi Adam,
There are at least three ways to handle this with Lightstreamer, depending on how the bands of rate behave.
1) If you have a fixed number of bands, then you only need to dedicate a subset of fields (in the schema) to each band. Your Data Adapter will publish all the bands for each item. Your Client will subscribe to all the bands or only to those it is interested in.
2) If you have a variable and dynamic number of bands, the you need to use COMMAND mode. This way, your Data Adapter will publish updates on the available bands and your Client will keep the up-to-date state of all the bands and prices.
3) If the price/limit band depends on the specific user, you can leverage the customizeUpdate callback in the Metadata Adapter to dynamically change the price before sending it to the Client. But consider that this method in only available in Java-based Metadata Adapter and not in .NET ones (but you can still have a .NET Data Adapter and a simple Java Metadata Adapter to handle event customization).
Hope that helps.
Cheers,
Alessandro
adam.connelly
Thanks for the reply. There may be variable bands, etc so I can't really use your first solution. I'll have a think about either 2 or 3, but I think for now I'm just going to have something that will take a List and convert it to a dictionary, and vice-versa. The idea being that I can basically store it as csv and then unpack it at the client side. For example:
myDict["myfield"] = "item1;item2;";
One of the problems that I have is that the bands potentially vary per update (they may not in reality, but...)
After I've got everything working I plan on changing this, though since I don't think it's a great solution.
Cheers,
Adam
Alessandro Alinone
OK Adam, probably COMMAND mode should do the trick.