Source code for sdk.lusid.models.credit_spread_curve_data

# coding: utf-8


    FINBOURNE Technology  # noqa: E501

    Generated by OpenAPI Generator (

    Do not edit the class manually.

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

from datetime import datetime
from typing import Any, Dict, List, Optional, Union
from pydantic.v1 import Field, StrictFloat, StrictInt, StrictStr, conlist, constr, validator
from lusid.models.complex_market_data import ComplexMarketData
from lusid.models.market_data_options import MarketDataOptions

[docs] class CreditSpreadCurveData(ComplexMarketData): """ A credit spread curve matching tenors against par spread quotes # noqa: E501 """ base_date: datetime = Field(..., alias="baseDate", description="EffectiveAt date of the quoted rates") dom_ccy: StrictStr = Field(..., alias="domCcy", description="Domestic currency of the curve") tenors: conlist(StrictStr) = Field(..., description="The tenors for which the rates apply For more information on tenors, see [knowledge base article KA-02097](") spreads: conlist(Union[StrictFloat, StrictInt]) = Field(..., description="Par spread quotes corresponding to the tenors.") recovery_rate: Union[StrictFloat, StrictInt] = Field(..., alias="recoveryRate", description="The recovery rate in default.") reference_date: Optional[datetime] = Field(None, alias="referenceDate", description="If tenors are provided, this is the date against which the tenors will be resolved. This is of importance to CDX spread quotes, which are usually quoted in tenors relative to the CDX start date. In this case, the ReferenceDate would be equal to the CDX start date, and the BaseDate would be the date for which the spreads are valid. If not provided, this defaults to the BaseDate of the curve.") maturities: Optional[conlist(datetime)] = Field(None, description="The maturity dates for which the rates apply. Either tenors or maturities should be provided, not both.") 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_options: Optional[MarketDataOptions] = Field(None, alias="marketDataOptions") 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", "baseDate", "domCcy", "tenors", "spreads", "recoveryRate", "referenceDate", "maturities", "lineage", "marketDataOptions"]
[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) -> CreditSpreadCurveData: """Create an instance of CreditSpreadCurveData 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) # override the default output from pydantic by calling `to_dict()` of market_data_options if self.market_data_options: _dict['marketDataOptions'] = self.market_data_options.to_dict() # 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 reference_date (nullable) is None # and __fields_set__ contains the field if self.reference_date is None and "reference_date" in self.__fields_set__: _dict['referenceDate'] = None # set to None if maturities (nullable) is None # and __fields_set__ contains the field if self.maturities is None and "maturities" in self.__fields_set__: _dict['maturities'] = None # 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) -> CreditSpreadCurveData: """Create an instance of CreditSpreadCurveData from a dict""" if obj is None: return None if not isinstance(obj, dict): return CreditSpreadCurveData.parse_obj(obj) _obj = CreditSpreadCurveData.parse_obj({ "market_data_type": obj.get("marketDataType"), "base_date": obj.get("baseDate"), "dom_ccy": obj.get("domCcy"), "tenors": obj.get("tenors"), "spreads": obj.get("spreads"), "recovery_rate": obj.get("recoveryRate"), "reference_date": obj.get("referenceDate"), "maturities": obj.get("maturities"), "lineage": obj.get("lineage"), "market_data_options": MarketDataOptions.from_dict(obj.get("marketDataOptions")) if obj.get("marketDataOptions") is not None else None }) # 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