You can refer to this demo (the source code of the example is also provided) which shows a simple Stock-List client updated with real-time data generated by a simulator and injected via Lightstreamer. We provide example of the Adapter implementation both in Java and in C#.NET.

Specifically about your case, you should build a Data Adapter that connects with the third-party application to receive the market rates and generate Items to which clients subscribe and receive all updates in real time.

Do you mean that to every different users you should apply different margins or the margins are the same for all the clients?
Based on this response there could be some different implementation choices.

About "Maximum execution time ..." error please you can refer to this previous post:

Hi,

the file is intended to be launched from a command line as
Code:

php filename.php


you can certainly try to run it as a page but

you may have problems due to the php.ini configurations (not sure about this, it's some time since I had to work with php)
the file contains a while(true) but the php runtime has a limit in the execution time, after that the execution will be stopped

HTH
but if you have no chance to run the PHP code from a command line and not as a page I do not have better suggestions than your solution of increase the timeout.