private PriceIndexObservation(PriceIndex index, YearMonth fixingMonth)
 {
     JodaBeanUtils.notNull(index, "index");
     JodaBeanUtils.notNull(fixingMonth, "fixingMonth");
     this.index       = index;
     this.fixingMonth = fixingMonth;
 }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 100346066:         // index
                    this.index_Renamed = (PriceIndex)newValue;
                    break;

                case 106898:         // lag
                    this.lag_Renamed = (Period)newValue;
                    break;

                case -1409010088:         // indexCalculationMethod
                    this.indexCalculationMethod_Renamed = (PriceIndexCalculationMethod)newValue;
                    break;

                case 922631823:         // firstIndexValue
                    this.firstIndexValue_Renamed = (double?)newValue;
                    break;

                case -91774989:         // gearing
                    this.gearing_Renamed = (ValueSchedule)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
 public virtual void test_getFloatingRateName()
 {
     foreach (PriceIndex index in PriceIndex.extendedEnum().lookupAll().values())
     {
         assertEquals(index.FloatingRateName, FloatingRateName.of(index.Name));
     }
 }
Example #4
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Adds a Price index forward curve to the provider.
 /// <para>
 /// This adds the specified forward curve to the provider.
 /// This operates using <seealso cref="Map#put(Object, Object)"/> semantics using the index as the key.
 ///
 /// </para>
 /// </summary>
 /// <param name="index">  the index of the curve </param>
 /// <param name="forwardCurve">  the Price index forward curve </param>
 /// <returns> this, for chaining </returns>
 public ImmutableRatesProviderBuilder priceIndexCurve(PriceIndex index, Curve forwardCurve)
 {
     ArgChecker.notNull(index, "index");
     ArgChecker.notNull(forwardCurve, "forwardCurve");
     this.indexCurves_Renamed[index] = forwardCurve;
     return(this);
 }
Example #5
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 100346066:         // index
                    this.index_Renamed = (PriceIndex)newValue;
                    break;

                case 106898:         // lag
                    this.lag_Renamed = (Period)newValue;
                    break;

                case -1409010088:         // indexCalculationMethod
                    this.indexCalculationMethod_Renamed = (PriceIndexCalculationMethod)newValue;
                    break;

                case -159410813:         // notionalExchange
                    this.notionalExchange_Renamed = (bool?)newValue.Value;
                    break;

                case -716438393:         // paymentDateOffset
                    this.paymentDateOffset_Renamed = (DaysAdjustment)newValue;
                    break;

                case 896049114:         // accrualBusinessDayAdjustment
                    this.accrualBusinessDayAdjustment_Renamed = (BusinessDayAdjustment)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 100346066:         // index
                    this.index = (PriceIndex)newValue;
                    break;

                case 113107279:         // valuationDate
                    this.valuationDate = (LocalDate)newValue;
                    break;

                case 95027439:         // curve
                    this.curve = (NodalCurve)newValue;
                    break;

                case -843784602:         // fixings
                    this.fixings = (LocalDateDoubleTimeSeries)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
 public PriceIndex toPriceIndex()
 {
     if (!type.Price)
     {
         throw new System.InvalidOperationException("Incorrect index type, expected Price: " + externalName);
     }
     return(PriceIndex.of(indexName));
 }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(InflationRateCalculation beanToCopy)
 {
     this.index_Renamed = beanToCopy.Index;
     this.lag_Renamed   = beanToCopy.Lag;
     this.indexCalculationMethod_Renamed = beanToCopy.IndexCalculationMethod;
     this.firstIndexValue_Renamed        = beanToCopy.firstIndexValue;
     this.gearing_Renamed = beanToCopy.gearing;
 }
Example #9
0
 /// <summary>
 /// Adds an index forward curve to the provider with associated time-series.
 /// <para>
 /// This adds the specified forward curve and time-series to the provider.
 /// This operates using <seealso cref="Map#put(Object, Object)"/> semantics using the index as the key.
 ///
 /// </para>
 /// </summary>
 /// <param name="index">  the index of the curve </param>
 /// <param name="forwardCurve">  the index forward curve </param>
 /// <param name="timeSeries">  the associated time-series </param>
 /// <returns> this, for chaining </returns>
 public ImmutableRatesProviderBuilder priceIndexCurve(PriceIndex index, Curve forwardCurve, LocalDateDoubleTimeSeries timeSeries)
 {
     ArgChecker.notNull(index, "index");
     ArgChecker.notNull(forwardCurve, "forwardCurve");
     ArgChecker.notNull(timeSeries, "timeSeries");
     this.indexCurves_Renamed[index] = forwardCurve;
     this.timeSeries_Renamed[index]  = timeSeries;
     return(this);
 }
Example #10
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(InflationRateSwapLegConvention beanToCopy)
 {
     this.index_Renamed = beanToCopy.Index;
     this.lag_Renamed   = beanToCopy.Lag;
     this.indexCalculationMethod_Renamed       = beanToCopy.IndexCalculationMethod;
     this.notionalExchange_Renamed             = beanToCopy.NotionalExchange;
     this.paymentDateOffset_Renamed            = beanToCopy.paymentDateOffset;
     this.accrualBusinessDayAdjustment_Renamed = beanToCopy.accrualBusinessDayAdjustment;
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableConstructor private SimplePriceIndexValues(com.opengamma.strata.basics.index.PriceIndex index, java.time.LocalDate valuationDate, com.opengamma.strata.market.curve.NodalCurve curve, com.opengamma.strata.collect.timeseries.LocalDateDoubleTimeSeries fixings)
        private SimplePriceIndexValues(PriceIndex index, LocalDate valuationDate, NodalCurve curve, LocalDateDoubleTimeSeries fixings)
        {
            ArgChecker.isFalse(fixings.Empty, "Fixings must not be empty");
            curve.Metadata.XValueType.checkEquals(ValueType.MONTHS, "Incorrect x-value type for price curve");
            curve.Metadata.YValueType.checkEquals(ValueType.PRICE_INDEX, "Incorrect y-value type for price curve");
            this.index         = ArgChecker.notNull(index, "index");
            this.valuationDate = ArgChecker.notNull(valuationDate, "valuationDate");
            this.fixings       = ArgChecker.notNull(fixings, "fixings");
            this.curve         = ArgChecker.notNull(curve, "curve");
        }
 private InflationRateCalculation(PriceIndex index, Period lag, PriceIndexCalculationMethod indexCalculationMethod, double?firstIndexValue, ValueSchedule gearing)
 {
     JodaBeanUtils.notNull(index, "index");
     JodaBeanUtils.notNull(lag, "lag");
     JodaBeanUtils.notNull(indexCalculationMethod, "indexCalculationMethod");
     this.index = index;
     this.lag   = lag;
     this.indexCalculationMethod = indexCalculationMethod;
     this.firstIndexValue        = firstIndexValue;
     this.gearing = gearing;
     validate();
 }
        public virtual void test_gbpHicp()
        {
            PriceIndex test = PriceIndex.of("GB-HICP");

            assertEquals(test.Name, "GB-HICP");
            assertEquals(test.Currency, GBP);
            assertEquals(test.Region, GB);
            assertEquals(test.Active, true);
            assertEquals(test.PublicationFrequency, Frequency.P1M);
            assertEquals(test.FloatingRateName, FloatingRateName.of("GB-HICP"));
            assertEquals(test.ToString(), "GB-HICP");
        }
Example #14
0
 private InflationRateSwapLegConvention(PriceIndex index, Period lag, PriceIndexCalculationMethod indexCalculationMethod, bool notionalExchange, DaysAdjustment paymentDateOffset, BusinessDayAdjustment accrualBusinessDayAdjustment)
 {
     JodaBeanUtils.notNull(index, "index");
     JodaBeanUtils.notNull(lag, "lag");
     JodaBeanUtils.notNull(indexCalculationMethod, "indexCalculationMethod");
     this.index = index;
     this.lag   = lag;
     this.indexCalculationMethod       = indexCalculationMethod;
     this.notionalExchange             = notionalExchange;
     this.paymentDateOffset            = paymentDateOffset;
     this.accrualBusinessDayAdjustment = accrualBusinessDayAdjustment;
 }
 public double initialGuess(MarketData marketData, ValueType valueType)
 {
     if (ValueType.PRICE_INDEX.Equals(valueType))
     {
         PriceIndex index             = template.Convention.FloatingLeg.Index;
         LocalDateDoubleTimeSeries ts = marketData.getTimeSeries(IndexQuoteId.of(index));
         double latestIndex           = ts.LatestValue;
         double rate = marketData.getValue(rateId);
         double year = template.Tenor.Period.Years;
         return(latestIndex * Math.Pow(1.0 + rate, year));
     }
     if (ValueType.ZERO_RATE.Equals(valueType))
     {
         return(marketData.getValue(rateId));
     }
     throw new System.ArgumentException("No default initial guess when value type is not 'PriceIndex' or 'ZeroRate'.");
 }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 100346066:         // index
                    this.index = (PriceIndex)newValue;
                    break;

                case 265281235:         // fixingMonth
                    this.fixingMonth = (YearMonth)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Example #17
0
        public async Task ValidateConnectingFund_decimalMismatch()
        {
            //deploy a fund instance, but do no tests, that's something for the fund test suite
            Fund _FundContract;

            _FundContract = await Fund.New(_contract.ContractAddress, RpcClient);

            //make new price index but with other decimals
            // Deploy our test contract
            Meadow.Core.EthTypes.UInt256 fiatDecimals2 = 5;
            PriceIndex _contract2 = await PriceIndex.New(initPrice, "meadowInit", 4, (byte)fiatDecimals2, "BTC", "USD", RpcClient);

            //connect fund
            var txParams = new TransactionParams {
                From = Accounts[0]
            };                                                           // admin
            await _contract2.connectFund(_FundContract.ContractAddress).SendTransaction(txParams);
        }
Example #18
0
 public PriceIndexValues priceIndexValues(PriceIndex index)
 {
     return(priceIndexValues_Renamed);
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Creates an instance from an index, start index value and reference end month.
 /// </summary>
 /// <param name="index">  the index </param>
 /// <param name="startIndexValue">  the start index value </param>
 /// <param name="referenceEndMonth">  the reference end month </param>
 /// <returns> the inflation rate computation </returns>
 public static InflationEndMonthRateComputation of(PriceIndex index, double startIndexValue, YearMonth referenceEndMonth)
 {
     return(new InflationEndMonthRateComputation(startIndexValue, PriceIndexObservation.of(index, referenceEndMonth)));
 }
 public virtual void test_of_lookup_null()
 {
     assertThrowsIllegalArg(() => PriceIndex.of(null));
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_name(PriceIndex convention, String name)
        public virtual void test_name(PriceIndex convention, string name)
        {
            assertEquals(convention.Name, name);
        }
 //-------------------------------------------------------------------------
 // inflation rate calculation
 private static RateCalculation parseInflationRateCalculation(CsvRow row, string leg, PriceIndex priceIndex, Currency currency)
 {
     InflationRateCalculation.Builder builder = InflationRateCalculation.builder();
     // basics
     builder.index(priceIndex);
     builder.lag(parseInflationLag(findValue(row, leg, INFLATION_LAG_FIELD), currency));
     builder.indexCalculationMethod(parseInflationMethod(findValue(row, leg, INFLATION_METHOD_FIELD), currency));
     // optionals
     findValue(row, leg, INFLATION_FIRST_INDEX_VALUE_FIELD).map(s => LoaderUtils.parseDouble(s)).ifPresent(v => builder.firstIndexValue(v));
     findValue(row, leg, GEARING_FIELD).map(s => LoaderUtils.parseDouble(s)).ifPresent(v => builder.gearing(ValueSchedule.of(v)));
     return(builder.build());
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Creates an instance 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="fixingMonth">  the fixing month </param>
 /// <returns> the rate observation </returns>
 public static PriceIndexObservation of(PriceIndex index, YearMonth fixingMonth)
 {
     return(new PriceIndexObservation(index, fixingMonth));
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_toString(PriceIndex convention, String name)
        public virtual void test_toString(PriceIndex convention, string name)
        {
            assertEquals(convention.ToString(), name);
        }
 //-----------------------------------------------------------------------
 /// <summary>
 /// Sets the index of prices.
 /// <para>
 /// The pay-off is computed based on this index
 /// The most common implementations are provided in <seealso cref="PriceIndices"/>.
 /// </para>
 /// </summary>
 /// <param name="index">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder index(PriceIndex index)
 {
     JodaBeanUtils.notNull(index, "index");
     this.index_Renamed = index;
     return(this);
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_of_lookup(PriceIndex convention, String name)
        public virtual void test_of_lookup(PriceIndex convention, string name)
        {
            assertEquals(PriceIndex.of(name), convention);
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Creates an instance from an index, reference start month and reference end month.
 /// </summary>
 /// <param name="index">  the index </param>
 /// <param name="referenceStartMonth">  the reference start month </param>
 /// <param name="referenceEndMonth">  the reference end month </param>
 /// <returns> the inflation rate computation </returns>
 public static InflationMonthlyRateComputation of(PriceIndex index, YearMonth referenceStartMonth, YearMonth referenceEndMonth)
 {
     return(new InflationMonthlyRateComputation(PriceIndexObservation.of(index, referenceStartMonth), PriceIndexObservation.of(index, referenceEndMonth)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Creates an instance from an index, reference start month and reference end month.
 /// <para>
 /// The second start/end observations will be one month later than the start/end month.
 ///
 /// </para>
 /// </summary>
 /// <param name="index">  the index </param>
 /// <param name="referenceStartMonth">  the reference start month </param>
 /// <param name="referenceEndMonth">  the reference end month </param>
 /// <param name="weight">  the weight </param>
 /// <returns> the inflation rate computation </returns>
 public static InflationInterpolatedRateComputation of(PriceIndex index, YearMonth referenceStartMonth, YearMonth referenceEndMonth, double weight)
 {
     return(new InflationInterpolatedRateComputation(PriceIndexObservation.of(index, referenceStartMonth), PriceIndexObservation.of(index, referenceStartMonth.plusMonths(1)), PriceIndexObservation.of(index, referenceEndMonth), PriceIndexObservation.of(index, referenceEndMonth.plusMonths(1)), weight));
 }
 /// <summary>
 /// Obtains a rate calculation for the specified price index with known start index value.
 /// <para>
 /// The calculation will use the specified month lag.
 /// The first index value will be set to the specified value
 /// All other optional fields will be set to their default values.
 /// Thus, fixing will be in advance, with no gearing.
 /// If this method provides insufficient control, use the <seealso cref="#builder() builder"/>.
 ///
 /// </para>
 /// </summary>
 /// <param name="index">  the price index </param>
 /// <param name="monthLag">  the month lag </param>
 /// <param name="indexCalculationMethod">  the reference price index calculation method </param>
 /// <param name="firstIndexValue">  the first index value </param>
 /// <returns> the inflation rate calculation </returns>
 public static InflationRateCalculation of(PriceIndex index, int monthLag, PriceIndexCalculationMethod indexCalculationMethod, double firstIndexValue)
 {
     return(InflationRateCalculation.builder().index(index).lag(Period.ofMonths(monthLag)).indexCalculationMethod(indexCalculationMethod).firstIndexValue(firstIndexValue).build());
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance based on a curve with no seasonality adjustment.
 /// <para>
 /// Each x-value on the curve is the number of months between the valuation month and the estimation month.
 /// For example, zero represents the valuation month, one the next month and so on.
 /// </para>
 /// <para>
 /// The time-series contains one value per month and must have at least one entry.
 /// The value is stored in the time-series on the last date of each month (which may be a non-working day).
 /// </para>
 /// <para>
 /// The curve will be altered to be consistent with the time-series. The last element of the
 /// series is added as the first point of the interpolated curve to ensure a coherent transition.
 ///
 /// </para>
 /// </summary>
 /// <param name="index">  the Price index </param>
 /// <param name="valuationDate">  the valuation date for which the curve is valid </param>
 /// <param name="fixings">  the time-series of fixings </param>
 /// <param name="curve">  the underlying forward curve for index estimation </param>
 /// <returns> the values instance </returns>
 public static SimplePriceIndexValues of(PriceIndex index, LocalDate valuationDate, NodalCurve curve, LocalDateDoubleTimeSeries fixings)
 {
     return(new SimplePriceIndexValues(index, valuationDate, curve, fixings));
 }