Source code for sdk.lusid.models.opaque_market_data

# coding: utf-8

"""
    LUSID API

    FINBOURNE Technology  # noqa: E501

    Contact: info@finbourne.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


from __future__ import annotations
import pprint
import re  # noqa: F401
import json


from typing import Any, Dict, Optional
from pydantic.v1 import Field, StrictStr, constr, validator
from lusid.models.complex_market_data import ComplexMarketData

[docs] class OpaqueMarketData(ComplexMarketData): """ A representation of an un-built piece of complex market data, to allow for passing through to the vendor library for building. The market data will usually be in some standard form such as XML or Json, representing a curve or surface. # noqa: E501 """ document: constr(strict=True, min_length=1) = Field(..., description="The document as a string.") format: constr(strict=True, min_length=1) = Field(..., description="What format is the document stored in, e.g. Xml. Supported string (enumeration) values are: [Unknown, Xml, Json, Csv].") name: constr(strict=True, min_length=1) = Field(..., description="Internal name of document. This is not used for search, it is simply a designator that helps identify the document and could be anything (filename, ftp address or similar)") lineage: Optional[constr(strict=True, max_length=1024, min_length=0)] = Field(None, description="Description of the complex market data's lineage e.g. 'FundAccountant_GreenQuality'.") market_data_type: StrictStr = Field(..., alias="marketDataType", description="The available values are: DiscountFactorCurveData, EquityVolSurfaceData, FxVolSurfaceData, IrVolCubeData, OpaqueMarketData, YieldCurveData, FxForwardCurveData, FxForwardPipsCurveData, FxForwardTenorCurveData, FxForwardTenorPipsCurveData, FxForwardCurveByQuoteReference, CreditSpreadCurveData, EquityCurveByPricesData, ConstantVolatilitySurface") additional_properties: Dict[str, Any] = {} __properties = ["marketDataType", "document", "format", "name", "lineage"]
[docs] @validator('market_data_type') def market_data_type_validate_enum(cls, value): """Validates the enum""" if value not in ('DiscountFactorCurveData', 'EquityVolSurfaceData', 'FxVolSurfaceData', 'IrVolCubeData', 'OpaqueMarketData', 'YieldCurveData', 'FxForwardCurveData', 'FxForwardPipsCurveData', 'FxForwardTenorCurveData', 'FxForwardTenorPipsCurveData', 'FxForwardCurveByQuoteReference', 'CreditSpreadCurveData', 'EquityCurveByPricesData', 'ConstantVolatilitySurface'): raise ValueError("must be one of enum values ('DiscountFactorCurveData', 'EquityVolSurfaceData', 'FxVolSurfaceData', 'IrVolCubeData', 'OpaqueMarketData', 'YieldCurveData', 'FxForwardCurveData', 'FxForwardPipsCurveData', 'FxForwardTenorCurveData', 'FxForwardTenorPipsCurveData', 'FxForwardCurveByQuoteReference', 'CreditSpreadCurveData', 'EquityCurveByPricesData', 'ConstantVolatilitySurface')") return value
[docs] class Config: """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True
[docs] def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.dict(by_alias=True))
[docs] def to_json(self) -> str: """Returns the JSON representation of the model using alias""" return json.dumps(self.to_dict())
[docs] @classmethod def from_json(cls, json_str: str) -> OpaqueMarketData: """Create an instance of OpaqueMarketData from a JSON string""" return cls.from_dict(json.loads(json_str))
[docs] def to_dict(self): """Returns the dictionary representation of the model using alias""" _dict = self.dict(by_alias=True, exclude={ "additional_properties" }, exclude_none=True) # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: for _key, _value in self.additional_properties.items(): _dict[_key] = _value # set to None if lineage (nullable) is None # and __fields_set__ contains the field if self.lineage is None and "lineage" in self.__fields_set__: _dict['lineage'] = None return _dict
[docs] @classmethod def from_dict(cls, obj: dict) -> OpaqueMarketData: """Create an instance of OpaqueMarketData from a dict""" if obj is None: return None if not isinstance(obj, dict): return OpaqueMarketData.parse_obj(obj) _obj = OpaqueMarketData.parse_obj({ "market_data_type": obj.get("marketDataType"), "document": obj.get("document"), "format": obj.get("format"), "name": obj.get("name"), "lineage": obj.get("lineage") }) # store additional fields in additional_properties for _key in obj.keys(): if _key not in cls.__properties: _obj.additional_properties[_key] = obj.get(_key) return _obj