public static SurfaceFittedSmileDataPoints FromFudgeMsg(IFudgeFieldContainer message, IFudgeDeserializer deserializer)
        {
            IList <IFudgeField> tFields = message.GetAllByName(T_FIELD_NAME);
            IList <IFudgeField> kFields = message.GetAllByName(K_FIELD_NAME);
            var map = new Dictionary <double, List <double> >();

            for (int i = 0; i < tFields.Count; i++)
            {
                var           t  = (double)tFields[i].Value;
                List <double> ks = GetList <double>(kFields[i]);
                map.Add(t, ks);
            }
            return(new SurfaceFittedSmileDataPoints(map));
        }
        public static ViewCalculationConfiguration FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var name = ffc.GetValue <string>("name");

            List <ValueRequirement> specificRequirements = GetList <ValueRequirement>(ffc, "specificRequirement", deserializer);

            //TODO MAP deserializer by magic
            var portfolioRequirementsBySecurityType = new Dictionary <string, HashSet <Tuple <string, ValueProperties> > >();

            foreach (var portfolioReqField in ffc.GetAllByName("portfolioRequirementsBySecurityType"))
            {
                const string securitytypeKey = "securityType";
                var          securityType    = ((IFudgeFieldContainer)portfolioReqField.Value).GetValue <string>(securitytypeKey);

                var enumerable = ((IFudgeFieldContainer)portfolioReqField.Value).GetAllByName("portfolioRequirement").Select(f => GetReqPair(f, deserializer));

                portfolioRequirementsBySecurityType.Add(securityType, new HashSet <Tuple <string, ValueProperties> >(enumerable));
            }

            var defaultProperties = deserializer.FromField <ValueProperties>(ffc.GetByName("defaultProperties"));
            var deltaDefinition   = deserializer.FromField <DeltaDefinition>(ffc.GetByName("deltaDefinition"));

            IResolutionRuleTransform transform = null;
            IFudgeField transformField         = ffc.GetByName("resolutionRuleTransform");

            if (transformField != null)
            {
                transform = deserializer.FromField <IResolutionRuleTransform>(transformField);
            }

            return(new ViewCalculationConfiguration(name, specificRequirements, portfolioRequirementsBySecurityType, deltaDefinition, defaultProperties, transform));
        }
        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));
        }
예제 #4
0
 public static PresentValueSensitivity FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     var data = new Dictionary<string, List<Tuple<double, double>>>();
     var curveNames = ffc.GetAllByName("curve name");
     var sensitivities = ffc.GetAllByName("sensitivities");
     int id = 0;
     foreach (var tuple in curveNames.Zip(sensitivities, Tuple.Create))
     {
         string curveName = new StringBuilder("TODO ").Append(id++).ToString(); //I believe the java is broken
         var listSensitivities = (IFudgeFieldContainer) tuple.Item2;
         var pairsFields = listSensitivities.GetAllByName(null);
         var tuples = pairsFields.Select(ReadPair).ToList();
         data.Add(curveName, tuples);
     }
     return new PresentValueSensitivity(data);
 }
예제 #5
0
        public static ViewDefinition FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var name           = ffc.GetValue <string>("name");
            var uniqueIdString = ffc.GetString("uniqueId");
            var uniqueId       = uniqueIdString == null ? null : UniqueId.Parse(uniqueIdString);

            var resultModelDefinition = deserializer.FromField <ResultModelDefinition>(ffc.GetByName("resultModelDefinition"));

            UniqueId portfolioIdentifier = ValueRequirement.GetUniqueIdentifier(ffc, deserializer, "identifier");
            var      user = deserializer.FromField <UserPrincipal>(ffc.GetByName("user"));

            var currency = ffc.GetValue <Currency>("currency");

            var minDeltaCalcPeriod = ReadNullableTimeSpanField(ffc, "minDeltaCalcPeriod");
            var maxDeltaCalcPeriod = ReadNullableTimeSpanField(ffc, "maxDeltaCalcPeriod");

            var minFullCalcPeriod = ReadNullableTimeSpanField(ffc, "fullDeltaCalcPeriod");
            var maxFullCalcPeriod = ReadNullableTimeSpanField(ffc, "maxFullCalcPeriod");

            var calculationConfigurationsByName = ffc.GetAllByName("calculationConfiguration")
                                                  .Select(deserializer.FromField <ViewCalculationConfiguration>)
                                                  .ToDictionary(vcc => vcc.Name);

            return(new ViewDefinition(name, resultModelDefinition, portfolioIdentifier, user, currency, minDeltaCalcPeriod, maxDeltaCalcPeriod, minFullCalcPeriod, maxFullCalcPeriod, calculationConfigurationsByName, uniqueId));
        }
예제 #6
0
        public static PresentValueSensitivity FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var data          = new Dictionary <string, List <Tuple <double, double> > >();
            var curveNames    = ffc.GetAllByName("curve name");
            var sensitivities = ffc.GetAllByName("sensitivities");
            int id            = 0;

            foreach (var tuple in curveNames.Zip(sensitivities, Tuple.Create))
            {
                string curveName         = new StringBuilder("TODO ").Append(id++).ToString(); //I believe the java is broken
                var    listSensitivities = (IFudgeFieldContainer)tuple.Item2;
                var    pairsFields       = listSensitivities.GetAllByName(null);
                var    tuples            = pairsFields.Select(ReadPair).ToList();
                data.Add(curveName, tuples);
            }
            return(new PresentValueSensitivity(data));
        }
예제 #7
0
 public static InterpolatedYieldCurveSpecificationWithSecurities FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return(new InterpolatedYieldCurveSpecificationWithSecurities(
                new DateTimeOffset(
                    ((FudgeDate)ffc.GetValue("curveDate")).ToDateTime()),
                (string)ffc.GetValue("name"),
                ffc.GetValue <Currency>("currency"),
                ffc.GetAllByName("resolvedStrips").Select(deserializer.FromField <FixedIncomeStripWithSecurity>).ToList()
                ));
 }
예제 #8
0
 public static InterpolatedYieldCurveSpecificationWithSecurities FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return new InterpolatedYieldCurveSpecificationWithSecurities(
         new DateTimeOffset(
         ((FudgeDate) ffc.GetValue("curveDate")).ToDateTime()),
         (string) ffc.GetValue("name"),
         ffc.GetValue<Currency>("currency"),
         ffc.GetAllByName("resolvedStrips").Select(deserializer.FromField<FixedIncomeStripWithSecurity>).ToList()
         );
 }
        public static CompiledViewDefinitionImpl FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            ViewDefinition defn      = deserializer.FromField <ViewDefinition>(ffc.GetByName("viewDefinition"));
            IPortfolio     portfolio = deserializer.FromField <IPortfolio>(ffc.GetByName("portfolio"));

            DateTimeOffset latestValidity   = ffc.GetValue <FudgeDateTime>("latestValidity").ToDateTimeOffsetWithDefault();
            DateTimeOffset earliestValidity = ffc.GetValue <FudgeDateTime>("earliestValidity").ToDateTimeOffsetWithDefault();

            var configs = ffc.GetAllByName("compiledCalculationConfigurations").Select(deserializer.FromField <CompiledViewCalculationConfigurationImpl>).ToDictionary(c => c.Name, c => (ICompiledViewCalculationConfiguration)c);

            return(new CompiledViewDefinitionImpl(defn, portfolio, latestValidity, earliestValidity, configs));
        }
        private static IList <object> ReadAllAsObjectList(IFudgeFieldContainer ffc, string name, IFudgeDeserializer deserializer, out bool wrappedPrimitive)
        {
            var fields = ffc.GetAllByName(name);

            if (IsWrappedPrimitive(fields[0]))
            {
                wrappedPrimitive = true;
                return(fields.Select(GetWrappedPrimitive).ToList());
            }
            wrappedPrimitive = false;
            return(fields.Select(deserializer.FromField <object>).ToList());
        }
예제 #11
0
        public static InterpolatedYieldCurveSpecification FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var    curveDate           = ffc.GetValue <DateTimeOffset>("curveDate");
            string name                = ffc.GetString("name");
            var    currency            = ffc.GetValue <Currency>("currency");
            var    region              = ExternalId.Parse(ffc.GetString("region"));
            var    resolvedStripFields = ffc.GetAllByName("resolvedStrips");

            var resolvedStrips = resolvedStripFields.Select(deserializer.FromField <FixedIncomeStripWithIdentifier>)
                                 .ToList();

            return(new InterpolatedYieldCurveSpecification(curveDate, name, currency, resolvedStrips, region));
        }
예제 #12
0
        public static FittedSmileDataPoints FromFudgeMsg(IFudgeFieldContainer message, IFudgeDeserializer deserializer)
        {
            var tenorPairFields       = message.GetAllByName(TENOR_PAIR_FIELD_NAME);
            var externalIdsFields     = message.GetAllByName(EXTERNAL_IDS_ARRAY_FIELD_NAME);
            var relativeStrikesFields = message.GetAllByName(RELATIVE_STRIKES_ARRAY_FIELD_NAME);
            var externalIds           = new Dictionary <Pair <Tenor, Tenor>, ExternalId[]>();
            var relativeStrikes       = new Dictionary <Pair <Tenor, Tenor>, double[]>();

            if (tenorPairFields.Count != externalIdsFields.Count || tenorPairFields.Count != relativeStrikesFields.Count)
            {
                throw new OpenGammaException("Should never happen");
            }
            for (int i = 0; i < tenorPairFields.Count; i++)
            {
                var tenors              = deserializer.FromField <Pair <Tenor, Tenor> >(tenorPairFields[i]);
                var externalIdList      = GetList <string>(externalIdsFields[i]).Select(ExternalId.Parse).ToList();
                var relativeStrikesList = GetList <double>(relativeStrikesFields[i]);
                externalIds.Add(tenors, externalIdList.ToArray());
                relativeStrikes.Add(tenors, relativeStrikesList.ToArray());
            }
            return(new FittedSmileDataPoints(externalIds, relativeStrikes));
        }
 private static List <T> GetList <T>(IFudgeFieldContainer ffc, string fieldName, IFudgeDeserializer deserializer) where T : class
 {
     return(ffc.GetAllByName(fieldName).Select(deserializer.FromField <T>).ToList());
 }
예제 #14
0
        public static CompiledViewDefinitionImpl FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            ViewDefinition defn = deserializer.FromField<ViewDefinition>(ffc.GetByName("viewDefinition"));
            IPortfolio portfolio = deserializer.FromField<IPortfolio>(ffc.GetByName("portfolio"));

            DateTimeOffset latestValidity = ffc.GetValue<FudgeDateTime>("latestValidity").ToDateTimeOffsetWithDefault();
            DateTimeOffset earliestValidity = ffc.GetValue<FudgeDateTime>("earliestValidity").ToDateTimeOffsetWithDefault();

            var configs = ffc.GetAllByName("compiledCalculationConfigurations").Select(deserializer.FromField<CompiledViewCalculationConfigurationImpl>).ToDictionary(c => c.Name, c => (ICompiledViewCalculationConfiguration)c);
            return new CompiledViewDefinitionImpl(defn, portfolio, latestValidity, earliestValidity, configs);
        }
예제 #15
0
        public static ViewDefinition FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var name = ffc.GetValue<string>("name");
            var uniqueIdString = ffc.GetString("uniqueId");
            var uniqueId = uniqueIdString == null ? null : UniqueId.Parse(uniqueIdString);

            var resultModelDefinition = deserializer.FromField<ResultModelDefinition>(ffc.GetByName("resultModelDefinition"));

            UniqueId portfolioIdentifier = ValueRequirement.GetUniqueIdentifier(ffc, deserializer, "identifier");
            var user = deserializer.FromField<UserPrincipal>(ffc.GetByName("user"));

            var currency = ffc.GetValue<Currency>("currency");

            var minDeltaCalcPeriod = ReadNullableTimeSpanField(ffc, "minDeltaCalcPeriod");
            var maxDeltaCalcPeriod = ReadNullableTimeSpanField(ffc, "maxDeltaCalcPeriod");

            var minFullCalcPeriod = ReadNullableTimeSpanField(ffc, "fullDeltaCalcPeriod");
            var maxFullCalcPeriod = ReadNullableTimeSpanField(ffc, "maxFullCalcPeriod");

            var calculationConfigurationsByName = ffc.GetAllByName("calculationConfiguration")
                .Select(deserializer.FromField<ViewCalculationConfiguration>)
                .ToDictionary(vcc => vcc.Name);

            return new ViewDefinition(name, resultModelDefinition, portfolioIdentifier, user, currency, minDeltaCalcPeriod, maxDeltaCalcPeriod, minFullCalcPeriod, maxFullCalcPeriod, calculationConfigurationsByName, uniqueId);
        }
예제 #16
0
        public static InterpolatedYieldCurveSpecification FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var curveDate = ffc.GetValue<DateTimeOffset>("curveDate");
            string name = ffc.GetString("name");
            var currency = ffc.GetValue<Currency>("currency");
            var region = ExternalId.Parse(ffc.GetString("region"));
            var resolvedStripFields = ffc.GetAllByName("resolvedStrips");

            var resolvedStrips = resolvedStripFields.Select(deserializer.FromField<FixedIncomeStripWithIdentifier>)
                .ToList();
            return new InterpolatedYieldCurveSpecification(curveDate, name, currency, resolvedStrips, region);
        }