public virtual void test_withInfo()
        {
            BillSecurity @base    = BillSecurity.builder().dayCount(DAY_COUNT).info(INFO).legalEntityId(LEGAL_ENTITY).notional(NOTIONAL).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build();
            SecurityInfo info     = SecurityInfo.of(SECURITY_ID, SecurityPriceInfo.ofCurrencyMinorUnit(CCY));
            BillSecurity expected = BillSecurity.builder().dayCount(DAY_COUNT).info(info).legalEntityId(LEGAL_ENTITY).notional(NOTIONAL).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build();

            assertEquals(@base.withInfo(info), expected);
        }
        public virtual void test_load_invalidNoQuantity()
        {
            EtdContractSpecId specId   = EtdContractSpecId.of("OG-ETD", "F-ECAG-FGBL");
            EtdContractSpec   contract = EtdContractSpec.builder().id(specId).type(EtdType.FUTURE).exchangeId(ExchangeIds.ECAG).contractCode(FGBL).description("Dummy").priceInfo(SecurityPriceInfo.of(Currency.GBP, 100)).build();
            ReferenceData     refData  = ImmutableReferenceData.of(specId, contract);
            PositionCsvLoader test     = PositionCsvLoader.of(refData);
            ValueWithFailures <IList <Position> > trades = test.parse(ImmutableList.of(CharSource.wrap("Strata Position Type,Exchange,Contract Code,Expiry\nFUT,ECAG,FGBL,2017-06")));

            assertEquals(trades.Failures.size(), 1);
            FailureItem failure = trades.Failures.get(0);

            assertEquals(failure.Reason, FailureReason.PARSING);
            assertEquals(failure.Message, "CSV file position could not be parsed at line 2: " + "Security must contain a quantity column, either 'Quantity' or 'Long Quantity' and 'Short Quantity'");
        }
        //-------------------------------------------------------------------------
        public virtual void test_parse_option()
        {
            EtdContractSpecId specId   = EtdContractSpecId.of("OG-ETD", "O-ECAG-OGBL");
            EtdContractSpec   contract = EtdContractSpec.builder().id(specId).type(EtdType.OPTION).exchangeId(ExchangeIds.ECAG).contractCode(OGBL).description("Dummy").priceInfo(SecurityPriceInfo.of(Currency.GBP, 100)).build();
            ReferenceData     refData  = ImmutableReferenceData.of(specId, contract);
            PositionCsvLoader test     = PositionCsvLoader.of(refData);
            ValueWithFailures <IList <EtdOptionPosition> > trades = test.parse(ImmutableList.of(FILE.CharSource), typeof(EtdOptionPosition));

            IList <EtdOptionPosition> filtered = trades.Value;

            assertEquals(filtered.Count, 3);

            EtdOptionPosition expected1 = EtdOptionPosition.builder().info(PositionInfo.builder().id(StandardId.of("OG", "123431")).build()).security(EtdOptionSecurity.of(contract, YearMonth.of(2017, 6), EtdVariant.ofMonthly(), 0, PutCall.PUT, 3d, YearMonth.of(2017, 9))).longQuantity(15d).shortQuantity(2d).build();

            assertBeanEquals(expected1, filtered[0]);

            EtdOptionPosition expected2 = EtdOptionPosition.builder().info(PositionInfo.builder().id(StandardId.of("OG", "123432")).build()).security(EtdOptionSecurity.of(contract, YearMonth.of(2017, 6), EtdVariant.ofFlexOption(13, EtdSettlementType.CASH, EtdOptionType.AMERICAN), 0, PutCall.CALL, 4d)).longQuantity(0d).shortQuantity(13d).build();

            assertBeanEquals(expected2, filtered[1]);

            EtdOptionPosition expected3 = EtdOptionPosition.builder().info(PositionInfo.builder().id(StandardId.of("OG", "123433")).build()).security(EtdOptionSecurity.of(contract, YearMonth.of(2017, 6), EtdVariant.ofWeekly(2), 0, PutCall.PUT, 5.1d)).longQuantity(0d).shortQuantity(20d).build();

            assertBeanEquals(expected3, filtered[2]);
        }
        //-------------------------------------------------------------------------
        public virtual void test_parse_future()
        {
            EtdContractSpecId specId   = EtdContractSpecId.of("OG-ETD", "F-ECAG-FGBL");
            EtdContractSpec   contract = EtdContractSpec.builder().id(specId).type(EtdType.FUTURE).exchangeId(ExchangeIds.ECAG).contractCode(FGBL).description("Dummy").priceInfo(SecurityPriceInfo.of(Currency.GBP, 100)).build();
            ReferenceData     refData  = ImmutableReferenceData.of(specId, contract);
            PositionCsvLoader test     = PositionCsvLoader.of(refData);
            ValueWithFailures <IList <EtdFuturePosition> > trades = test.parse(ImmutableList.of(FILE.CharSource), typeof(EtdFuturePosition));
            IList <EtdFuturePosition> filtered = trades.Value;

            assertEquals(filtered.Count, 4);

            EtdFuturePosition expected1 = EtdFuturePosition.builder().info(PositionInfo.builder().id(StandardId.of("OG", "123421")).build()).security(EtdFutureSecurity.of(contract, YearMonth.of(2017, 6), EtdVariant.ofMonthly())).longQuantity(15d).shortQuantity(2d).build();

            assertBeanEquals(expected1, filtered[0]);

            EtdFuturePosition expected2 = EtdFuturePosition.builder().info(PositionInfo.builder().id(StandardId.of("OG", "123422")).build()).security(EtdFutureSecurity.of(contract, YearMonth.of(2017, 6), EtdVariant.ofFlexFuture(13, EtdSettlementType.CASH))).longQuantity(0d).shortQuantity(13d).build();

            assertBeanEquals(expected2, filtered[1]);

            EtdFuturePosition expected3 = EtdFuturePosition.builder().info(PositionInfo.builder().id(StandardId.of("OG", "123423")).build()).security(EtdFutureSecurity.of(contract, YearMonth.of(2017, 6), EtdVariant.ofWeekly(2))).longQuantity(0d).shortQuantity(20d).build();

            assertBeanEquals(expected3, filtered[2]);

            EtdFuturePosition expected4 = EtdFuturePosition.builder().info(PositionInfo.builder().id(StandardId.of("OG", "123424")).build()).security(EtdFutureSecurity.of(contract, YearMonth.of(2017, 6), EtdVariant.ofDaily(3))).longQuantity(30d).shortQuantity(0d).build();

            assertBeanEquals(expected4, filtered[3]);
        }
Esempio n. 5
0
 internal static EtdContractSpec sut2()
 {
     return(EtdContractSpec.builder().type(EtdType.OPTION).exchangeId(ExchangeIds.IFEN).contractCode(EtdContractCode.of("BAR")).description("A test option template").priceInfo(SecurityPriceInfo.of(Currency.EUR, 10)).addAttribute(AttributeType.NAME, "NAME").build());
 }
Esempio n. 6
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());
 }
Esempio n. 7
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());
 }
Esempio n. 8
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());
 }
 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());
 }
 //-------------------------------------------------------------------------
 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());
 }
 /// <summary>
 /// Sets the information about the security price - currency, tick size, tick value, contract size.
 /// </summary>
 /// <param name="priceInfo">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public EtdContractSpecBuilder priceInfo(SecurityPriceInfo priceInfo)
 {
     JodaBeanUtils.notNull(priceInfo, "priceInfo");
     this.priceInfo_Renamed = priceInfo;
     return(this);
 }