Source code for sdk.lusid.models.fixed_schedule

# 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.ex_dividend_configuration import ExDividendConfiguration
from lusid.models.flow_convention_name import FlowConventionName
from lusid.models.flow_conventions import FlowConventions
from lusid.models.schedule import Schedule

[docs] class FixedSchedule(Schedule): """ Schedule for fixed coupon payments # noqa: E501 """ start_date: datetime = Field(..., alias="startDate", description="Date to start generate from") maturity_date: datetime = Field(..., alias="maturityDate", description="Date to generate to") flow_conventions: Optional[FlowConventions] = Field(None, alias="flowConventions") coupon_rate: Optional[Union[StrictFloat, StrictInt]] = Field(None, alias="couponRate", description="Coupon rate given as a fraction.") convention_name: Optional[FlowConventionName] = Field(None, alias="conventionName") ex_dividend_days: Optional[StrictInt] = Field(None, alias="exDividendDays", description="Optional. Number of calendar days in the ex-dividend period. If the settlement date falls in the ex-dividend period then the coupon paid is zero and the accrued interest is negative. If set, this must be a non-negative number. If not set, or set to 0, then there is no ex-dividend period. NOTE: This field is deprecated. If you wish to set the ExDividendDays on a bond, please use the ExDividendConfiguration.") notional: Optional[Union[StrictFloat, StrictInt]] = Field(None, description="Scaling factor, the quantity outstanding on which the rate will be paid.") payment_currency: StrictStr = Field(..., alias="paymentCurrency", description="Payment currency. This does not have to be the same as the nominal bond or observation/reset currency.") stub_type: Optional[StrictStr] = Field(None, alias="stubType", description="StubType required of the schedule Supported string (enumeration) values are: [ShortFront, ShortBack, LongBack, LongFront, Both].") ex_dividend_configuration: Optional[ExDividendConfiguration] = Field(None, alias="exDividendConfiguration") schedule_type: StrictStr = Field(..., alias="scheduleType", description="The available values are: FixedSchedule, FloatSchedule, OptionalitySchedule, StepSchedule, Exercise, FxRateSchedule, FxLinkedNotionalSchedule, Invalid") additional_properties: Dict[str, Any] = {} __properties = ["scheduleType", "startDate", "maturityDate", "flowConventions", "couponRate", "conventionName", "exDividendDays", "notional", "paymentCurrency", "stubType", "exDividendConfiguration"]
[docs] @validator('schedule_type') def schedule_type_validate_enum(cls, value): """Validates the enum""" if value not in ('FixedSchedule', 'FloatSchedule', 'OptionalitySchedule', 'StepSchedule', 'Exercise', 'FxRateSchedule', 'FxLinkedNotionalSchedule', 'Invalid'): raise ValueError("must be one of enum values ('FixedSchedule', 'FloatSchedule', 'OptionalitySchedule', 'StepSchedule', 'Exercise', 'FxRateSchedule', 'FxLinkedNotionalSchedule', 'Invalid')") 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) -> FixedSchedule: """Create an instance of FixedSchedule 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_conventions if self.flow_conventions: _dict['flowConventions'] = self.flow_conventions.to_dict() # override the default output from pydantic by calling `to_dict()` of convention_name if self.convention_name: _dict['conventionName'] = self.convention_name.to_dict() # override the default output from pydantic by calling `to_dict()` of ex_dividend_configuration if self.ex_dividend_configuration: _dict['exDividendConfiguration'] = self.ex_dividend_configuration.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 ex_dividend_days (nullable) is None # and __fields_set__ contains the field if self.ex_dividend_days is None and "ex_dividend_days" in self.__fields_set__: _dict['exDividendDays'] = None # set to None if stub_type (nullable) is None # and __fields_set__ contains the field if self.stub_type is None and "stub_type" in self.__fields_set__: _dict['stubType'] = None return _dict
[docs] @classmethod def from_dict(cls, obj: dict) -> FixedSchedule: """Create an instance of FixedSchedule from a dict""" if obj is None: return None if not isinstance(obj, dict): return FixedSchedule.parse_obj(obj) _obj = FixedSchedule.parse_obj({ "schedule_type": obj.get("scheduleType"), "start_date": obj.get("startDate"), "maturity_date": obj.get("maturityDate"), "flow_conventions": FlowConventions.from_dict(obj.get("flowConventions")) if obj.get("flowConventions") is not None else None, "coupon_rate": obj.get("couponRate"), "convention_name": FlowConventionName.from_dict(obj.get("conventionName")) if obj.get("conventionName") is not None else None, "ex_dividend_days": obj.get("exDividendDays"), "notional": obj.get("notional"), "payment_currency": obj.get("paymentCurrency"), "stub_type": obj.get("stubType"), "ex_dividend_configuration": ExDividendConfiguration.from_dict(obj.get("exDividendConfiguration")) if obj.get("exDividendConfiguration") 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