Пример #1
0
        public double GetConversionRate(Func<ValueRequirement, double> inputs, Currency source, Currency target)
        {
            var currencyMatrixValue = _matrix.GetConversion(source, target);
            if (currencyMatrixValue is CurrencyMatrixValue.CurrencyMatrixCross)
            {
                var cross = (CurrencyMatrixValue.CurrencyMatrixCross)currencyMatrixValue;
                return GetConversionRate(inputs, source, cross.CrossCurrency) * GetConversionRate(inputs, cross.CrossCurrency, target);
            }
            else if (currencyMatrixValue is CurrencyMatrixValue.CurrencyMatrixFixed)
            {
                var fixedValue = (CurrencyMatrixValue.CurrencyMatrixFixed)currencyMatrixValue;
                return fixedValue.FixedValue;
            }
            else if (currencyMatrixValue is CurrencyMatrixValue.CurrencyMatrixValueRequirement)
            {
                var valueRequirement = (CurrencyMatrixValue.CurrencyMatrixValueRequirement)currencyMatrixValue;

                double rate = inputs(valueRequirement.ValueRequirement);
                if (valueRequirement.IsReciprocal)
                {
                    rate = 1.0 / rate;
                }
                return rate;
            }
            else if (currencyMatrixValue == null)
            {
                throw new ArgumentException();
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Пример #2
0
 private InterpolatedYieldCurveSpecificationWithSecurities(DateTimeOffset curveDate, string name, Currency currency, List <FixedIncomeStripWithSecurity> strips)
 {
     _curveDate = curveDate;
     _name      = name;
     _currency  = currency;
     _strips    = strips;
 }
        public override VolatilitySurfaceData DeserializeImpl(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            Currency currency          = ffc.GetValue <Currency>("currency");
            string   definitionName    = ffc.GetValue <string>("definitionName");
            string   specificationName = ffc.GetValue <string>("specificationName");
            string   interpolatorName  = ffc.GetValue <string>("interpolatorName");

            bool           xWrapped;
            IList <object> xs = ReadAllAsObjectList(ffc, "xs", deserializer, out xWrapped);
            bool           yWrapped;
            IList <object> ys = ReadAllAsObjectList(ffc, "ys", deserializer, out yWrapped);

            Type xType        = GetType(xs);
            Type yType        = GetType(ys);
            var  values       = new Dictionary <Tuple <object, object>, double>();
            var  valuesFields = ffc.GetAllByName("values");

            foreach (var valueField in valuesFields)
            {
                var    subMessage = (IFudgeFieldContainer)valueField.Value;
                var    xField     = subMessage.GetByName("x");
                var    yField     = subMessage.GetByName("y");
                object x          = xWrapped ? GetWrappedPrimitive(xField) : deserializer.FromField(xField, xType);
                object y          = yWrapped ? GetWrappedPrimitive(yField) : deserializer.FromField(yField, yType);
                double value      = subMessage.GetValue <double>("value");
                values.Add(new Tuple <object, object>(x, y), value);
            }

            return(Build(xType, yType, definitionName, specificationName, currency, interpolatorName, xs, ys, values));
        }
        public double GetConversionRate(Func <ValueRequirement, double> inputs, Currency source, Currency target)
        {
            var currencyMatrixValue = _matrix.GetConversion(source, target);

            if (currencyMatrixValue is CurrencyMatrixValue.CurrencyMatrixCross)
            {
                var cross = (CurrencyMatrixValue.CurrencyMatrixCross)currencyMatrixValue;
                return(GetConversionRate(inputs, source, cross.CrossCurrency) * GetConversionRate(inputs, cross.CrossCurrency, target));
            }
            else if (currencyMatrixValue is CurrencyMatrixValue.CurrencyMatrixFixed)
            {
                var fixedValue = (CurrencyMatrixValue.CurrencyMatrixFixed)currencyMatrixValue;
                return(fixedValue.FixedValue);
            }
            else if (currencyMatrixValue is CurrencyMatrixValue.CurrencyMatrixValueRequirement)
            {
                var valueRequirement = (CurrencyMatrixValue.CurrencyMatrixValueRequirement)currencyMatrixValue;

                double rate = inputs(valueRequirement.ValueRequirement);
                if (valueRequirement.IsReciprocal)
                {
                    rate = 1.0 / rate;
                }
                return(rate);
            }
            else if (currencyMatrixValue == null)
            {
                throw new ArgumentException();
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Пример #5
0
 private InterpolatedYieldCurveSpecificationWithSecurities(DateTimeOffset curveDate, string name, Currency currency, List<FixedIncomeStripWithSecurity> strips)
 {
     _curveDate = curveDate;
     _name = name;
     _currency = currency;
     _strips = strips;
 }
Пример #6
0
 public SABRFittedSurfaces(InterpolatedDoublesSurface alphaSurface, InterpolatedDoublesSurface betaSurface, InterpolatedDoublesSurface nuSurface, InterpolatedDoublesSurface rhoSurface, Currency currency, string dayCountName)
 {
     _alphaSurface = alphaSurface;
     _betaSurface  = betaSurface;
     _nuSurface    = nuSurface;
     _rhoSurface   = rhoSurface;
     _currency     = currency;
     _dayCountName = dayCountName;
 }
Пример #7
0
 public SABRFittedSurfaces(InterpolatedDoublesSurface alphaSurface, InterpolatedDoublesSurface betaSurface, InterpolatedDoublesSurface nuSurface, InterpolatedDoublesSurface rhoSurface, Currency currency, string dayCountName)
 {
     _alphaSurface = alphaSurface;
     _betaSurface = betaSurface;
     _nuSurface = nuSurface;
     _rhoSurface = rhoSurface;
     _currency = currency;
     _dayCountName = dayCountName;
 }
Пример #8
0
 public static SABRFittedSurfaces FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return(new SABRFittedSurfaces(
                deserializer.FromField <InterpolatedDoublesSurface>(ffc.GetByName("AlphaSurface")),
                deserializer.FromField <InterpolatedDoublesSurface>(ffc.GetByName("BetaSurface")),
                deserializer.FromField <InterpolatedDoublesSurface>(ffc.GetByName("NuSurface")),
                deserializer.FromField <InterpolatedDoublesSurface>(ffc.GetByName("RhoSurface")),
                Currency.Create(ffc.GetString("Currency")),
                ffc.GetString("DayCountName")
                ));
 }
Пример #9
0
 public VolatilityCubeKey(Currency currency, string name)
 {
     _currency = currency;
     _name     = name;
 }
 public VolatilityCubeDefinition GetDefinition(Currency currency, string name)
 {
     return _restTarget.Resolve("definitions", "searchSingle").WithParam("currency", currency.ISOCode).WithParam("name", name).Get<VolatilityCubeDefinition>();
 }
Пример #11
0
 public YieldCurveKey(Currency currency, string name)
 {
     _currency = currency;
     _name     = name;
 }
 public VolatilityCubeDefinition GetDefinition(Currency currency, string name)
 {
     return(_restTarget.Resolve("definitions", "searchSingle").WithParam("currency", currency.ISOCode).WithParam("name", name).Get <VolatilityCubeDefinition>());
 }
 public static VolatilitySurfaceData <TX, TY> Build <TX, TY>(string definitionName, string specificationName, Currency currency, string interpolatorName, IList <object> xs, IList <object> ys, Dictionary <Tuple <object, object>, double> values)
 {
     return(new VolatilitySurfaceData <TX, TY>(definitionName, specificationName, currency, interpolatorName, xs.Cast <TX>().ToList(), ys.Cast <TY>().ToList(),
                                               values.ToDictionary(kvp => Tuple.Create((TX)kvp.Key.Item1, (TY)kvp.Key.Item2), kvp => kvp.Value)
                                               ));
 }
 private static VolatilitySurfaceData Build(Type xType, Type yType, string definitionName, string specificationName, Currency currency, string interpolatorName, IList <object> xs, IList <object> ys, Dictionary <Tuple <object, object>, double> values)
 {
     return((VolatilitySurfaceData)GenericUtils.Call(GenericBuildMethod, new[] { xType, yType }, new object[] { definitionName, specificationName, currency, interpolatorName, xs, ys, values }));
 }