-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- CSA Enforced Stream Path Exposures (1) - Client To Dealer Trade Payment (7, 8) - Float Coupon Stream Shell Skeleton (29, 30) - Float Coupon Stream VM Trade (31, 32) Bug Fixes/Clean-up: - MPoR To Calibration To Timeline (41, 42) - Float Coupon Stream Fix #1 (49, 50) - Float Coupon Stream Fix #2 (51, 52) Samples: - Fixed Coupon Classical Plus MPoR (2) - Classical+ Positive Exposure #1 (3, 4) - Classical+ Positive Exposure #2 (5, 6) - Classical+ Collateralized Exposure #1 (9, 10) - Classical+ Collateralized Exposure #2 (11, 12) - Classical+ Collateralized Positive Exposure #1 (13, 14) - Classical+ Collateralized Positive Exposure #2 (15, 16) - Variation Margin Gap #1 (17, 18) - Variation Margin Gap #2 (19, 20) - Classical+ Positive Exposure #3 (21) - Fixed Coupon Classical Minus MPoR (22, 23) - Long/Short Stream APS2017 MPoR (24) - Long Fixed Aggressive MPoR (25, 26) - Long Fixed Conservative MPoR (27, 28) - Short Fixed Classical+ MPoR (33, 34) - Short Fixed Classical- MPoR (35, 36) - Short Fixed Aggressive MPoR (37, 38) - Short Fixed Conservative MPoR (39, 40) - Long Float Classical Plus Time #1 (43, 44) - Long Float Classical Plus Time #2 (45, 46) - Long Float Classical Plus Time #3 (47, 48) - Long Float Classical Plus Time #4 (53, 54) - Long Float Classical Plus Time #5 (55, 56) - Long Float Classical Plus Time #6 (57, 58) - Long Float Classical Plus Time #7 (59, 60)
- Loading branch information
1 parent
3e3378f
commit e9a9b46
Showing
17 changed files
with
5,211 additions
and
64 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
Features: | ||
|
||
- CSA Enforced Stream Path Exposures (1) | ||
- Client To Dealer Trade Payment (7, 8) | ||
- Float Coupon Stream Shell Skeleton (29, 30) | ||
- Float Coupon Stream VM Trade (31, 32) | ||
|
||
|
||
Bug Fixes/Clean-up: | ||
|
||
- MPoR To Calibration To Timeline (41, 42) | ||
- Float Coupon Stream Fix #1 (49, 50) | ||
- Float Coupon Stream Fix #2 (51, 52) | ||
|
||
|
||
Samples: | ||
|
||
- Fixed Coupon Classical Plus MPoR (2) | ||
- Classical+ Positive Exposure #1 (3, 4) | ||
- Classical+ Positive Exposure #2 (5, 6) | ||
- Classical+ Collateralized Exposure #1 (9, 10) | ||
- Classical+ Collateralized Exposure #2 (11, 12) | ||
- Classical+ Collateralized Positive Exposure #1 (13, 14) | ||
- Classical+ Collateralized Positive Exposure #2 (15, 16) | ||
- Variation Margin Gap #1 (17, 18) | ||
- Variation Margin Gap #2 (19, 20) | ||
- Classical+ Positive Exposure #3 (21) | ||
- Fixed Coupon Classical Minus MPoR (22, 23) | ||
- Long/Short Stream APS2017 MPoR (24) | ||
- Long Fixed Aggressive MPoR (25, 26) | ||
- Long Fixed Conservative MPoR (27, 28) | ||
- Short Fixed Classical+ MPoR (33, 34) | ||
- Short Fixed Classical- MPoR (35, 36) | ||
- Short Fixed Aggressive MPoR (37, 38) | ||
- Short Fixed Conservative MPoR (39, 40) | ||
- Long Float Classical Plus Time #1 (43, 44) | ||
- Long Float Classical Plus Time #2 (45, 46) | ||
- Long Float Classical Plus Time #3 (47, 48) | ||
- Long Float Classical Plus Time #4 (53, 54) | ||
- Long Float Classical Plus Time #5 (55, 56) | ||
- Long Float Classical Plus Time #6 (57, 58) | ||
- Long Float Classical Plus Time #7 (59, 60) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
190 changes: 190 additions & 0 deletions
190
src/main/java/org/drip/exposure/mpor/FloatCouponStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
|
||
package org.drip.exposure.mpor; | ||
|
||
/* | ||
* -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | ||
*/ | ||
|
||
/*! | ||
* Copyright (C) 2018 Lakshmi Krishnamurthy | ||
* | ||
* This file is part of DRIP, a free-software/open-source library for buy/side financial/trading model | ||
* libraries targeting analysts and developers | ||
* https://lakshmidrip.github.io/DRIP/ | ||
* | ||
* DRIP is composed of four main libraries: | ||
* | ||
* - DRIP Fixed Income - https://lakshmidrip.github.io/DRIP-Fixed-Income/ | ||
* - DRIP Asset Allocation - https://lakshmidrip.github.io/DRIP-Asset-Allocation/ | ||
* - DRIP Numerical Optimizer - https://lakshmidrip.github.io/DRIP-Numerical-Optimizer/ | ||
* - DRIP Statistical Learning - https://lakshmidrip.github.io/DRIP-Statistical-Learning/ | ||
* | ||
* - DRIP Fixed Income: Library for Instrument/Trading Conventions, Treasury Futures/Options, | ||
* Funding/Forward/Overnight Curves, Multi-Curve Construction/Valuation, Collateral Valuation and XVA | ||
* Metric Generation, Calibration and Hedge Attributions, Statistical Curve Construction, Bond RV | ||
* Metrics, Stochastic Evolution and Option Pricing, Interest Rate Dynamics and Option Pricing, LMM | ||
* Extensions/Calibrations/Greeks, Algorithmic Differentiation, and Asset Backed Models and Analytics. | ||
* | ||
* - DRIP Asset Allocation: Library for model libraries for MPT framework, Black Litterman Strategy | ||
* Incorporator, Holdings Constraint, and Transaction Costs. | ||
* | ||
* - DRIP Numerical Optimizer: Library for Numerical Optimization and Spline Functionality. | ||
* | ||
* - DRIP Statistical Learning: Library for Statistical Evaluation and Machine Learning. | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* FloatCouponStream estimates the Variation Margin and the Trade Payments for the given Float Coupon Stream | ||
* off of the Realized Market Path. The References are: | ||
* | ||
* - Andersen, L. B. G., M. Pykhtin, and A. Sokol (2017): Re-thinking Margin Period of Risk, | ||
* https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2902737, eSSRN. | ||
* | ||
* - Andersen, L. B. G., M. Pykhtin, and A. Sokol (2017): Credit Exposure in the Presence of Initial Margin, | ||
* https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2806156, eSSRN. | ||
* | ||
* - Albanese, C., and L. Andersen (2014): Accounting for OTC Derivatives: Funding Adjustments and the | ||
* Re-Hypothecation Option, eSSRN, https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2482955. | ||
* | ||
* - Burgard, C., and M. Kjaer (2017): Derivatives Funding, Netting, and Accounting, eSSRN, | ||
* https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2534011. | ||
* | ||
* - Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing, Risk | ||
* 21 (2) 97-102. | ||
* | ||
* @author Lakshmi Krishnamurthy | ||
*/ | ||
|
||
public class FloatCouponStream implements org.drip.exposure.mpor.MarginTradeVertex | ||
{ | ||
private double _notional = java.lang.Double.NaN; | ||
private org.drip.product.rates.Stream _stream = null; | ||
|
||
/** | ||
* FloatCouponStream Constructor | ||
* | ||
* @param stream The Fixed Coupon Stream Instance | ||
* @param notional The Fixed Coupon Stream Notional | ||
* | ||
* @throws java.lang.Exception Thrown if the Inputs are Invalid | ||
*/ | ||
|
||
public FloatCouponStream ( | ||
final org.drip.product.rates.Stream stream, | ||
final double notional) | ||
throws java.lang.Exception | ||
{ | ||
if (null == (_stream = stream) || | ||
!org.drip.quant.common.NumberUtil.IsValid (_notional = notional)) | ||
{ | ||
throw new java.lang.Exception ("FloatCouponStream Constructor => Invalid Inputs"); | ||
} | ||
} | ||
|
||
@Override public double variationMarginEstimate ( | ||
final int forwardDate, | ||
final org.drip.exposure.universe.MarketPath marketPath) | ||
throws java.lang.Exception | ||
{ | ||
if (null == marketPath) | ||
{ | ||
throw new java.lang.Exception ("FloatCouponStream::variationMarginEstimate => Invalid Inputs"); | ||
} | ||
|
||
if (forwardDate <= _stream.effective().julian() || forwardDate >= _stream.maturity().julian()) | ||
{ | ||
return 0.; | ||
} | ||
|
||
double variationMarginEstimate = 0.; | ||
|
||
double overnightReplicatorForward = marketPath.marketVertex (forwardDate).overnightReplicator(); | ||
|
||
for (org.drip.analytics.cashflow.CompositePeriod period : _stream.periods()) | ||
{ | ||
int periodEndDate = period.endDate(); | ||
|
||
if (periodEndDate < forwardDate) | ||
{ | ||
continue; | ||
} | ||
|
||
org.drip.analytics.cashflow.ComposableUnitFloatingPeriod composableUnitFloatingPeriod = | ||
(org.drip.analytics.cashflow.ComposableUnitFloatingPeriod) period.periods().get (0); | ||
|
||
variationMarginEstimate += period.couponDCF() * | ||
period.notional (periodEndDate) * | ||
marketPath.marketVertex | ||
(composableUnitFloatingPeriod.referenceIndexPeriod().fixingDate()).positionManifestValue() * | ||
period.couponFactor (periodEndDate) * | ||
overnightReplicatorForward / | ||
marketPath.marketVertex (period.payDate()).overnightReplicator(); | ||
} | ||
|
||
return variationMarginEstimate * _notional; | ||
} | ||
|
||
@Override public org.drip.exposure.mpor.TradePayment tradePayment ( | ||
final int forwardDate, | ||
final org.drip.exposure.universe.MarketPath marketPath) | ||
{ | ||
if (null == marketPath) | ||
{ | ||
return null; | ||
} | ||
|
||
if (forwardDate < _stream.effective().julian() || forwardDate > _stream.maturity().julian()) | ||
{ | ||
return org.drip.exposure.mpor.TradePayment.Standard (0.); | ||
} | ||
|
||
double overnightReplicatorForward = marketPath.marketVertex (forwardDate).overnightReplicator(); | ||
|
||
for (org.drip.analytics.cashflow.CompositePeriod period : _stream.periods()) | ||
{ | ||
int periodPayDate = period.payDate(); | ||
|
||
if (periodPayDate == forwardDate) | ||
{ | ||
int periodEndDate = period.endDate(); | ||
|
||
org.drip.analytics.cashflow.ComposableUnitFloatingPeriod composableUnitFloatingPeriod = | ||
(org.drip.analytics.cashflow.ComposableUnitFloatingPeriod) period.periods().get (0); | ||
|
||
try | ||
{ | ||
return org.drip.exposure.mpor.TradePayment.Standard ( | ||
_notional * period.couponDCF() * | ||
period.notional (periodEndDate) * | ||
marketPath.marketVertex | ||
(composableUnitFloatingPeriod.referenceIndexPeriod().fixingDate()).positionManifestValue() * | ||
period.couponFactor (periodEndDate) * | ||
overnightReplicatorForward / | ||
marketPath.marketVertex (period.payDate()).overnightReplicator() | ||
); | ||
} | ||
catch (java.lang.Exception e) | ||
{ | ||
e.printStackTrace(); | ||
|
||
return null; | ||
} | ||
} | ||
} | ||
|
||
return org.drip.exposure.mpor.TradePayment.Standard (0.); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
src/main/java/org/drip/sample/fixfloatexposure/package-info.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.