/** * Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.strata.pricer.impl.option; import java.io.Serializable; import java.util.Set; import org.joda.beans.BeanDefinition; import org.joda.beans.ImmutableBean; import org.joda.beans.JodaBeanUtils; import org.joda.beans.MetaBean; import org.joda.beans.Property; import org.joda.beans.PropertyDefinition; import org.joda.beans.impl.light.LightMetaBean; /** * A data bundle with the data require for the normal option model (Bachelier model). */ @BeanDefinition(style = "light") public final class NormalFunctionData implements ImmutableBean, Serializable { // this class has been replaced by NormalFormulaRepository // it is retained for testing purposes /** * The forward value of the underlying asset * For example, the forward value of a stock, or the forward Libor rate. */ @PropertyDefinition private final double forward; /** * The numeraire associated with the equation. */ @PropertyDefinition private final double numeraire; /** * The normal volatility (sigma). */ @PropertyDefinition private final double normalVolatility; //------------------------------------------------------------------------- /** * Data bundle for pricing in a normal framework. * That is, the forward value of the underlying asset is a martingale in the chosen numeraire measure. * * @param forward the forward value of the underlying asset, such as forward value of a stock, or forward Libor rate * @param numeraire the numeraire associated with the equation * @param normalVolatility the normal volatility (sigma) * @return the function data */ public static NormalFunctionData of(double forward, double numeraire, double normalVolatility) { return new NormalFunctionData(forward, numeraire, normalVolatility); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code NormalFunctionData}. */ private static MetaBean META_BEAN = LightMetaBean.of(NormalFunctionData.class); /** * The meta-bean for {@code NormalFunctionData}. * @return the meta-bean, not null */ public static MetaBean meta() { return META_BEAN; } static { JodaBeanUtils.registerMetaBean(META_BEAN); } /** * The serialization version id. */ private static final long serialVersionUID = 1L; private NormalFunctionData( double forward, double numeraire, double normalVolatility) { this.forward = forward; this.numeraire = numeraire; this.normalVolatility = normalVolatility; } @Override public MetaBean metaBean() { return META_BEAN; } @Override public <R> Property<R> property(String propertyName) { return metaBean().<R>metaProperty(propertyName).createProperty(this); } @Override public Set<String> propertyNames() { return metaBean().metaPropertyMap().keySet(); } //----------------------------------------------------------------------- /** * Gets the forward value of the underlying asset * For example, the forward value of a stock, or the forward Libor rate. * @return the value of the property */ public double getForward() { return forward; } //----------------------------------------------------------------------- /** * Gets the numeraire associated with the equation. * @return the value of the property */ public double getNumeraire() { return numeraire; } //----------------------------------------------------------------------- /** * Gets the normal volatility (sigma). * @return the value of the property */ public double getNormalVolatility() { return normalVolatility; } //----------------------------------------------------------------------- @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { NormalFunctionData other = (NormalFunctionData) obj; return JodaBeanUtils.equal(forward, other.forward) && JodaBeanUtils.equal(numeraire, other.numeraire) && JodaBeanUtils.equal(normalVolatility, other.normalVolatility); } return false; } @Override public int hashCode() { int hash = getClass().hashCode(); hash = hash * 31 + JodaBeanUtils.hashCode(forward); hash = hash * 31 + JodaBeanUtils.hashCode(numeraire); hash = hash * 31 + JodaBeanUtils.hashCode(normalVolatility); return hash; } @Override public String toString() { StringBuilder buf = new StringBuilder(128); buf.append("NormalFunctionData{"); buf.append("forward").append('=').append(forward).append(',').append(' '); buf.append("numeraire").append('=').append(numeraire).append(',').append(' '); buf.append("normalVolatility").append('=').append(JodaBeanUtils.toString(normalVolatility)); buf.append('}'); return buf.toString(); } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }