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, mos...
What is wrong to use“IF-
Else” for business rules?
• It is good for simple, static rules, the rules are coded in
applicati...
Rule Engine
What is Rule Engine?
• The rule engine is
an application
which executes
one or more
actions based on
fact and ...
Rete Algorithm
Designed by Dr. Charles L. Fogy
• Rules are loaded into
memory as network of
nodes, each note is a
pattern ...
Who needs pricing engine?
• Financial Company - Commission calculation
• Insurance Company - Claim adjudication and
paymen...
Benefits Of Using Rule
Engine
• Separate business logic from application codes
• Dynamically change rules without compiling...
Example 1 - Pricing
Engine for trading
commission
8
Business Requirements
• Realtime
• Multiple layers (regular pricing, risk pricing etc).
• Any combination of trade attribu...
Core Pricing Engine
Trading Commission Pricing Engine
Conceptual Architecture
Trade Pre-
Processor
Rule Engine
Rule Manage...
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 ...
Data Model and Formats
• Source trade messages are serialized binary JSON
• Pricing rule data are saved in database modele...
Rule Examples
package com.upupconsultant.pricing.rule.client.Client123
import com.upupconsultant.pricing.model.Trade
impor...
Rule Examples - continue
rule “Risk Client123 99123479"
salience 1000
activation-group “RISK GRP"
agenda-group “RISK PRICI...
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...
Commercial Pricing Engine
solution is very expensive …
• Tens of Millions dollars project …, and it is a
blackbox.
• Doesn...
Core Pricing Engine
Medical Claim Pricing Engine High
Level Architecture
Claim Pre-
Processor
Rule Engine
Rule Manager UI
...
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/ht...
of 24

PricingEngine_v2.5

Published on: Mar 4, 2016
Source: www.slideshare.net


Transcripts - 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
  • 12. Commission Calculation Flow Diagram 12
  • 13. Commission Calculation Sequence Diagram 13
  • 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
  • 22. Prototype and Demo 22
  • 23. Q & A 23
  • 24. Reference • http://en.wikipedia.org/wiki/Rete_algorithm • http://docs.jboss.org/drools/release/6.1.0.Final/ drools-docs/html_single/index.html

Related Documents