コード例 #1
0
        public virtual void test_ofTradeUnitValue()
        {
            SecurityPriceInfo priceInfo = SecurityPriceInfo.of(USD, 2000);
            double            value     = priceInfo.calculateMonetaryValue(3, 2);

            assertEquals(value, 12_000d);
        }
コード例 #2
0
        public virtual void test_ofCurrencyMinorUnit_JPY()
        {
            SecurityPriceInfo test = SecurityPriceInfo.ofCurrencyMinorUnit(JPY);

            assertEquals(test.TickSize, 1d);
            assertEquals(test.TickValue, CurrencyAmount.of(JPY, 1));
            assertEquals(test.ContractSize, 1d);
            assertEquals(test.Currency, JPY);
        }
コード例 #3
0
        public virtual void test_ofCurrencyMinorUnit_GBP()
        {
            SecurityPriceInfo test = SecurityPriceInfo.ofCurrencyMinorUnit(GBP);

            assertEquals(test.TickSize, 0.01);
            assertEquals(test.TickValue, CurrencyAmount.of(GBP, 0.01));
            assertEquals(test.ContractSize, 1d);
            assertEquals(test.Currency, GBP);
        }
コード例 #4
0
        public virtual void test_of_withContractSize()
        {
            SecurityPriceInfo test = SecurityPriceInfo.of(0.01, CurrencyAmount.of(GBP, 0.01), 20);

            assertEquals(test.TickSize, 0.01);
            assertEquals(test.TickValue, CurrencyAmount.of(GBP, 0.01));
            assertEquals(test.ContractSize, 20d);
            assertEquals(test.Currency, GBP);
        }
コード例 #5
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            SecurityPriceInfo test = SecurityPriceInfo.of(0.01, CurrencyAmount.of(GBP, 0.01));

            coverImmutableBean(test);
            SecurityPriceInfo test2 = SecurityPriceInfo.of(0.02, CurrencyAmount.of(GBP, 1), 20);

            coverBeanEquals(test, test2);
        }
コード例 #6
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         SecurityPriceInfo other = (SecurityPriceInfo)obj;
         return(JodaBeanUtils.equal(tickSize, other.tickSize) && JodaBeanUtils.equal(tickValue, other.tickValue) && JodaBeanUtils.equal(contractSize, other.contractSize));
     }
     return(false);
 }
コード例 #7
0
        public virtual void test_calculateMonetaryValue()
        {
            // CME-ED, 1bp = $25
            SecurityPriceInfo test = SecurityPriceInfo.of(0.005, CurrencyAmount.of(USD, 12.50), 1);

            assertEquals(test.calculateMonetaryValue(1, 98), 245_000d);
            assertEquals(test.calculateMonetaryValue(1, 98.02), 245_050d);
            // quantity is simple multiplier
            assertEquals(test.calculateMonetaryValue(2, 98), 2 * 245_000d);
            assertEquals(test.calculateMonetaryValue(3, 98), 3 * 245_000d);
            // contract size is simple multiplier
            SecurityPriceInfo test2 = SecurityPriceInfo.of(0.005, CurrencyAmount.of(USD, 12.50), 2);

            assertEquals(test2.calculateMonetaryValue(1, 98), 2 * 245_000d);
        }
コード例 #8
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance from the identifier, tick size and tick value.
 /// <para>
 /// This creates an instance, building the <seealso cref="SecurityPriceInfo"/> from
 /// the tick size and tick value, setting the contract size to 1.
 /// </para>
 /// <para>
 /// A {@code SecurityInfo} also contains a hash map of additional information,
 /// keyed by <seealso cref="AttributeType"/>. This hash map may contain anything
 /// of interest, and is populated using <seealso cref="#withAttribute(AttributeType, Object)"/>.
 ///
 /// </para>
 /// </summary>
 /// <param name="id">  the security identifier </param>
 /// <param name="tickSize">  the size of each tick, not negative or zero </param>
 /// <param name="tickValue">  the value of each tick </param>
 /// <returns> the security information </returns>
 public static SecurityInfo of(SecurityId id, double tickSize, CurrencyAmount tickValue)
 {
     return(new SecurityInfo(id, SecurityPriceInfo.of(tickSize, tickValue), ImmutableMap.of()));
 }
コード例 #9
0
 /// <summary>
 /// Obtains an instance from the identifier and pricing info.
 /// <para>
 /// A {@code SecurityInfo} also contains a hash map of additional information,
 /// keyed by <seealso cref="AttributeType"/>. This hash map may contain anything
 /// of interest, and is populated using <seealso cref="#withAttribute(AttributeType, Object)"/>.
 ///
 /// </para>
 /// </summary>
 /// <param name="id">  the security identifier </param>
 /// <param name="priceInfo">  the information about the price </param>
 /// <returns> the security information </returns>
 public static SecurityInfo of(SecurityId id, SecurityPriceInfo priceInfo)
 {
     return(new SecurityInfo(id, priceInfo, ImmutableMap.of()));
 }
コード例 #10
0
        public virtual void test_serialization()
        {
            SecurityPriceInfo test = SecurityPriceInfo.of(0.01, CurrencyAmount.of(GBP, 0.01));

            assertSerialization(test);
        }
コード例 #11
0
        public virtual void test_getTradeUnitValue()
        {
            SecurityPriceInfo test = SecurityPriceInfo.of(0.005, CurrencyAmount.of(USD, 12.50), 2);

            assertEquals(test.TradeUnitValue, 5000d);
        }