public virtual void test_parse()
        {
            EtdContractSpecId test = EtdContractSpecId.parse("A~B");

            assertEquals(test.StandardId, StandardId.of("A", "B"));
            assertEquals(test.ToString(), "A~B");
        }
Exemplo n.º 2
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(EtdFutureSecurity beanToCopy)
 {
     this.info_Renamed           = beanToCopy.Info;
     this.contractSpecId_Renamed = beanToCopy.ContractSpecId;
     this.expiry_Renamed         = beanToCopy.Expiry;
     this.variant_Renamed        = beanToCopy.Variant;
 }
Exemplo n.º 3
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 3237038:         // info
                    this.info_Renamed = (SecurityInfo)newValue;
                    break;

                case 948987368:         // contractSpecId
                    this.contractSpecId_Renamed = (EtdContractSpecId)newValue;
                    break;

                case -1289159373:         // expiry
                    this.expiry_Renamed = (YearMonth)newValue;
                    break;

                case 236785797:         // variant
                    this.variant_Renamed = (EtdVariant)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
 /// <summary>
 /// Builds a new specification from the data in this builder.
 /// </summary>
 /// <returns> a specification instance built from the data in this builder </returns>
 public EtdContractSpec build()
 {
     if (id_Renamed == null)
     {
         id_Renamed = EtdIdUtils.contractSpecId(type_Renamed, exchangeId_Renamed, contractCode_Renamed);
     }
     return(new EtdContractSpec(id_Renamed, type_Renamed, exchangeId_Renamed, contractCode_Renamed, description_Renamed, priceInfo_Renamed, attributes));
 }
        public virtual void test_of()
        {
            EtdContractSpecId test = EtdContractSpecId.of(StandardId.of("A", "B"));

            assertEquals(test.StandardId, StandardId.of("A", "B"));
            assertEquals(test.ReferenceDataType, typeof(EtdContractSpec));
            assertEquals(test.ToString(), "A~B");
        }
Exemplo n.º 6
0
 private EtdFutureSecurity(SecurityInfo info, EtdContractSpecId contractSpecId, YearMonth expiry, EtdVariant variant)
 {
     JodaBeanUtils.notNull(info, "info");
     JodaBeanUtils.notNull(contractSpecId, "contractSpecId");
     JodaBeanUtils.notNull(expiry, "expiry");
     JodaBeanUtils.notNull(variant, "variant");
     this.info           = info;
     this.contractSpecId = contractSpecId;
     this.expiry         = expiry;
     this.variant        = variant;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(EtdOptionSecurity beanToCopy)
 {
     this.info_Renamed                  = beanToCopy.Info;
     this.contractSpecId_Renamed        = beanToCopy.ContractSpecId;
     this.expiry_Renamed                = beanToCopy.Expiry;
     this.variant_Renamed               = beanToCopy.Variant;
     this.version_Renamed               = beanToCopy.Version;
     this.putCall_Renamed               = beanToCopy.PutCall;
     this.strikePrice_Renamed           = beanToCopy.StrikePrice;
     this.underlyingExpiryMonth_Renamed = beanToCopy.underlyingExpiryMonth;
 }
        //-------------------------------------------------------------------------
        public virtual void test_equalsHashCode()
        {
            EtdContractSpecId a  = EtdContractSpecId.of(StandardId.of("A", "B"));
            EtdContractSpecId a2 = EtdContractSpecId.of(StandardId.of("A", "B"));
            EtdContractSpecId b  = EtdContractSpecId.of(StandardId.of("C", "D"));

            assertEquals(a.GetHashCode(), a2.GetHashCode());
            assertEquals(a.Equals(a), true);
            assertEquals(a.Equals(a2), true);
            assertEquals(a.Equals(b), false);
            assertEquals(a.Equals(null), false);
            assertEquals(a.Equals(ANOTHER_TYPE), false);
        }
Exemplo n.º 9
0
 private EtdOptionSecurity(SecurityInfo info, EtdContractSpecId contractSpecId, YearMonth expiry, EtdVariant variant, int version, PutCall putCall, double strikePrice, YearMonth underlyingExpiryMonth)
 {
     JodaBeanUtils.notNull(info, "info");
     JodaBeanUtils.notNull(contractSpecId, "contractSpecId");
     JodaBeanUtils.notNull(expiry, "expiry");
     JodaBeanUtils.notNull(variant, "variant");
     ArgChecker.notNegative(version, "version");
     JodaBeanUtils.notNull(putCall, "putCall");
     this.info                  = info;
     this.contractSpecId        = contractSpecId;
     this.expiry                = expiry;
     this.variant               = variant;
     this.version               = version;
     this.putCall               = putCall;
     this.strikePrice           = strikePrice;
     this.underlyingExpiryMonth = underlyingExpiryMonth;
 }
Exemplo n.º 10
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Creates an identifier for a contract specification.
        /// <para>
        /// This will have the format:
        /// {@code 'OG-ETD~F-ECAG-FGBS'} or {@code 'OG-ETD~O-ECAG-OGBS'}.
        ///
        /// </para>
        /// </summary>
        /// <param name="type">  type of the contract - future or option </param>
        /// <param name="exchangeId">  the MIC code of the exchange where the instruments are traded </param>
        /// <param name="contractCode">  the code supplied by the exchange for use in clearing and margining, such as in SPAN </param>
        /// <returns> the identifier </returns>
        public static EtdContractSpecId contractSpecId(EtdType type, ExchangeId exchangeId, EtdContractCode contractCode)
        {
            ArgChecker.notNull(type, "type");
            ArgChecker.notNull(exchangeId, "exchangeId");
            ArgChecker.notNull(contractCode, "contractCode");
            switch (type.innerEnumValue)
            {
            case com.opengamma.strata.product.etd.EtdType.InnerEnum.FUTURE:
                return(EtdContractSpecId.of(ETD_SCHEME, FUT_PREFIX + exchangeId + SEPARATOR + contractCode));

            case com.opengamma.strata.product.etd.EtdType.InnerEnum.OPTION:
                return(EtdContractSpecId.of(ETD_SCHEME, OPT_PREFIX + exchangeId + SEPARATOR + contractCode));

            default:
                throw new System.ArgumentException("Unknown ETD type: " + type);
            }
        }
Exemplo n.º 11
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 3237038:         // info
                    this.info_Renamed = (SecurityInfo)newValue;
                    break;

                case 948987368:         // contractSpecId
                    this.contractSpecId_Renamed = (EtdContractSpecId)newValue;
                    break;

                case -1289159373:         // expiry
                    this.expiry_Renamed = (YearMonth)newValue;
                    break;

                case 236785797:         // variant
                    this.variant_Renamed = (EtdVariant)newValue;
                    break;

                case 351608024:         // version
                    this.version_Renamed = (int?)newValue.Value;
                    break;

                case -219971059:         // putCall
                    this.putCall_Renamed = (PutCall)newValue;
                    break;

                case 50946231:         // strikePrice
                    this.strikePrice_Renamed = (double?)newValue.Value;
                    break;

                case 1929351536:         // underlyingExpiryMonth
                    this.underlyingExpiryMonth_Renamed = (YearMonth)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
        //-------------------------------------------------------------------------
        public virtual void test_serialization()
        {
            EtdContractSpecId test = EtdContractSpecId.of("A", "B");

            assertSerialization(test);
        }
 /// <summary>
 /// Sets the ID of the contract specification.
 /// </summary>
 /// <param name="id"> the ID </param>
 /// <returns> the ID of the template </returns>
 public EtdContractSpecBuilder id(EtdContractSpecId id)
 {
     JodaBeanUtils.notNull(id, "id");
     this.id_Renamed = id;
     return(this);
 }
 //-------------------------------------------------------------------------
 internal static EtdFutureSecurity sut()
 {
     return(EtdFutureSecurity.builder().info(SecurityInfo.of(SecurityId.of("A", "B"), SecurityPriceInfo.of(Currency.GBP, 100))).contractSpecId(EtdContractSpecId.of("test", "123")).expiry(YearMonth.of(2017, 6)).build());
 }
 internal static EtdFutureSecurity sut2()
 {
     return(EtdFutureSecurity.builder().info(SecurityInfo.of(SecurityId.of("B", "C"), SecurityPriceInfo.of(Currency.EUR, 10))).contractSpecId(EtdContractSpecId.of("test", "234")).expiry(YearMonth.of(2017, 9)).variant(EtdVariant.ofWeekly(2)).build());
 }
Exemplo n.º 16
0
 //-------------------------------------------------------------------------
 internal static EtdContractSpec sut()
 {
     return(EtdContractSpec.builder().id(EtdContractSpecId.of("test", "123")).type(EtdType.FUTURE).exchangeId(ExchangeIds.ECAG).contractCode(EtdContractCode.of("FOO")).description("A test future template").priceInfo(SecurityPriceInfo.of(Currency.GBP, 100)).build());
 }
Exemplo n.º 17
0
        public virtual void test_contractSpecId_option()
        {
            EtdContractSpecId test = EtdIdUtils.contractSpecId(EtdType.OPTION, ExchangeIds.ECAG, OGBS);

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "O-ECAG-OGBS"));
        }
Exemplo n.º 18
0
        public virtual void test_contractSpecId_future()
        {
            EtdContractSpecId test = EtdIdUtils.contractSpecId(EtdType.FUTURE, ExchangeIds.ECAG, FGBS);

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "F-ECAG-FGBS"));
        }
Exemplo n.º 19
0
 internal static EtdOptionSecurity sut2()
 {
     return(EtdOptionSecurity.builder().info(SecurityInfo.of(SecurityId.of("B", "C"), SecurityPriceInfo.of(Currency.EUR, 10))).contractSpecId(EtdContractSpecId.of("test", "234")).expiry(YearMonth.of(2017, 9)).variant(EtdVariant.ofWeekly(2)).version(4).putCall(PutCall.CALL).strikePrice(3).underlyingExpiryMonth(YearMonth.of(2017, 12)).build());
 }
Exemplo n.º 20
0
 //-------------------------------------------------------------------------
 internal static EtdOptionSecurity sut()
 {
     return(EtdOptionSecurity.builder().info(SecurityInfo.of(SecurityId.of("A", "B"), SecurityPriceInfo.of(Currency.GBP, 100))).contractSpecId(EtdContractSpecId.of("test", "123")).expiry(YearMonth.of(2017, 6)).putCall(PutCall.PUT).strikePrice(2).build());
 }
Exemplo n.º 21
0
 /// <summary>
 /// Sets the ID of the contract specification from which this security is derived. </summary>
 /// <param name="contractSpecId">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder contractSpecId(EtdContractSpecId contractSpecId)
 {
     JodaBeanUtils.notNull(contractSpecId, "contractSpecId");
     this.contractSpecId_Renamed = contractSpecId;
     return(this);
 }