From 4105751009a4a36e66294aedadd324a8735d1def Mon Sep 17 00:00:00 2001 From: Lakshmi Krishnamurthy Date: Sun, 21 Jan 2024 18:37:38 -0500 Subject: [PATCH] Features: - Reservation Pricer Baseline Indifference Value #1 (1, 2) - Reservation Pricer Baseline Indifference Value #2 (3, 4) - Reservation Pricer Baseline Indifference Value #3 (5, 6) - Indifference Reservation Pricer Process Shell (7, 8, 9) - Indifference Reservation Pricer Pay-off Price (11, 12) - Claims Adjusted Utility Value #1 (13, 14, 15) - Claims Adjusted Utility Value #2 (16, 17, 18) - Claims Adjusted Reservation Utility Function (19, 20, 21) - Optimal Claims Adjusted Underlier Units (22, 23) - Baseline Flow Claims Unit Array (24) - Reservation Pricer Indifference Price Shell (25, 26) - Claims Adjusted Unit Price Array #1 (27, 28) - Claims Adjusted Unit Price Array #2 (29, 30) - Reservation Pricer Utility Value #1 (31, 32, 33) - Claims Adjusted Endowment Portfolio Solver (34, 35, 36) - Reservation Pricer Utility Value #2 (37, 38) - Optimal Claims Price Adjusted Function (39, 40, 41) - Optimal Claims Adjusted Endowment Portfolio #1 (42, 43, 44) - Optimal Claims Adjusted Endowment Portfolio #2 (45, 46, 47) - Optimal Claims Adjusted Endowment Portfolio #3 (48, 49, 50) - Claims Adjusted Unit Price Array #2 (51, 52) - Underlier Utility Optimization Run #1 (53, 54, 55) - Underlier Utility Optimization Run #2 (56, 57, 58) - OMS Indifference Reservation Price Run (59, 60) Bug Fixes/Re-organization: - Bid Ask Claims Handler Delete (10) Samples: IdeaDRIP: --- ReleaseNotes/05_25_2023.txt | 37 ++++++ ScheduleSheet.xlsx | Bin 51445 -> 51429 bytes ...sHandler.java => ReservationPriceRun.java} | 31 +---- .../oms/indifference/ReservationPricer.java | 121 ++++++++++++++++-- .../ReservationPricerProcessShell.java | 63 ++++++++- .../indifference/UtilityOptimizationRun.java | 32 ++--- 6 files changed, 223 insertions(+), 61 deletions(-) create mode 100644 ReleaseNotes/05_25_2023.txt rename src/main/java/org/drip/oms/indifference/{BidAskClaimsHandler.java => ReservationPriceRun.java} (89%) diff --git a/ReleaseNotes/05_25_2023.txt b/ReleaseNotes/05_25_2023.txt new file mode 100644 index 000000000000..1692393ab093 --- /dev/null +++ b/ReleaseNotes/05_25_2023.txt @@ -0,0 +1,37 @@ + +Features: + + - Reservation Pricer Baseline Indifference Value #1 (1, 2) + - Reservation Pricer Baseline Indifference Value #2 (3, 4) + - Reservation Pricer Baseline Indifference Value #3 (5, 6) + - Indifference Reservation Pricer Process Shell (7, 8, 9) + - Indifference Reservation Pricer Pay-off Price (11, 12) + - Claims Adjusted Utility Value #1 (13, 14, 15) + - Claims Adjusted Utility Value #2 (16, 17, 18) + - Claims Adjusted Reservation Utility Function (19, 20, 21) + - Optimal Claims Adjusted Underlier Units (22, 23) + - Baseline Flow Claims Unit Array (24) + - Reservation Pricer Indifference Price Shell (25, 26) + - Claims Adjusted Unit Price Array #1 (27, 28) + - Claims Adjusted Unit Price Array #2 (29, 30) + - Reservation Pricer Utility Value #1 (31, 32, 33) + - Claims Adjusted Endowment Portfolio Solver (34, 35, 36) + - Reservation Pricer Utility Value #2 (37, 38) + - Optimal Claims Price Adjusted Function (39, 40, 41) + - Optimal Claims Adjusted Endowment Portfolio #1 (42, 43, 44) + - Optimal Claims Adjusted Endowment Portfolio #2 (45, 46, 47) + - Optimal Claims Adjusted Endowment Portfolio #3 (48, 49, 50) + - Claims Adjusted Unit Price Array #2 (51, 52) + - Underlier Utility Optimization Run #1 (53, 54, 55) + - Underlier Utility Optimization Run #2 (56, 57, 58) + - OMS Indifference Reservation Price Run (59, 60) + + +Bug Fixes/Re-organization: + + - Bid Ask Claims Handler Delete (10) + + +Samples: + +IdeaDRIP: diff --git a/ScheduleSheet.xlsx b/ScheduleSheet.xlsx index beebd1d3a83fb7cc9cb255939ebba33c475d84a1..be6afae66bfbe6dc7f85f035181f69ab3b8cdb35 100644 GIT binary patch delta 3691 zcmYLMbyU+0_uoiq6;N=L(uy!@NQ^y*bO=ZYh?Im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jU*Ikh;7v3;Q=G!kNX--K6d68@OkHQ)>|f1Gq#=8ED-=?6$`2yc2_cxJ^SZ`sar7SdT**t-G&=B*bRemUi>mggnb%_u0-KBOb zSo4l2?01OK3n&|_FqWCVrn)cP8sG2Q%;MoUjmuj#f^B)&Hkb^iYng0>MEfQM+Mb2f zIhHOd0X!SfT65<^sD!`*r_+|X2k|9+)I{*R$M;3(Y#XaltZ`K8%+M$wIi%j{JlU%H zWLK>`D#P?hom)P0E@n)R2jAB0<0$dVyU`XymQ*`u2M{pJli~`gsWO_J>zEJ-fx>$s4o7%+Cd0+L!D5C{1B=vrg!gzA5sI>zSAQ^(?SP_Q_5t zJLx|??ru}2{?E_Hj1PwVpM0V*cq6a{dK0e!7Dvl;s(?$--ktKlSz|?~Dpd^*-G&oD zI}-jtix8kxbydG1H`|AlVq;-`!4_*?%k8(w8n diff --git a/src/main/java/org/drip/oms/indifference/BidAskClaimsHandler.java b/src/main/java/org/drip/oms/indifference/ReservationPriceRun.java similarity index 89% rename from src/main/java/org/drip/oms/indifference/BidAskClaimsHandler.java rename to src/main/java/org/drip/oms/indifference/ReservationPriceRun.java index 9704787d63bc..175f268f4e18 100644 --- a/src/main/java/org/drip/oms/indifference/BidAskClaimsHandler.java +++ b/src/main/java/org/drip/oms/indifference/ReservationPriceRun.java @@ -1,8 +1,6 @@ package org.drip.oms.indifference; -import org.drip.function.definition.R1ToR1; - /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ @@ -76,8 +74,8 @@ */ /** - * BidAskClaimsHandler works the Bid/Ask Sided Claims Price using the Indifference Pricing Scheme. The - * References are: + * ReservationPriceRun captures the Results of a Claims Adjusted Indifference Pricing Run. + * The References are: * *

*
    @@ -112,30 +110,7 @@ * @author Lakshmi Krishnamurthy */ -public class BidAskClaimsHandler +public class ReservationPriceRun { - private double _units = Double.NaN; - private R1ToR1 _payoffFunction = null; - - /** - * Retrieve the Claims Payoff Function - * - * @return The Claims Payoff Function - */ - - public R1ToR1 payoffFunction() - { - return _payoffFunction; - } - - /** - * Retrieve the Sided Units - * - * @return The Sided Units - */ - public double units() - { - return _units; - } } diff --git a/src/main/java/org/drip/oms/indifference/ReservationPricer.java b/src/main/java/org/drip/oms/indifference/ReservationPricer.java index 60f3c43cb66a..80a20b64686e 100644 --- a/src/main/java/org/drip/oms/indifference/ReservationPricer.java +++ b/src/main/java/org/drip/oms/indifference/ReservationPricer.java @@ -2,6 +2,8 @@ package org.drip.oms.indifference; import org.drip.function.definition.R1ToR1; +import org.drip.function.r1tor1solver.FixedPointFinderOutput; +import org.drip.function.r1tor1solver.FixedPointFinderZheng; import org.drip.measure.continuous.R1Univariate; import org.drip.numerical.common.NumberUtil; import org.drip.numerical.integration.R1ToR1Integrator; @@ -117,7 +119,7 @@ public class ReservationPricer { - private BidAskClaimsHandler _bidAskClaimsHandler = null; + private R1ToR1 _payoffFunction = null; private R1ToR1 _privateValuationObjectiveFunction = null; /** @@ -132,17 +134,74 @@ public R1ToR1 privateValuationObjectiveFunction() } /** - * Retrieve the Bid/Ask Claims Handler + * Retrieve the Payoff Function * - * @return The Bid/Ask Claims Handler + * @return The Payoff Function */ - public BidAskClaimsHandler bidAskClaimsHandler() + public R1ToR1 payoffFunction() { - return _bidAskClaimsHandler; + return _payoffFunction; } - public double baselineIndifferenceFunction ( + public double claimsAdjustedPrice ( + final R1ToR1 claimsAdjustedUnderlierUnitFunction, + final double indifferencePrice) + throws Exception + { + if (null == claimsAdjustedUnderlierUnitFunction) { + throw new Exception ("ReservationPricer::claimsAdjustedPrice => Cannot find Root"); + } + + FixedPointFinderOutput fixedPointFinderOutput = new FixedPointFinderZheng ( + indifferencePrice, + new R1ToR1 (null) { + @Override public final double evaluate ( + final double claimsAdjustedPrice) + throws Exception + { + return claimsAdjustedUnderlierUnitFunction.evaluate (claimsAdjustedPrice); + } + }, + false + ).findRoot(); + + if (null == fixedPointFinderOutput) { + throw new Exception ("ReservationPricer::claimsAdjustedEndowmentPortfolio => Cannot find Root"); + } + + return fixedPointFinderOutput.getRoot(); + } + + public double baselineUtilityValue ( + final R1ToR1 risklessUnitsFunction, + final double terminalRisklessPrice, + final double terminalUnderlierPrice, + final double underlierUnits) + throws Exception + { + return _privateValuationObjectiveFunction.evaluate ( + terminalRisklessPrice * risklessUnitsFunction.evaluate (underlierUnits) + + terminalUnderlierPrice * underlierUnits + ); + } + + public double claimsAdjustedUtilityValue ( + final R1ToR1 risklessUnitsFunction, + final double terminalRisklessPrice, + final double terminalUnderlierPrice, + final double underlierUnits, + final double claimUnits) + throws Exception + { + return _privateValuationObjectiveFunction.evaluate ( + terminalRisklessPrice * risklessUnitsFunction.evaluate (underlierUnits) + + terminalUnderlierPrice * underlierUnits + + claimUnits * _payoffFunction.evaluate (terminalUnderlierPrice) + ); + } + + public double baselineUtilityFunction ( final R1ToR1 risklessUnitsFunction, final R1Univariate terminalUnderlierDistribution, final double terminalRisklessPrice, @@ -154,7 +213,46 @@ public double baselineIndifferenceFunction ( !NumberUtil.IsValid (terminalRisklessPrice) || !NumberUtil.IsValid (underlierUnits)) { throw new Exception ( - "ReservationPricer::baselineIndifferenceFunction => Invalid Terminal Distribution" + "ReservationPricer::baselineUtilityFunction => Invalid Terminal Distribution" + ); + } + + double[] terminalUnderlierSupportArray = terminalUnderlierDistribution.support(); + + return R1ToR1Integrator.Boole ( + new R1ToR1 (null) { + @Override public double evaluate ( + double terminalUnderlierPrice) + throws Exception + { + return baselineUtilityValue ( + risklessUnitsFunction, + terminalRisklessPrice, + terminalUnderlierPrice, + underlierUnits + ) * terminalUnderlierDistribution.density (terminalUnderlierPrice); + } + }, + terminalUnderlierSupportArray[0], + terminalUnderlierSupportArray[1] + ); + } + + public double claimsAdjustedUtilityFunction ( + final R1ToR1 risklessUnitsFunction, + final R1Univariate terminalUnderlierDistribution, + final double terminalRisklessPrice, + final double underlierUnits, + final double claimsUnits) + throws Exception + { + if (null == risklessUnitsFunction || + null == terminalUnderlierDistribution || + !NumberUtil.IsValid (terminalRisklessPrice) || + !NumberUtil.IsValid (underlierUnits) || + !NumberUtil.IsValid (claimsUnits)) { + throw new Exception ( + "ReservationPricer::claimsAdjustedUtilityFunction => Invalid Terminal Distribution" ); } @@ -166,9 +264,12 @@ public double baselineIndifferenceFunction ( double terminalUnderlierPrice) throws Exception { - return _privateValuationObjectiveFunction.evaluate ( - terminalRisklessPrice * risklessUnitsFunction.evaluate (underlierUnits) + - terminalUnderlierPrice * underlierUnits + return claimsAdjustedUtilityValue ( + risklessUnitsFunction, + terminalRisklessPrice, + terminalUnderlierPrice, + underlierUnits, + claimsUnits ) * terminalUnderlierDistribution.density (terminalUnderlierPrice); } }, diff --git a/src/main/java/org/drip/oms/indifference/ReservationPricerProcessShell.java b/src/main/java/org/drip/oms/indifference/ReservationPricerProcessShell.java index be0051c8600a..a48a8e9a0cb9 100644 --- a/src/main/java/org/drip/oms/indifference/ReservationPricerProcessShell.java +++ b/src/main/java/org/drip/oms/indifference/ReservationPricerProcessShell.java @@ -125,6 +125,13 @@ protected abstract double optimalBaselineUnderlierUnits ( final double terminalRisklessPrice) throws Exception; + protected abstract R1ToR1 claimsAdjustedUnderlierUnitFunction ( + final R1ToR1 risklessUnitsFunction, + final R1Univariate terminalUnderlierDistribution, + final double terminalRisklessPrice, + final double claimsUnits + ); + /** * Retrieve the Endowment Value * @@ -174,19 +181,61 @@ public R1ToR1 risklessUnitsFunction ( public UtilityOptimizationRun baselineFlow ( final double terminalRisklessPrice, + final double terminalUnderlierPrice, final R1ToR1 risklessUnitsFunction, - final R1Univariate terminalUnderlierDistribution) + final R1Univariate terminalUnderlierDistribution, + final double[] claimsUnitArray) { - double optimalBaselineUnderlierUnits = Double.NaN; + if (null == claimsUnitArray || !NumberUtil.IsValid (claimsUnitArray)) { + return null; + } + + int claimsUnitCount = claimsUnitArray.length; + double[] claimsUnitAdjustedPriceArray = new double[claimsUnitCount]; + + if (0 == claimsUnitCount) { + return null; + } try { - if (!NumberUtil.IsValid ( - optimalBaselineUnderlierUnits = optimalBaselineUnderlierUnits ( + double optimalBaselineUnderlierUnits = optimalBaselineUnderlierUnits ( + risklessUnitsFunction, + terminalUnderlierDistribution, + terminalRisklessPrice + ); + + if (!NumberUtil.IsValid (optimalBaselineUnderlierUnits)) { + return null; + } + + double indifferencePrice = _reservationPricer.baselineUtilityValue ( + risklessUnitsFunction, + terminalRisklessPrice, + terminalUnderlierPrice, + optimalBaselineUnderlierUnits + ); + + if (!NumberUtil.IsValid (indifferencePrice)) { + return null; + } + + for (int claimsUnitIndex = 0; claimsUnitIndex < claimsUnitCount; ++claimsUnitIndex) { + R1ToR1 claimsAdjustedUnderlierUnitFunction = claimsAdjustedUnderlierUnitFunction ( risklessUnitsFunction, terminalUnderlierDistribution, - terminalRisklessPrice - ) - )); + terminalRisklessPrice, + claimsUnitArray[claimsUnitIndex] + ); + + if (null == claimsAdjustedUnderlierUnitFunction) { + return null; + } + + claimsUnitAdjustedPriceArray[claimsUnitIndex] = _reservationPricer.claimsAdjustedPrice ( + claimsAdjustedUnderlierUnitFunction, + indifferencePrice + ); + } } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/org/drip/oms/indifference/UtilityOptimizationRun.java b/src/main/java/org/drip/oms/indifference/UtilityOptimizationRun.java index 8928f1992dc9..e55d93120ace 100644 --- a/src/main/java/org/drip/oms/indifference/UtilityOptimizationRun.java +++ b/src/main/java/org/drip/oms/indifference/UtilityOptimizationRun.java @@ -114,49 +114,49 @@ public class UtilityOptimizationRun { - private double _reservationValue = Double.NaN; - private EndowmentPortfolio _endowmentPortfolio = null; + private double _underlierUnits = Double.NaN; + private double _optimalExpectationValue = Double.NaN; /** * UtilityOptimizationRun Constructor * - * @param endowmentPortfolio Optimal Endowment Portfolio - * @param reservationValue Optimal Utility Indifference/Reservation Value + * @param optimalExpectationValue Optimal Expectation Value + * @param underlierUnits Optimal Underlier Units * * @throws Exception Thrown if the Inputs are Invalid */ public UtilityOptimizationRun ( - final EndowmentPortfolio endowmentPortfolio, - final double reservationValue) + final double optimalExpectationValue, + final double underlierUnits) throws Exception { - if (null == (_endowmentPortfolio = endowmentPortfolio) || - !NumberUtil.IsValid (_reservationValue = reservationValue)) + if (!NumberUtil.IsValid (_optimalExpectationValue = optimalExpectationValue) || + !NumberUtil.IsValid (_underlierUnits = underlierUnits)) { throw new Exception ("UtilityOptimizationRun Contructor => Invalid Inputs"); } } /** - * Retrieve the Optimal Endowment Portfolio + * Retrieve the Optimal Expectation Value * - * @return The Optimal Endowment Portfolio + * @return The Optimal Expectation Value */ - public EndowmentPortfolio endowmentPortfolio() + public double optimalExpectationValue() { - return _endowmentPortfolio; + return _optimalExpectationValue; } /** - * Retrieve the Optimal Utility Indifference/Reservation Value + * Retrieve the Optimal Underlier Units * - * @return The Optimal Utility Indifference/Reservation Value + * @return The Optimal Underlier Units */ - public double reservationValue() + public double underlierUnits() { - return _reservationValue; + return _underlierUnits; } }