From 86df40a575de7b37df2514dbe5383153f0509605 Mon Sep 17 00:00:00 2001 From: Lakshmi Krishnamurthy Date: Sun, 4 Feb 2024 03:21:03 -0500 Subject: [PATCH] Features: - No-Claims Inventory Utility Expectation #1 (1, 2, 3) - Indifference Reservation Pricing Run #1 (4, 5, 6) - Bid/Ask Optimal Inventory Vertex (7, 8, 9) - Indifference Reservation Pricing Run #2 (10) - No-Claims Inventory Utility Expectation #2 (11, 12) - Bid Claims Position Value Adjustment (13, 14) - Ask Claims Position Value Adjustment (15, 16) - Indifference Reservation Pricing Run #3 (17, 18) - Utility Expectation Optimization Run Shell (19, 20, 21) - Utility Expectation Optimization Run Value (22, 23) - Utility Expectation Optimization Run Constructor (24, 25, 26) - Utility Function Expectation Run #1 (27, 28) - Utility Function Expectation Run #2 (29, 30) - Utility Function Expectation Run #3 (31, 32) - Utility Function Expectation Run #4 (33, 34) - Utility Function Expectation Run #5 (35, 36) - Utility Function Expectation Run #6 (37, 38) - Claims Utility Expectation Inference Run #1 (39, 40, 41) - Claims Utility Expectation Inference Run - Reservation Value (42, 43) - Claims Utility Expectation Inference Run - Constructor (44, 45, 46) - Claims Utility Expectation Inference Run #2 (47, 48, 49) - Claims Utility Expectation Inference Run #3 (50, 51, 52) - Claims Utility Expectation Inference Run #4 (53, 54) - Claims Utility Expectation Inference Run #5 (55, 56, 57) - Claims Utility Expectation Inference Run #6 (58, 59, 60) Bug Fixes/Re-organization: Samples: IdeaDRIP: --- ReleaseNotes/06_15_2023.txt | 35 +++ ScheduleSheet.xlsx | Bin 52751 -> 52761 bytes .../ClaimsUtilityExpectationInferenceRun.java | 152 +++++++++++ .../oms/indifference/ReservationPricer.java | 249 ++++++++++++++++-- .../indifference/ReservationPricingRun.java | 19 +- .../UtilityExpectationOptimizationRun.java | 146 ++++++++++ .../UtilityFunctionExpectation.java | 201 +++++++------- 7 files changed, 687 insertions(+), 115 deletions(-) create mode 100644 ReleaseNotes/06_15_2023.txt create mode 100644 src/main/java/org/drip/oms/indifference/ClaimsUtilityExpectationInferenceRun.java create mode 100644 src/main/java/org/drip/oms/indifference/UtilityExpectationOptimizationRun.java diff --git a/ReleaseNotes/06_15_2023.txt b/ReleaseNotes/06_15_2023.txt new file mode 100644 index 00000000000..b0679986e05 --- /dev/null +++ b/ReleaseNotes/06_15_2023.txt @@ -0,0 +1,35 @@ + +Features: + + - No-Claims Inventory Utility Expectation #1 (1, 2, 3) + - Indifference Reservation Pricing Run #1 (4, 5, 6) + - Bid/Ask Optimal Inventory Vertex (7, 8, 9) + - Indifference Reservation Pricing Run #2 (10) + - No-Claims Inventory Utility Expectation #2 (11, 12) + - Bid Claims Position Value Adjustment (13, 14) + - Ask Claims Position Value Adjustment (15, 16) + - Indifference Reservation Pricing Run #3 (17, 18) + - Utility Expectation Optimization Run Shell (19, 20, 21) + - Utility Expectation Optimization Run Value (22, 23) + - Utility Expectation Optimization Run Constructor (24, 25, 26) + - Utility Function Expectation Run #1 (27, 28) + - Utility Function Expectation Run #2 (29, 30) + - Utility Function Expectation Run #3 (31, 32) + - Utility Function Expectation Run #4 (33, 34) + - Utility Function Expectation Run #5 (35, 36) + - Utility Function Expectation Run #6 (37, 38) + - Claims Utility Expectation Inference Run #1 (39, 40, 41) + - Claims Utility Expectation Inference Run - Reservation Value (42, 43) + - Claims Utility Expectation Inference Run - Constructor (44, 45, 46) + - Claims Utility Expectation Inference Run #2 (47, 48, 49) + - Claims Utility Expectation Inference Run #3 (50, 51, 52) + - Claims Utility Expectation Inference Run #4 (53, 54) + - Claims Utility Expectation Inference Run #5 (55, 56, 57) + - Claims Utility Expectation Inference Run #6 (58, 59, 60) + + +Bug Fixes/Re-organization: + +Samples: + +IdeaDRIP: diff --git a/ScheduleSheet.xlsx b/ScheduleSheet.xlsx index 98e1584568c446e18f31dadc1a3cf79703c4a10c..32cf2a4702ebf968e3c8c62e4a3e9df06453a35d 100644 GIT binary patch delta 3980 zcmV;74|DL3oCBGh1F-A{1tziK83vQ_1|EOfFc5y9wEqzKJ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9Cau_RJvW z?0cf-O+66s7Z%RG86@XprhNDL{3ZXny^}bikU?9CKp-GnV%t|khfcLg%y~YY@6^T0 zYg)o|JH?e@FcRSmWO&9vwuNPRmp-jpQY^6}IvHfr_2FHlXM1KolLyUCl`c;E#^-xk ze26*upxw;Lw@vCu8M!a;BEMiBMCY)G?d%uN@4%=Rt5x!&=9s$t9qX|Ix5>1T!=c`P8Iag4ubA!_K&ZMR7=S5U z06ZwZI%nWE_ruvkAip>^Sv5|w{Q%j>Kc9eC_N^43c(soTvOem1E%%(R;+)yJ)Wi`| z=%K*ERg?Pt_uC?NLhipj7Bvpv0@m}qd1F}EK z&Y*>JA?@9!w}Sr8HQT?o^KP2s1A9h0@gD}~R6es_**XM*Yu_j;mNz_&&U_5l&$WL|iGj{BQ z7KJh*I)no5Uq6}!0O<0#a+8ku2SP(n!w;FY8NLPJ;Mn1V93vRW$*LEv$(>*U zPQm7>EL&hN=4fBxb`t}UE|H-!BF;v3StjJTHXTd21R0^0(Zmve>_PG*B5i$;^u4%` zjsvFGzp<00N_MBKJyaSdHsQ}QhI$Zh0in;%DQW%!m6dT6c{8l-=Nr?S==IZ6zB zzv||@GX8&NUA0~l0!k7P2qj9wC}gAy#uEYE2N8iFfBG#4=>L2FKh*y&E7W|iI^Ov^ z6iXT-N(mbOr3?1*CRHw7P}eEYeW{&{UPFbL#<2Le(3Z<2owR;Y@8CGa}xpr4DVpywave*oCw Bv$g;L diff --git a/src/main/java/org/drip/oms/indifference/ClaimsUtilityExpectationInferenceRun.java b/src/main/java/org/drip/oms/indifference/ClaimsUtilityExpectationInferenceRun.java new file mode 100644 index 00000000000..6607c3aa3ca --- /dev/null +++ b/src/main/java/org/drip/oms/indifference/ClaimsUtilityExpectationInferenceRun.java @@ -0,0 +1,152 @@ + +package org.drip.oms.indifference; + +import org.drip.numerical.common.NumberUtil; + +/* + * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ + +/*! + * Copyright (C) 2024 Lakshmi Krishnamurthy + * + * This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics, + * asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment + * analytics, and portfolio construction analytics within and across fixed income, credit, commodity, + * equity, FX, and structured products. It also includes auxiliary libraries for algorithm support, + * numerical analysis, numerical optimization, spline builder, model validation, statistical learning, + * graph builder/navigator, and computational support. + * + * https://lakshmidrip.github.io/DROP/ + * + * DROP is composed of three modules: + * + * - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/ + * - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/ + * - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/ + * + * DROP Product Core implements libraries for the following: + * - Fixed Income Analytics + * - Loan Analytics + * - Transaction Cost Analytics + * + * DROP Portfolio Core implements libraries for the following: + * - Asset Allocation Analytics + * - Asset Liability Management Analytics + * - Capital Estimation Analytics + * - Exposure Analytics + * - Margin Analytics + * - XVA Analytics + * + * DROP Computational Core implements libraries for the following: + * - Algorithm Support + * - Computation Support + * - Function Analysis + * - Graph Algorithm + * - Model Validation + * - Numerical Analysis + * - Numerical Optimizer + * - Spline Builder + * - Statistical Learning + * + * Documentation for DROP is Spread Over: + * + * - Main => https://lakshmidrip.github.io/DROP/ + * - Wiki => https://github.com/lakshmiDRIP/DROP/wiki + * - GitHub => https://github.com/lakshmiDRIP/DROP + * - Repo Layout Taxonomy => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md + * - Javadoc => https://lakshmidrip.github.io/DROP/Javadoc/index.html + * - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal + * - Release Versions => https://lakshmidrip.github.io/DROP/version.html + * - Community Credits => https://lakshmidrip.github.io/DROP/credits.html + * - Issues Catalog => https://github.com/lakshmiDRIP/DROP/issues + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ClaimsUtilityExpectationInferenceRun holds the Results of the Optimal Utility Expectation Inference + * Run on the Claims-Based Agent Utility Function. The References are: + * + *

+ *
    + *
  • + * Birge, J. R. (2008): Financial Engineering Elsevier Amsterdam Netherlands + *
  • + *
  • + * Carmona, R. (2009): Indifference Pricing: Theory and Applications Princeton + * University Press Princeton NJ + *
  • + *
  • + * Vassilis, P. (2005): Slow and Fast Markets Journal of Economics and Business 57 + * (6) 576-593 + *
  • + *
  • + * Weiss, D. (2006): After the Trade is Made: Processing Securities Transactions Portfolio + * Publishing London UK + *
  • + *
  • + * Wikipedia (2021): Indifference Price https://en.wikipedia.org/wiki/Indifference_price + *
  • + *
+ * + *

+ * + * + * @author Lakshmi Krishnamurthy + */ + +public class ClaimsUtilityExpectationInferenceRun extends UtilityExpectationOptimizationRun +{ + private double _reservationValue = Double.NaN; + + /** + * ClaimsUtilityExpectationInferenceRun Constructor + * + * @param optimalValue Optimal Value of the Utility Expectation Optimization Run + * @param reservationValue Claims Reservation Value + * + * @throws Exception Thrown if the Inputs are Invalid + */ + + public ClaimsUtilityExpectationInferenceRun ( + final double optimalValue, + final double reservationValue) + throws Exception + { + super (optimalValue); + + if (!NumberUtil.IsValid (_reservationValue = reservationValue)) { + throw new Exception ( + "ClaimsUtilityExpectationInferenceRun Constructor => Invalid Reservation Value" + ); + } + } + + /** + * Retrieve the Claims Reservation Value + * + * @return Claims Reservation Value + */ + + public double reservationValue() + { + return _reservationValue; + } +} diff --git a/src/main/java/org/drip/oms/indifference/ReservationPricer.java b/src/main/java/org/drip/oms/indifference/ReservationPricer.java index f1800263c4e..77708cddb29 100644 --- a/src/main/java/org/drip/oms/indifference/ReservationPricer.java +++ b/src/main/java/org/drip/oms/indifference/ReservationPricer.java @@ -2,6 +2,7 @@ package org.drip.oms.indifference; import org.drip.measure.continuous.R1Univariate; +import org.drip.measure.discrete.R1Distribution; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -175,12 +176,23 @@ public InventoryVertex optimalNoClaimsInventoryVertex() } /** - * Retrieve the Optimal Claims Based Inventory Vertex + * Retrieve the Optimal Bid Claims Based Inventory Vertex * - * @return Optimal Claims Based Inventory Vertex + * @return Optimal Bid Claims Based Inventory Vertex */ - public InventoryVertex optimalClaimsInventoryVertex() + public InventoryVertex optimalBidClaimsInventoryVertex() + { + return _inventoryVertex; + } + + /** + * Retrieve the Optimal Ask Claims Based Inventory Vertex + * + * @return Optimal Ask Claims Based Inventory Vertex + */ + + public InventoryVertex optimalAskClaimsInventoryVertex() { return _inventoryVertex; } @@ -206,13 +218,40 @@ public double noClaimsInventoryUtilityExpectation ( null, optimalNoClaimsInventoryVertex(), moneyMarketPrice - ).optimalValue (underlierPriceDistribution, 0.); + ).optimizationRun (underlierPriceDistribution, 0.).optimalValue(); + } + + /** + * Compute the No-Claims Inventory-based Optimal Utility Value + * + * @param underlierPriceDistribution Discrete Underlier Price Distribution + * @param underlierPriceArray Underlier Price Array + * @param moneyMarketPrice Price of Money Market Entity + * + * @return The No-Claims Inventory-based Optimal Utility Value + * + * @throws Exception Thrown if the No-Claims Inventory-based Optimal Utility Value cannot be calculated + */ + + public double noClaimsInventoryUtilityExpectation ( + final R1Distribution underlierPriceDistribution, + final double[] underlierPriceArray, + final double moneyMarketPrice) + throws Exception + { + return new UtilityFunctionExpectation ( + _utilityFunction, + null, + optimalNoClaimsInventoryVertex(), + moneyMarketPrice + ).optimizationRun (underlierPriceDistribution, underlierPriceArray, 0.).optimalValue(); } /** * Compute the Bid Claims Inventory-based Position Value Adjustment * * @param underlierPriceDistribution Discrete Underlier Price Distribution + * @param moneyMarketPrice Price of Money Market Entity * @param noClaimsInventoryUtilityExpectation No-Claims Inventory Utility Expectation * * @return The Bid Claims Inventory-based Position Value Adjustment @@ -227,18 +266,69 @@ public double bidClaimsPositionValueAdjustment ( final double noClaimsInventoryUtilityExpectation) throws Exception { - return new UtilityFunctionExpectation ( - _utilityFunction, - _bidClaimsPositionPricer, - optimalClaimsInventoryVertex(), - moneyMarketPrice - ).inferPositionValueAdjustment (underlierPriceDistribution, noClaimsInventoryUtilityExpectation); + ClaimsUtilityExpectationInferenceRun claimsUtilityExpectationInferenceRun = + new UtilityFunctionExpectation ( + _utilityFunction, + _bidClaimsPositionPricer, + optimalBidClaimsInventoryVertex(), + moneyMarketPrice + ).inferPositionAdjustment ( + underlierPriceDistribution, + noClaimsInventoryUtilityExpectation + ); + + if (null == claimsUtilityExpectationInferenceRun) { + throw new Exception (" Cannot generate Claims Utility Expectation Inference Run"); + } + + return claimsUtilityExpectationInferenceRun.optimalValue(); + } + + /** + * Compute the Bid Claims Inventory-based Position Value Adjustment + * + * @param underlierPriceDistribution Discrete Underlier Price Distribution + * @param underlierPriceArray Underlier Price Array + * @param moneyMarketPrice Price of Money Market Entity + * @param noClaimsInventoryUtilityExpectation No-Claims Inventory Utility Expectation + * + * @return The Bid Claims Inventory-based Position Value Adjustment + * + * @throws Exception Thrown if the Bid Claims Inventory-based Position Value Adjustment cannot be + * calculated + */ + + public double bidClaimsPositionValueAdjustment ( + final R1Distribution underlierPriceDistribution, + final double[] underlierPriceArray, + final double moneyMarketPrice, + final double noClaimsInventoryUtilityExpectation) + throws Exception + { + ClaimsUtilityExpectationInferenceRun claimsUtilityExpectationInferenceRun = + new UtilityFunctionExpectation ( + _utilityFunction, + _bidClaimsPositionPricer, + optimalBidClaimsInventoryVertex(), + moneyMarketPrice + ).inferPositionAdjustment ( + underlierPriceDistribution, + underlierPriceArray, + noClaimsInventoryUtilityExpectation + ); + + if (null == claimsUtilityExpectationInferenceRun) { + throw new Exception (" Cannot generate Claims Utility Expectation Inference Run"); + } + + return claimsUtilityExpectationInferenceRun.optimalValue(); } /** * Compute the Ask Claims Inventory-based Position Value Adjustment * * @param underlierPriceDistribution Discrete Underlier Price Distribution + * @param moneyMarketPrice Price of Money Market Entity * @param noClaimsInventoryUtilityExpectation No-Claims Inventory Utility Expectation * * @return The Ask Claims Inventory-based Position Value Adjustment @@ -253,19 +343,144 @@ public double askClaimsPositionValueAdjustment ( final double noClaimsInventoryUtilityExpectation) throws Exception { - return new UtilityFunctionExpectation ( - _utilityFunction, - _askClaimsPositionPricer, - optimalClaimsInventoryVertex(), - moneyMarketPrice - ).inferPositionValueAdjustment (underlierPriceDistribution, noClaimsInventoryUtilityExpectation); + ClaimsUtilityExpectationInferenceRun claimsUtilityExpectationInferenceRun = + new UtilityFunctionExpectation ( + _utilityFunction, + _bidClaimsPositionPricer, + optimalBidClaimsInventoryVertex(), + moneyMarketPrice + ).inferPositionAdjustment ( + underlierPriceDistribution, + noClaimsInventoryUtilityExpectation + ); + + if (null == claimsUtilityExpectationInferenceRun) { + throw new Exception (" Cannot generate Claims Utility Expectation Inference Run"); + } + + return claimsUtilityExpectationInferenceRun.optimalValue(); } + /** + * Compute the Ask Claims Inventory-based Position Value Adjustment + * + * @param underlierPriceDistribution Discrete Underlier Price Distribution + * @param underlierPriceArray Underlier Price Array + * @param moneyMarketPrice Price of Money Market Entity + * @param noClaimsInventoryUtilityExpectation No-Claims Inventory Utility Expectation + * + * @return The Ask Claims Inventory-based Position Value Adjustment + * + * @throws Exception Thrown if the Bid Claims Inventory-based Position Value Adjustment cannot be + * calculated + */ + + public double askClaimsPositionValueAdjustment ( + final R1Distribution underlierPriceDistribution, + final double[] underlierPriceArray, + final double moneyMarketPrice, + final double noClaimsInventoryUtilityExpectation) + throws Exception + { + ClaimsUtilityExpectationInferenceRun claimsUtilityExpectationInferenceRun = + new UtilityFunctionExpectation ( + _utilityFunction, + _askClaimsPositionPricer, + optimalAskClaimsInventoryVertex(), + moneyMarketPrice + ).inferPositionAdjustment ( + underlierPriceDistribution, + underlierPriceArray, + noClaimsInventoryUtilityExpectation + ); + + if (null == claimsUtilityExpectationInferenceRun) { + throw new Exception (" Cannot generate Claims Utility Expectation Inference Run"); + } + + return claimsUtilityExpectationInferenceRun.optimalValue(); + } + + /** + * Run a Reservation Pricing Flow + * + * @param underlierPriceDistribution Discrete Underlier Price Distribution + * @param moneyMarketPrice Price of Money Market Entity + * + * @return Reservation Pricing Flow + */ + public ReservationPricingRun reservationPricingRun ( final R1Univariate underlierPriceDistribution, final double moneyMarketPrice) - throws Exception { + try { + double noClaimsInventoryUtilityExpectation = noClaimsInventoryUtilityExpectation ( + underlierPriceDistribution, + moneyMarketPrice + ); + + return new ReservationPricingRun ( + bidClaimsPositionValueAdjustment ( + underlierPriceDistribution, + moneyMarketPrice, + noClaimsInventoryUtilityExpectation + ), + askClaimsPositionValueAdjustment ( + underlierPriceDistribution, + moneyMarketPrice, + noClaimsInventoryUtilityExpectation + ), + noClaimsInventoryUtilityExpectation + ); + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } + + /** + * Run a Reservation Pricing Flow + * + * @param underlierPriceDistribution Discrete Underlier Price Distribution + * @param underlierPriceArray Underlier Price Array + * @param moneyMarketPrice Price of Money Market Entity + * + * @return Reservation Pricing Flow + */ + + public ReservationPricingRun reservationPricingRun ( + final R1Distribution underlierPriceDistribution, + final double[] underlierPriceArray, + final double moneyMarketPrice) + { + try { + double noClaimsInventoryUtilityExpectation = noClaimsInventoryUtilityExpectation ( + underlierPriceDistribution, + underlierPriceArray, + moneyMarketPrice + ); + + return new ReservationPricingRun ( + bidClaimsPositionValueAdjustment ( + underlierPriceDistribution, + underlierPriceArray, + moneyMarketPrice, + noClaimsInventoryUtilityExpectation + ), + askClaimsPositionValueAdjustment ( + underlierPriceDistribution, + underlierPriceArray, + moneyMarketPrice, + noClaimsInventoryUtilityExpectation + ), + noClaimsInventoryUtilityExpectation + ); + } catch (Exception e) { + e.printStackTrace(); + } + return null; } } diff --git a/src/main/java/org/drip/oms/indifference/ReservationPricingRun.java b/src/main/java/org/drip/oms/indifference/ReservationPricingRun.java index c4af6287bfc..49c26736bb8 100644 --- a/src/main/java/org/drip/oms/indifference/ReservationPricingRun.java +++ b/src/main/java/org/drip/oms/indifference/ReservationPricingRun.java @@ -122,17 +122,21 @@ public class ReservationPricingRun * * @param bidPrivateValue Bid Reservation Value * @param askPrivateValue Ask Reservation Value + * @param noClaimsInventoryUtilityExpectation No-Claims Inventory Utility Expectation * * @throws Exception Thrown if the Private Values are Invalid */ public ReservationPricingRun ( final double bidPrivateValue, - final double askPrivateValue) + final double askPrivateValue, + final double noClaimsInventoryUtilityExpectation) throws Exception { if (!NumberUtil.IsValid (_bidPrivateValue = bidPrivateValue) || - !NumberUtil.IsValid (_askPrivateValue = askPrivateValue)) { + !NumberUtil.IsValid (_askPrivateValue = askPrivateValue) || + !NumberUtil.IsValid (_noClaimsInventoryUtilityExpectation = noClaimsInventoryUtilityExpectation)) + { throw new Exception ("ReservationPricingRun Constructor => Invalid Inputs"); } } @@ -158,4 +162,15 @@ public double askPrivateValue() { return _askPrivateValue; } + + /** + * Retrieve the No-Claims Inventory Utility Expectation + * + * @return No-Claims Inventory Utility Expectation + */ + + public double noClaimsInventoryUtilityExpectation() + { + return _noClaimsInventoryUtilityExpectation; + } } diff --git a/src/main/java/org/drip/oms/indifference/UtilityExpectationOptimizationRun.java b/src/main/java/org/drip/oms/indifference/UtilityExpectationOptimizationRun.java new file mode 100644 index 00000000000..24a903b76a0 --- /dev/null +++ b/src/main/java/org/drip/oms/indifference/UtilityExpectationOptimizationRun.java @@ -0,0 +1,146 @@ + +package org.drip.oms.indifference; + +import org.drip.numerical.common.NumberUtil; + +/* + * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ + +/*! + * Copyright (C) 2024 Lakshmi Krishnamurthy + * + * This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics, + * asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment + * analytics, and portfolio construction analytics within and across fixed income, credit, commodity, + * equity, FX, and structured products. It also includes auxiliary libraries for algorithm support, + * numerical analysis, numerical optimization, spline builder, model validation, statistical learning, + * graph builder/navigator, and computational support. + * + * https://lakshmidrip.github.io/DROP/ + * + * DROP is composed of three modules: + * + * - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/ + * - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/ + * - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/ + * + * DROP Product Core implements libraries for the following: + * - Fixed Income Analytics + * - Loan Analytics + * - Transaction Cost Analytics + * + * DROP Portfolio Core implements libraries for the following: + * - Asset Allocation Analytics + * - Asset Liability Management Analytics + * - Capital Estimation Analytics + * - Exposure Analytics + * - Margin Analytics + * - XVA Analytics + * + * DROP Computational Core implements libraries for the following: + * - Algorithm Support + * - Computation Support + * - Function Analysis + * - Graph Algorithm + * - Model Validation + * - Numerical Analysis + * - Numerical Optimizer + * - Spline Builder + * - Statistical Learning + * + * Documentation for DROP is Spread Over: + * + * - Main => https://lakshmidrip.github.io/DROP/ + * - Wiki => https://github.com/lakshmiDRIP/DROP/wiki + * - GitHub => https://github.com/lakshmiDRIP/DROP + * - Repo Layout Taxonomy => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md + * - Javadoc => https://lakshmidrip.github.io/DROP/Javadoc/index.html + * - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal + * - Release Versions => https://lakshmidrip.github.io/DROP/version.html + * - Community Credits => https://lakshmidrip.github.io/DROP/credits.html + * - Issues Catalog => https://github.com/lakshmiDRIP/DROP/issues + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * UtilityExpectationOptimizationRun holds the Results of the Optimal Expectation Run of the Agent + * Utility Function. The References are: + * + *

+ *
    + *
  • + * Birge, J. R. (2008): Financial Engineering Elsevier Amsterdam Netherlands + *
  • + *
  • + * Carmona, R. (2009): Indifference Pricing: Theory and Applications Princeton + * University Press Princeton NJ + *
  • + *
  • + * Vassilis, P. (2005): Slow and Fast Markets Journal of Economics and Business 57 + * (6) 576-593 + *
  • + *
  • + * Weiss, D. (2006): After the Trade is Made: Processing Securities Transactions Portfolio + * Publishing London UK + *
  • + *
  • + * Wikipedia (2021): Indifference Price https://en.wikipedia.org/wiki/Indifference_price + *
  • + *
+ * + *

+ * + * + * @author Lakshmi Krishnamurthy + */ + +public class UtilityExpectationOptimizationRun +{ + private double _optimalValue = Double.NaN; + + /** + * UtilityExpectationOptimizationRun Constructor + * + * @param optimalValue Optimal Value of the Utility Expectation Optimization Run + * + * @throws Exception Thrown if Inputs are Invalid + */ + + public UtilityExpectationOptimizationRun ( + final double optimalValue) + throws Exception + { + if (!NumberUtil.IsValid (_optimalValue = optimalValue)) { + throw new Exception ("UtilityExpectationOptimizationRun Constructor => Invalid Optimal Value"); + } + } + + /** + * Retrieve the Optimal Value of the Utility Expectation Optimization Run + * + * @return Optimal Value of the Utility Expectation Optimization Run + */ + + public double optimalValue() + { + return _optimalValue; + } +} diff --git a/src/main/java/org/drip/oms/indifference/UtilityFunctionExpectation.java b/src/main/java/org/drip/oms/indifference/UtilityFunctionExpectation.java index dd07b1996f5..6bdabf4c46d 100644 --- a/src/main/java/org/drip/oms/indifference/UtilityFunctionExpectation.java +++ b/src/main/java/org/drip/oms/indifference/UtilityFunctionExpectation.java @@ -223,173 +223,182 @@ public double agentObjectiveValue ( } /** - * Compute the Optimal Expectation of the Agent Utility Function given the Underlier Price Array and + * Generate the Utility Expectation Optimization Run given the Underlier Price Array and * Discrete Distribution * * @param underlierPriceDistribution Discrete Underlier Price Distribution * @param underlierPriceArray Underlier Price Array * @param positionValueAdjustment Position Value Adjustment * - * @return Expectation of the Agent Utility Function - * - * @throws Exception Thrown if the Inputs are Invalid + * @return The Utility Expectation Optimization Run Results */ - public double optimalValue ( + public UtilityExpectationOptimizationRun optimizationRun ( final R1Distribution underlierPriceDistribution, final double[] underlierPriceArray, final double positionValueAdjustment) - throws Exception { if (null == underlierPriceDistribution || null == underlierPriceArray || 0 == underlierPriceArray.length) { - throw new Exception ("UtilityFunctionExpectation::evaluate => Invalid Inputs"); + return null; } - double utilityFunctionExpectationValue = 0.; + try { + double utilityFunctionExpectationValue = 0.; - for (double underlierPrice : underlierPriceArray) { - utilityFunctionExpectationValue += underlierPriceDistribution.probability (underlierPrice) * - agentObjectiveValue (underlierPrice, positionValueAdjustment); + for (double underlierPrice : underlierPriceArray) { + utilityFunctionExpectationValue += underlierPriceDistribution.probability (underlierPrice) * + agentObjectiveValue (underlierPrice, positionValueAdjustment); + } + + return new UtilityExpectationOptimizationRun (utilityFunctionExpectationValue); + } catch (Exception e) { + e.printStackTrace(); } - return utilityFunctionExpectationValue; + return null; } /** - * Infer the Position Value Adjustment given the Target Utility Expectation Value + * Run the Position Value Inference for the Claims given the Target Utility Expectation Value * * @param underlierPriceDistribution Discrete Underlier Price Distribution * @param targetUtilityExpectationValue Target Utility Expectation Value * - * @return The Position Value Adjustment - * - * @throws Exception Thrown if the Position Value Adjustment cannot be inferred + * @return Claims Position Value Inference */ - public double inferPositionValueAdjustment ( + public ClaimsUtilityExpectationInferenceRun inferPositionAdjustment ( final R1Distribution underlierPriceDistribution, final double[] underlierPriceArray, final double targetUtilityExpectationValue) - throws Exception { if (null == underlierPriceDistribution || !NumberUtil.IsValid (targetUtilityExpectationValue)) { - throw new Exception ( - "UtilityFunctionExpectation::inferPositionValueAdjustment => Invalid Inputs" - ); + return null; } - FixedPointFinderOutput fixedPointFinderOutput = new FixedPointFinderBrent ( - 0., - new R1ToR1 (null) { - @Override public double evaluate ( - final double positionValueAdjustment) - throws Exception - { - return optimalValue ( - underlierPriceDistribution, - underlierPriceArray, - positionValueAdjustment - ) - targetUtilityExpectationValue; - } - }, - false - ).findRoot ( - InitializationHeuristics.FromBracketingMidHint ( - optimalValue (underlierPriceDistribution, underlierPriceArray, 0.) - - targetUtilityExpectationValue - ) - ); - - if (null == fixedPointFinderOutput || !fixedPointFinderOutput.containsRoot()) { - throw new Exception ( - "UtilityFunctionExpectation::inferPositionValueAdjustment => Cannot Infer Root" + try { + FixedPointFinderOutput fixedPointFinderOutput = new FixedPointFinderBrent ( + 0., + new R1ToR1 (null) { + @Override public double evaluate ( + final double positionValueAdjustment) + throws Exception + { + return optimizationRun ( + underlierPriceDistribution, + underlierPriceArray, + positionValueAdjustment + ).optimalValue() - targetUtilityExpectationValue; + } + }, + false + ).findRoot ( + InitializationHeuristics.FromBracketingMidHint ( + optimizationRun (underlierPriceDistribution, underlierPriceArray, 0.).optimalValue() - + targetUtilityExpectationValue + ) ); + + return null == fixedPointFinderOutput || !fixedPointFinderOutput.containsRoot() ? null : + new ClaimsUtilityExpectationInferenceRun ( + targetUtilityExpectationValue, + fixedPointFinderOutput.getRoot() + ); + } catch (Exception e) { + e.printStackTrace(); } - return fixedPointFinderOutput.getRoot(); + return null; } /** - * Compute the Optimal Expectation of the Agent Utility Function given the Underlier Price Array and - * Discrete Distribution + * Generate the Utility Expectation Optimization Run given the Underlier Price Distribution * * @param underlierPriceDistribution Discrete Underlier Price Distribution * @param positionValueAdjustment Position Value Adjustment * - * @return Expectation of the Agent Utility Function - * - * @throws Exception Thrown if the Inputs are Invalid + * @return Utility Expectation Optimization Run */ - public double optimalValue ( + public UtilityExpectationOptimizationRun optimizationRun ( final R1Univariate underlierPriceDistribution, final double positionValueAdjustment) - throws Exception { if (null == underlierPriceDistribution) { - throw new Exception ("UtilityFunctionExpectation::evaluate => Invalid Inputs"); + return null; } - return NewtonCotesQuadratureGenerator.GaussLaguerreLeftDefinite (0., 100).integrate ( - new R1ToR1 (null) { - @Override public double evaluate ( - final double underlierPrice) - throws Exception - { - return underlierPriceDistribution.density (underlierPrice) * - agentObjectiveValue (underlierPrice, positionValueAdjustment); - } - } - ); + try { + return new UtilityExpectationOptimizationRun ( + NewtonCotesQuadratureGenerator.GaussLaguerreLeftDefinite (0., 100).integrate ( + new R1ToR1 (null) { + @Override public double evaluate ( + final double underlierPrice) + throws Exception + { + return underlierPriceDistribution.density (underlierPrice) * + agentObjectiveValue (underlierPrice, positionValueAdjustment); + } + } + ) + ); + } catch (Exception e) { + e.printStackTrace(); + } + + return null; } /** - * Infer the Position Value Adjustment given the Target Utility Expectation Value + * Run the Position Adjustment Inference for the Claims given the Target Utility Expectation Value * * @param underlierPriceDistribution Discrete Underlier Price Distribution * @param targetUtilityExpectationValue Target Utility Expectation Value * - * @return The Position Value Adjustment - * - * @throws Exception Thrown if the Position Value Adjustment cannot be inferred + * @return The Position Adjustment Inference Run */ - public double inferPositionValueAdjustment ( + public ClaimsUtilityExpectationInferenceRun inferPositionAdjustment ( final R1Univariate underlierPriceDistribution, final double targetUtilityExpectationValue) throws Exception { if (null == underlierPriceDistribution || !NumberUtil.IsValid (targetUtilityExpectationValue)) { - throw new Exception ( - "UtilityFunctionExpectation::inferPositionValueAdjustment => Invalid Inputs" - ); + return null; } - FixedPointFinderOutput fixedPointFinderOutput = new FixedPointFinderBrent ( - 0., - new R1ToR1 (null) { - @Override public double evaluate ( - final double positionValueAdjustment) - throws Exception - { - return optimalValue (underlierPriceDistribution, positionValueAdjustment) - - targetUtilityExpectationValue; - } - }, - false - ).findRoot ( - InitializationHeuristics.FromBracketingMidHint ( - optimalValue (underlierPriceDistribution, 0.) - targetUtilityExpectationValue - ) - ); - - if (null == fixedPointFinderOutput || !fixedPointFinderOutput.containsRoot()) { - throw new Exception ( - "UtilityFunctionExpectation::inferPositionValueAdjustment => Cannot Infer Root" + try { + FixedPointFinderOutput fixedPointFinderOutput = new FixedPointFinderBrent ( + 0., + new R1ToR1 (null) { + @Override public double evaluate ( + final double positionValueAdjustment) + throws Exception + { + return optimizationRun ( + underlierPriceDistribution, + positionValueAdjustment + ).optimalValue() - targetUtilityExpectationValue; + } + }, + false + ).findRoot ( + InitializationHeuristics.FromBracketingMidHint ( + optimizationRun (underlierPriceDistribution, 0.).optimalValue() - + targetUtilityExpectationValue + ) ); + + return null == fixedPointFinderOutput || !fixedPointFinderOutput.containsRoot() ? null : + new ClaimsUtilityExpectationInferenceRun ( + targetUtilityExpectationValue, + fixedPointFinderOutput.getRoot() + ); + } catch (Exception e) { + e.printStackTrace(); } - return fixedPointFinderOutput.getRoot(); + return null; } }