Skip to content

Commit

Permalink
Adds per-period premia to backpricing options
Browse files Browse the repository at this point in the history
  • Loading branch information
gavbrennan committed Jul 2, 2024
1 parent 979f019 commit 4c7b969
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class MultiPeriodBackpricingOption : IHasVega, IAssetInstrument
public int? DeclaredPeriod { get; set; }

public List<DateTime[]> FxFixingDates { get; set; }
public double[] PeriodPremia { get; set; }
public Currency PaymentCurrency { get; set; }
public FxConversionType FxConversionType { get; set; } = FxConversionType.None;
public string DiscountCurve { get; set; }
Expand Down Expand Up @@ -119,7 +120,8 @@ public Dictionary<string, List<DateTime>> PastFixingDates(DateTime valDate) => v
OffsetFixingId = OffsetFixingId,
ScaleStrike = ScaleStrike,
ScaleProportion = ScaleProportion,
MetaData = new(MetaData)
MetaData = new(MetaData),
PeriodPremia = PeriodPremia,
};

public IAssetInstrument SetStrike(double strike) => throw new InvalidOperationException();
Expand Down Expand Up @@ -163,6 +165,7 @@ public void FromTransportObject(TO_Instrument to_instrument, ICalendarProvider c
OffsetFixingId = to.OffsetFixingId;
ScaleProportion = to.ScaleProportion;
ScaleStrike = to.ScaleStrike;
PeriodPremia = to.PeriodPremia;
}

public TO_Instrument ToTransportObject() => new()
Expand Down Expand Up @@ -202,6 +205,7 @@ public void FromTransportObject(TO_Instrument to_instrument, ICalendarProvider c
ScaleProportion = ScaleProportion,
ScaleStrike = ScaleStrike,
MetaData = new(MetaData),
PeriodPremia = PeriodPremia,
}
};
}
Expand Down
10 changes: 6 additions & 4 deletions src/Qwack.Paths/Payoffs/MultiPeriodBackPricingOptionPP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.ServiceModel;
using Qwack.Core.Basic;
using Qwack.Core.Instruments;
using Qwack.Core.Models;
Expand All @@ -11,7 +10,6 @@
using Qwack.Paths.Features;
using Qwack.Paths.Regressors;
using Qwack.Transport.BasicTypes;
using Qwack.Transport.TransportObjects.Instruments.Funding;

namespace Qwack.Paths.Payoffs
{
Expand Down Expand Up @@ -51,6 +49,7 @@ public class MultiPeriodBackPricingOptionPP : IPathProcess, IRequiresFinish, IAs
private double? _scaleProportion;

private double[] _contangoScaleFactors;
private double[] _periodPremia;


private Vector<double>[][] _exercisedPeriod;
Expand Down Expand Up @@ -83,7 +82,8 @@ public MultiPeriodBackPricingOptionPP(string assetName,
int? declaredPeriod = null,
DateShifter dateShifter = null,
double? scaleStrike = null,
double? scaleProportion = null)
double? scaleProportion = null,
double[] periodPremia = null)
{
_avgDates = avgDates;
_decisionDate = decisionDate;
Expand All @@ -99,6 +99,8 @@ public MultiPeriodBackPricingOptionPP(string assetName,
_dateShifter = dateShifter;
_scaleStrike = scaleStrike;
_scaleProportion = scaleProportion;
_periodPremia = periodPremia ?? avgDates.Select(x => 0.0).ToArray(); //default to zero spreads

if (_ccy.Ccy != "USD")
_fxName = $"USD/{_ccy.Ccy}";

Expand Down Expand Up @@ -282,7 +284,7 @@ public void Process(IPathBlock block)
setReg[i] = SettlementRegressor?.Predict(spotAtExpiry[i]) ?? spotAtExpiry[i];
}
var futVec = new Vector<double>(futSum);
avgs[a] = (futVec + pastSum) / nTotalVec[a];
avgs[a] = (futVec + pastSum) / nTotalVec[a] + new Vector<double>(_periodPremia[a]);
}

avgVec = (_callPut == OptionType.C) ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public class TO_MultiPeriodBackpricingOption
public double? ScaleStrike { get; set; }
[ProtoMember(32)]
public double? ScaleProportion { get; set;}

[ProtoMember(33)]
public double[] PeriodPremia { get; set; }

}
}
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.44</VersionPrefix>
<VersionPrefix>0.8.45</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.44
0.8.45

0 comments on commit 4c7b969

Please sign in to comment.