On 19/09/2016 14:22, Robert McInnis wrote:
One of the examples I provided was a stock feed/portfolio management example.
The 'market' consisted of just 16 stock symbols and their associated market price when I was making the example.
1000 portfolios were generated with 5-16 buy orders initially pushed (assume 10 positions on average). Any buy orders would also be tracked and would also force an update of the associated portfolio.
I then generated 2000 random StockTicks and pushed them thru the market individually, simulating a ticker plant. This would trigger the necessary updates only to those portfolios containing the stock, as well as updating the overall portfolio value.
This example took about 20 minutes to code, with a few more minutes to tweak the output to make it more appealing.
How would you do that with the Signals2 object?
The same way you'd do it with any other event-based (or pub/sub) system. Presumably a Stock would define a MarketPriceChanged signal and the Portfolios would subscribe to that signal for each of their contained stocks. Buy orders and stock ticks would trigger a change in the market price, which would raise the signal for the affected stocks.