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 typing import List, Dict, Optional, Any, Union, TYPE_CHECKING
from typing_extensions import Annotated
from pydantic.v1 import BaseModel, StrictStr, StrictInt, StrictBool, StrictFloat, StrictBytes, Field, validator, ValidationError, conlist, constr
from datetime import datetime
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(description="Date from which LUSID starts generating the payment schedule.", alias="startDate") maturity_date: datetime = Field(description="Last date of the payment generation schedule. May not necessarily be the maturity date of the underlying instrument (e.g. in case the instrument has multiple payment schedules).", alias="maturityDate") flow_conventions: Optional[FlowConventions] = Field(default=None, alias="flowConventions") coupon_rate: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Coupon rate given as a fraction.", alias="couponRate") convention_name: Optional[FlowConventionName] = Field(default=None, alias="conventionName") ex_dividend_days: Optional[StrictInt] = Field(default=None, 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.", alias="exDividendDays") notional: Optional[Union[StrictFloat, StrictInt]] = Field(default=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="When a payment schedule doesn't have regular payment intervals just because of the first and/or last coupons of the schedule, we call those irregular coupons stubs. This configuration specifies what type of stub is used when building the schedule Supported values are: None = this is a regular payment schedule with no stubs. DO NOT use it with irregular schedules or you will get incorrect and unexpected behaviour. ShortFront = this is an irregular payment schedule where only the first coupon is irregular, and covers a payment period that is shorter than the regular payment period. ShortBack = this is an irregular payment schedule where only the last coupon is irregular, and covers a payment period that is shorter than the regular payment period. LongFront = this is an irregular payment schedule where only the first coupon is irregular, and covers a payment period that is longer than the regular payment period. LongBack = this is an irregular payment schedule where only the last coupon is irregular, and covers a payment period that is longer than the regular payment period. Both = this is an irregular payment schedule where both the first and the last coupons are irregular, and the length of these periods is calculated based on the first coupon payment date that should have been explicitly set.") ex_dividend_configuration: Optional[ExDividendConfiguration] = Field(default=None, alias="exDividendConfiguration") schedule_type: StrictStr = Field(...,alias="scheduleType", description="Available values: FixedSchedule, FloatSchedule, OptionalitySchedule, StepSchedule, Exercise, FxRateSchedule, FxLinkedNotionalSchedule, BondConversionSchedule, 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""" # Finbourne have removed enum validation on all models, except for this use case: # Workflow and notification application SDK use the property name 'type' as the discriminator on a number of classes. # During instantiation, the value of 'type' is checked against the enum values, # check it's a class that uses the 'type' property as a discriminator # list of classes can be found by searching for 'actual_instance: Union[' in the generated code if 'FixedSchedule' not in [ # For notification application classes 'AmazonSqsNotificationType', 'AmazonSqsNotificationTypeResponse', 'AmazonSqsPrincipalAuthNotificationType', 'AmazonSqsPrincipalAuthNotificationTypeResponse', 'AzureServiceBusTypeResponse', 'AzureServiceBusNotificationType', 'EmailNotificationType', 'EmailNotificationTypeResponse', 'SmsNotificationType', 'SmsNotificationTypeResponse', 'WebhookNotificationType', 'WebhookNotificationTypeResponse', # For workflow application classes 'CreateChildTasksAction', 'RunWorkerAction', 'TriggerParentTaskAction', 'CreateChildTasksActionResponse', 'RunWorkerActionResponse', 'TriggerChildTasksAction', 'TriggerChildTasksActionResponse', 'TriggerParentTaskActionResponse', 'CreateNewTaskActivity', 'UpdateMatchingTasksActivity', 'CreateNewTaskActivityResponse', 'UpdateMatchingTasksActivityResponse', 'Fail', 'GroupReconciliation', 'HealthCheck', 'LuminesceView', 'SchedulerJob', 'Sleep', 'FailResponse', 'GroupReconciliationResponse', 'HealthCheckResponse', 'LuminesceViewResponse', 'SchedulerJobResponse', 'SleepResponse', 'Library', 'LibraryResponse', 'DayRegularity', 'RelativeMonthRegularity', 'SpecificMonthRegularity', 'WeekRegularity', 'YearRegularity', 'LusidEntityDataQualityCheck', 'LusidEntityDataQualityCheckResponse', 'TriggerChildTasksActionResponse']: return value # Only validate the 'type' property of the class if "schedule_type" != "type": return value if value not in ['FixedSchedule', 'FloatSchedule', 'OptionalitySchedule', 'StepSchedule', 'Exercise', 'FxRateSchedule', 'FxLinkedNotionalSchedule', 'BondConversionSchedule', 'Invalid']: raise ValueError("must be one of enum values ('FixedSchedule', 'FloatSchedule', 'OptionalitySchedule', 'StepSchedule', 'Exercise', 'FxRateSchedule', 'FxLinkedNotionalSchedule', 'BondConversionSchedule', 'Invalid')") return value
[docs] class Config: """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True
def __str__(self): """For `print` and `pprint`""" return pprint.pformat(self.dict(by_alias=False)) def __repr__(self): """For `print` and `pprint`""" return self.to_str()
[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
FixedSchedule.update_forward_refs()