45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using YLErp.Modules.VolatilityModule;
|
|
|
|
namespace YLErp.Modules.CalcModules
|
|
{
|
|
[TestClass]
|
|
public class ImpliedVolCalcTest
|
|
{
|
|
[TestMethod]
|
|
public void TestMethod1()
|
|
{
|
|
var ValueDate = new DateTime(2023, 2, 27);
|
|
var tradeObj = new trade
|
|
{
|
|
TradeType = "场内期权",
|
|
UnderlyingCode = "CF305",
|
|
UnderlyingId = 0,
|
|
TradeDate = ValueDate,
|
|
BuySell = "买入",
|
|
StartDate = ValueDate,
|
|
ExerciseDate = new DateTime(2023, 4, 6),
|
|
MaturityDate = new DateTime(2023, 4, 6),
|
|
TradePrice = 151,
|
|
TradeStatus = "确认成交",
|
|
ExerciseMode = "European",
|
|
OptionType = "看跌",
|
|
Strike = 14000,
|
|
Notional = 1,
|
|
UnderlyingInstrumentType = ConsGlobal.InstrumentType.CommodityFutures,
|
|
ExchangeOptionCode = "CF305P14000",
|
|
AssetId = 0,
|
|
id = 0,
|
|
UnderlyingAssetClass = "CF",
|
|
|
|
//用于反算隐含波动率
|
|
StructureType = "场内期权",
|
|
TradeSinglePrice = 151
|
|
};
|
|
|
|
var volValue = 100 * VolatilityHelper.GetImpliedVol(ValueDate, tradeObj, null, 14295, true);
|
|
|
|
Assert.IsTrue(volValue > 15 && volValue < 17);
|
|
}
|
|
}
|
|
}
|