64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
using Qdp.Pricing.Library.Options.Products.Asian;
|
|
using YLErp.BLL;
|
|
|
|
namespace YLErp.Modules.CalculationModule
|
|
{
|
|
/// <summary>
|
|
/// 亚式期权计算帮助类
|
|
/// </summary>
|
|
public static class AsianOptionCalcHelper
|
|
{
|
|
/// <summary>
|
|
/// 获取亚式期权均价
|
|
/// </summary>
|
|
public static double GetAveragePrice(OtcTradeBase trade, trade_asian_option asiaOption, double price, DateTime valueDate, out int fixingCount)
|
|
{
|
|
fixingCount = 0;
|
|
|
|
var startDate = asiaOption?.AveragingPeriodStartDate ?? trade.TradeDate.Value;
|
|
|
|
//均价起算日大于结算日的情况下取计值日
|
|
if (startDate > valueDate)
|
|
{
|
|
return price;
|
|
}
|
|
|
|
if (startDate == valueDate)
|
|
{
|
|
fixingCount = 1;
|
|
return price;
|
|
}
|
|
|
|
var fixings = AsianOptionFixingService.GetFixingString(valueDate, trade, asiaOption);
|
|
|
|
if (string.IsNullOrEmpty(fixings))
|
|
{
|
|
return price;
|
|
}
|
|
|
|
var req = new OptionTradeParamRequest(valuedateBLL.SysRiskFreeRate())
|
|
{
|
|
tradeId = trade.TradeNumber,
|
|
fixings = fixings,
|
|
hasNightMarket = false,
|
|
maturityShift = 0,
|
|
ParamOverride = null,
|
|
preciseTimeMode = false,
|
|
timeToMaturityDays = double.NaN,
|
|
volSurfaceNames = null
|
|
};
|
|
|
|
var QdpTrade = QdpTradeBuilder.GetAsianOptionTrade(trade, asiaOption, req);
|
|
|
|
if (QdpTrade != null && QdpTrade.Instrument != null && QdpTrade.Instrument is AsianOption asianOpt)
|
|
{
|
|
fixingCount = asianOpt.Fixings.Count;
|
|
|
|
return asiaOption.StrikeType == "Floating" ? asianOpt.ActualStrike : asianOpt.FinalPrice();
|
|
}
|
|
|
|
return price;
|
|
}
|
|
}
|
|
}
|