Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- 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:
  • Loading branch information
Lakshmik committed Jan 21, 2024
1 parent 1de1193 commit 4105751
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 61 deletions.
37 changes: 37 additions & 0 deletions ReleaseNotes/05_25_2023.txt
Original file line number Diff line number Diff line change
@@ -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:
Binary file modified ScheduleSheet.xlsx
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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 -*-
*/
Expand Down Expand Up @@ -76,8 +74,8 @@
*/

/**
* <i>BidAskClaimsHandler</i> works the Bid/Ask Sided Claims Price using the Indifference Pricing Scheme. The
* References are:
* <i>ReservationPriceRun</i> captures the Results of a Claims Adjusted Indifference Pricing Run.
* The References are:
*
* <br><br>
* <ul>
Expand Down Expand Up @@ -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;
}
}
121 changes: 111 additions & 10 deletions src/main/java/org/drip/oms/indifference/ReservationPricer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -117,7 +119,7 @@

public class ReservationPricer
{
private BidAskClaimsHandler _bidAskClaimsHandler = null;
private R1ToR1 _payoffFunction = null;
private R1ToR1 _privateValuationObjectiveFunction = null;

/**
Expand All @@ -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,
Expand All @@ -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"
);
}

Expand All @@ -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);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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();

Expand Down
Loading

0 comments on commit 4105751

Please sign in to comment.