# 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.instrument_event_configuration import InstrumentEventConfiguration
from lusid.models.model_property import ModelProperty
from lusid.models.resource_id import ResourceId
[docs]
class CreateSimplePositionPortfolioRequest(BaseModel):
"""
CreateSimplePositionPortfolioRequest
"""
display_name: StrictStr = Field(...,alias="displayName", description="The name of the simple position portfolio.")
description: Optional[StrictStr] = Field(None,alias="description", description="A description for the simple position portfolio.")
code: StrictStr = Field(...,alias="code", description="The code of the simple position portfolio. Together with the scope this uniquely identifies the simple position portfolio.")
created: Optional[datetime] = Field(default=None, description="The effective datetime at which to create the simple position portfolio. No holdings can be set on the simple position portfolio before this date. Defaults to the current LUSID system datetime if not specified.")
base_currency: StrictStr = Field(...,alias="baseCurrency", description="The base currency of the simple position portfolio in ISO 4217 currency code format.")
corporate_action_source_id: Optional[ResourceId] = Field(default=None, alias="corporateActionSourceId")
accounting_method: Optional[StrictStr] = Field(None,alias="accountingMethod", description="Determines the accounting treatment given to the simple position portfolio's tax lots. Default value: AverageCost. Available values: Default, AverageCost, FirstInFirstOut, LastInFirstOut, HighestCostFirst, LowestCostFirst, ProRateByUnits, ProRateByCost, ProRateByCostPortfolioCurrency, IntraDayThenFirstInFirstOut, LongTermHighestCostFirst, LongTermHighestCostFirstPortfolioCurrency, HighestCostFirstPortfolioCurrency, LowestCostFirstPortfolioCurrency, MaximumLossMinimumGain, MaximumLossMinimumGainPortfolioCurrency.")
sub_holding_keys: Optional[List[StrictStr]] = Field(default=None, description="A set of unique transaction properties to group the simple position portfolio's holdings by, perhaps for strategy tagging. Each property must be from the 'Transaction' domain and identified by a key in the format {domain}/{scope}/{code}, for example 'Transaction/strategies/quantsignal'. See https://support.lusid.com/knowledgebase/article/KA-01879/en-us for more information.", alias="subHoldingKeys")
properties: Optional[Dict[str, ModelProperty]] = Field(default=None, description="A set of unique portfolio properties to add custom data to the simple position portfolio. Each property must be from the 'Portfolio' domain and identified by a key in the format {domain}/{scope}/{code}, for example 'Portfolio/Manager/Id'. Note these properties must be pre-defined.")
instrument_scopes: Optional[List[StrictStr]] = Field(default=None, description="The resolution strategy used to resolve instruments of holdings upserted to this portfolio.", alias="instrumentScopes")
amortisation_method: Optional[StrictStr] = Field(None,alias="amortisationMethod", description="The amortisation method used by the portfolio for the calculation. Available values: NoAmortisation, StraightLine, EffectiveYield, StraightLineSettlementDate, EffectiveYieldSettlementDate.")
transaction_type_scope: Optional[StrictStr] = Field(None,alias="transactionTypeScope", description="The scope of the transaction types.")
cash_gain_loss_calculation_date: Optional[StrictStr] = Field(None,alias="cashGainLossCalculationDate", description="The option when the Cash Gain Loss to be calulated. Default value: SettlementDate. Available values: Default, SettlementDate, TransactionDate.")
instrument_event_configuration: Optional[InstrumentEventConfiguration] = Field(default=None, alias="instrumentEventConfiguration")
amortisation_rule_set_id: Optional[ResourceId] = Field(default=None, alias="amortisationRuleSetId")
__properties = ["displayName", "description", "code", "created", "baseCurrency", "corporateActionSourceId", "accountingMethod", "subHoldingKeys", "properties", "instrumentScopes", "amortisationMethod", "transactionTypeScope", "cashGainLossCalculationDate", "instrumentEventConfiguration", "amortisationRuleSetId"]
[docs]
@validator('accounting_method')
def accounting_method_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 'CreateSimplePositionPortfolioRequest' 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 "accounting_method" != "type":
return value
if value is None:
return value
if value not in ['Default', 'AverageCost', 'FirstInFirstOut', 'LastInFirstOut', 'HighestCostFirst', 'LowestCostFirst', 'ProRateByUnits', 'ProRateByCost', 'ProRateByCostPortfolioCurrency', 'IntraDayThenFirstInFirstOut', 'LongTermHighestCostFirst', 'LongTermHighestCostFirstPortfolioCurrency', 'HighestCostFirstPortfolioCurrency', 'LowestCostFirstPortfolioCurrency', 'MaximumLossMinimumGain', 'MaximumLossMinimumGainPortfolioCurrency']:
raise ValueError("must be one of enum values ('Default', 'AverageCost', 'FirstInFirstOut', 'LastInFirstOut', 'HighestCostFirst', 'LowestCostFirst', 'ProRateByUnits', 'ProRateByCost', 'ProRateByCostPortfolioCurrency', 'IntraDayThenFirstInFirstOut', 'LongTermHighestCostFirst', 'LongTermHighestCostFirstPortfolioCurrency', 'HighestCostFirstPortfolioCurrency', 'LowestCostFirstPortfolioCurrency', 'MaximumLossMinimumGain', 'MaximumLossMinimumGainPortfolioCurrency')")
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) -> CreateSimplePositionPortfolioRequest:
"""Create an instance of CreateSimplePositionPortfolioRequest 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={
},
exclude_none=True)
# override the default output from pydantic by calling `to_dict()` of corporate_action_source_id
if self.corporate_action_source_id:
_dict['corporateActionSourceId'] = self.corporate_action_source_id.to_dict()
# override the default output from pydantic by calling `to_dict()` of each value in properties (dict)
_field_dict = {}
if self.properties:
for _key in self.properties:
if self.properties[_key]:
_field_dict[_key] = self.properties[_key].to_dict()
_dict['properties'] = _field_dict
# override the default output from pydantic by calling `to_dict()` of instrument_event_configuration
if self.instrument_event_configuration:
_dict['instrumentEventConfiguration'] = self.instrument_event_configuration.to_dict()
# override the default output from pydantic by calling `to_dict()` of amortisation_rule_set_id
if self.amortisation_rule_set_id:
_dict['amortisationRuleSetId'] = self.amortisation_rule_set_id.to_dict()
# set to None if description (nullable) is None
# and __fields_set__ contains the field
if self.description is None and "description" in self.__fields_set__:
_dict['description'] = None
# set to None if created (nullable) is None
# and __fields_set__ contains the field
if self.created is None and "created" in self.__fields_set__:
_dict['created'] = None
# set to None if sub_holding_keys (nullable) is None
# and __fields_set__ contains the field
if self.sub_holding_keys is None and "sub_holding_keys" in self.__fields_set__:
_dict['subHoldingKeys'] = None
# set to None if properties (nullable) is None
# and __fields_set__ contains the field
if self.properties is None and "properties" in self.__fields_set__:
_dict['properties'] = None
# set to None if instrument_scopes (nullable) is None
# and __fields_set__ contains the field
if self.instrument_scopes is None and "instrument_scopes" in self.__fields_set__:
_dict['instrumentScopes'] = None
# set to None if amortisation_method (nullable) is None
# and __fields_set__ contains the field
if self.amortisation_method is None and "amortisation_method" in self.__fields_set__:
_dict['amortisationMethod'] = None
# set to None if transaction_type_scope (nullable) is None
# and __fields_set__ contains the field
if self.transaction_type_scope is None and "transaction_type_scope" in self.__fields_set__:
_dict['transactionTypeScope'] = None
# set to None if cash_gain_loss_calculation_date (nullable) is None
# and __fields_set__ contains the field
if self.cash_gain_loss_calculation_date is None and "cash_gain_loss_calculation_date" in self.__fields_set__:
_dict['cashGainLossCalculationDate'] = None
return _dict
[docs]
@classmethod
def from_dict(cls, obj: dict) -> CreateSimplePositionPortfolioRequest:
"""Create an instance of CreateSimplePositionPortfolioRequest from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return CreateSimplePositionPortfolioRequest.parse_obj(obj)
_obj = CreateSimplePositionPortfolioRequest.parse_obj({
"display_name": obj.get("displayName"),
"description": obj.get("description"),
"code": obj.get("code"),
"created": obj.get("created"),
"base_currency": obj.get("baseCurrency"),
"corporate_action_source_id": ResourceId.from_dict(obj.get("corporateActionSourceId")) if obj.get("corporateActionSourceId") is not None else None,
"accounting_method": obj.get("accountingMethod"),
"sub_holding_keys": obj.get("subHoldingKeys"),
"properties": dict(
(_k, ModelProperty.from_dict(_v))
for _k, _v in obj.get("properties").items()
)
if obj.get("properties") is not None
else None,
"instrument_scopes": obj.get("instrumentScopes"),
"amortisation_method": obj.get("amortisationMethod"),
"transaction_type_scope": obj.get("transactionTypeScope"),
"cash_gain_loss_calculation_date": obj.get("cashGainLossCalculationDate"),
"instrument_event_configuration": InstrumentEventConfiguration.from_dict(obj.get("instrumentEventConfiguration")) if obj.get("instrumentEventConfiguration") is not None else None,
"amortisation_rule_set_id": ResourceId.from_dict(obj.get("amortisationRuleSetId")) if obj.get("amortisationRuleSetId") is not None else None
})
return _obj
CreateSimplePositionPortfolioRequest.update_forward_refs()