SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
Pricing Engine Build
Above Rule Engine
Wei Zhang
zhang.wei.ny@gmail.com
Up Up Consultant, LLC
1
As developers, how we
implement business rules?
• No matter what programming language we use, C/
C++, JAVA, Scala etc, most likely we implement
business rules using “IF-ELSE” or “CASE” or
“SWITCH”, etc.
2
What is wrong to use“IF-
Else” for business rules?
• It is good for simple, static rules, the rules are coded in
applications as “if - else - then”. If you find your codes have too
many “if - else - then”, and business asks you to change the logic
often, then you have trouble. Any logic change, even single line of
codes, is required IT code changes, test, QA and code release
• Yes, we can build data driven applications, most likely, rules are
stored as data and coded as stored procedures inside database.
But when new line of business added or changed, IT must
remodel the database and implement new logic in stored
procedures, which need IT code development and release.
The programming language is PL/SQL or T-SQL and the
performance is depending on data volume and database load
3
Rule Engine
What is Rule Engine?
• The rule engine is
an application
which executes
one or more
actions based on
fact and rules
Pattern Matcher
Agenda
Working
Memory
Knowledge
Base
facts - e.g. trades business rules
4
Execution
Engine
Rete Algorithm
Designed by Dr. Charles L. Fogy
• Rules are loaded into
memory as network of
nodes, each note is a
pattern of left-hand-side
rule (condition). when a
fact is inserted into
working memory, the
root node passes it to its
child nodes and then
propagates though the
network until it reaches
the terminal node …
5
Who needs pricing engine?
• Financial Company - Commission calculation
• Insurance Company - Claim adjudication and
payment
• Service provider - Pharmacy Benefit Management,
pharmacy claim adjudication, billing and payment
• Any company needs to dynamically price the
product based on complex business rules
6
Benefits Of Using Rule
Engine
• Separate business logic from application codes
• Dynamically change rules without compiling
• Significantly Performance gain for a system with
large set of complex rules (10K against 100 rules,
500 transaction/s, 30 - 50 ms difference)
• DSL for business users to read and write rules
7
Example 1 - Pricing
Engine for trading
commission
8
Business Requirements
• Realtime
• Multiple layers (regular pricing, risk pricing etc).
• Any combination of trade attributes can be part of
business rule(s)
• Rules are managed by business users
• Support real time P & L calculation and real time
client balance calculation
9
Core Pricing Engine
Trading Commission Pricing Engine
Conceptual Architecture
Trade Pre-
Processor
Rule Engine
Rule Manager UI
& Publisher
Pricing
Q
Queues
SourceTrade
Queues
Rule Q
Priced Trade
Distributor
Files
Web
Service
Database
10
Rule Manager Use Case
11
Commission Calculation Flow Diagram
12
Commission Calculation Sequence
Diagram
13
Before and After using Rule
Engine
• Overnight batch processes
• Tiered pricing can’t be handled automatically, like risk commission
calculation, must be processes manually by business team.
• New type business contract needs to take weeks to be implemented by IT
team.
• Fully automated realtime pricing
• Tiered pricing with risk models are supported
• New business rules are created and managed effortlessly
14
Data Model and Formats
• Source trade messages are serialized binary JSON
• Pricing rule data are saved in database modeled
as relational tables. Rule data are published to rule
engine in xml format then transformed into DRL.
• Trade messages are serialized java objects
15
Rule Examples
package com.upupconsultant.pricing.rule.client.Client123
import com.upupconsultant.pricing.model.Trade
import com.upupconsultant.pricing.model.BasicPricigInstruction
global com.upupconsultant.pricing.service.PricingService services
dialect "mvel"
declare Trade
@role ( event )
@expires( 2s )
end
rule “Regular Client123 99123478"
salience 1000
activation-group “REG GRP"
agenda-group “REG PRICING"
when
$t: Trade(
clientId==“123”,
country==“US”,
currency==“USD”,
ticker=“IBM”,
) from entry-point "trade stream"
then
#BASE
BasicPricingInstruction inst = new BasicPricingInstruction("PERCENT",0.4)
services.reqularPricng($t,inst,kcontext.getRule().getName())
end
16
Rule Examples - continue
rule “Risk Client123 99123479"
salience 1000
activation-group “RISK GRP"
agenda-group “RISK PRICING"
when
$t: Trade(
clientId==“123”,
riskPercentage>=0.5
) from entry-point "trade stream"
then
#RISK PRICING
BasicPricingInstruction inst = new BasicPricingInstruction(“RISK”,”MODEL”,”1")
services.riskPricng($t,inst,kcontext.getRule().getName())
end
17
Example 2 - Pricing
Engine for medical claim
payment
18
Business Requirements
• Multiple layers pricing (co-pay / co-insurance, in-
network / out-network provider, maximum out of pocket
expense etc).
• Eligibility rules are complex and managed by
enrollment and service team.
• Pricing models are created or modified and needs to
be tested by re-adjudicating the historical claims.
• Priced claims should be integrated with payment
system with multiple protocols - SOA or MQ
19
Commercial Pricing Engine
solution is very expensive …
• Tens of Millions dollars project …, and it is a
blackbox.
• Doesn’t support multi-tiered pricing out of box,
customer solution is required …
• Open source solution is much cheaper …
• All the functions and features needed are there or easy to be build …
• Performance is well approved by many companies cross industries
…
20
Core Pricing Engine
Medical Claim Pricing Engine High
Level Architecture
Claim Pre-
Processor
Rule Engine
Rule Manager UI
& Publisher
Queues
Rule Q
Adjudicated
Claim Distributor
Files
Web
Service
Database
Files DB
21
Prototype and Demo
22
Q & A
23
Reference
• http://en.wikipedia.org/wiki/Rete_algorithm
• http://docs.jboss.org/drools/release/6.1.0.Final/
drools-docs/html_single/index.html

Weitere ähnliche Inhalte

Ähnlich wie PricingEngine_v2.5

Empowering Enterprise Planning Solutions with Calculation Manager
Empowering Enterprise Planning Solutions with Calculation ManagerEmpowering Enterprise Planning Solutions with Calculation Manager
Empowering Enterprise Planning Solutions with Calculation ManagerAlithya
 
EmpoweringEnterprisePlanning_CalculationManager_2015HUGMNTechDay
EmpoweringEnterprisePlanning_CalculationManager_2015HUGMNTechDayEmpoweringEnterprisePlanning_CalculationManager_2015HUGMNTechDay
EmpoweringEnterprisePlanning_CalculationManager_2015HUGMNTechDayVatsal Gaonkar
 
Presentation application change management and data masking strategies for ...
Presentation   application change management and data masking strategies for ...Presentation   application change management and data masking strategies for ...
Presentation application change management and data masking strategies for ...xKinAnx
 
The Search for the Single Source of Truth - Eliminating a Multi-Instance Envi...
The Search for the Single Source of Truth - Eliminating a Multi-Instance Envi...The Search for the Single Source of Truth - Eliminating a Multi-Instance Envi...
The Search for the Single Source of Truth - Eliminating a Multi-Instance Envi...eprentise
 
Analytics on z Systems Focus on Real Time - Hélène Lyon
Analytics on z Systems Focus on Real Time - Hélène LyonAnalytics on z Systems Focus on Real Time - Hélène Lyon
Analytics on z Systems Focus on Real Time - Hélène LyonNRB
 
SQL in the cloud performance benchmarks
SQL in the cloud performance benchmarks SQL in the cloud performance benchmarks
SQL in the cloud performance benchmarks Thavash Govender
 
Collateral: Cast Iron for BigMachines
Collateral: Cast Iron for BigMachinesCollateral: Cast Iron for BigMachines
Collateral: Cast Iron for BigMachinesSean O'Connell
 
Engineering Truly Adaptive and Dynamic Planning
Engineering Truly Adaptive and Dynamic PlanningEngineering Truly Adaptive and Dynamic Planning
Engineering Truly Adaptive and Dynamic PlanningQuantum Retail
 
Next generation business automation with the red hat decision manager and red...
Next generation business automation with the red hat decision manager and red...Next generation business automation with the red hat decision manager and red...
Next generation business automation with the red hat decision manager and red...Masahiko Umeno
 
Salesforce Multitenant Architecture: How We Do the Magic We Do
Salesforce Multitenant Architecture: How We Do the Magic We DoSalesforce Multitenant Architecture: How We Do the Magic We Do
Salesforce Multitenant Architecture: How We Do the Magic We DoSalesforce Developers
 
Copy of Alok_Singh_CV
Copy of Alok_Singh_CVCopy of Alok_Singh_CV
Copy of Alok_Singh_CVAlok Singh
 
Microservices & Data Design: Database Week SF
Microservices & Data Design: Database Week SFMicroservices & Data Design: Database Week SF
Microservices & Data Design: Database Week SFAmazon Web Services
 
Microservices and Data Design
Microservices and Data DesignMicroservices and Data Design
Microservices and Data DesignAWS Germany
 
Microservices & Data Design: Database Week San Francisco
Microservices & Data Design: Database Week San FranciscoMicroservices & Data Design: Database Week San Francisco
Microservices & Data Design: Database Week San FranciscoAmazon Web Services
 
Oracle Enterprise Manager Seven Robust Features to Put in Action final
Oracle Enterprise Manager Seven Robust Features to Put in Action finalOracle Enterprise Manager Seven Robust Features to Put in Action final
Oracle Enterprise Manager Seven Robust Features to Put in Action finalDatavail
 
Dileep Rai Oracle EBS. 010417
Dileep Rai Oracle EBS. 010417Dileep Rai Oracle EBS. 010417
Dileep Rai Oracle EBS. 010417Dileep Rai
 

Ähnlich wie PricingEngine_v2.5 (20)

Microservices & Data Design
Microservices & Data DesignMicroservices & Data Design
Microservices & Data Design
 
Empowering Enterprise Planning Solutions with Calculation Manager
Empowering Enterprise Planning Solutions with Calculation ManagerEmpowering Enterprise Planning Solutions with Calculation Manager
Empowering Enterprise Planning Solutions with Calculation Manager
 
EmpoweringEnterprisePlanning_CalculationManager_2015HUGMNTechDay
EmpoweringEnterprisePlanning_CalculationManager_2015HUGMNTechDayEmpoweringEnterprisePlanning_CalculationManager_2015HUGMNTechDay
EmpoweringEnterprisePlanning_CalculationManager_2015HUGMNTechDay
 
Presentation application change management and data masking strategies for ...
Presentation   application change management and data masking strategies for ...Presentation   application change management and data masking strategies for ...
Presentation application change management and data masking strategies for ...
 
Avalara AvaTax Integration
Avalara AvaTax IntegrationAvalara AvaTax Integration
Avalara AvaTax Integration
 
The Search for the Single Source of Truth - Eliminating a Multi-Instance Envi...
The Search for the Single Source of Truth - Eliminating a Multi-Instance Envi...The Search for the Single Source of Truth - Eliminating a Multi-Instance Envi...
The Search for the Single Source of Truth - Eliminating a Multi-Instance Envi...
 
Analytics on z Systems Focus on Real Time - Hélène Lyon
Analytics on z Systems Focus on Real Time - Hélène LyonAnalytics on z Systems Focus on Real Time - Hélène Lyon
Analytics on z Systems Focus on Real Time - Hélène Lyon
 
SQL in the cloud performance benchmarks
SQL in the cloud performance benchmarks SQL in the cloud performance benchmarks
SQL in the cloud performance benchmarks
 
Collateral: Cast Iron for BigMachines
Collateral: Cast Iron for BigMachinesCollateral: Cast Iron for BigMachines
Collateral: Cast Iron for BigMachines
 
Engineering Truly Adaptive and Dynamic Planning
Engineering Truly Adaptive and Dynamic PlanningEngineering Truly Adaptive and Dynamic Planning
Engineering Truly Adaptive and Dynamic Planning
 
Next generation business automation with the red hat decision manager and red...
Next generation business automation with the red hat decision manager and red...Next generation business automation with the red hat decision manager and red...
Next generation business automation with the red hat decision manager and red...
 
MaheshCV_Yepme
MaheshCV_YepmeMaheshCV_Yepme
MaheshCV_Yepme
 
Salesforce Multitenant Architecture: How We Do the Magic We Do
Salesforce Multitenant Architecture: How We Do the Magic We DoSalesforce Multitenant Architecture: How We Do the Magic We Do
Salesforce Multitenant Architecture: How We Do the Magic We Do
 
Copy of Alok_Singh_CV
Copy of Alok_Singh_CVCopy of Alok_Singh_CV
Copy of Alok_Singh_CV
 
Microservices & Data Design: Database Week SF
Microservices & Data Design: Database Week SFMicroservices & Data Design: Database Week SF
Microservices & Data Design: Database Week SF
 
Microservices and Data Design
Microservices and Data DesignMicroservices and Data Design
Microservices and Data Design
 
Microservices & Data Design: Database Week San Francisco
Microservices & Data Design: Database Week San FranciscoMicroservices & Data Design: Database Week San Francisco
Microservices & Data Design: Database Week San Francisco
 
Oracle Enterprise Manager Seven Robust Features to Put in Action final
Oracle Enterprise Manager Seven Robust Features to Put in Action finalOracle Enterprise Manager Seven Robust Features to Put in Action final
Oracle Enterprise Manager Seven Robust Features to Put in Action final
 
GetSet ERP Brochure
GetSet ERP BrochureGetSet ERP Brochure
GetSet ERP Brochure
 
Dileep Rai Oracle EBS. 010417
Dileep Rai Oracle EBS. 010417Dileep Rai Oracle EBS. 010417
Dileep Rai Oracle EBS. 010417
 

PricingEngine_v2.5

  • 1. Pricing Engine Build Above Rule Engine Wei Zhang zhang.wei.ny@gmail.com Up Up Consultant, LLC 1
  • 2. As developers, how we implement business rules? • No matter what programming language we use, C/ C++, JAVA, Scala etc, most likely we implement business rules using “IF-ELSE” or “CASE” or “SWITCH”, etc. 2
  • 3. What is wrong to use“IF- Else” for business rules? • It is good for simple, static rules, the rules are coded in applications as “if - else - then”. If you find your codes have too many “if - else - then”, and business asks you to change the logic often, then you have trouble. Any logic change, even single line of codes, is required IT code changes, test, QA and code release • Yes, we can build data driven applications, most likely, rules are stored as data and coded as stored procedures inside database. But when new line of business added or changed, IT must remodel the database and implement new logic in stored procedures, which need IT code development and release. The programming language is PL/SQL or T-SQL and the performance is depending on data volume and database load 3
  • 4. Rule Engine What is Rule Engine? • The rule engine is an application which executes one or more actions based on fact and rules Pattern Matcher Agenda Working Memory Knowledge Base facts - e.g. trades business rules 4 Execution Engine
  • 5. Rete Algorithm Designed by Dr. Charles L. Fogy • Rules are loaded into memory as network of nodes, each note is a pattern of left-hand-side rule (condition). when a fact is inserted into working memory, the root node passes it to its child nodes and then propagates though the network until it reaches the terminal node … 5
  • 6. Who needs pricing engine? • Financial Company - Commission calculation • Insurance Company - Claim adjudication and payment • Service provider - Pharmacy Benefit Management, pharmacy claim adjudication, billing and payment • Any company needs to dynamically price the product based on complex business rules 6
  • 7. Benefits Of Using Rule Engine • Separate business logic from application codes • Dynamically change rules without compiling • Significantly Performance gain for a system with large set of complex rules (10K against 100 rules, 500 transaction/s, 30 - 50 ms difference) • DSL for business users to read and write rules 7
  • 8. Example 1 - Pricing Engine for trading commission 8
  • 9. Business Requirements • Realtime • Multiple layers (regular pricing, risk pricing etc). • Any combination of trade attributes can be part of business rule(s) • Rules are managed by business users • Support real time P & L calculation and real time client balance calculation 9
  • 10. Core Pricing Engine Trading Commission Pricing Engine Conceptual Architecture Trade Pre- Processor Rule Engine Rule Manager UI & Publisher Pricing Q Queues SourceTrade Queues Rule Q Priced Trade Distributor Files Web Service Database 10
  • 11. Rule Manager Use Case 11
  • 14. Before and After using Rule Engine • Overnight batch processes • Tiered pricing can’t be handled automatically, like risk commission calculation, must be processes manually by business team. • New type business contract needs to take weeks to be implemented by IT team. • Fully automated realtime pricing • Tiered pricing with risk models are supported • New business rules are created and managed effortlessly 14
  • 15. Data Model and Formats • Source trade messages are serialized binary JSON • Pricing rule data are saved in database modeled as relational tables. Rule data are published to rule engine in xml format then transformed into DRL. • Trade messages are serialized java objects 15
  • 16. Rule Examples package com.upupconsultant.pricing.rule.client.Client123 import com.upupconsultant.pricing.model.Trade import com.upupconsultant.pricing.model.BasicPricigInstruction global com.upupconsultant.pricing.service.PricingService services dialect "mvel" declare Trade @role ( event ) @expires( 2s ) end rule “Regular Client123 99123478" salience 1000 activation-group “REG GRP" agenda-group “REG PRICING" when $t: Trade( clientId==“123”, country==“US”, currency==“USD”, ticker=“IBM”, ) from entry-point "trade stream" then #BASE BasicPricingInstruction inst = new BasicPricingInstruction("PERCENT",0.4) services.reqularPricng($t,inst,kcontext.getRule().getName()) end 16
  • 17. Rule Examples - continue rule “Risk Client123 99123479" salience 1000 activation-group “RISK GRP" agenda-group “RISK PRICING" when $t: Trade( clientId==“123”, riskPercentage>=0.5 ) from entry-point "trade stream" then #RISK PRICING BasicPricingInstruction inst = new BasicPricingInstruction(“RISK”,”MODEL”,”1") services.riskPricng($t,inst,kcontext.getRule().getName()) end 17
  • 18. Example 2 - Pricing Engine for medical claim payment 18
  • 19. Business Requirements • Multiple layers pricing (co-pay / co-insurance, in- network / out-network provider, maximum out of pocket expense etc). • Eligibility rules are complex and managed by enrollment and service team. • Pricing models are created or modified and needs to be tested by re-adjudicating the historical claims. • Priced claims should be integrated with payment system with multiple protocols - SOA or MQ 19
  • 20. Commercial Pricing Engine solution is very expensive … • Tens of Millions dollars project …, and it is a blackbox. • Doesn’t support multi-tiered pricing out of box, customer solution is required … • Open source solution is much cheaper … • All the functions and features needed are there or easy to be build … • Performance is well approved by many companies cross industries … 20
  • 21. Core Pricing Engine Medical Claim Pricing Engine High Level Architecture Claim Pre- Processor Rule Engine Rule Manager UI & Publisher Queues Rule Q Adjudicated Claim Distributor Files Web Service Database Files DB 21