//------------------------------------------------------------------------- /// <summary> /// Creates an {@code IborRateObservation} from an index and fixing date. /// <para> /// The reference data is used to find the maturity date from the fixing date. /// /// </para> /// </summary> /// <param name="index"> the index </param> /// <param name="fixingDate"> the fixing date </param> /// <param name="refData"> the reference data to use when resolving holiday calendars </param> /// <returns> the rate observation </returns> public static OvernightIndexObservation of(OvernightIndex index, LocalDate fixingDate, ReferenceData refData) { LocalDate publicationDate = index.calculatePublicationFromFixing(fixingDate, refData); LocalDate effectiveDate = index.calculateEffectiveFromFixing(fixingDate, refData); LocalDate maturityDate = index.calculateMaturityFromEffective(effectiveDate, refData); return(OvernightIndexObservation.builder().index(index).fixingDate(fixingDate).publicationDate(publicationDate).effectiveDate(effectiveDate).maturityDate(maturityDate).yearFraction(index.DayCount.yearFraction(effectiveDate, maturityDate)).build()); }
//------------------------------------------------------------------------- public virtual void coverage() { OvernightIndexObservation test = OvernightIndexObservation.of(GBP_SONIA, FIXING_DATE, REF_DATA); coverImmutableBean(test); OvernightIndexObservation test2 = OvernightIndexObservation.of(EUR_EONIA, FIXING_DATE.plusDays(1), REF_DATA); coverBeanEquals(test, test2); }
//------------------------------------------------------------------------- public virtual void test_of() { OvernightIndexObservation test = OvernightIndexObservation.of(GBP_SONIA, FIXING_DATE, REF_DATA); assertEquals(test.Index, GBP_SONIA); assertEquals(test.FixingDate, FIXING_DATE); assertEquals(test.PublicationDate, PUBLICATION_DATE); assertEquals(test.EffectiveDate, EFFECTIVE_DATE); assertEquals(test.MaturityDate, MATURITY_DATE); assertEquals(test.Currency, GBP_SONIA.Currency); assertEquals(test.ToString(), "OvernightIndexObservation[GBP-SONIA on 2016-02-22]"); }
//------------------------------------------------------------------------- /// <summary> /// Compares this observation to another based on the index and fixing date. /// <para> /// The publication, effective and maturity dates are ignored. /// /// </para> /// </summary> /// <param name="obj"> the other observation </param> /// <returns> true if equal </returns> public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj != null && obj.GetType() == this.GetType()) { OvernightIndexObservation other = (OvernightIndexObservation)obj; return(JodaBeanUtils.equal(index, other.index) && JodaBeanUtils.equal(fixingDate, other.fixingDate)); } return(false); }
public virtual void test_serialization() { OvernightIndexObservation test = OvernightIndexObservation.of(GBP_SONIA, FIXING_DATE, REF_DATA); assertSerialization(test); }