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));
        }
 public override SimplePortfolioNode DeserializeImpl(IFudgeFieldContainer msg, IFudgeDeserializer deserializer)
 {
     return(new SimplePortfolioNode(
                UniqueId.Parse(msg.GetString("identifier")), msg.GetString("name"),
                deserializer.FromField <IList <PortfolioNode> >(msg.GetByName("subNodes")) ?? new List <PortfolioNode>(),
                deserializer.FromField <IList <IPosition> >(msg.GetByName("positions")) ?? new List <IPosition>()));
 }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
 public static VolatilityCubeDefinition FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return(new VolatilityCubeDefinition(
                deserializer.FromField <List <string> >(ffc.GetByName("swapTenors")).Select(s => new Tenor(s)).ToList(),
                deserializer.FromField <List <string> >(ffc.GetByName("optionExpiries")).Select(s => new Tenor(s)).ToList(),
                ffc.GetMessage("relativeStrikes").Select(f => f.Value).Cast <double>().ToList()
                ));
 }
        public static ArrayLocalDateDoubleTimeSeries FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var dateTimeConverterField = ffc.GetByOrdinal(1);
            var fastTimeSeriesField = ffc.GetByOrdinal(2);

            var dateTimeConverter = deserializer.FromField<LocalDateEpochDaysConverter>(dateTimeConverterField);
            var fastTimeSeries = deserializer.FromField<FastArrayIntDoubleTimeSeries>(fastTimeSeriesField);
            return new ArrayLocalDateDoubleTimeSeries(dateTimeConverter, fastTimeSeries);
        }
Ejemplo n.º 7
0
        public static ArrayLocalDateDoubleTimeSeries FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var dateTimeConverterField = ffc.GetByOrdinal(1);
            var fastTimeSeriesField    = ffc.GetByOrdinal(2);

            var dateTimeConverter = deserializer.FromField <LocalDateEpochDaysConverter>(dateTimeConverterField);
            var fastTimeSeries    = deserializer.FromField <FastArrayIntDoubleTimeSeries>(fastTimeSeriesField);

            return(new ArrayLocalDateDoubleTimeSeries(dateTimeConverter, fastTimeSeries));
        }
Ejemplo n.º 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")
                ));
 }
Ejemplo n.º 9
0
        public static SecurityDocument FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            DateTimeOffset versionToInstant;
            DateTimeOffset correctionFromInstant;
            DateTimeOffset correctionToInstant;
            DateTimeOffset versionFromInstant = GetDocumentValues(ffc, out versionToInstant, out correctionFromInstant, out correctionToInstant);

            var uid = (ffc.GetString("uniqueId") != null) ? UniqueId.Parse(ffc.GetString("uniqueId")) : deserializer.FromField<UniqueId>(ffc.GetByName("uniqueId"));
            var security = deserializer.FromField<ISecurity>(ffc.GetByName("security"));

            return new SecurityDocument(uid, security, versionFromInstant, versionToInstant, correctionFromInstant, correctionToInstant);
        }
        public static MarketDataSnapshotDocument FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            DateTimeOffset versionToInstant;
            DateTimeOffset correctionFromInstant;
            DateTimeOffset correctionToInstant;
            DateTimeOffset versionFromInstant = GetDocumentValues(ffc, out versionToInstant, out correctionFromInstant, out correctionToInstant);

            var uid = (ffc.GetString("uniqueId") != null) ? UniqueId.Parse(ffc.GetString("uniqueId")) : deserializer.FromField<UniqueId>(ffc.GetByName("uniqueId"));
            var snapshot = deserializer.FromField<ManageableMarketDataSnapshot>(ffc.GetByName("snapshot"));

            return new MarketDataSnapshotDocument(uid, snapshot, versionFromInstant, versionToInstant, correctionFromInstant, correctionToInstant);
        }
        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));
        }
Ejemplo n.º 12
0
        public static YieldCurveDefinitionDocument FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            DateTimeOffset versionToInstant;
            DateTimeOffset correctionFromInstant;
            DateTimeOffset correctionToInstant;
            DateTimeOffset versionFromInstant = GetDocumentValues(ffc, out versionToInstant, out correctionFromInstant, out correctionToInstant);

            var uid = (ffc.GetString("uniqueId") != null) ? UniqueId.Parse(ffc.GetString("uniqueId")) : deserializer.FromField<UniqueId>(ffc.GetByName("uniqueId"));
            var definition  = deserializer.FromField<YieldCurveDefinition>(ffc.GetByName("yieldCurveDefinition"));

            return new YieldCurveDefinitionDocument(versionFromInstant, versionToInstant, correctionFromInstant, correctionToInstant) { YieldCurveDefinition = definition, UniqueId = uid};
        }
Ejemplo n.º 13
0
 public static FixedIncomeStripWithSecurity FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     var originalstrip = deserializer.FromField<FixedIncomeStrip>(ffc.GetByName("strip"));
     var resolvedTenor = new Tenor(ffc.GetString("resolvedTenor"));
     DateTimeOffset maturity = GetDateTime(ffc.GetByName("maturity"));
     ExternalId securityIdentifier = ExternalId.Parse(ffc.GetString("identifier"));
     var security = deserializer.FromField<ISecurity>(ffc.GetByName("security"));
     return new FixedIncomeStripWithSecurity(originalstrip,
                                             resolvedTenor,
                                             maturity,
                                             securityIdentifier,
                                             security
         );
 }
Ejemplo n.º 14
0
        public static FixedIncomeStripWithSecurity FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var            originalstrip      = deserializer.FromField <FixedIncomeStrip>(ffc.GetByName("strip"));
            var            resolvedTenor      = new Tenor(ffc.GetString("resolvedTenor"));
            DateTimeOffset maturity           = GetDateTime(ffc.GetByName("maturity"));
            ExternalId     securityIdentifier = ExternalId.Parse(ffc.GetString("identifier"));
            var            security           = deserializer.FromField <ISecurity>(ffc.GetByName("security"));

            return(new FixedIncomeStripWithSecurity(originalstrip,
                                                    resolvedTenor,
                                                    maturity,
                                                    securityIdentifier,
                                                    security
                                                    ));
        }
Ejemplo n.º 15
0
 public static TestWrapper <T> FromFudgeMsg(IFudgeFieldContainer ffc,
                                            IFudgeDeserializer deserializer)
 {
     return(new TestWrapper <T> {
         Test = deserializer.FromField <T>(ffc.GetByName("test"))
     });
 }
Ejemplo n.º 16
0
        public static UniqueId GetUniqueIdentifier(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer, string fieldName)
        {
            UniqueId    portfolioIdentifier;
            IFudgeField idField = ffc.GetByName(fieldName);

            if (idField != null)
            {
                var value = idField.Value;
                if (value is string)
                {
                    portfolioIdentifier = UniqueId.Parse((string)value);
                }
                else if (value is IFudgeFieldContainer)
                {
                    portfolioIdentifier = deserializer.FromField <UniqueId>(idField);
                }
                else
                {
                    throw new ArgumentException(String.Format("Couldn't read UID {0}", value));
                }
            }
            else
            {
                portfolioIdentifier = null;
            }
            return(portfolioIdentifier);
        }
Ejemplo n.º 17
0
        public override ComputedValue DeserializeImpl(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var valueSpecification = deserializer.FromField <ValueSpecification>(ffc.GetByName("specification"));
            var value = GetValue(deserializer, ffc.GetByName("value"), valueSpecification);

            return(new ComputedValue(valueSpecification, value));
        }
Ejemplo n.º 18
0
        public static object FromField(IFudgeDeserializer deserializer, IFudgeField valueField)
        {
            if (valueField.Type != FudgeMsgFieldType.Instance)
            {
                return(valueField.Value);
            }

            var fudgeFieldContainer = (IFudgeFieldContainer)valueField.Value;

            foreach (var typeField in fudgeFieldContainer.GetAllByOrdinal(0))
            {
                switch (typeField.Value as string)
                {
                case "java.lang.Number":
                case "java.lang.String":
                    return(fudgeFieldContainer.GetValue("value"));

                case "org.fudgemsg.StandardFudgeMsg":
                    return(valueField.Value);    //TODO: this is not right

                default:
                    continue;
                }
            }
            return(deserializer.FromField(valueField, null));
        }
        public static ManageableMarketDataSnapshot FromFudgeMsg(IFudgeFieldContainer ffc,
                                                                IFudgeDeserializer deserializer)
        {
            var      uidString = ffc.GetString("uniqueId");
            UniqueId uid       = uidString == null ? null : UniqueId.Parse(uidString);

            var surfaceMessage = ffc.GetMessage("volatilitySurfaces");
            Dictionary <VolatilitySurfaceKey, ManageableVolatilitySurfaceSnapshot> surfaces;

            if (surfaceMessage == null)
            {
                //Handle old format
                surfaces = new Dictionary <VolatilitySurfaceKey, ManageableVolatilitySurfaceSnapshot>();
            }
            else
            {
                surfaces = MapBuilder.FromFudgeMsg <VolatilitySurfaceKey, ManageableVolatilitySurfaceSnapshot>(surfaceMessage, deserializer);
            }
            var manageableMarketDataSnapshot = new ManageableMarketDataSnapshot(
                ffc.GetString("basisViewName"),
                deserializer.FromField <ManageableUnstructuredMarketDataSnapshot>(ffc.GetByName("globalValues")),
                MapBuilder.FromFudgeMsg <YieldCurveKey, ManageableYieldCurveSnapshot>(ffc.GetMessage("yieldCurves"), deserializer),
                MapBuilder.FromFudgeMsg <VolatilityCubeKey, ManageableVolatilityCubeSnapshot>(ffc.GetMessage("volatilityCubes"), deserializer),
                surfaces,
                uid

                )
            {
                Name = ffc.GetString("name")
            };

            return(manageableMarketDataSnapshot);
        }
Ejemplo n.º 20
0
            private void ObjectAdd(MorePropertyData prop, object obj, IFudgeField field, IFudgeDeserializer deserializer)
            {
                // Handles both reference and inline
                object subObject = deserializer.FromField(field, prop.PropertyData.Type);

                prop.PropertyData.Setter(obj, subObject);
            }
Ejemplo n.º 21
0
        public override ValueSpecification DeserializeImpl(IFudgeFieldContainer msg, IFudgeDeserializer deserializer)
        {
            string          valueName  = null;
            ValueProperties properties = null;

            foreach (var fudgeField in msg)
            {
                switch (fudgeField.Name)
                {
                case "valueName":
                    valueName = (string)fudgeField.Value;
                    break;

                case "properties":
                    properties = deserializer.FromField <ValueProperties>(fudgeField);
                    break;

                default:
                    break;
                }
            }

            var targetSpecification = new ComputationTargetSpecificationBuilder(deserializer.Context, typeof(ComputationTargetSpecification)).DeserializeImpl(msg, deserializer); //Can't register twice

            return(new ValueSpecification(valueName, targetSpecification, properties));
        }
Ejemplo n.º 22
0
        public void LoadReq(FudgeMsg message, IFudgeDeserializer deserializer)
        {
            var values = new Dictionary <Tuple <Currency, Currency>, CurrencyMatrixValue>();

            foreach (var field in message)
            {
                Currency source = Currency.Create(field.Name);
                foreach (var field2 in (IFudgeFieldContainer)field.Value)
                {
                    Currency target = Currency.Create(field2.Name);

                    if (field2.Value is IFudgeFieldContainer)
                    {
                        CurrencyMatrixValue value = deserializer.FromField <CurrencyMatrixValue.CurrencyMatrixValueRequirement>(field2);
                        values.Add(Tuple.Create(source, target), value);
                        values.Add(Tuple.Create(target, source), value.Reciprocal);
                    }
                    else
                    {
                        values.Remove(Tuple.Create(target, source));
                    }
                }
            }
            foreach (var valueEntry in values)
            {
                AddConversion(valueEntry.Key.Item1, valueEntry.Key.Item2, valueEntry.Value);
            }
        }
        private static Tuple <string, ValueProperties> GetReqPair(IFudgeField field, IFudgeDeserializer deserializer)
        {
            var    ffc            = (IFudgeFieldContainer)field.Value;
            string requiredOutput = ffc.GetString("requiredOutput");
            var    constraints    = deserializer.FromField <ValueProperties>(ffc.GetByName("constraints"));

            return(Tuple.Create(requiredOutput, constraints));
        }
Ejemplo n.º 24
0
 public static ViewCycleExecutionOptions FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     IFudgeField mdsField = ffc.GetByName("marketDataSpecification");
     var marketDataSpecification = mdsField  == null ? null : deserializer.FromField<MarketDataSpecification>(mdsField);
     var valuationValue = ffc.GetValue("valuation");
     var valuation = (FudgeDateTime)(valuationValue == IndicatorType.Instance ? null : valuationValue);
     return new ViewCycleExecutionOptions(valuation.ToDateTimeOffsetWithDefault(), marketDataSpecification);
 }
        private static Pair <ValueSpecification, object> GetValue(IFudgeField field, IFudgeDeserializer deserializer)
        {
            var msg   = (IFudgeFieldContainer)field.Value;
            var spec  = deserializer.FromField <ValueSpecification>(msg.GetByName("first"));
            var value = ComputedValueBuilder.GetValue(deserializer, msg.GetByName("second"), spec);

            return(new Pair <ValueSpecification, object>(spec, value));
        }
Ejemplo n.º 26
0
        protected static Tuple <DateTimeNumericEncoding, T[], double[]> FromFudgeMsgImpl(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var encoding = deserializer.FromField <DateTimeNumericEncoding>(ffc.GetByOrdinal(1));
            var times    = ffc.GetValue <T[]>(2);
            var values   = ffc.GetValue <double[]>(3);

            return(System.Tuple.Create(encoding, times, values));
        }
Ejemplo n.º 27
0
        public static ViewCycleExecutionOptions FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            IFudgeField mdsField = ffc.GetByName("marketDataSpecification");
            var         marketDataSpecification = mdsField == null ? null : deserializer.FromField <MarketDataSpecification>(mdsField);
            var         valuationValue          = ffc.GetValue("valuation");
            var         valuation = (FudgeDateTime)(valuationValue == IndicatorType.Instance ? null : valuationValue);

            return(new ViewCycleExecutionOptions(valuation.ToDateTimeOffsetWithDefault(), marketDataSpecification));
        }
Ejemplo n.º 28
0
            private void ListAppend <T>(MorePropertyData prop, object obj, IFudgeField field, IFudgeDeserializer deserializer) where T : class
            {
                IList <T> newList     = deserializer.FromField <IList <T> >(field);
                IList <T> currentList = (IList <T>)prop.PropertyData.Getter(obj);

                foreach (T item in newList)
                {
                    currentList.Add(item);
                }
            }
        /// <remarks>
        ///     See also <see cref="ComputedValueBuilder.GetValue"/>
        /// </remarks>
        private static object Deserialize(IFudgeDeserializer deserializer, IFudgeTypeMappingStrategy typeMap, string labelType, IFudgeField labelValue)
        {
            if (labelValue.Type != FudgeMsgFieldType.Instance)
            {
                return(labelValue.Value);
            }
            Type labelClass = typeMap.GetType(labelType);

            return(deserializer.FromField(labelValue, labelClass));
        }
Ejemplo n.º 30
0
        public static ManageableUnstructuredMarketDataSnapshot FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var dictionary = new Dictionary <MarketDataValueSpecification, IDictionary <string, ValueSnapshot> >();

            foreach (var entryField in ffc.GetAllByOrdinal(1))
            {
                var entryMsg = (IFudgeFieldContainer)entryField.Value;
                MarketDataValueSpecification valueSpec = null;
                string        valueName = null;
                ValueSnapshot value     = null;

                foreach (var field in entryMsg)
                {
                    switch (field.Name)
                    {
                    case "valueSpec":
                        valueSpec = deserializer.FromField <MarketDataValueSpecification>(field);
                        break;

                    case "valueName":
                        valueName = (string)field.Value;
                        break;

                    case "value":
                        value = deserializer.FromField <ValueSnapshot>(field);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                IDictionary <string, ValueSnapshot> innerDict;
                if (!dictionary.TryGetValue(valueSpec, out innerDict))
                {
                    innerDict = new Dictionary <string, ValueSnapshot>();
                    dictionary.Add(valueSpec, innerDict);
                }
                innerDict.Add(valueName, value);
            }
            return(new ManageableUnstructuredMarketDataSnapshot(dictionary));
        }
Ejemplo n.º 31
0
        public static ValueRequirement FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            ValueProperties constraints = deserializer.FromField <ValueProperties>(ffc.GetByName("constraints")) ?? ValueProperties.Create();

            var computationTargetType       = ffc.GetValue <string>("computationTargetType");
            var computationTargetIdentifier = GetUniqueIdentifier(ffc, deserializer, "computationTargetIdentifier");
            var targetSpec = new ComputationTargetSpecification(EnumBuilder <ComputationTargetType> .Parse(computationTargetType), computationTargetIdentifier);
            var valueName  = ffc.GetValue <string>("valueName");

            return(new ValueRequirement(valueName, targetSpec, constraints));
        }
Ejemplo n.º 32
0
        public override DependencyNode DeserializeImpl(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var target = deserializer.FromField <ComputationTarget>(ffc.GetByName("target"));

            string parameterizedFunctionUniqueId = ffc.GetString("parameterizedFunctionUniqueId");
            var    functionParametersField       = ffc.GetByName("functionParameters");
            var    functionParameters            = functionParametersField != null?deserializer.FromField <IFunctionParameters>(functionParametersField) : null;

            string functionShortName = ffc.GetString("functionShortName");
            string functionUniqueId  = ffc.GetString("functionUniqueId");

            ICompiledFunctionDefinition function = new CompiledFunctionDefinitionStub(target.Type, functionShortName, functionUniqueId);
            var parameterizedFunction            = new ParameterizedFunction(function, functionParameters, parameterizedFunctionUniqueId);

            var inputValues          = DeserializeSet <ValueSpecification>(deserializer, ffc, "inputValues");
            var outputValues         = DeserializeSet <ValueSpecification>(deserializer, ffc, "outputValues");
            var terminalOutputValues = DeserializeSet <ValueSpecification>(deserializer, ffc, "terminalOutputValues");

            return(new DependencyNode(target, inputValues, outputValues, terminalOutputValues, parameterizedFunction));
        }
Ejemplo n.º 33
0
        public static ValueRequirement FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            ValueProperties constraints = deserializer.FromField<ValueProperties>(ffc.GetByName("constraints")) ?? ValueProperties.Create();

            var computationTargetType = ffc.GetValue<string>("computationTargetType");
            var computationTargetIdentifier = GetUniqueIdentifier(ffc, deserializer, "computationTargetIdentifier");
            var targetSpec = new ComputationTargetSpecification(EnumBuilder<ComputationTargetType>.Parse(computationTargetType), computationTargetIdentifier);
            var valueName = ffc.GetValue<string>("valueName");

            return new ValueRequirement(valueName, targetSpec, constraints);
        }
Ejemplo n.º 34
0
 private static object GetValue(IFudgeDeserializer deserializer, IFudgeField valueField)
 {
     if (valueField.Type != FudgeMsgFieldType.Instance)
     {
         if (valueField.Value is string)
         {
             return(UniqueId.Parse((string)valueField.Value));
         }
         throw new ArgumentException("Computation target type which I don't know how to deserialize");
     }
     return(deserializer.FromField <object>(valueField));
 }
Ejemplo n.º 35
0
        public override PortfolioDocument DeserializeImpl(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            DateTimeOffset versionToInstant;
            DateTimeOffset correctionFromInstant;
            DateTimeOffset correctionToInstant;
            DateTimeOffset versionFromInstant = AbstractDocument.GetDocumentValues(ffc, out versionToInstant, out correctionFromInstant, out correctionToInstant);

            var uid       = (ffc.GetString("uniqueId") != null) ? UniqueId.Parse(ffc.GetString("uniqueId")) : deserializer.FromField <UniqueId>(ffc.GetByName("uniqueId"));
            var portfolio = deserializer.FromField <ManageablePortfolio>(ffc.GetByName("portfolio"));

            return(new PortfolioDocument(versionFromInstant, versionToInstant, correctionFromInstant, correctionToInstant, uid, portfolio));
        }
Ejemplo n.º 36
0
        public override IPosition DeserializeImpl(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var     id     = ffc.GetValue <string>("uniqueId");
            var     secKey = deserializer.FromField <ExternalIdBundle>(ffc.GetByName("securityKey"));
            var     quant  = ffc.GetValue <string>("quantity");
            var     trades = deserializer.FromField <IList <ITrade> >(ffc.GetByName("trades")) ?? new List <ITrade>();
            decimal quantity;

            if (!decimal.TryParse(quant, out quantity))
            {
                if (quant == "0E-8")
                {
                    quantity = 0;
                }
                else
                {
                    throw new OpenGammaException("Failed to parse quantity " + quant);
                }
            }
            return(new SimplePosition(id == null ? null : UniqueId.Parse(id), quantity, secKey, trades));
        }
Ejemplo n.º 37
0
        public static SecurityDocument FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            DateTimeOffset versionToInstant;
            DateTimeOffset correctionFromInstant;
            DateTimeOffset correctionToInstant;
            DateTimeOffset versionFromInstant = GetDocumentValues(ffc, out versionToInstant, out correctionFromInstant, out correctionToInstant);

            var uid      = (ffc.GetString("uniqueId") != null) ? UniqueId.Parse(ffc.GetString("uniqueId")) : deserializer.FromField <UniqueId>(ffc.GetByName("uniqueId"));
            var security = deserializer.FromField <ISecurity>(ffc.GetByName("security"));

            return(new SecurityDocument(uid, security, versionFromInstant, versionToInstant, correctionFromInstant, correctionToInstant));
        }
Ejemplo n.º 38
0
        public static VolatilityCubeData FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var dataPoints = MapBuilder.FromFudgeMsg(ffc.GetMessage("dataPoints"), deserializer.FromField<VolatilityPoint>, f => (double)f.Value);
            var otherValues = deserializer.FromField<SnapshotDataBundle>(ffc.GetByName("otherData"));

            Dictionary<Pair<Tenor, Tenor>, double> strikes = null;

            var strikesField = ffc.GetMessage("strikes");
            if (strikesField != null)
            {
                strikes = strikesField.Select(deserializer.FromField<StrikeEntry>).ToDictionary(s => new Pair<Tenor, Tenor>(new Tenor(s.SwapTenor), new Tenor(s.OptionExpiry)), s => s.Strike);
            }
            return new VolatilityCubeData(dataPoints, otherValues, strikes);
        }
Ejemplo n.º 39
0
        public static YieldCurveDefinition FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            Currency currency = null;
            string name = null;
            string interpolatorName = null;
            var strips = new List<FixedIncomeStrip>();
            ExternalId region = null;
            foreach (var fudgeField in ffc)
            {
                switch (fudgeField.Name)
                {
                    case "currency":
                        currency = Currency.Create((string)fudgeField.Value);
                        break;
                    case "name":
                        name = (string)fudgeField.Value;
                        break;
                    case "interpolatorName":
                        interpolatorName = (string)fudgeField.Value;
                        break;
                    case "region":
                        region = ExternalId.Parse((string)fudgeField.Value);
                        break;
                    case "strip":
                        strips.Add(deserializer.FromField<FixedIncomeStrip>(fudgeField));
                        break;
                }
            }

            var yieldCurveDefinition = new YieldCurveDefinition(currency, name, interpolatorName);
            yieldCurveDefinition.Region = region;
            yieldCurveDefinition.AddStrip(strips.ToArray());
            return yieldCurveDefinition;
        }
Ejemplo n.º 40
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")
         );
 }
Ejemplo n.º 41
0
        public void LoadReq(FudgeMsg message, IFudgeDeserializer deserializer)
        {
            var values = new Dictionary<Tuple<Currency, Currency>, CurrencyMatrixValue>();
            foreach (var field in message)
            {
                Currency source = Currency.Create(field.Name);
                foreach (var field2 in (IFudgeFieldContainer)field.Value)
                {
                    Currency target = Currency.Create(field2.Name);

                    if (field2.Value is IFudgeFieldContainer)
                    {
                        CurrencyMatrixValue value = deserializer.FromField<CurrencyMatrixValue.CurrencyMatrixValueRequirement>(field2);
                        values.Add(Tuple.Create(source, target), value);
                        values.Add(Tuple.Create(target, source), value.Reciprocal);
                    }
                    else
                    {
                        values.Remove(Tuple.Create(target, source));
                    }
                }
            }
            foreach (var valueEntry in values)
            {
                AddConversion(valueEntry.Key.Item1, valueEntry.Key.Item2, valueEntry.Value);
            }
        }
Ejemplo n.º 42
0
 public static ForwardCurve FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return new ForwardCurve(deserializer.FromField<Math.Curve.Curve>(ffc.GetByName("forwardCurve")));
 }
Ejemplo n.º 43
0
 public void Deserialize(IFudgeFieldContainer msg, IFudgeDeserializer deserializer)
 {
     // Skip message
     Other = deserializer.FromField<ClassWithMessageIn>(msg.GetByName("other"));
 }
            protected virtual bool DeserializeField(IFudgeDeserializer deserializer, IFudgeField field)
            {
                switch (field.Name)
                {
                    case "name":
                        Name = field.GetString();
                        return true;
                    case "mainAddress":
                        MainAddress = deserializer.FromField<Address>(field);
                        return true;
                }

                // Field not recognised
                return false;
            }
Ejemplo n.º 45
0
 public static VolatilityCubeDefinition FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return new VolatilityCubeDefinition(
         deserializer.FromField<List<string>>(ffc.GetByName("swapTenors")).Select(s => new Tenor(s)).ToList(),
         deserializer.FromField<List<string>>(ffc.GetByName("optionExpiries")).Select(s => new Tenor(s)).ToList(),
         ffc.GetMessage("relativeStrikes").Select(f => f.Value).Cast<double>().ToList()
         );
 }
Ejemplo n.º 46
0
        /// <inheritdoc/>
        public object Deserialize(IFudgeFieldContainer msg, IFudgeDeserializer deserializer)
        {
            // We create the new object without constructing it, so we can register it before trying
            // to deserialize the parameters.  This allows us to support cycles.
            object result = FormatterServices.GetUninitializedObject(type);
            deserializer.Register(msg, result);

            var args = new object[constructorParams.Length];
            foreach (var field in msg)
            {
                if (field.Name != null)
                {
                    string name = field.Name.ToLower();

                    for (int i = 0; i < constructorParams.Length; i++)
                    {
                        var constructorParam = constructorParams[i];
                        if (constructorParam.LowerName == name)
                        {
                            switch (constructorParam.Kind)
                            {
                                case TypeData.TypeKind.FudgePrimitive:
                                    args[i] = context.TypeHandler.ConvertType(field.Value, constructorParam.TypeData.Type); ;
                                    break;
                                default:
                                    args[i] = deserializer.FromField(field, constructorParam.TypeData.Type);
                                    break;
                            }
                            break;
                        }
                    }
                }
            }

            constructor.Invoke(result, args);
            return result;
        }
Ejemplo n.º 47
0
 public static CycleExecutionFailedCall FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return new CycleExecutionFailedCall(deserializer.FromField<ViewCycleExecutionOptions>(ffc.GetByName("executionOptions")), deserializer.FromField<JavaException>(ffc.GetByName("exception")));
 }
Ejemplo n.º 48
0
 public static ViewDefinitionCompilationFailedCall FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return new ViewDefinitionCompilationFailedCall(ffc.GetValue<DateTimeOffset>("valuationTime"), deserializer.FromField<JavaException>(ffc.GetByName("exception")));
 }
Ejemplo n.º 49
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);
        }
Ejemplo n.º 50
0
 public static UniqueId GetUniqueIdentifier(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer, string fieldName)
 {
     UniqueId portfolioIdentifier;
     IFudgeField idField = ffc.GetByName(fieldName);
     if (idField != null)
     {
         var value = idField.Value;
         if (value is string)
         {
             portfolioIdentifier = UniqueId.Parse((string) value);
         }
         else if (value is IFudgeFieldContainer)
         {
             portfolioIdentifier = deserializer.FromField<UniqueId>(idField);
         }
         else
         {
             throw new ArgumentException(String.Format("Couldn't read UID {0}", value));
         }
     }
     else
     {
         portfolioIdentifier = null;
     }
     return portfolioIdentifier;
 }
Ejemplo n.º 51
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);
        }
Ejemplo n.º 52
0
 public static FixedIncomeStripWithIdentifier FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return new FixedIncomeStripWithIdentifier(ExternalId.Parse(ffc.GetString("identifier")), deserializer.FromField<FixedIncomeStrip>(ffc.GetByName("strip")));
 }
            protected override bool DeserializeField(IFudgeDeserializer deserializer, IFudgeField field)
            {
                // Let the base process first
                if (base.DeserializeField(deserializer, field))
                    return true;

                // Now process our fields
                switch (field.Name)
                {
                    case "siblings":
                        siblings.Add(deserializer.FromField<Person>(field));
                        return true;
                }

                // Neither recognised the field
                return false;
            }