|
Attention! Read the forum rules carefully before posting a topic.
Try to find an answer in Wiki before asking a question. Submit programming questions in this forum only. Off topics are strictly forbidden.
Any topics which do not satisfy these rules will be deleted.
Retrieve Historical and Indicator data on a secondary thread ? |
hyperscalper
|
Post subject: Retrieve Historical and Indicator data on a secondary thread ? |
Post rating: 0
|
Posted: Tue 06 May, 2014, 22:01
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
Hi,
I have a lot of historical data to pull in a IStrategy over 28 currency pairs, and this often causes the onTick and onBar queues to overload and accumulate an excessive number of pending callback events.
Can I safely offload Indicator queries and historical data retrievals to another Thread, other than the onTick/onBar callback thread, so that these events can execute concurrently while I'm pulling historical data to get my system "primed"?
I'm always "religious" about making sure Order operations are on the callback Thread, or are marshalled onto the callback Thread using IContext.executeTask(Callable).
So I guess what I'm really asking is which operations do not require execution on the callback Thread, and can safely be done on an auxiliary thread? Is retrieving data using IHistory something which can be done on a secondary thread?
Thanks! HyperScalper
|
|
|
|
 |
CriticalSection
|
Post subject: Re: Retrieve Historical and Indicator data on a secondary thread ? |
Post rating: 0
|
Posted: Wed 07 May, 2014, 01:18
|
|
User rating: 70
Joined: Sat 22 Sep, 2012, 17:43 Posts: 118 Location: Brazil, Fortaleza, Ceará
|
Yes IHistory operations can be handled in an auxiliary thread, this was actually one of the very first things I implemented when I started working with JForex. A BarHistoryReader component populates historical buffers. While live bars and ticks occur, if the BHR is still busy, these bars and ticks are deemed to be part of the historical context and are sent into the BHR also. The BHR terminates after assembling the appropriate historical information including the live occurrences appearing while it was busy assembling. When the historical picture including the live data sent in is fully assembled, the BHR detaches from the buffers it was populating and dies. Meanwhile subsequent live ticks and bars are fed into the same buffers the BHR was using now by the main thread. That main thread notifies a BufferProcessing thread which goes to work on the newly updated buffers so the main thread can return asap from each onbar() / ontick() call.
|
|
|
|
 |
API Support
|
Post subject: Re: Retrieve Historical and Indicator data on a secondary thread ? |
Post rating: 0
|
Posted: Thu 08 May, 2014, 15:26
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
hyperscalper wrote: Is retrieving data using IHistory something which can be done on a secondary thread? Yes it is and it is trivial to check that. Note that if you are loading huge amounts of data with IHistory.read* asynchronous methods, their listeners already work in their own thread.
|
|
|
|
 |
hyperscalper
|
Post subject: Re: Retrieve Historical and Indicator data on a secondary thread ? |
Post rating: 0
|
Posted: Mon 12 May, 2014, 17:13
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
Perfect !! I implemented the sample Strategy code as a test as shown in the JavaDoc for
void readBars(Instrument instrument, Period period, OfferSide side, Filter filter, int numberOfCandlesBefore, long time, int numberOfCandlesAfter, LoadingDataListener barListener, LoadingProgressListener loadingProgress) throws JFException
Worked the first time through! This will really help me. Just need to take care on synchronization where that's needed.
HyperScalper
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|