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>()));
 }
        public override ICurrencyMatrix DeserializeImpl(IFudgeFieldContainer message, IFudgeDeserializer deserializer)
        {
            var matrixImpl = new CurrencyMatrix();

            IFudgeField field = message.GetByName(UniqueIDFieldName);

            if (field != null)
            {
                var uid = UniqueId.Parse((string)field.Value);
                matrixImpl.UniqueId = uid;
            }
            field = message.GetByName(CrossConvertFieldName);
            if (field != null)
            {
                var crossconvert = (FudgeMsg)field.Value;
                matrixImpl.LoadCross(crossconvert);
            }
            field = message.GetByName(FixedRateFieldName);
            if (field != null)
            {
                throw new NotImplementedException();
            }
            field = message.GetByName(ValueRequirementsFieldName);
            if (field != null)
            {
                FudgeMsg value = (FudgeMsg)field.Value;
                matrixImpl.LoadReq(value, deserializer);
            }

            return(matrixImpl);
        }
        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 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));
        }
 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 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")
                ));
 }
Beispiel #7
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};
        }
        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 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));
        }
        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);
        }
Beispiel #11
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
         );
 }
Beispiel #12
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
                                                    ));
        }
Beispiel #13
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);
        }
Beispiel #14
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));
        }
Beispiel #15
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;
 }
Beispiel #16
0
 public static TestWrapper <T> FromFudgeMsg(IFudgeFieldContainer ffc,
                                            IFudgeDeserializer deserializer)
 {
     return(new TestWrapper <T> {
         Test = deserializer.FromField <T>(ffc.GetByName("test"))
     });
 }
        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);
        }
        public override ComputationTarget DeserializeImpl(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var computationTargetType = EnumBuilder <ComputationTargetType> .Parse(ffc.GetMessage("type").GetString(1));

            object value = GetValue(deserializer, ffc.GetByName("value"));

            return(new ComputationTarget(computationTargetType, value));
        }
Beispiel #19
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);
 }
        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));
        }
Beispiel #21
0
 private static DateTimeOffset GetToDateTimeOffsetWithDefault(IFudgeFieldContainer msg, string fieldName)
 {
     //TODO strict once [PLAT-1683] is fixed
     if (msg.GetByName(fieldName).Type == IndicatorFieldType.Instance)
     {
         return(new DateTimeOffset());
     }
     return(msg.GetValue <DateTimeOffset>(fieldName));
 }
Beispiel #22
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);
        }
Beispiel #23
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));
        }
        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));
        }
Beispiel #25
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));
        }
Beispiel #26
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));
        }
Beispiel #27
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));
        }
Beispiel #29
0
        public override ITrade DeserializeImpl(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            //TODO: the rest of this
            var uniqueIdentifier = UniqueId.Parse(ffc.GetString("uniqueId"));

            var tradeDate = ffc.GetValue <DateTimeOffset>("tradeDate");

            var securityKey = deserializer.FromField <ExternalIdBundle>(ffc.GetByName("securityKey"));

            var counterPartyIdentifier = ExternalId.Parse(ffc.GetString("counterpartyKey") ?? ffc.GetString("counterparty")); //NOTE: this is a hack because we don't use proto yet
            var quant = ffc.GetValue <string>("quantity");

            return(new SimpleTrade(uniqueIdentifier, tradeDate, securityKey, new CounterpartyImpl(counterPartyIdentifier), decimal.Parse(quant)));
        }
Beispiel #30
0
 public static ChangeEvent FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     var changeType = EnumBuilder<ChangeType>.Parse(ffc.GetMessage("type").GetString(1));
     var beforeField = ffc.GetString("beforeId");
     var beforeId = beforeField == null ? null : UniqueId.Parse(beforeField);
     var afterField = ffc.GetString("afterId");
     var afterId = afterField == null ? null : UniqueId.Parse(afterField);
     var versionField = ffc.GetByName("versionInstant");
     var versionInstant = (FudgeDateTime) versionField.Value;
     return new ChangeEvent(changeType,
         beforeId,
         afterId,
         new Instant(versionInstant));
 }
Beispiel #31
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);
        }
        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
            });
        }
        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));
        }
Beispiel #34
0
        protected override InMemoryViewDeltaResultModel BuildObject(IFudgeFieldContainer msg, IFudgeDeserializer deserializer, Dictionary <string, ViewCalculationResultModel> configurationMap, UniqueId viewProcessId, UniqueId viewCycleId, DateTimeOffset inputDataTimestamp, DateTimeOffset resultTimestamp, TimeSpan calculationDuration)
        {
            var            tsField = msg.GetByName("previousTS");
            DateTimeOffset previousResultTimestamp;

            if (tsField.Type == IndicatorFieldType.Instance)
            {
                previousResultTimestamp = default(DateTimeOffset);
            }
            else
            {
                previousResultTimestamp = ((FudgeDateTime)tsField.Value).ToDateTimeOffsetWithDefault();
            }

            return(new InMemoryViewDeltaResultModel(viewProcessId, viewCycleId, inputDataTimestamp, resultTimestamp, configurationMap, previousResultTimestamp, calculationDuration));
        }
Beispiel #35
0
        public static ChangeEvent FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var changeType = EnumBuilder <ChangeType> .Parse(ffc.GetMessage("type").GetString(1));

            var beforeField    = ffc.GetString("beforeId");
            var beforeId       = beforeField == null ? null : UniqueId.Parse(beforeField);
            var afterField     = ffc.GetString("afterId");
            var afterId        = afterField == null ? null : UniqueId.Parse(afterField);
            var versionField   = ffc.GetByName("versionInstant");
            var versionInstant = (FudgeDateTime)versionField.Value;

            return(new ChangeEvent(changeType,
                                   beforeId,
                                   afterId,
                                   new Instant(versionInstant)));
        }
        public static MultipleCurrencyAmount FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
        {
            var currencies = ffc.GetMessage("currencies").Select(f => (string)f.Value).Select(Currency.Create).ToList();
            var amounts    = (double[])ffc.GetByName("amounts").Value;

            if (currencies.Count != amounts.Length)
            {
                throw new ArgumentException("Mismatched labels and value", "ffc");
            }
            var dict = new SortedDictionary <Currency, CurrencyAmount>();

            for (int i = 0; i < currencies.Count; i++)
            {
                dict.Add(currencies[i], new CurrencyAmount(currencies[i], amounts[i]));
            }
            return(new MultipleCurrencyAmount(dict));
        }
Beispiel #37
0
 public static CycleExecutionFailedCall FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return new CycleExecutionFailedCall(deserializer.FromField<ViewCycleExecutionOptions>(ffc.GetByName("executionOptions")), deserializer.FromField<JavaException>(ffc.GetByName("exception")));
 }
Beispiel #38
0
 public static ViewDefinitionCompilationFailedCall FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return new ViewDefinitionCompilationFailedCall(ffc.GetValue<DateTimeOffset>("valuationTime"), deserializer.FromField<JavaException>(ffc.GetByName("exception")));
 }
Beispiel #39
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")
         );
 }
 public static CycleExecutionFailedCall FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return(new CycleExecutionFailedCall(deserializer.FromField <ViewCycleExecutionOptions>(ffc.GetByName("executionOptions")), deserializer.FromField <JavaException>(ffc.GetByName("exception"))));
 }
Beispiel #41
0
 public override UserMarketDataSpecification DeserializeImpl(IFudgeFieldContainer msg, IFudgeDeserializer deserializer)
 {
     return(new UserMarketDataSpecification(deserializer.FromField <UniqueId>(msg.GetByName("userSnapshotId"))));
 }
Beispiel #42
0
 public override IPortfolio DeserializeImpl(IFudgeFieldContainer msg, IFudgeDeserializer deserializer)
 {
     return(new SimplePortfolio(deserializer.FromField <PortfolioNode>(msg.GetByName("root")), UniqueId.Parse(msg.GetString("identifier")), msg.GetString("name")));
 }
 public void Deserialize(IFudgeFieldContainer msg, IFudgeDeserializer deserializer)
 {
     // Skip message
     Other = deserializer.FromField<ClassWithMessageIn>(msg.GetByName("other"));
 }
Beispiel #44
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);
        }
Beispiel #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()
         );
 }
Beispiel #46
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);
        }
Beispiel #47
0
 public static ForwardCurve FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return new ForwardCurve(deserializer.FromField<Math.Curve.Curve>(ffc.GetByName("forwardCurve")));
 }
Beispiel #48
0
 public static FixedIncomeStripWithIdentifier FromFudgeMsg(IFudgeFieldContainer ffc, IFudgeDeserializer deserializer)
 {
     return new FixedIncomeStripWithIdentifier(ExternalId.Parse(ffc.GetString("identifier")), deserializer.FromField<FixedIncomeStrip>(ffc.GetByName("strip")));
 }