public virtual void test_ofTradeUnitValue() { SecurityPriceInfo priceInfo = SecurityPriceInfo.of(USD, 2000); double value = priceInfo.calculateMonetaryValue(3, 2); assertEquals(value, 12_000d); }
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); }
//------------------------------------------------------------------------- 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); }
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); }
//------------------------------------------------------------------------- /// <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())); }
public virtual void test_serialization() { SecurityPriceInfo test = SecurityPriceInfo.of(0.01, CurrencyAmount.of(GBP, 0.01)); assertSerialization(test); }
public virtual void test_getTradeUnitValue() { SecurityPriceInfo test = SecurityPriceInfo.of(0.005, CurrencyAmount.of(USD, 12.50), 2); assertEquals(test.TradeUnitValue, 5000d); }