Thanks, Klaus. Yes, your solution is a good improvement.

On Sat, Mar 23, 2013 at 1:04 PM, Klaus <[email protected]> wrote:

> Dear Eugene,
>
> here is my take on this.
> It predates your question, as I ran into this problem some time back.
> (Thus, the interface does not match yours exactly)
> It contains an improvement insofar, as updating is only necessary if a max
> or min
> value is removed.
> One could go beyond this in case value repetition occurs (rather likely
> for
> base data, less for indicators as they change based on history)
> In this case several max or min values may be at the same time part of the
> window.
> One could count them and wait with updating until the last one drops out.
> As I focussed on indicators, this optimization is not contained.
>
> I hope it is what you are looking for.
> If there are further optimizations, I would be interested as well, of
> course.
>
> Cheers
>  Klaus
>
>
>
> Am Samstag, 23. März 2013 10:47:43 UTC-3 schrieb Eugene Kononov:
>
>> Hello JBTers,
>>
>> Consider this challenge: over a time window of fixed length (let's say 2
>> hour time window), I'd like to know the high price and low price in that
>> window. The straightforward solution is to iterate over the prices in the
>> window and compute the min and max values, which has to be done every time
>> an old price drops from the window and the new price is added to the
>> window. This works, but it's very inefficient. It requires N operations
>> where N is the length of the time window. This makes strategy optimization
>> which uses this indicator painfully slow. All other indicators in JBT
>> require just one operation to update the indicator.
>>
>> So, the challenge is to to make the min/max calculation in a moving
>> window more computationally efficient. I attached the inefficient solution,
>> where the update() method has to be called every time before min or max can
>> be returned.
>>
>> Any takers to improve this?
>>
>> Thanks,
>> Eugene.
>>
>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "JBookTrader" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/jbooktrader?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"JBookTrader" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jbooktrader?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to