I am using Drools 5. I am struggling to write rule for this logic -

If a stock price changes more than 10% within an hour then report the change.

I understand I have to use sliding window feature but unable to write the rule.

For example I got an update for IBM stock @ 12:30 for price 100 and then another update IBM stock @ 12:35 for price 111. Since the time difference is within an hour and the change is also greater than 10% I want to report this price change.

 

Stock class -

 

Public class Stock {

   Private String stock;

   Private double price;

   Private Date time;

   Private double priceChange;

   Private Boolean highlight;

}

 

 

rule "Stock Price change more than 10% within an hour"

 

when

 

then

set the priceChange attribute of Stock object

set highlight to true     

end

 

 

Secondly if the window is large and number of records coming in is high then could there be a memory issue?

 

Also since every record is getting stored in database, can I not use the database directly instead of sliding window?

 

Thanks

 

Mr. Bhangale Bhushan
Associate Manager
Kale Consultants Ltd.
bhushan_bhangale@kaleconsultants.com
tel: +91 (0)206 608 3777
http://www.kaleconsultants.com

 

 

 

 




Disclaimer: This email (including any attachments) is intended for the sole
use of the recipient/s and may contain material that is CONFIDENTIAL. Any
unauthorized disclosure / copying / distribution or forwarding of this message 
or part is STRICTLY PROHIBITED. If you have erroneously received this message,
please delete it immediately and notify the sender. No liability is assumed for
any errors and/or omissions in the contents of this message. Information in 
this message that does not relate to the official business of this Company
shall be understood as neither given nor endorsed by it. If verification is
required please request a hard-copy version. 

To know more about Kale Consultants, visit www.kaleconsultants.com 

-=-=-=-=-=-=-=-=-=-