Source code for sdk.lusid.models.fund_valuation_request

# 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.aggregate_spec import AggregateSpec
from lusid.models.fund_valuation_schedule import FundValuationSchedule
from lusid.models.market_data_overrides import MarketDataOverrides
from lusid.models.order_by_spec import OrderBySpec
from lusid.models.order_flow_configuration import OrderFlowConfiguration
from lusid.models.property_filter import PropertyFilter
from lusid.models.resource_id import ResourceId

[docs] class FundValuationRequest(BaseModel): """ Specification object for the parameters of a valuation # noqa: E501 """ as_at: Optional[datetime] = Field(default=None, description="The asAt date to use.", alias="asAt") metrics: List[AggregateSpec] = Field(description="The set of specifications to calculate or retrieve during the valuation and present in the results. For example: AggregateSpec('Valuation/PV','Sum') for returning the PV (present value) of holdings AggregateSpec('Holding/default/Units','Sum') for returning the units of holidays AggregateSpec('Instrument/default/LusidInstrumentId','Value') for returning the Lusid Instrument identifier") group_by: Optional[List[StrictStr]] = Field(default=None, description="The set of items by which to perform grouping. This primarily matters when one or more of the metric operators is a mapping that reduces set size, e.g. sum or proportion. The group-by statement determines the set of keys by which to break the results out.", alias="groupBy") filters: Optional[List[PropertyFilter]] = Field(default=None, description="A set of filters to use to reduce the data found in a request. Equivalent to the 'where ...' part of a Sql select statement. For example, filter a set of values within a given range or matching a particular value.") sort: Optional[List[OrderBySpec]] = Field(default=None, description="A (possibly empty/null) set of specifications for how to order the results.") equip_with_subtotals: Optional[StrictBool] = Field(default=None, description="Flag directing the Valuation call to populate the results with subtotals of aggregates.", alias="equipWithSubtotals") return_result_as_expanded_types: Optional[StrictBool] = Field(default=None, description="Financially meaningful results can be presented as either simple flat types or more complex expanded types. For example, the present value (PV) of a holding could be represented either as a simple decimal (with currency implied) or as a decimal-currency pair. This flag allows either representation to be returned. In the PV example, the returned value would be the decimal-currency pair if this flag is true, or the decimal only if this flag is false.", alias="returnResultAsExpandedTypes") include_order_flow: Optional[OrderFlowConfiguration] = Field(default=None, alias="includeOrderFlow") fund_valuation_schedule: FundValuationSchedule = Field(alias="fundValuationSchedule") market_data_overrides: Optional[MarketDataOverrides] = Field(default=None, alias="marketDataOverrides") corporate_action_source_id: Optional[ResourceId] = Field(default=None, alias="corporateActionSourceId") __properties = ["asAt", "metrics", "groupBy", "filters", "sort", "equipWithSubtotals", "returnResultAsExpandedTypes", "includeOrderFlow", "fundValuationSchedule", "marketDataOverrides", "corporateActionSourceId"]
[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) -> FundValuationRequest: """Create an instance of FundValuationRequest 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 each item in metrics (list) _items = [] if self.metrics: for _item in self.metrics: if _item: _items.append(_item.to_dict()) _dict['metrics'] = _items # override the default output from pydantic by calling `to_dict()` of each item in filters (list) _items = [] if self.filters: for _item in self.filters: if _item: _items.append(_item.to_dict()) _dict['filters'] = _items # override the default output from pydantic by calling `to_dict()` of each item in sort (list) _items = [] if self.sort: for _item in self.sort: if _item: _items.append(_item.to_dict()) _dict['sort'] = _items # override the default output from pydantic by calling `to_dict()` of include_order_flow if self.include_order_flow: _dict['includeOrderFlow'] = self.include_order_flow.to_dict() # override the default output from pydantic by calling `to_dict()` of fund_valuation_schedule if self.fund_valuation_schedule: _dict['fundValuationSchedule'] = self.fund_valuation_schedule.to_dict() # override the default output from pydantic by calling `to_dict()` of market_data_overrides if self.market_data_overrides: _dict['marketDataOverrides'] = self.market_data_overrides.to_dict() # 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() # set to None if as_at (nullable) is None # and __fields_set__ contains the field if self.as_at is None and "as_at" in self.__fields_set__: _dict['asAt'] = None # set to None if group_by (nullable) is None # and __fields_set__ contains the field if self.group_by is None and "group_by" in self.__fields_set__: _dict['groupBy'] = None # set to None if filters (nullable) is None # and __fields_set__ contains the field if self.filters is None and "filters" in self.__fields_set__: _dict['filters'] = None # set to None if sort (nullable) is None # and __fields_set__ contains the field if self.sort is None and "sort" in self.__fields_set__: _dict['sort'] = None return _dict
[docs] @classmethod def from_dict(cls, obj: dict) -> FundValuationRequest: """Create an instance of FundValuationRequest from a dict""" if obj is None: return None if not isinstance(obj, dict): return FundValuationRequest.parse_obj(obj) _obj = FundValuationRequest.parse_obj({ "as_at": obj.get("asAt"), "metrics": [AggregateSpec.from_dict(_item) for _item in obj.get("metrics")] if obj.get("metrics") is not None else None, "group_by": obj.get("groupBy"), "filters": [PropertyFilter.from_dict(_item) for _item in obj.get("filters")] if obj.get("filters") is not None else None, "sort": [OrderBySpec.from_dict(_item) for _item in obj.get("sort")] if obj.get("sort") is not None else None, "equip_with_subtotals": obj.get("equipWithSubtotals"), "return_result_as_expanded_types": obj.get("returnResultAsExpandedTypes"), "include_order_flow": OrderFlowConfiguration.from_dict(obj.get("includeOrderFlow")) if obj.get("includeOrderFlow") is not None else None, "fund_valuation_schedule": FundValuationSchedule.from_dict(obj.get("fundValuationSchedule")) if obj.get("fundValuationSchedule") is not None else None, "market_data_overrides": MarketDataOverrides.from_dict(obj.get("marketDataOverrides")) if obj.get("marketDataOverrides") is not None else None, "corporate_action_source_id": ResourceId.from_dict(obj.get("corporateActionSourceId")) if obj.get("corporateActionSourceId") is not None else None }) return _obj
FundValuationRequest.update_forward_refs()