Skip to content

Commit

Permalink
Lookback
Browse files Browse the repository at this point in the history
  • Loading branch information
gavbrennan committed Jul 8, 2024
1 parent 5b59113 commit eb797f5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Qwack.Models/MCModels/AssetFxMCModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public void Initialize()
}
foreach (var product in _payoffs)
{
if (Settings.AvoidRegressionForBackPricing && (product.Value.AssetInstrument is Core.Instruments.Asset.BackPricingOption || product.Value.AssetInstrument is MultiPeriodBackpricingOption))
if (Settings.AvoidRegressionForBackPricing && (product.Value.AssetInstrument is BackPricingOption || product.Value.AssetInstrument is MultiPeriodBackpricingOption || product.Value.AssetInstrument is AsianLookbackOption))
product.Value.VanillaModel = VanillaModel;

Engine.AddPathProcess(product.Value);
Expand Down
23 changes: 19 additions & 4 deletions src/Qwack.Models/MCModels/AssetPathPayoff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ public IAssetFxModel VanillaModel
bpob.VanillaModel = value;
break;
case MultiPeriodBackpricingOption mpbpo:
var mbpob = _subInstruments.First() as Paths.Payoffs.MultiPeriodBackPricingOptionPP;
var mbpob = _subInstruments.First() as MultiPeriodBackPricingOptionPP;
mbpob.VanillaModel = value;
break;
case AsianLookbackOption lbo:
var albo = _subInstruments.First() as LookBackOptionPP;
albo.VanillaModel = value;
break;
}
}
}
Expand All @@ -96,11 +100,15 @@ public void SetRegressor(LinearAveragePriceRegressor regressor)
if (bpob.AverageRegressor == regressor) bpob.AverageRegressor = regressor;
break;
case MultiPeriodBackpricingOption mpbpo:
var mbpo = _subInstruments.First() as Paths.Payoffs.MultiPeriodBackPricingOptionPP;
var mbpo = _subInstruments.First() as MultiPeriodBackPricingOptionPP;
if (mbpo.SettlementRegressor == regressor) mbpo.SettlementRegressor = regressor;
for (var i = 0; i < mbpo.AverageRegressors.Length; i++)
if (mbpo.AverageRegressors[i] == regressor) mbpo.AverageRegressors[i] = regressor;
break;
case AsianLookbackOption albo:
var lbopp = _subInstruments.First() as LookBackOptionPP;
if (lbopp.SettlementRegressor == regressor) lbopp.SettlementRegressor = regressor;
break;
}
}

Expand Down Expand Up @@ -216,11 +224,18 @@ public AssetPathPayoff(IAssetInstrument assetInstrument, ICurrencyProvider curre
break;
case AsianLookbackOption alb:
var settleFixingDate = alb.SettlementFixingDates == null ? alb.SettlementDate.SubtractPeriod(RollType.P, alb.FixingCalendar, 2.Bd()) : DateTime.MinValue;

var albpp = new LookBackOptionPP(alb.AssetId, alb.FixingDates.ToList(), alb.CallPut, alb.DiscountCurve, alb.PaymentCurrency, alb.SettlementDate, alb.Notional, SimulationCcy, alb.DecisionDate, alb.SettlementFixingDates ?? new[] { settleFixingDate }, alb.WindowSize)
{
VanillaModel = VanillaModel
};
_subInstruments = new List<IAssetPathPayoff>
{
new LookBackOptionPP(alb.AssetId, alb.FixingDates.ToList(), alb.CallPut, alb.DiscountCurve, alb.PaymentCurrency, alb.SettlementDate, alb.Notional, SimulationCcy, alb.DecisionDate, alb.SettlementFixingDates ?? new[] { settleFixingDate }, alb.WindowSize)
albpp
};
if (albpp.SettlementRegressor != null)
Regressors = new[] { albpp.SettlementRegressor };
else
Regressors = Array.Empty<LinearAveragePriceRegressor>();
break;
case Core.Instruments.Asset.BackPricingOption bpo:
var bp = new Paths.Payoffs.BackPricingOption(bpo.AssetId, bpo.FixingDates.ToList(), bpo.DecisionDate, bpo.SettlementDate, bpo.SettlementDate, bpo.CallPut, bpo.DiscountCurve, bpo.PaymentCurrency, bpo.Notional, SimulationCcy)
Expand Down
2 changes: 1 addition & 1 deletion version.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<VersionPrefix>0.8.55</VersionPrefix>
<VersionPrefix>0.8.56</VersionPrefix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.55
0.8.56

0 comments on commit eb797f5

Please sign in to comment.