Пример #1
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;
 }
Пример #2
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);
            }
Пример #3
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Obtains an instance from a contract specification, expiry year-month and variant.
        /// <para>
        /// The security identifier will be automatically created using <seealso cref="EtdIdUtils"/>.
        /// The specification must be for a future.
        ///
        /// </para>
        /// </summary>
        /// <param name="spec">  the future contract specification </param>
        /// <param name="expiry">  the expiry year-month of the future </param>
        /// <param name="variant">  the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' </param>
        /// <returns> a future security based on this contract specification </returns>
        /// <exception cref="IllegalStateException"> if the product type of the contract specification is not {@code FUTURE} </exception>
        public static EtdFutureSecurity of(EtdContractSpec spec, YearMonth expiry, EtdVariant variant)
        {
            if (spec.Type != EtdType.FUTURE)
            {
                throw new System.InvalidOperationException(Messages.format("Cannot create an EtdFutureSecurity from a contract specification of type '{}'", spec.Type));
            }
            SecurityId securityId = EtdIdUtils.futureId(spec.ExchangeId, spec.ContractCode, expiry, variant);

            return(EtdFutureSecurity.builder().info(SecurityInfo.of(securityId, spec.PriceInfo)).contractSpecId(spec.Id).expiry(expiry).variant(variant).build());
        }
Пример #4
0
        /// <summary>
        /// Obtains an instance from a contract specification, expiry year-month, variant,
        /// version, put/call, strike price and underlying expiry.
        /// <para>
        /// The security identifier will be automatically created using <seealso cref="EtdIdUtils"/>.
        /// The specification must be for an option.
        ///
        /// </para>
        /// </summary>
        /// <param name="spec">  the option contract specification </param>
        /// <param name="expiry">  the expiry year-month of the option </param>
        /// <param name="variant">  the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' </param>
        /// <param name="version">  the non-negative version, zero if versioning does not apply </param>
        /// <param name="putCall">  whether the option is a put or call </param>
        /// <param name="strikePrice">  the strike price of the option </param>
        /// <param name="underlyingExpiryMonth">  the expiry of the underlying instrument, such as a future, may be null </param>
        /// <returns> an option security based on this contract specification </returns>
        /// <exception cref="IllegalStateException"> if the product type of the contract specification is not {@code OPTION} </exception>
        public static EtdOptionSecurity of(EtdContractSpec spec, YearMonth expiry, EtdVariant variant, int version, PutCall putCall, double strikePrice, YearMonth underlyingExpiryMonth)
        {
            if (spec.Type != EtdType.OPTION)
            {
                throw new System.InvalidOperationException(Messages.format("Cannot create an EtdOptionSecurity from a contract specification of type '{}'", spec.Type));
            }
            SecurityId securityId = EtdIdUtils.optionId(spec.ExchangeId, spec.ContractCode, expiry, variant, version, putCall, strikePrice, underlyingExpiryMonth);

            return(EtdOptionSecurity.builder().info(SecurityInfo.of(securityId, spec.PriceInfo)).contractSpecId(spec.Id).expiry(expiry).variant(variant).version(version).putCall(putCall).strikePrice(strikePrice).underlyingExpiryMonth(underlyingExpiryMonth).build());
        }
        public virtual void test_flexFuture()
        {
            EtdVariant test = EtdVariant.ofFlexFuture(2, EtdSettlementType.CASH);

            assertEquals(test.Type, EtdExpiryType.DAILY);
            assertEquals(test.DateCode.Value, 2);
            assertEquals(test.SettlementType.get(), EtdSettlementType.CASH);
            assertEquals(test.OptionType.Present, false);
            assertEquals(test.Flex, true);
            assertEquals(test.Code, "02C");
        }
        public virtual void test_flexOption()
        {
            EtdVariant test = EtdVariant.ofFlexOption(24, EtdSettlementType.CASH, EtdOptionType.AMERICAN);

            assertEquals(test.Type, EtdExpiryType.DAILY);
            assertEquals(test.DateCode.Value, 24);
            assertEquals(test.SettlementType.get(), EtdSettlementType.CASH);
            assertEquals(test.OptionType.get(), EtdOptionType.AMERICAN);
            assertEquals(test.Flex, true);
            assertEquals(test.Code, "24CA");
        }
Пример #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_daily()
        {
            EtdVariant test = EtdVariant.ofDaily(24);

            assertEquals(test.Type, EtdExpiryType.DAILY);
            assertEquals(test.DateCode.Value, 24);
            assertEquals(test.SettlementType.Present, false);
            assertEquals(test.OptionType.Present, false);
            assertEquals(test.Flex, false);
            assertEquals(test.Code, "24");
        }
        public virtual void test_monthly()
        {
            EtdVariant test = EtdVariant.ofMonthly();

            assertEquals(test.Type, EtdExpiryType.MONTHLY);
            assertEquals(test.DateCode.HasValue, false);
            assertEquals(test.SettlementType.Present, false);
            assertEquals(test.OptionType.Present, false);
            assertEquals(test.Flex, false);
            assertEquals(test.Code, "");
        }
Пример #10
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;
 }
        public virtual void test_weekly()
        {
            EtdVariant test = EtdVariant.ofWeekly(2);

            assertEquals(test.Type, EtdExpiryType.WEEKLY);
            assertEquals(test.DateCode.Value, 2);
            assertEquals(test.SettlementType.Present, false);
            assertEquals(test.OptionType.Present, false);
            assertEquals(test.Flex, false);
            assertEquals(test.Code, "W2");
        }
Пример #12
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         EtdVariant other = (EtdVariant)obj;
         return(JodaBeanUtils.equal(type, other.type) && JodaBeanUtils.equal(dateCode, other.dateCode) && JodaBeanUtils.equal(settlementType, other.settlementType) && JodaBeanUtils.equal(optionType, other.optionType));
     }
     return(false);
 }
Пример #13
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;
 }
Пример #14
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);
            }
Пример #15
0
        /// <summary>
        /// Creates an identifier for an ETD future instrument.
        /// <para>
        /// A typical monthly ETD will have the format:
        /// {@code 'OG-ETD~O-ECAG-OGBS-201706'}.
        /// </para>
        /// <para>
        /// A more complex flex ETD (12th of the month, Physical settlement) will have the format:
        /// {@code 'OG-ETD~O-ECAG-OGBS-20170612E'}.
        ///
        /// </para>
        /// </summary>
        /// <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>
        /// <param name="expiryMonth">  the month of expiry </param>
        /// <param name="variant">  the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' </param>
        /// <returns> the identifier </returns>
        public static SecurityId futureId(ExchangeId exchangeId, EtdContractCode contractCode, YearMonth expiryMonth, EtdVariant variant)
        {
            ArgChecker.notNull(exchangeId, "exchangeId");
            ArgChecker.notNull(contractCode, "contractCode");
            ArgChecker.notNull(expiryMonth, "expiryMonth");
            ArgChecker.isTrue(expiryMonth.Year >= 1000 && expiryMonth.Year <= 9999, "Invalid expiry year: ", expiryMonth);
            ArgChecker.notNull(variant, "variant");

            string id = (new StringBuilder(40)).Append(FUT_PREFIX).Append(exchangeId).Append(SEPARATOR).Append(contractCode).Append(SEPARATOR).Append(expiryMonth.format(YM_FORMAT)).Append(variant.Code).ToString();

            return(SecurityId.of(ETD_SCHEME, id));
        }
 /// <summary>
 /// Creates an option security based on this contract specification.
 /// <para>
 /// The security identifier will be automatically created using <seealso cref="EtdIdUtils"/>.
 /// The <seealso cref="#getType() type"/> must be <seealso cref="EtdType#OPTION"/> otherwise an exception will be thrown.
 ///
 /// </para>
 /// </summary>
 /// <param name="expiryMonth">  the expiry month of the option </param>
 /// <param name="variant">  the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' </param>
 /// <param name="version">  the non-negative version, zero by default </param>
 /// <param name="putCall">  whether the option is a put or call </param>
 /// <param name="strikePrice">  the strike price of the option </param>
 /// <param name="underlyingExpiryMonth">  the expiry of the underlying instrument, such as a future </param>
 /// <returns> an option security based on this contract specification </returns>
 /// <exception cref="IllegalStateException"> if the product type of the contract specification is not {@code OPTION} </exception>
 public EtdOptionSecurity createOption(YearMonth expiryMonth, EtdVariant variant, int version, PutCall putCall, double strikePrice, YearMonth underlyingExpiryMonth)
 {
     return(EtdOptionSecurity.of(this, expiryMonth, variant, version, putCall, strikePrice, underlyingExpiryMonth));
 }
 internal static EtdVariant sut2()
 {
     return(EtdVariant.ofFlexOption(6, EtdSettlementType.CASH, EtdOptionType.EUROPEAN));
 }
Пример #18
0
        public virtual void test_optionId_daily21_version()
        {
            SecurityId test = EtdIdUtils.optionId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofDaily(21), 11, PutCall.PUT, 12.34);

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "O-ECAG-FGBS-20170621-V11-P12.34"));
        }
Пример #19
0
        public virtual void test_optionId_weekly()
        {
            SecurityId test = EtdIdUtils.optionId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofWeekly(3), 0, PutCall.CALL, -1.45);

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "O-ECAG-FGBS-201706W3-CM1.45"));
        }
Пример #20
0
        public virtual void test_futureId_flex()
        {
            SecurityId test = EtdIdUtils.futureId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofFlexFuture(26, EtdSettlementType.DERIVATIVE));

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "F-ECAG-FGBS-20170626D"));
        }
Пример #21
0
        public virtual void test_futureId_daily()
        {
            SecurityId test = EtdIdUtils.futureId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofDaily(2));

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "F-ECAG-FGBS-20170602"));
        }
Пример #22
0
        public virtual void test_optionIdUnderlying_daily9_version()
        {
            SecurityId test = EtdIdUtils.optionId(ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofDaily(9), 3, PutCall.PUT, 12.34, YearMonth.of(2017, 9));

            assertEquals(test.StandardId, StandardId.of("OG-ETD", "O-ECAG-FGBS-20170609-V3-P12.34-U201709"));
        }
Пример #23
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance from a contract specification, expiry year-month, variant, version, put/call and strike price.
 /// <para>
 /// The security identifier will be automatically created using <seealso cref="EtdIdUtils"/>.
 /// The specification must be for an option.
 ///
 /// </para>
 /// </summary>
 /// <param name="spec">  the option contract specification </param>
 /// <param name="expiry">  the expiry year-month of the option </param>
 /// <param name="variant">  the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' </param>
 /// <param name="version">  the non-negative version, zero if versioning does not apply </param>
 /// <param name="putCall">  whether the option is a put or call </param>
 /// <param name="strikePrice">  the strike price of the option </param>
 /// <returns> an option security based on this contract specification </returns>
 /// <exception cref="IllegalStateException"> if the product type of the contract specification is not {@code OPTION} </exception>
 public static EtdOptionSecurity of(EtdContractSpec spec, YearMonth expiry, EtdVariant variant, int version, PutCall putCall, double strikePrice)
 {
     return(of(spec, expiry, variant, version, putCall, strikePrice, null));
 }
Пример #24
0
        /// <summary>
        /// Creates an identifier for an ETD option instrument.
        /// <para>
        /// This takes into account the expiry of the underlying instrument. If the underlying expiry
        /// is the same as the expiry of the option, the identifier is the same as the normal one.
        /// Otherwise, the underlying expiry is added after the option expiry. For example:
        /// {@code 'OG-ETD~O-ECAG-OGBS-201706-P1.50-U201709'}.
        ///
        /// </para>
        /// </summary>
        /// <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>
        /// <param name="expiryMonth">  the month of expiry </param>
        /// <param name="variant">  the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' </param>
        /// <param name="version">  the non-negative version, zero by default </param>
        /// <param name="putCall">  the Put/Call flag </param>
        /// <param name="strikePrice">  the strike price </param>
        /// <param name="underlyingExpiryMonth">  the expiry of the underlying instrument, such as a future, may be null </param>
        /// <returns> the identifier </returns>
        public static SecurityId optionId(ExchangeId exchangeId, EtdContractCode contractCode, YearMonth expiryMonth, EtdVariant variant, int version, PutCall putCall, double strikePrice, YearMonth underlyingExpiryMonth)
        {
            ArgChecker.notNull(exchangeId, "exchangeId");
            ArgChecker.notNull(contractCode, "contractCode");
            ArgChecker.notNull(expiryMonth, "expiryMonth");
            ArgChecker.notNull(variant, "variant");
            ArgChecker.notNull(putCall, "putCall");

            string putCallStr  = putCall == PutCall.PUT ? "P" : "C";
            string versionCode = version > 0 ? "V" + version + SEPARATOR : "";

            NumberFormat f = NumberFormat.getIntegerInstance(Locale.ENGLISH);

            f.GroupingUsed          = false;
            f.MaximumFractionDigits = 8;
            string strikeStr = f.format(strikePrice).replace('-', 'M');

            string underlying = "";

            if (underlyingExpiryMonth != null && !underlyingExpiryMonth.Equals(expiryMonth))
            {
                underlying = SEPARATOR + "U" + underlyingExpiryMonth.format(YM_FORMAT);
            }

            string id = (new StringBuilder(40)).Append(OPT_PREFIX).Append(exchangeId).Append(SEPARATOR).Append(contractCode).Append(SEPARATOR).Append(expiryMonth.format(YM_FORMAT)).Append(variant.Code).Append(SEPARATOR).Append(versionCode).Append(putCallStr).Append(strikeStr).Append(underlying).ToString();

            return(SecurityId.of(ETD_SCHEME, id));
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Creates a future security based on this contract specification.
 /// <para>
 /// The security identifier will be automatically created using <seealso cref="EtdIdUtils"/>.
 /// The <seealso cref="#getType() type"/> must be <seealso cref="EtdType#FUTURE"/> otherwise an exception will be thrown.
 ///
 /// </para>
 /// </summary>
 /// <param name="expiryMonth">  the expiry month of the future </param>
 /// <param name="variant">  the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' </param>
 /// <returns> a future security based on this contract specification </returns>
 /// <exception cref="IllegalStateException"> if the product type of the contract specification is not {@code FUTURE} </exception>
 public EtdFutureSecurity createFuture(YearMonth expiryMonth, EtdVariant variant)
 {
     return(EtdFutureSecurity.of(this, expiryMonth, variant));
 }
Пример #26
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());
 }
 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());
 }
Пример #28
0
 /// <summary>
 /// Sets the variant of ETD.
 /// <para>
 /// This captures the variant of the ETD. The most common variant is 'Monthly'.
 /// Other variants are 'Weekly', 'Daily' and 'Flex'.
 /// </para>
 /// <para>
 /// When building, this defaults to 'Monthly'.
 /// </para>
 /// </summary>
 /// <param name="variant">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder variant(EtdVariant variant)
 {
     JodaBeanUtils.notNull(variant, "variant");
     this.variant_Renamed = variant;
     return(this);
 }
Пример #29
0
 /// <summary>
 /// Creates an identifier for an ETD option instrument.
 /// <para>
 /// A typical monthly ETD with version zero will have the format:
 /// {@code 'OG-ETD~O-ECAG-OGBS-201706-P1.50'}.
 /// </para>
 /// <para>
 /// A more complex flex ETD (12th of the month, Cash settlement, European) with version two will have the format:
 /// {@code 'OG-ETD~O-ECAG-OGBS-20170612CE-V2-P1.50'}.
 ///
 /// </para>
 /// </summary>
 /// <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>
 /// <param name="expiryMonth">  the month of expiry </param>
 /// <param name="variant">  the variant of the ETD, such as 'Monthly', 'Weekly, 'Daily' or 'Flex' </param>
 /// <param name="version">  the non-negative version, zero by default </param>
 /// <param name="putCall">  the Put/Call flag </param>
 /// <param name="strikePrice">  the strike price </param>
 /// <returns> the identifier </returns>
 public static SecurityId optionId(ExchangeId exchangeId, EtdContractCode contractCode, YearMonth expiryMonth, EtdVariant variant, int version, PutCall putCall, double strikePrice)
 {
     return(optionId(exchangeId, contractCode, expiryMonth, variant, version, putCall, strikePrice, null));
 }