//-------------------------------------------------------------------------
        public virtual void test_of_map()
        {
            ImmutableMap <SecurityId, RepoGroup>               repoSecurityGroups = ImmutableMap.of(SEC_A1, GROUP_REPO_X);
            ImmutableMap <LegalEntityId, RepoGroup>            repoGroups         = ImmutableMap.of(ISSUER_A, GROUP_REPO_Y, ISSUER_B, GROUP_REPO_Y, ISSUER_C, GROUP_REPO_Y, ISSUER_D, GROUP_REPO_Y);
            ImmutableMap <Pair <RepoGroup, Currency>, CurveId> repoCurves         = ImmutableMap.of(Pair.of(GROUP_REPO_X, USD), CURVE_ID_USD1, Pair.of(GROUP_REPO_Y, USD), CURVE_ID_USD2, Pair.of(GROUP_REPO_Y, GBP), CURVE_ID_GBP1);

            ImmutableMap <LegalEntityId, LegalEntityGroup>            issuerGroups = ImmutableMap.of(ISSUER_A, GROUP_ISSUER_M, ISSUER_B, GROUP_ISSUER_N, ISSUER_C, GROUP_ISSUER_M);
            ImmutableMap <Pair <LegalEntityGroup, Currency>, CurveId> issuerCurves = ImmutableMap.of(Pair.of(GROUP_ISSUER_M, USD), CURVE_ID_USD3, Pair.of(GROUP_ISSUER_N, USD), CURVE_ID_USD4, Pair.of(GROUP_ISSUER_N, GBP), CURVE_ID_GBP2);

            LegalEntityDiscountingMarketDataLookup test = LegalEntityDiscountingMarketDataLookup.of(repoSecurityGroups, repoGroups, repoCurves, issuerGroups, issuerCurves);

            assertEquals(test.queryType(), typeof(LegalEntityDiscountingMarketDataLookup));

            assertEquals(test.requirements(SEC_A1, ISSUER_A, USD), FunctionRequirements.builder().valueRequirements(CURVE_ID_USD1, CURVE_ID_USD3).outputCurrencies(USD).build());
            assertEquals(test.requirements(SEC_A2, ISSUER_A, USD), FunctionRequirements.builder().valueRequirements(CURVE_ID_USD2, CURVE_ID_USD3).outputCurrencies(USD).build());
            assertEquals(test.requirements(SEC_B1, ISSUER_B, USD), FunctionRequirements.builder().valueRequirements(CURVE_ID_USD2, CURVE_ID_USD4).outputCurrencies(USD).build());
            assertEquals(test.requirements(SEC_B1, ISSUER_B, GBP), FunctionRequirements.builder().valueRequirements(CURVE_ID_GBP1, CURVE_ID_GBP2).outputCurrencies(GBP).build());
            assertThrowsIllegalArg(() => test.requirements(SEC_B1, LegalEntityId.of("XXX", "XXX"), GBP));
            assertThrowsIllegalArg(() => test.requirements(SecurityId.of("XXX", "XXX"), LegalEntityId.of("XXX", "XXX"), GBP));
            assertThrowsIllegalArg(() => test.requirements(SEC_A1, ISSUER_A, GBP));
            assertThrowsIllegalArg(() => test.requirements(SEC_C1, ISSUER_C, GBP));
            assertThrowsIllegalArg(() => test.requirements(SEC_D1, ISSUER_D, GBP));

            assertEquals(test.discountingProvider(MOCK_MARKET_DATA), DefaultLookupLegalEntityDiscountingProvider.of((DefaultLegalEntityDiscountingMarketDataLookup)test, MOCK_MARKET_DATA));
        }
        // parses the base SecurityPosition
        internal static SecurityPosition parseSecurityPosition(CsvRow row, PositionInfo info, PositionCsvInfoResolver resolver)
        {
            string           securityIdScheme = row.findValue(SECURITY_ID_SCHEME_FIELD).orElse(DEFAULT_SECURITY_SCHEME);
            string           securityIdValue  = row.getValue(SECURITY_ID_FIELD);
            SecurityId       securityId       = SecurityId.of(securityIdScheme, securityIdValue);
            DoublesPair      quantity         = CsvLoaderUtils.parseQuantity(row);
            SecurityPosition position         = SecurityPosition.ofLongShort(info, securityId, quantity.First, quantity.Second);

            return(resolver.completePosition(row, position));
        }
        // parses a SecurityTrade from the CSV row
        private static SecurityTrade parseSecurityTrade(CsvRow row, TradeInfo info, TradeCsvInfoResolver resolver)
        {
            string     securityIdScheme = row.findValue(SECURITY_ID_SCHEME_FIELD).orElse(DEFAULT_SECURITY_SCHEME);
            string     securityIdValue  = row.getValue(SECURITY_ID_FIELD);
            SecurityId securityId       = SecurityId.of(securityIdScheme, securityIdValue);
            double     price            = LoaderUtils.parseDouble(row.getValue(PRICE_FIELD));
            double     quantity         = parseTradeQuantity(row);

            return(SecurityTrade.of(info, securityId, quantity, price));
        }
Ejemplo n.º 4
0
        //-------------------------------------------------------------------------
        public virtual void test_discountFactor_notFound()
        {
            LegalEntityId    issuerId    = LegalEntityId.of("OG-Ticker", "Issuer-2");
            LegalEntityGroup issuerGroup = LegalEntityGroup.of("ISSUER2");
            RepoGroup        repoGroup   = RepoGroup.of("ISSUER2 BND 5Y");
            SecurityId       securityId  = SecurityId.of("OG-Ticker", "Issuer-2-bond-5Y");
            ImmutableLegalEntityDiscountingProvider test = ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), DSC_FACTORS_ISSUER)).issuerCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_ISSUER, issuerId, issuerGroup)).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_SECURITY, GBP), DSC_FACTORS_REPO)).repoCurveGroups(ImmutableMap.of(issuerId, repoGroup)).repoCurveSecurityGroups(ImmutableMap.of(ID_SECURITY, GROUP_REPO_SECURITY)).valuationDate(DATE).build();

            assertThrowsIllegalArg(() => test.issuerCurveDiscountFactors(ID_ISSUER, USD));
            assertThrowsIllegalArg(() => test.issuerCurveDiscountFactors(LegalEntityId.of("OG-Ticker", "foo"), GBP));
            assertThrowsIllegalArg(() => test.issuerCurveDiscountFactors(issuerId, GBP));
            assertThrowsIllegalArg(() => test.repoCurveDiscountFactors(ID_SECURITY, ID_ISSUER, USD));
            assertThrowsIllegalArg(() => test.repoCurveDiscountFactors(SecurityId.of("OG-Ticker", "foo-bond"), LegalEntityId.of("OG-Ticker", "foo"), GBP));
            assertThrowsIllegalArg(() => test.repoCurveDiscountFactors(securityId, issuerId, GBP));
        }
 static BondDataSets()
 {
     for (int i = 0; i < NB_BOND_USD; ++i)
     {
         LocalDate        endDate        = START_DATE_USD[i].plus(BOND_TENOR_USD[i]);
         PeriodicSchedule periodSchedule = PeriodicSchedule.of(START_DATE_USD[i], endDate, Frequency.P6M, BUSINESS_ADJUST_USD, StubConvention.SHORT_INITIAL, false);
         FixedCouponBond  product        = FixedCouponBond.builder().securityId(SecurityId.of(BOND_SECURITY_ID[i])).dayCount(DAY_COUNT_USD).fixedRate(RATE_USD[i]).legalEntityId(ISSUER_ID_USD).currency(USD).notional(NOTIONAL_USD).accrualSchedule(periodSchedule).settlementDateOffset(SETTLEMENT_DAYS_USD).yieldConvention(YIELD_CONVENTION_USD).exCouponPeriod(EX_COUPON_USD).build();
         BOND_USD[i] = product;
     }
     for (int i = 0; i < NB_BOND_EUR; ++i)
     {
         LocalDate        endDate        = START_DATE_EUR[i].plus(BOND_TENOR_EUR[i]);
         PeriodicSchedule periodSchedule = PeriodicSchedule.of(START_DATE_EUR[i], endDate, Frequency.P12M, BUSINESS_ADJUST_EUR, StubConvention.SHORT_INITIAL, false);
         FixedCouponBond  product        = FixedCouponBond.builder().securityId(SecurityId.of(BOND_SECURITY_ID_EUR[i])).dayCount(DAY_COUNT_EUR).fixedRate(RATE_EUR[i]).legalEntityId(ISSUER_ID_EUR).currency(EUR).notional(NOTIONAL_EUR).accrualSchedule(periodSchedule).settlementDateOffset(SETTLEMENT_DAYS_EUR).yieldConvention(YIELD_CONVENTION_EUR).exCouponPeriod(EX_COUPON_EUR).build();
         BOND_EUR[i] = product;
     }
 }