I have been struggling with my streaming provider and although reading through the API a few thousand times and examining the Google Provider did help a lot I'm still stuck.
I subscribe to ticks data from my server, start a new thread just like in the google provider and inside a while loop start to create instances of the Quote object just like below, the same way as demonstrated in the Google Provider. The ticks come in perfect but what next...
CODE:
Please log in to see this code.
I don't understand what am I supposed to do next in order to:
- use the UpdateQuote(q) correctly
So far I have figured out, UpdateQuote(q); in this case will only update the quotes shown in the quotes window and it has to be called everytime I get a new tick from my server so I get all the h/l/c/o values into WL correctly. Does it do anything else? I have tried so many ways already that I think it sometimes updates the chart as well in some mystical manner that I don't completely understand. Does it add to the Quote collection that can be accessed by user at a required timestamp in order to form a new bar correctly with the appropriate h/l values that appeared in the tick data? Is that what the HeartBeat does?
- get bars to close in sync with the server and update on the chart
I have just as many Quote objects as I have ticks coming in and I want to close the bar at the moment when the tick changes the timeframe increment, 1 minute for example. What I'm worried about is if I use local time it might become out of sync with server time and eventually WL will put ticks that server_time are on the current bar, on the previous bar for example. What is the best workaround for this? Is this what the Heartbeat(DateTime timestamp) method is used for? From what I have figured out so far, the local time is somehow important but I can't figure out why. I thought I can make the provider independant from the local time, because it always differs depending on the connection so I wanted to close the bar as soon as I get a tick which is timestamped with a different server minute, is that even possible? What is the parameter that is passed with the Heartbeat, I have tried pasing various DateTime objects and could not figure out what it really affects.
- where do the bars go
The only method that I figured out that saves the actual bars to drive is the SaveBarsObject(bars); from the Static Part. What about the Streaming Provider, will the bars be saved on the drive if one of the above mentioned methods will be implemented correctly? What I'm worried about is runing the provider for a long time in streaming mode. Are there any guidelines or suggestions on this, if I keep it on for a long time I will eventually get an out of memory if the bars are not saved or should the static part be called from time to time or is it neccesary to form Bars objects from Quotes as well and add them to existing bars. The RequestData method seems to be called in the start when going into streaming mode but after that WL Streaming Provider seems to deal with the bars elsewhere.
- alternative method with collecting the quotes and passing them onto the minibar
I have the same issue with the UpdateMiniBar (Quote q, double open, double high, double low) as I have with the UpdateQute and HeartBeat. When is it suppposed to be called? Does it update the chart or save the bars to disk?
Any info on above problems will be very usefull and helpfull. Thank you.