3 ms·
It's not the orders you need to monitor from the sound of it (at least once the trade is complete), it's the position that you hold in the market vs the current
by boothead 14y ago
It's not the orders you need to monitor from the sound of it (at least once the trade is complete), it's the position that you hold in the market vs the current price.
* Actually the previous statement could be wrong: You might also want to do this on a per order basis, although they are on some sense functions of each other.
I would suggest the following:
For any market which you have a position in, subscribe to that market's price feed. I'd use zeromq for this, but there are plently of pub/sub libraries and products. The previous point implies that you are republishing your market data feed into specific channels. How they are mapped depends on many factors, but basically you want to de-multiplex the market data so that you are able to pick out one market's price data as a stream of updates from the whole.
Once you have a feed of the market with a position you can use it to transform the stream of market data to multiple streams of values. You might have new steam of PnL values for each order you have on the market, or a stream of price differences or whatever, you then re-publish those streams. Depending on how many of these derivative streams you have and the rate of data, you might want to do some downsampling too.
What I've described above is pretty similar to the market data architecture in hedge funds that I've worked at. Have a look at the ideas behind function reactive programming http://en.wikipedia.org/wiki/Functional_reactive_programming http://en.wikipedia.org/wiki/Functional_reactive_programming for more info on stream processing.
For the front end, you'll bridge the particular stream of data to a WebSocket (probably translating it to json or a binary data format that javascript can understand at the same time). I don't know how you do that in RoR, I'd use gevent or eventlet in the python world. You'll then need to route this data in some way to a representation of the order/position in the front end. I'd suggest looking at knockout.js, ember.js, angular or something similar as those declarative style libraries will massively reduce the complexity of your client side coding.
Last bit is visualization and there's really only one sane choice for this imho: D3 and libraries built on top of it. Look out for http://square.github.com/cubism/ http://square.github.com/cubism/ and http://square.github.com/crossfilter/ http://square.github.com/crossfilter/ and http://code.shutterstock.com/rickshaw/ http://code.shutterstock.com/rickshaw/ for those bits.
Bit of a whirlwind here, hope it helps!
- brutuscat 14y agoGreat! I think you nailed it. Function reactive programming was being developed in my head somehow. I really really appreciate your comment. Thanks!
- brutuscat 14y agoRegarding the front end, it's exactly what I'm doing right now. I receive the data, do some processing, pack it into json format and wire that using WebSockets to the client. It works really well.