Source code for sdk.lusid.models.term_deposit

# 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 datetime import datetime
from typing import Any, Dict, Optional, Union
from pydantic.v1 import Field, StrictFloat, StrictInt, StrictStr, validator
from lusid.models.flow_conventions import FlowConventions
from lusid.models.lusid_instrument import LusidInstrument

[docs] class TermDeposit(LusidInstrument): """ LUSID representation of a Term Deposit. # noqa: E501 """ start_date: datetime = Field(..., alias="startDate", description="The start date of the instrument. For term deposits this is the start date of the interest calculation period.") maturity_date: datetime = Field(..., alias="maturityDate", description="The maturity date of the instrument. For term deposits this is the last date of the interest calculation period.") contract_size: Union[StrictFloat, StrictInt] = Field(..., alias="contractSize", description="The principal amount of the term deposit.") flow_convention: FlowConventions = Field(..., alias="flowConvention") rate: Union[StrictFloat, StrictInt] = Field(..., description="The fixed rate for the term deposit. Specified as a decimal, e.g 0.03 is meant to be 3% interest") dom_ccy: Optional[StrictStr] = Field(None, alias="domCcy", description="The domestic currency of the instrument. This should be the same as the Currency set on the FlowConventions. You do not need to populate this field for Term Deposits in LUSID as all functionality is driven by the Currency set on the FlowConventions. LUSID will not store values saved on this field.") instrument_type: StrictStr = Field(..., alias="instrumentType", description="The available values are: QuotedSecurity, InterestRateSwap, FxForward, Future, ExoticInstrument, FxOption, CreditDefaultSwap, InterestRateSwaption, Bond, EquityOption, FixedLeg, FloatingLeg, BespokeCashFlowsLeg, Unknown, TermDeposit, ContractForDifference, EquitySwap, CashPerpetual, CapFloor, CashSettled, CdsIndex, Basket, FundingLeg, FxSwap, ForwardRateAgreement, SimpleInstrument, Repo, Equity, ExchangeTradedOption, ReferenceInstrument, ComplexBond, InflationLinkedBond, InflationSwap, SimpleCashFlowLoan, TotalReturnSwap, InflationLeg, FundShareClass, FlexibleLoan") additional_properties: Dict[str, Any] = {} __properties = ["instrumentType", "startDate", "maturityDate", "contractSize", "flowConvention", "rate", "domCcy"]
[docs] @validator('instrument_type') def instrument_type_validate_enum(cls, value): """Validates the enum""" if value not in ('QuotedSecurity', 'InterestRateSwap', 'FxForward', 'Future', 'ExoticInstrument', 'FxOption', 'CreditDefaultSwap', 'InterestRateSwaption', 'Bond', 'EquityOption', 'FixedLeg', 'FloatingLeg', 'BespokeCashFlowsLeg', 'Unknown', 'TermDeposit', 'ContractForDifference', 'EquitySwap', 'CashPerpetual', 'CapFloor', 'CashSettled', 'CdsIndex', 'Basket', 'FundingLeg', 'FxSwap', 'ForwardRateAgreement', 'SimpleInstrument', 'Repo', 'Equity', 'ExchangeTradedOption', 'ReferenceInstrument', 'ComplexBond', 'InflationLinkedBond', 'InflationSwap', 'SimpleCashFlowLoan', 'TotalReturnSwap', 'InflationLeg', 'FundShareClass', 'FlexibleLoan'): raise ValueError("must be one of enum values ('QuotedSecurity', 'InterestRateSwap', 'FxForward', 'Future', 'ExoticInstrument', 'FxOption', 'CreditDefaultSwap', 'InterestRateSwaption', 'Bond', 'EquityOption', 'FixedLeg', 'FloatingLeg', 'BespokeCashFlowsLeg', 'Unknown', 'TermDeposit', 'ContractForDifference', 'EquitySwap', 'CashPerpetual', 'CapFloor', 'CashSettled', 'CdsIndex', 'Basket', 'FundingLeg', 'FxSwap', 'ForwardRateAgreement', 'SimpleInstrument', 'Repo', 'Equity', 'ExchangeTradedOption', 'ReferenceInstrument', 'ComplexBond', 'InflationLinkedBond', 'InflationSwap', 'SimpleCashFlowLoan', 'TotalReturnSwap', 'InflationLeg', 'FundShareClass', 'FlexibleLoan')") 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) -> TermDeposit: """Create an instance of TermDeposit 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 flow_convention if self.flow_convention: _dict['flowConvention'] = self.flow_convention.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 dom_ccy (nullable) is None # and __fields_set__ contains the field if self.dom_ccy is None and "dom_ccy" in self.__fields_set__: _dict['domCcy'] = None return _dict
[docs] @classmethod def from_dict(cls, obj: dict) -> TermDeposit: """Create an instance of TermDeposit from a dict""" if obj is None: return None if not isinstance(obj, dict): return TermDeposit.parse_obj(obj) _obj = TermDeposit.parse_obj({ "instrument_type": obj.get("instrumentType"), "start_date": obj.get("startDate"), "maturity_date": obj.get("maturityDate"), "contract_size": obj.get("contractSize"), "flow_convention": FlowConventions.from_dict(obj.get("flowConvention")) if obj.get("flowConvention") is not None else None, "rate": obj.get("rate"), "dom_ccy": obj.get("domCcy") }) # 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