public static ValuationReport Generate(string valuationId, string baseParty, Fra fra, Market market, AssetValuation assetValuation) { var valuationReport = new ValuationReport { header = new NotificationMessageHeader { messageId = new MessageId { Value = valuationId } }, market = market }; // Associate id with the valuation // var tradeValuationItem = new TradeValuationItem(); valuationReport.tradeValuationItem = new[] { tradeValuationItem }; var trade = new Trade(); XsdClassesFieldResolver.TradeSetFra(trade, fra); tradeValuationItem.Items = new object[] { trade }; tradeValuationItem.valuationSet = new ValuationSet { baseParty = PartyReferenceFactory.Create(baseParty), assetValuation = new[] { assetValuation } }; return(valuationReport); }
public void TestCreateFraValuationReport1() { var rateCurve = TestRateCurve(new DateTime(2009, 7, 15)); var fra = new Fra(); var pair = rateCurve.GetFpMLData(); var marketFactory = new MarketFactory(); marketFactory.AddPricingStructure(pair); Market market = marketFactory.Create(); const string baseParty = _NAB; var assetValuation = new AssetValuation(); var listOfQuotations = new List <Quotation>(); IEnumerable <StringDoubleRangeItem> valuationSet = CreateValuationSetList(54321, 123.5); foreach (StringDoubleRangeItem item in valuationSet) { var quotation = new Quotation { measureType = AssetMeasureTypeHelper.Parse(item.StringValue), value = (decimal)item.DoubleValue, valueSpecified = true }; listOfQuotations.Add(quotation); } assetValuation.quote = listOfQuotations.ToArray(); ValuationReport valuationReport = ValuationReportGenerator.Generate("some-valuation-Id", baseParty, fra, market, assetValuation); Debug.WriteLine("ValuationReport:"); Debug.WriteLine(XmlSerializerHelper.SerializeToString(valuationReport)); }
private static Trade trade(string counterparty, double notional) { TradeInfo tradeInfo = TradeInfo.builder().counterparty(StandardId.of("cpty", counterparty)).build(); Fra fra = Fra.builder().buySell(BUY).notional(notional).startDate(date(2015, 8, 5)).endDate(date(2015, 11, 5)).paymentDate(AdjustableDate.of(date(2015, 8, 7))).fixedRate(0.25d).index(GBP_LIBOR_3M).build(); return(FraTrade.builder().info(tradeInfo).product(fra).build()); }
public object DoReport(Fra forwardRateAgreement) { if (forwardRateAgreement != null) { var result = new object[9, 2]; result[0, 0] = "adjustedEffectiveDate"; result[1, 0] = "fixedRate"; result[2, 0] = "paymentDate"; result[3, 0] = "calculationPeriodNumberOfDays"; result[4, 0] = "adjustedTerminationDate"; result[5, 0] = "buyerPartyReference"; result[6, 0] = "sellerPartyReference"; result[7, 0] = "currency"; result[8, 0] = "notionalAmount"; result[0, 1] = forwardRateAgreement.adjustedEffectiveDate.Value; result[1, 1] = forwardRateAgreement.fixedRate; result[2, 1] = forwardRateAgreement.paymentDate.unadjustedDate.Value; result[3, 1] = forwardRateAgreement.calculationPeriodNumberOfDays; result[4, 1] = forwardRateAgreement.adjustedTerminationDate; result[5, 1] = forwardRateAgreement.buyerPartyReference.href; result[6, 1] = forwardRateAgreement.sellerPartyReference.href; result[7, 1] = forwardRateAgreement.notional.currency.Value; result[8, 1] = forwardRateAgreement.notional.amount; return(result); } return(null); }
private FraTrade(TradeInfo info, Fra product) { JodaBeanUtils.notNull(info, "info"); JodaBeanUtils.notNull(product, "product"); this.info = info; this.product = product; }
public virtual void test_createTrade_periods_adjust_payOffset() { FraConvention @base = ImmutableFraConvention.builder().index(GBP_LIBOR_3M).spotDateOffset(NEXT_SAME_BUS_DAY).paymentDateOffset(PLUS_TWO_DAYS).build(); LocalDate tradeDate = LocalDate.of(2016, 8, 11); FraTrade test = @base.createTrade(tradeDate, Period.ofMonths(1), Period.ofMonths(4), BUY, NOTIONAL_2M, 0.25d, REF_DATA); Fra expected = Fra.builder().buySell(BUY).notional(NOTIONAL_2M).startDate(date(2016, 9, 12)).endDate(date(2016, 12, 12)).paymentDate(AdjustableDate.of(date(2016, 9, 14), PLUS_TWO_DAYS.Adjustment)).fixedRate(0.25d).index(GBP_LIBOR_3M).build(); assertEquals(test.Info.TradeDate, tradeDate); assertEquals(test.Product, expected); }
//------------------------------------------------------------------------- public virtual void test_createTrade() { FraTemplate @base = FraTemplate.of(Period.ofMonths(3), Period.ofMonths(6), FRA_GBP_LIBOR_3M); LocalDate tradeDate = LocalDate.of(2015, 5, 4); // trade date is a holiday! FraTrade test = @base.createTrade(tradeDate, BUY, NOTIONAL_2M, 0.25d, REF_DATA); Fra expected = Fra.builder().buySell(BUY).notional(NOTIONAL_2M).startDate(date(2015, 8, 5)).endDate(date(2015, 11, 5)).fixedRate(0.25d).index(GBP_LIBOR_3M).build(); assertEquals(test.Info.TradeDate, tradeDate); assertEquals(test.Product, expected); }
//------------------------------------------------------------------------- public virtual void test_createTrade_periods() { FraConvention @base = ImmutableFraConvention.builder().index(GBP_LIBOR_3M).spotDateOffset(NEXT_SAME_BUS_DAY).build(); LocalDate tradeDate = LocalDate.of(2015, 5, 5); FraTrade test = @base.createTrade(tradeDate, Period.ofMonths(3), Period.ofMonths(6), BUY, NOTIONAL_2M, 0.25d, REF_DATA); Fra expected = Fra.builder().buySell(BUY).notional(NOTIONAL_2M).startDate(date(2015, 8, 5)).endDate(date(2015, 11, 5)).fixedRate(0.25d).index(GBP_LIBOR_3M).build(); assertEquals(test.Info.TradeDate, tradeDate); assertEquals(test.Product, expected); }
public virtual void test_createTrade_paymentOffset() { FraConvention convention = ((ImmutableFraConvention)FRA_GBP_LIBOR_3M).toBuilder().paymentDateOffset(PLUS_TWO_DAYS).build(); FraTemplate @base = FraTemplate.of(Period.ofMonths(3), Period.ofMonths(6), convention); LocalDate tradeDate = LocalDate.of(2015, 5, 4); // trade date is a holiday! FraTrade test = @base.createTrade(tradeDate, BUY, NOTIONAL_2M, 0.25d, REF_DATA); Fra expected = Fra.builder().buySell(BUY).notional(NOTIONAL_2M).startDate(date(2015, 8, 5)).endDate(date(2015, 11, 5)).paymentDate(AdjustableDate.of(date(2015, 8, 7), PLUS_TWO_DAYS.Adjustment)).fixedRate(0.25d).index(GBP_LIBOR_3M).build(); assertEquals(test.Info.TradeDate, tradeDate); assertEquals(test.Product, expected); }
public virtual void test_toTrade_dates_paymentOffset() { FraConvention @base = ImmutableFraConvention.builder().index(GBP_LIBOR_3M).spotDateOffset(NEXT_SAME_BUS_DAY).paymentDateOffset(PLUS_TWO_DAYS).build(); LocalDate tradeDate = LocalDate.of(2015, 5, 5); LocalDate startDate = date(2015, 8, 5); LocalDate endDate = date(2015, 11, 5); LocalDate paymentDate = date(2015, 8, 7); FraTrade test = @base.toTrade(tradeDate, startDate, endDate, paymentDate, BUY, NOTIONAL_2M, 0.25d); Fra expected = Fra.builder().buySell(BUY).notional(NOTIONAL_2M).startDate(date(2015, 8, 5)).endDate(date(2015, 11, 5)).paymentDate(AdjustableDate.of(paymentDate, PLUS_TWO_DAYS.Adjustment)).fixedRate(0.25d).index(GBP_LIBOR_3M).build(); assertEquals(test.Info.TradeDate, tradeDate); assertEquals(test.Product, expected); }
//------------------------------------------------------------------------- public virtual FunctionRequirements requirements(FraTrade trade, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData) { // extract data from product Fra product = trade.Product; ISet <IborIndex> indices = new HashSet <IborIndex>(); indices.Add(product.Index); product.IndexInterpolated.ifPresent(indices.add); ImmutableSet <Currency> currencies = ImmutableSet.of(product.Currency); // use lookup to build requirements RatesMarketDataLookup ratesLookup = parameters.getParameter(typeof(RatesMarketDataLookup)); return(ratesLookup.requirements(currencies, indices)); }
public virtual void test_trade() { FraCurveNode node = FraCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD); LocalDate valuationDate = LocalDate.of(2015, 1, 22); double rate = 0.035; ImmutableMarketData marketData = ImmutableMarketData.builder(valuationDate).addValue(QUOTE_ID, rate).build(); FraTrade trade = node.trade(1d, marketData, REF_DATA); LocalDate startDateExpected = BDA_MOD_FOLLOW.adjust(OFFSET.adjust(valuationDate, REF_DATA).plus(PERIOD_TO_START), REF_DATA); LocalDate endDateExpected = BDA_MOD_FOLLOW.adjust(OFFSET.adjust(valuationDate, REF_DATA).plus(PERIOD_TO_END), REF_DATA); Fra productExpected = Fra.builder().buySell(BuySell.SELL).currency(GBP).dayCount(ACT_365F).startDate(startDateExpected).endDate(endDateExpected).paymentDate(AdjustableDate.of(startDateExpected)).notional(1.0d).index(GBP_LIBOR_3M).fixedRate(rate + SPREAD).build(); TradeInfo tradeInfoExpected = TradeInfo.builder().tradeDate(valuationDate).build(); assertEquals(trade.Product, productExpected); assertEquals(trade.Info, tradeInfoExpected); }
//------------------------------------------------------------------------- public virtual void test_resolve_Ibor() { Fra fra = Fra.builder().buySell(BUY).notional(NOTIONAL_1M).startDate(date(2015, 6, 15)).endDate(date(2015, 9, 15)).paymentDate(AdjustableDate.of(date(2015, 6, 20), BDA_MOD_FOLLOW)).fixedRate(FIXED_RATE).index(GBP_LIBOR_3M).fixingDateOffset(MINUS_TWO_DAYS).build(); ResolvedFra test = fra.resolve(REF_DATA); assertEquals(test.Currency, GBP); assertEquals(test.Notional, NOTIONAL_1M, 0d); assertEquals(test.StartDate, date(2015, 6, 15)); assertEquals(test.EndDate, date(2015, 9, 15)); assertEquals(test.PaymentDate, date(2015, 6, 22)); assertEquals(test.FixedRate, FIXED_RATE, 0d); assertEquals(test.FloatingRate, IborRateComputation.of(GBP_LIBOR_3M, date(2015, 6, 11), REF_DATA)); assertEquals(test.YearFraction, ACT_365F.yearFraction(date(2015, 6, 15), date(2015, 9, 15)), 0d); assertEquals(test.Discounting, ISDA); }
public virtual void test_resolve_IborInterpolated() { Fra fra = Fra.builder().buySell(SELL).notional(NOTIONAL_1M).startDate(date(2015, 6, 12)).endDate(date(2015, 9, 5)).businessDayAdjustment(BDA_MOD_FOLLOW).fixedRate(FIXED_RATE).index(GBP_LIBOR_3M).indexInterpolated(GBP_LIBOR_2M).fixingDateOffset(MINUS_TWO_DAYS).build(); ResolvedFra test = fra.resolve(REF_DATA); assertEquals(test.Currency, GBP); assertEquals(test.Notional, -NOTIONAL_1M, 0d); // sell assertEquals(test.StartDate, date(2015, 6, 12)); assertEquals(test.EndDate, date(2015, 9, 7)); assertEquals(test.PaymentDate, date(2015, 6, 12)); assertEquals(test.FixedRate, FIXED_RATE, 0d); assertEquals(test.FloatingRate, IborInterpolatedRateComputation.of(GBP_LIBOR_2M, GBP_LIBOR_3M, date(2015, 6, 10), REF_DATA)); assertEquals(test.YearFraction, ACT_365F.yearFraction(date(2015, 6, 12), date(2015, 9, 7)), 0d); assertEquals(test.Discounting, ISDA); }
/// <summary> /// /// </summary> /// <param name="fraInputRange"></param> /// <returns></returns> public static Fra GetFpMLFra(FraInputRange fraInputRange) { var fra = new Fra { adjustedEffectiveDate = DateTypesHelper.ToRequiredIdentifierDate(fraInputRange.AdjustedEffectiveDate), adjustedTerminationDate = fraInputRange.AdjustedTerminationDate, paymentDate = DateTypesHelper.ToAdjustableDate(fraInputRange.UnadjustedPaymentDate, fraInputRange.PaymentDateBusinessDayConvention, fraInputRange.PaymentDateBusinessCenters) }; if ("resetDate" != fraInputRange.FixingDayOffsetDateRelativeTo) { throw new ArgumentException("The fixing date must be specified as 'resetDate'-relative!", nameof(fraInputRange)); } var fixingDayType = EnumHelper.Parse <DayTypeEnum>(fraInputRange.FixingDayOffsetDayType); fra.fixingDateOffset = RelativeDateOffsetHelper.Create(fraInputRange.FixingDayOffsetPeriod, fixingDayType, fraInputRange.FixingDayOffsetBusinessDayConvention, fraInputRange.FixingDayOffsetBusinessCenters, fraInputRange.FixingDayOffsetDateRelativeTo); fra.dayCountFraction = DayCountFractionHelper.Parse(fraInputRange.DayCountFraction); IDayCounter dayCounter = DayCounterHelper.Parse(fra.dayCountFraction.Value); fra.calculationPeriodNumberOfDays = dayCounter.DayCount(fra.adjustedEffectiveDate.Value, fra.adjustedTerminationDate).ToString(); fra.notional = MoneyHelper.GetAmount(fraInputRange.NotionalAmount, fraInputRange.NotionalCurrency); fra.fixedRate = (decimal)fraInputRange.FixedRate; fra.floatingRateIndex = FloatingRateIndexHelper.Parse(fraInputRange.FloatingRateIndex); fra.indexTenor = new[] { PeriodHelper.Parse(fraInputRange.IndexTenor) }; fra.fraDiscounting = fraInputRange.FraDiscounting; PartyReference nabParty = PartyReferenceFactory.Create("NAB"); PartyReference counterParty = PartyReferenceFactory.Create("COUNTERPARTY"); if (bool.Parse(fraInputRange.Sell)) { fra.sellerPartyReference = nabParty; fra.buyerPartyReference = counterParty; } else { fra.sellerPartyReference = counterParty; fra.buyerPartyReference = nabParty; } return(fra); }
public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case 3237038: // info this.info_Renamed = (TradeInfo)newValue; break; case -309474065: // product this.product_Renamed = (Fra)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
public virtual void test_builder_NZD() { ImmutableIborIndex dummyIndex = ImmutableIborIndex.builder().name("NZD-INDEX-3M").currency(NZD).dayCount(ACT_360).fixingDateOffset(MINUS_TWO_DAYS).effectiveDateOffset(PLUS_TWO_DAYS).maturityDateOffset(TenorAdjustment.ofLastDay(TENOR_3M, BDA_MOD_FOLLOW)).fixingCalendar(SAT_SUN).fixingTime(LocalTime.NOON).fixingZone(ZoneId.of("NZ")).build(); Fra test = Fra.builder().buySell(BUY).notional(NOTIONAL_1M).startDate(date(2015, 6, 15)).endDate(date(2015, 9, 15)).paymentDate(AdjustableDate.of(date(2015, 6, 16))).fixedRate(FIXED_RATE).index(dummyIndex).fixingDateOffset(MINUS_TWO_DAYS).build(); assertEquals(test.BuySell, BUY); assertEquals(test.Currency, NZD); // defaulted assertEquals(test.Notional, NOTIONAL_1M, 0d); assertEquals(test.StartDate, date(2015, 6, 15)); assertEquals(test.EndDate, date(2015, 9, 15)); assertEquals(test.BusinessDayAdjustment, null); assertEquals(test.PaymentDate, AdjustableDate.of(date(2015, 6, 16))); assertEquals(test.FixedRate, FIXED_RATE, 0d); assertEquals(test.Index, dummyIndex); assertEquals(test.IndexInterpolated, null); assertEquals(test.FixingDateOffset, MINUS_TWO_DAYS); assertEquals(test.DayCount, ACT_360); // defaulted assertEquals(test.Discounting, AFMA); // defaulted }
//------------------------------------------------------------------------- public virtual void test_builder() { Fra test = sut(); assertEquals(test.BuySell, BUY); assertEquals(test.Currency, GBP); // defaulted assertEquals(test.Notional, NOTIONAL_1M, 0d); assertEquals(test.StartDate, date(2015, 6, 15)); assertEquals(test.EndDate, date(2015, 9, 15)); assertEquals(test.BusinessDayAdjustment, null); assertEquals(test.PaymentDate, AdjustableDate.of(date(2015, 6, 15))); assertEquals(test.FixedRate, FIXED_RATE, 0d); assertEquals(test.Index, GBP_LIBOR_3M); assertEquals(test.IndexInterpolated, null); assertEquals(test.FixingDateOffset, GBP_LIBOR_3M.FixingDateOffset); // defaulted assertEquals(test.DayCount, ACT_365F); // defaulted assertEquals(test.Discounting, ISDA); // defaulted assertEquals(test.CrossCurrency, false); assertEquals(test.allPaymentCurrencies(), ImmutableSet.of(GBP)); assertEquals(test.allCurrencies(), ImmutableSet.of(GBP)); }
//------------------------------------------------------------------------- public Trade parseTrade(FpmlDocument document, XmlElement tradeEl) { // supported elements: // 'buyerPartyReference' // 'sellerPartyReference' // 'adjustedTerminationDate' // 'paymentDate' // 'fixingDateOffset' // 'dayCountFraction' // 'notional' // 'fixedRate' // 'floatingRateIndex' // 'indexTenor+' // 'fraDiscounting' // ignored elements: // 'Product.model?' // 'buyerAccountReference?' // 'sellerAccountReference?' // 'calculationPeriodNumberOfDays' // 'additionalPayment*' TradeInfoBuilder tradeInfoBuilder = document.parseTradeInfo(tradeEl); XmlElement fraEl = tradeEl.getChild("fra"); Fra.Builder fraBuilder = Fra.builder(); // buy/sell and counterparty fraBuilder.buySell(document.parseBuyerSeller(fraEl, tradeInfoBuilder)); // start date fraBuilder.startDate(document.parseDate(fraEl.getChild("adjustedEffectiveDate"))); // end date fraBuilder.endDate(document.parseDate(fraEl.getChild("adjustedTerminationDate"))); // payment date fraBuilder.paymentDate(document.parseAdjustableDate(fraEl.getChild("paymentDate"))); // fixing offset fraBuilder.fixingDateOffset(document.parseRelativeDateOffsetDays(fraEl.getChild("fixingDateOffset"))); // dateRelativeTo required to refer to adjustedEffectiveDate, so ignored here // day count fraBuilder.dayCount(document.parseDayCountFraction(fraEl.getChild("dayCountFraction"))); // notional CurrencyAmount notional = document.parseCurrencyAmount(fraEl.getChild("notional")); fraBuilder.currency(notional.Currency); fraBuilder.notional(notional.Amount); // fixed rate fraBuilder.fixedRate(document.parseDecimal(fraEl.getChild("fixedRate"))); // index IList <Index> indexes = document.parseIndexes(fraEl); switch (indexes.Count) { case 1: fraBuilder.index((IborIndex)indexes[0]); break; case 2: fraBuilder.index((IborIndex)indexes[0]); fraBuilder.indexInterpolated((IborIndex)indexes[1]); break; default: throw new FpmlParseException("Expected one or two indexes, but found " + indexes.Count); } // discounting fraBuilder.discounting(FraDiscountingMethod.of(fraEl.getChild("fraDiscounting").Content)); return(FraTrade.builder().info(tradeInfoBuilder.build()).product(fraBuilder.build()).build()); }
//------------------------------------------------------------------------- /// <summary> /// Obtains an instance of a FRA trade. /// </summary> /// <param name="info"> the trade info </param> /// <param name="product"> the product </param> /// <returns> the trade </returns> public static FraTrade of(TradeInfo info, Fra product) { return(new FraTrade(info, product)); }
private ResolvedFra createNewFra(Fra product, double newFixedRate) { return Fra.builder().buySell(product.BuySell).notional(product.Notional).startDate(product.StartDate).endDate(product.EndDate).index(product.Index).fixedRate(newFixedRate).currency(product.Currency).build().resolve(REF_DATA); }
private static Bean bean() { return(Fra.builder().buySell(BUY).notional(1_000_000).startDate(date(2015, 8, 5)).endDate(date(2015, 11, 5)).paymentDate(AdjustableDate.of(date(2015, 8, 7))).fixedRate(0.25d).index(GBP_LIBOR_3M).build()); }
public static void TradeSetFra(Trade trade, Fra fra) { trade.Item = fra; trade.ItemElementName = ItemChoiceType15.fra; }
public static double InstrumentFactory_ParFraRate(string instrumentFactory, string model, string instrument) { Fra fra = ObjectMap.InstrumentFactories[instrumentFactory].Fras[instrument]; return(ObjectMap.LinearRateModels[model].ParFraRate(fra)); }
/// <summary> /// Sets the FRA product that was agreed when the trade occurred. /// <para> /// The product captures the contracted financial details of the trade. /// </para> /// </summary> /// <param name="product"> the new value, not null </param> /// <returns> this, for chaining, not null </returns> public Builder product(Fra product) { JodaBeanUtils.notNull(product, "product"); this.product_Renamed = product; return(this); }
internal static Fra sut2() { return(Fra.builder().buySell(SELL).currency(USD).notional(NOTIONAL_2M).startDate(date(2015, 6, 16)).endDate(date(2015, 8, 17)).businessDayAdjustment(BDA_MOD_FOLLOW).paymentDate(AdjustableDate.of(date(2015, 6, 17))).dayCount(ACT_360).fixedRate(0.30d).index(GBP_LIBOR_2M).indexInterpolated(GBP_LIBOR_3M).fixingDateOffset(MINUS_FIVE_DAYS).discounting(FraDiscountingMethod.NONE).build()); }
//------------------------------------------------------------------------- internal static Fra sut() { return(Fra.builder().buySell(BUY).notional(NOTIONAL_1M).startDate(date(2015, 6, 15)).endDate(date(2015, 9, 15)).fixedRate(FIXED_RATE).index(GBP_LIBOR_3M).build()); }
/// <summary> /// Restricted copy constructor. </summary> /// <param name="beanToCopy"> the bean to copy from, not null </param> internal Builder(FraTrade beanToCopy) { this.info_Renamed = beanToCopy.Info; this.product_Renamed = beanToCopy.Product; }
public string CreateFraValuationReport(ICoreCache cache, string nameSpace, string id, string baseParty, Fra fra, Market market, AssetValuation assetValuation, NamedValueSet properties) { ValuationReport valuationReport = ValuationReportGenerator.Generate(id, baseParty, fra, market, assetValuation); cache.SaveObject(valuationReport, nameSpace + "." + id, properties); return(id); }
public virtual void test_builder_noDates() { assertThrowsIllegalArg(() => Fra.builder().buySell(BUY).notional(NOTIONAL_1M).endDate(date(2015, 9, 15)).fixedRate(FIXED_RATE).index(GBP_LIBOR_3M).build()); }