Source code for sdk.lusid.models.complex_bond

# 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.lusid_instrument import LusidInstrument
from lusid.models.rounding_convention import RoundingConvention
from lusid.models.schedule import Schedule
from lusid.models.time_zone_conventions import TimeZoneConventions
from lusid.models.trading_conventions import TradingConventions

[docs] class ComplexBond(LusidInstrument): """ LUSID representation of a Complex Bond. Including Floating, Fixed-to-float, Sinkable, Callable, Puttable, and Mortgage Backed Securities. # noqa: E501 """ identifiers: Optional[Dict[str, Optional[StrictStr]]] = Field(default=None, description="External market codes and identifiers for the bond, e.g. ISIN.") calculation_type: Optional[StrictStr] = Field(None,alias="calculationType", description="The calculation type applied to the bond coupon amount. This is required for bonds that have a particular type of computing the period coupon, such as simple compounding, irregular coupons etc. The default CalculationType is `Standard`, which returns a coupon amount equal to Principal * Coupon Rate / Coupon Frequency. Coupon Frequency is 12M / Payment Frequency. Payment Frequency can be 1M, 3M, 6M, 12M etc. So Coupon Frequency can be 12, 4, 2, 1 respectively. Supported string (enumeration) values are: [Standard, DayCountCoupon, NoCalculationFloater, BrazilFixedCoupon, StandardWithCappedAccruedInterest].") schedules: Optional[List[Schedule]] = Field(default=None, description="schedules.") original_issue_price: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The price the complex bond was issued at. This is to be entered as a percentage of par, for example a value of 98.5 would represent 98.5%.", alias="originalIssuePrice") rounding_conventions: Optional[List[RoundingConvention]] = Field(default=None, description="Rounding conventions for analytics, if any.", alias="roundingConventions") asset_backed: Optional[StrictBool] = Field(default=None, description="If this flag is set to true, then the outstanding notional and principal repayments will be calculated based on pool factors in the quote store. Usually AssetBacked bonds also require a RollConvention setting of within the FlowConventions any given rates schedule (to ensure payment dates always happen on the same day of the month) and US Agency MBSs with Pay Delay features also require their rates schedules to include an ExDividendConfiguration to drive the lag between interest accrual and payment.", alias="assetBacked") asset_pool_identifier: Optional[StrictStr] = Field(None,alias="assetPoolIdentifier", description="Identifier used to retrieve pool factor information about this bond from the quote store. This is typically the bond's ISIN, but can also be ClientInternal. Please ensure you align the MarketDataKeyRule with the correct Quote (Quote.ClientInternal.* or Quote.Isin.*)") trading_conventions: Optional[TradingConventions] = Field(default=None, alias="tradingConventions") time_zone_conventions: Optional[TimeZoneConventions] = Field(default=None, alias="timeZoneConventions") instrument_type: StrictStr = Field(...,alias="instrumentType", description="Available 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, UnsettledCash, Cash, MasteredInstrument, LoanFacility, FlexibleDeposit, FlexibleRepo.") additional_properties: Dict[str, Any] = {} __properties = ["instrumentType", "identifiers", "calculationType", "schedules", "originalIssuePrice", "roundingConventions", "assetBacked", "assetPoolIdentifier", "tradingConventions", "timeZoneConventions"]
[docs] @validator('instrument_type') def instrument_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 'ComplexBond' 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 "instrument_type" != "type": return value 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', 'UnsettledCash', 'Cash', 'MasteredInstrument', 'LoanFacility', 'FlexibleDeposit', 'FlexibleRepo']: 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', 'UnsettledCash', 'Cash', 'MasteredInstrument', 'LoanFacility', 'FlexibleDeposit', 'FlexibleRepo')") 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) -> ComplexBond: """Create an instance of ComplexBond 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 each item in schedules (list) _items = [] if self.schedules: for _item in self.schedules: if _item: _items.append(_item.to_dict()) _dict['schedules'] = _items # override the default output from pydantic by calling `to_dict()` of each item in rounding_conventions (list) _items = [] if self.rounding_conventions: for _item in self.rounding_conventions: if _item: _items.append(_item.to_dict()) _dict['roundingConventions'] = _items # override the default output from pydantic by calling `to_dict()` of trading_conventions if self.trading_conventions: _dict['tradingConventions'] = self.trading_conventions.to_dict() # override the default output from pydantic by calling `to_dict()` of time_zone_conventions if self.time_zone_conventions: _dict['timeZoneConventions'] = self.time_zone_conventions.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 identifiers (nullable) is None # and __fields_set__ contains the field if self.identifiers is None and "identifiers" in self.__fields_set__: _dict['identifiers'] = None # set to None if calculation_type (nullable) is None # and __fields_set__ contains the field if self.calculation_type is None and "calculation_type" in self.__fields_set__: _dict['calculationType'] = None # set to None if schedules (nullable) is None # and __fields_set__ contains the field if self.schedules is None and "schedules" in self.__fields_set__: _dict['schedules'] = None # set to None if original_issue_price (nullable) is None # and __fields_set__ contains the field if self.original_issue_price is None and "original_issue_price" in self.__fields_set__: _dict['originalIssuePrice'] = None # set to None if rounding_conventions (nullable) is None # and __fields_set__ contains the field if self.rounding_conventions is None and "rounding_conventions" in self.__fields_set__: _dict['roundingConventions'] = None # set to None if asset_backed (nullable) is None # and __fields_set__ contains the field if self.asset_backed is None and "asset_backed" in self.__fields_set__: _dict['assetBacked'] = None # set to None if asset_pool_identifier (nullable) is None # and __fields_set__ contains the field if self.asset_pool_identifier is None and "asset_pool_identifier" in self.__fields_set__: _dict['assetPoolIdentifier'] = None return _dict
[docs] @classmethod def from_dict(cls, obj: dict) -> ComplexBond: """Create an instance of ComplexBond from a dict""" if obj is None: return None if not isinstance(obj, dict): return ComplexBond.parse_obj(obj) _obj = ComplexBond.parse_obj({ "instrument_type": obj.get("instrumentType"), "identifiers": obj.get("identifiers"), "calculation_type": obj.get("calculationType"), "schedules": [Schedule.from_dict(_item) for _item in obj.get("schedules")] if obj.get("schedules") is not None else None, "original_issue_price": obj.get("originalIssuePrice"), "rounding_conventions": [RoundingConvention.from_dict(_item) for _item in obj.get("roundingConventions")] if obj.get("roundingConventions") is not None else None, "asset_backed": obj.get("assetBacked"), "asset_pool_identifier": obj.get("assetPoolIdentifier"), "trading_conventions": TradingConventions.from_dict(obj.get("tradingConventions")) if obj.get("tradingConventions") is not None else None, "time_zone_conventions": TimeZoneConventions.from_dict(obj.get("timeZoneConventions")) if obj.get("timeZoneConventions") 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
ComplexBond.update_forward_refs()