All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.opengamma.strata.product.index.IborFutureSecurity Maven / Gradle / Ivy

There is a newer version: 2.12.56
Show newest version
/*
 * Copyright (C) 2016 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.strata.product.index;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.Map;
import java.util.NoSuchElementException;

import org.joda.beans.Bean;
import org.joda.beans.ImmutableBean;
import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaBean;
import org.joda.beans.MetaProperty;
import org.joda.beans.gen.BeanDefinition;
import org.joda.beans.gen.DerivedProperty;
import org.joda.beans.gen.PropertyDefinition;
import org.joda.beans.impl.direct.DirectFieldsBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaBean;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;

import com.google.common.collect.ImmutableSet;
import com.opengamma.strata.basics.ReferenceData;
import com.opengamma.strata.basics.currency.Currency;
import com.opengamma.strata.basics.index.IborIndex;
import com.opengamma.strata.basics.value.Rounding;
import com.opengamma.strata.collect.ArgChecker;
import com.opengamma.strata.product.PositionInfo;
import com.opengamma.strata.product.SecurityId;
import com.opengamma.strata.product.SecurityInfo;
import com.opengamma.strata.product.TradeInfo;

/**
 * A security representing a futures contract based on an Ibor index.
 * 

* An Ibor future is a financial instrument that is based on the future value of * an Ibor index interest rate. The profit or loss of an Ibor future is settled daily. * An Ibor future is also known as a STIR future (Short Term Interest Rate). *

* For example, the widely traded "CME Eurodollar futures contract" has a notional * of 1 million USD, is based on the USD Libor 3 month rate 'USD-LIBOR-3M', expiring * two business days before an IMM date (the 3rd Wednesday of the month). * *

Price

* The price of an Ibor future is based on the interest rate of the underlying index. * It is defined as {@code (100 - percentRate)}. *

* Strata uses decimal prices for Ibor futures in the trade model, pricers and market data. * The decimal price is based on the decimal rate equivalent to the percentage. * For example, a price of 99.32 implies an interest rate of 0.68% which is represented in Strata by 0.9932. */ @BeanDefinition public final class IborFutureSecurity implements RateIndexSecurity, ImmutableBean, Serializable { /** * The standard security information. *

* This includes the security identifier. */ @PropertyDefinition(validate = "notNull", overrideGet = true) private final SecurityInfo info; /** * The notional amount. *

* This is the full notional of the deposit, such as 1 million dollars. * The notional expressed here must be positive. * The currency of the notional the same as the currency of the index. */ @PropertyDefinition(validate = "ArgChecker.notNegativeOrZero") private final double notional; /** * The last date of trading. * This date is also the fixing date for the Ibor index. * This is typically 2 business days before the IMM date (3rd Wednesday of the month). */ @PropertyDefinition(validate = "notNull") private final LocalDate lastTradeDate; /** * The underlying Ibor index. *

* The future is based on this index. * It will be a well known market index such as 'USD-LIBOR-3M'. */ @PropertyDefinition(validate = "notNull", overrideGet = true) private final IborIndex index; /** * The definition of how to round the futures price, defaulted to no rounding. *

* The price is represented in decimal form, not percentage form. * As such, the decimal places expressed by the rounding refers to this decimal form. * For example, the common market price of 99.7125 for a 0.2875% rate is * represented as 0.997125 which has 6 decimal places. */ @PropertyDefinition(validate = "notNull") private final Rounding rounding; //------------------------------------------------------------------------- @Override @DerivedProperty public Currency getCurrency() { return index.getCurrency(); } @Override public ImmutableSet getUnderlyingIds() { return ImmutableSet.of(); } //------------------------------------------------------------------------- @Override public IborFutureSecurity withInfo(SecurityInfo info) { return toBuilder().info(info).build(); } //------------------------------------------------------------------------- @Override public IborFuture createProduct(ReferenceData refData) { return IborFuture.builder() .securityId(getSecurityId()) .notional(notional) .index(index) .lastTradeDate(lastTradeDate) .rounding(rounding) .build(); } @Override public IborFutureTrade createTrade( TradeInfo info, double quantity, double tradePrice, ReferenceData refData) { return new IborFutureTrade(info, createProduct(refData), quantity, tradePrice); } @Override public IborFuturePosition createPosition(PositionInfo positionInfo, double quantity, ReferenceData refData) { return IborFuturePosition.ofNet(positionInfo, createProduct(refData), quantity); } @Override public IborFuturePosition createPosition( PositionInfo positionInfo, double longQuantity, double shortQuantity, ReferenceData refData) { return IborFuturePosition.ofLongShort(positionInfo, createProduct(refData), longQuantity, shortQuantity); } //------------------------- AUTOGENERATED START ------------------------- /** * The meta-bean for {@code IborFutureSecurity}. * @return the meta-bean, not null */ public static IborFutureSecurity.Meta meta() { return IborFutureSecurity.Meta.INSTANCE; } static { MetaBean.register(IborFutureSecurity.Meta.INSTANCE); } /** * The serialization version id. */ private static final long serialVersionUID = 1L; /** * Returns a builder used to create an instance of the bean. * @return the builder, not null */ public static IborFutureSecurity.Builder builder() { return new IborFutureSecurity.Builder(); } private IborFutureSecurity( SecurityInfo info, double notional, LocalDate lastTradeDate, IborIndex index, Rounding rounding) { JodaBeanUtils.notNull(info, "info"); ArgChecker.notNegativeOrZero(notional, "notional"); JodaBeanUtils.notNull(lastTradeDate, "lastTradeDate"); JodaBeanUtils.notNull(index, "index"); JodaBeanUtils.notNull(rounding, "rounding"); this.info = info; this.notional = notional; this.lastTradeDate = lastTradeDate; this.index = index; this.rounding = rounding; } @Override public IborFutureSecurity.Meta metaBean() { return IborFutureSecurity.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the standard security information. *

* This includes the security identifier. * @return the value of the property, not null */ @Override public SecurityInfo getInfo() { return info; } //----------------------------------------------------------------------- /** * Gets the notional amount. *

* This is the full notional of the deposit, such as 1 million dollars. * The notional expressed here must be positive. * The currency of the notional the same as the currency of the index. * @return the value of the property */ public double getNotional() { return notional; } //----------------------------------------------------------------------- /** * Gets the last date of trading. * This date is also the fixing date for the Ibor index. * This is typically 2 business days before the IMM date (3rd Wednesday of the month). * @return the value of the property, not null */ public LocalDate getLastTradeDate() { return lastTradeDate; } //----------------------------------------------------------------------- /** * Gets the underlying Ibor index. *

* The future is based on this index. * It will be a well known market index such as 'USD-LIBOR-3M'. * @return the value of the property, not null */ @Override public IborIndex getIndex() { return index; } //----------------------------------------------------------------------- /** * Gets the definition of how to round the futures price, defaulted to no rounding. *

* The price is represented in decimal form, not percentage form. * As such, the decimal places expressed by the rounding refers to this decimal form. * For example, the common market price of 99.7125 for a 0.2875% rate is * represented as 0.997125 which has 6 decimal places. * @return the value of the property, not null */ public Rounding getRounding() { return rounding; } //----------------------------------------------------------------------- /** * Returns a builder that allows this bean to be mutated. * @return the mutable builder, not null */ public Builder toBuilder() { return new Builder(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { IborFutureSecurity other = (IborFutureSecurity) obj; return JodaBeanUtils.equal(info, other.info) && JodaBeanUtils.equal(notional, other.notional) && JodaBeanUtils.equal(lastTradeDate, other.lastTradeDate) && JodaBeanUtils.equal(index, other.index) && JodaBeanUtils.equal(rounding, other.rounding); } return false; } @Override public int hashCode() { int hash = getClass().hashCode(); hash = hash * 31 + JodaBeanUtils.hashCode(info); hash = hash * 31 + JodaBeanUtils.hashCode(notional); hash = hash * 31 + JodaBeanUtils.hashCode(lastTradeDate); hash = hash * 31 + JodaBeanUtils.hashCode(index); hash = hash * 31 + JodaBeanUtils.hashCode(rounding); return hash; } @Override public String toString() { StringBuilder buf = new StringBuilder(224); buf.append("IborFutureSecurity{"); buf.append("info").append('=').append(JodaBeanUtils.toString(info)).append(',').append(' '); buf.append("notional").append('=').append(JodaBeanUtils.toString(notional)).append(',').append(' '); buf.append("lastTradeDate").append('=').append(JodaBeanUtils.toString(lastTradeDate)).append(',').append(' '); buf.append("index").append('=').append(JodaBeanUtils.toString(index)).append(',').append(' '); buf.append("rounding").append('=').append(JodaBeanUtils.toString(rounding)).append(',').append(' '); buf.append("currency").append('=').append(JodaBeanUtils.toString(getCurrency())); buf.append('}'); return buf.toString(); } //----------------------------------------------------------------------- /** * The meta-bean for {@code IborFutureSecurity}. */ public static final class Meta extends DirectMetaBean { /** * The singleton instance of the meta-bean. */ static final Meta INSTANCE = new Meta(); /** * The meta-property for the {@code info} property. */ private final MetaProperty info = DirectMetaProperty.ofImmutable( this, "info", IborFutureSecurity.class, SecurityInfo.class); /** * The meta-property for the {@code notional} property. */ private final MetaProperty notional = DirectMetaProperty.ofImmutable( this, "notional", IborFutureSecurity.class, Double.TYPE); /** * The meta-property for the {@code lastTradeDate} property. */ private final MetaProperty lastTradeDate = DirectMetaProperty.ofImmutable( this, "lastTradeDate", IborFutureSecurity.class, LocalDate.class); /** * The meta-property for the {@code index} property. */ private final MetaProperty index = DirectMetaProperty.ofImmutable( this, "index", IborFutureSecurity.class, IborIndex.class); /** * The meta-property for the {@code rounding} property. */ private final MetaProperty rounding = DirectMetaProperty.ofImmutable( this, "rounding", IborFutureSecurity.class, Rounding.class); /** * The meta-property for the {@code currency} property. */ private final MetaProperty currency = DirectMetaProperty.ofDerived( this, "currency", IborFutureSecurity.class, Currency.class); /** * The meta-properties. */ private final Map> metaPropertyMap$ = new DirectMetaPropertyMap( this, null, "info", "notional", "lastTradeDate", "index", "rounding", "currency"); /** * Restricted constructor. */ private Meta() { } @Override protected MetaProperty metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case 3237038: // info return info; case 1585636160: // notional return notional; case -1041950404: // lastTradeDate return lastTradeDate; case 100346066: // index return index; case -142444: // rounding return rounding; case 575402001: // currency return currency; } return super.metaPropertyGet(propertyName); } @Override public IborFutureSecurity.Builder builder() { return new IborFutureSecurity.Builder(); } @Override public Class beanType() { return IborFutureSecurity.class; } @Override public Map> metaPropertyMap() { return metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code info} property. * @return the meta-property, not null */ public MetaProperty info() { return info; } /** * The meta-property for the {@code notional} property. * @return the meta-property, not null */ public MetaProperty notional() { return notional; } /** * The meta-property for the {@code lastTradeDate} property. * @return the meta-property, not null */ public MetaProperty lastTradeDate() { return lastTradeDate; } /** * The meta-property for the {@code index} property. * @return the meta-property, not null */ public MetaProperty index() { return index; } /** * The meta-property for the {@code rounding} property. * @return the meta-property, not null */ public MetaProperty rounding() { return rounding; } /** * The meta-property for the {@code currency} property. * @return the meta-property, not null */ public MetaProperty currency() { return currency; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 3237038: // info return ((IborFutureSecurity) bean).getInfo(); case 1585636160: // notional return ((IborFutureSecurity) bean).getNotional(); case -1041950404: // lastTradeDate return ((IborFutureSecurity) bean).getLastTradeDate(); case 100346066: // index return ((IborFutureSecurity) bean).getIndex(); case -142444: // rounding return ((IborFutureSecurity) bean).getRounding(); case 575402001: // currency return ((IborFutureSecurity) bean).getCurrency(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { metaProperty(propertyName); if (quiet) { return; } throw new UnsupportedOperationException("Property cannot be written: " + propertyName); } } //----------------------------------------------------------------------- /** * The bean-builder for {@code IborFutureSecurity}. */ public static final class Builder extends DirectFieldsBeanBuilder { private SecurityInfo info; private double notional; private LocalDate lastTradeDate; private IborIndex index; private Rounding rounding; /** * Restricted constructor. */ private Builder() { } /** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(IborFutureSecurity beanToCopy) { this.info = beanToCopy.getInfo(); this.notional = beanToCopy.getNotional(); this.lastTradeDate = beanToCopy.getLastTradeDate(); this.index = beanToCopy.getIndex(); this.rounding = beanToCopy.getRounding(); } //----------------------------------------------------------------------- @Override public Object get(String propertyName) { switch (propertyName.hashCode()) { case 3237038: // info return info; case 1585636160: // notional return notional; case -1041950404: // lastTradeDate return lastTradeDate; case 100346066: // index return index; case -142444: // rounding return rounding; default: throw new NoSuchElementException("Unknown property: " + propertyName); } } @Override public Builder set(String propertyName, Object newValue) { switch (propertyName.hashCode()) { case 3237038: // info this.info = (SecurityInfo) newValue; break; case 1585636160: // notional this.notional = (Double) newValue; break; case -1041950404: // lastTradeDate this.lastTradeDate = (LocalDate) newValue; break; case 100346066: // index this.index = (IborIndex) newValue; break; case -142444: // rounding this.rounding = (Rounding) newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return this; } @Override public Builder set(MetaProperty property, Object value) { super.set(property, value); return this; } @Override public IborFutureSecurity build() { return new IborFutureSecurity( info, notional, lastTradeDate, index, rounding); } //----------------------------------------------------------------------- /** * Sets the standard security information. *

* This includes the security identifier. * @param info the new value, not null * @return this, for chaining, not null */ public Builder info(SecurityInfo info) { JodaBeanUtils.notNull(info, "info"); this.info = info; return this; } /** * Sets the notional amount. *

* This is the full notional of the deposit, such as 1 million dollars. * The notional expressed here must be positive. * The currency of the notional the same as the currency of the index. * @param notional the new value * @return this, for chaining, not null */ public Builder notional(double notional) { ArgChecker.notNegativeOrZero(notional, "notional"); this.notional = notional; return this; } /** * Sets the last date of trading. * This date is also the fixing date for the Ibor index. * This is typically 2 business days before the IMM date (3rd Wednesday of the month). * @param lastTradeDate the new value, not null * @return this, for chaining, not null */ public Builder lastTradeDate(LocalDate lastTradeDate) { JodaBeanUtils.notNull(lastTradeDate, "lastTradeDate"); this.lastTradeDate = lastTradeDate; return this; } /** * Sets the underlying Ibor index. *

* The future is based on this index. * It will be a well known market index such as 'USD-LIBOR-3M'. * @param index the new value, not null * @return this, for chaining, not null */ public Builder index(IborIndex index) { JodaBeanUtils.notNull(index, "index"); this.index = index; return this; } /** * Sets the definition of how to round the futures price, defaulted to no rounding. *

* The price is represented in decimal form, not percentage form. * As such, the decimal places expressed by the rounding refers to this decimal form. * For example, the common market price of 99.7125 for a 0.2875% rate is * represented as 0.997125 which has 6 decimal places. * @param rounding the new value, not null * @return this, for chaining, not null */ public Builder rounding(Rounding rounding) { JodaBeanUtils.notNull(rounding, "rounding"); this.rounding = rounding; return this; } //----------------------------------------------------------------------- @Override public String toString() { StringBuilder buf = new StringBuilder(224); buf.append("IborFutureSecurity.Builder{"); buf.append("info").append('=').append(JodaBeanUtils.toString(info)).append(',').append(' '); buf.append("notional").append('=').append(JodaBeanUtils.toString(notional)).append(',').append(' '); buf.append("lastTradeDate").append('=').append(JodaBeanUtils.toString(lastTradeDate)).append(',').append(' '); buf.append("index").append('=').append(JodaBeanUtils.toString(index)).append(',').append(' '); buf.append("rounding").append('=').append(JodaBeanUtils.toString(rounding)).append(',').append(' '); buf.append("currency").append('=').append(JodaBeanUtils.toString(null)); buf.append('}'); return buf.toString(); } } //-------------------------- AUTOGENERATED END -------------------------- }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy