using YLErp.Modules.ApiModule.PricingModule;
namespace YLErp.Modules.ApiModule
{
[TestClass]
public class OptionPricingTest
{
///
/// 国信金阳,api算出9.47手,风险对冲页面9.04手,相差较大
///
[TestMethod]
public void TestGuoXinJinYang()
{
var req = new OptionPricingModelV2
{
TradeType = "亚式期权",
TradeSide = "Buy",
UnderlyingCode = "LH00",
ExerciseMode = "European",
OptionType = "看跌",
Strike = 23180,
StartDate = new DateTime(2022, 9, 1),
ExerciseDate = new DateTime(2022, 9, 30),
RiskFreeRate = 0,
DividendRate = 0,
ExtendFields = new Dictionary
{
{ "PayoffType", "EnhancedArithmeticAverage"},
{ "AveragingPeriodStartDate", "2022-09-01"},
{ "Fixings", "2022-09-01,23285;2022-09-02,23025;2022-09-05,23380;2022-09-06,23030;2022-09-07,23350;2022-09-08,22940"},
},
ValueDate = new DateTime(2022, 9, 9),
TTMDays = 15,
UnderlyingPrice = 22940,
VolValue = 0.25,
IsCalcGreeks = true,
Notional = 312d
};
var result = new OptionPricingApiService().GetOptionPrice(req);
var result2 = new
{
req.CalcId,
InitialMargin = result.initialMargin,
ContractSize = result.contractSize,
result.calcResult.Pv,
result.calcResult.Delta,
result.calcResult.Gamma,
result.calcResult.Vega,
result.calcResult.Theta,
result.calcResult.Rho,
result.calcResult.DeltaInLots
};
System.Diagnostics.Debug.WriteLine(JsonHelper.Serialize(result2));
}
}
}