本文整理汇总了Java中com.opengamma.analytics.financial.model.option.pricing.analytic.BlackScholesMertonModel类的典型用法代码示例。如果您正苦于以下问题:Java BlackScholesMertonModel类的具体用法?Java BlackScholesMertonModel怎么用?Java BlackScholesMertonModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlackScholesMertonModel类属于com.opengamma.analytics.financial.model.option.pricing.analytic包,在下文中一共展示了BlackScholesMertonModel类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculate
import com.opengamma.analytics.financial.model.option.pricing.analytic.BlackScholesMertonModel; //导入依赖的package包/类
@Override
public void calculate() {
if (contractPrice == null && impliedVolatility == null) {
throw new IllegalArgumentException("To find contract price, implied volatility must be known in advance. To find IV, contract price must be known in advance. Both are null.");
}
BlackScholesMertonModel model = new BlackScholesMertonModel();
if (contractPrice == null) {
// @param forward The forward value of the underlying -> getStrike
// @param strike The Strike -> getStrike
// @param timeToExpiry The time-to-expiry -> getTimeToExpiry
// @param lognormalVol The log-normal volatility -> impliedVolatility
// @param isCall True for calls, false for puts -> isCall()
contractPrice = BlackFormulaRepository.price(strike, strike, getTimeToExpiry(), impliedVolatility, isCall());
} else if (impliedVolatility == null) {
// @param price The <b>forward</b> price -> contractPrice
// @param forward The forward value of the underlying -> strike
// @param strike The Strike -> getStrike()
// @param timeToExpiry The time-to-expiry -> getTimeToExpiry()
// @param isCall true for call -> isCall()
impliedVolatility = BlackFormulaRepository.impliedVolatility(contractPrice, getStrike(), getStrike(), getTimeToExpiry(), isCall());
}
calculateGreeks();
}