"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .accruedinterest import AccruedInterest, AccruedInterestTypedDict
from .commission import Commission, CommissionTypedDict
from .fee import Fee, FeeTypedDict
from .lot import Lot, LotTypedDict
from .withholding import Withholding, WithholdingTypedDict
from .withholdingdata import WithholdingData, WithholdingDataTypedDict
from .yieldrecord import YieldRecord, YieldRecordTypedDict
from ascend_sdk import utils
from ascend_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from ascend_sdk.utils import validate_open_enum
from datetime import datetime
from enum import Enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ActivityAcatsPendingOutTypedDict(TypedDict):
    r"""Object containing metadata for pending outgoing acats memos"""

    acats_control_number: NotRequired[str]
    r"""Unique Identifier generated by the NSCC ACATS when a transfer is initiated or submitted"""
    additional_instructions: NotRequired[str]
    r"""Free form text field containing additional information about a transaction"""


class ActivityAcatsPendingOut(BaseModel):
    r"""Object containing metadata for pending outgoing acats memos"""

    acats_control_number: Optional[str] = None
    r"""Unique Identifier generated by the NSCC ACATS when a transfer is initiated or submitted"""

    additional_instructions: Optional[str] = None
    r"""Free form text field containing additional information about a transaction"""


class ActivityAccountMemo(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Indicates the memo location impacted by an entry"""

    MEMO_TYPE_UNSPECIFIED = "MEMO_TYPE_UNSPECIFIED"
    FULLY_PAID_STOCK_LOAN = "FULLY_PAID_STOCK_LOAN"
    FREE = "FREE"
    PENDING_OUTGOING_ACAT = "PENDING_OUTGOING_ACAT"
    PENDING_DRIP = "PENDING_DRIP"
    PENDING_WITHDRAWAL = "PENDING_WITHDRAWAL"


class ActivityAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Denotes whether the shares are incoming or outgoing"""

    ACTION_UNSPECIFIED = "ACTION_UNSPECIFIED"
    INCOMING = "INCOMING"
    OUTGOING = "OUTGOING"
    CASH_IN_LIEU = "CASH_IN_LIEU"


class ActivityMethod(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The method used for the account transfer"""

    ACCOUNT_TRANSFER_METHOD_UNSPECIFIED = "ACCOUNT_TRANSFER_METHOD_UNSPECIFIED"
    ACATS = "ACATS"
    INTERNAL = "INTERNAL"
    MANUAL = "MANUAL"


class ActivityAccountTransferTypedDict(TypedDict):
    r"""Object containing metadata for account transfer movements"""

    acats_asset_sequence_number: NotRequired[str]
    r"""Sequence number assigned by the DTCC ACATS transfer system for each asset transferred"""
    acats_control_number: NotRequired[str]
    r"""Unique Identifier generated by the NSCC ACATS when a transfer is initiated or submitted"""
    action: NotRequired[ActivityAction]
    r"""Denotes whether the shares are incoming or outgoing"""
    additional_instructions: NotRequired[str]
    r"""Free form text field containing additional information about a transaction"""
    contra_party_account_number: NotRequired[str]
    r"""Account number at the contra firm"""
    contra_party_id: NotRequired[str]
    r"""Contra party identifier"""
    institution: NotRequired[str]
    r"""Contra party institution for the account transfer"""
    method: NotRequired[ActivityMethod]
    r"""The method used for the account transfer"""


class ActivityAccountTransfer(BaseModel):
    r"""Object containing metadata for account transfer movements"""

    acats_asset_sequence_number: Optional[str] = None
    r"""Sequence number assigned by the DTCC ACATS transfer system for each asset transferred"""

    acats_control_number: Optional[str] = None
    r"""Unique Identifier generated by the NSCC ACATS when a transfer is initiated or submitted"""

    action: Annotated[
        Optional[ActivityAction], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Denotes whether the shares are incoming or outgoing"""

    additional_instructions: Optional[str] = None
    r"""Free form text field containing additional information about a transaction"""

    contra_party_account_number: Optional[str] = None
    r"""Account number at the contra firm"""

    contra_party_id: Optional[str] = None
    r"""Contra party identifier"""

    institution: Optional[str] = None
    r"""Contra party institution for the account transfer"""

    method: Annotated[
        Optional[ActivityMethod], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The method used for the account transfer"""


class AccruedInterestDescTypedDict(TypedDict):
    r"""Contains information on the amount of interest that has been earned but not yet paid between the last interest payment and the date of the trade"""


class AccruedInterestDesc(BaseModel):
    r"""Contains information on the amount of interest that has been earned but not yet paid between the last interest payment and the date of the trade"""


class ActivityActivityDateTypedDict(TypedDict):
    r"""The calendar date an activity took place"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityActivityDate(BaseModel):
    r"""The calendar date an activity took place"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityPaymentDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityPaymentDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityCapitalGainsQuantityTypedDict(TypedDict):
    r"""The position on which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityCapitalGainsQuantity(BaseModel):
    r"""The position on which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRecordDateTypedDict(TypedDict):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityRecordDate(BaseModel):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityCapitalGainsTypedDict(TypedDict):
    r"""Object containing metadata for capital gains"""

    corporate_action_general_information: NotRequired[
        Nullable[ActivityCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    long_term_gain: NotRequired[bool]
    r"""Can indicate the capital gain is eligible for preferential tax treatment"""
    payment_date: NotRequired[Nullable[ActivityPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    quantity: NotRequired[Nullable[ActivityCapitalGainsQuantityTypedDict]]
    r"""The position on which the corporate action was paid"""
    record_date: NotRequired[Nullable[ActivityRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""
    reinvested: NotRequired[bool]
    r"""Indicates whether the cash dividend was reinvested"""


class ActivityCapitalGains(BaseModel):
    r"""Object containing metadata for capital gains"""

    corporate_action_general_information: OptionalNullable[
        ActivityCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    long_term_gain: Optional[bool] = None
    r"""Can indicate the capital gain is eligible for preferential tax treatment"""

    payment_date: OptionalNullable[ActivityPaymentDate] = UNSET
    r"""The anticipated payment date at the depository"""

    quantity: OptionalNullable[ActivityCapitalGainsQuantity] = UNSET
    r"""The position on which the corporate action was paid"""

    record_date: OptionalNullable[ActivityRecordDate] = UNSET
    r"""The date on which positions are recorded in order to calculate entitlement"""

    reinvested: Optional[bool] = None
    r"""Indicates whether the cash dividend was reinvested"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "corporate_action_general_information",
            "long_term_gain",
            "payment_date",
            "quantity",
            "record_date",
            "reinvested",
        ]
        nullable_fields = [
            "corporate_action_general_information",
            "payment_date",
            "quantity",
            "record_date",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityCashRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityCashRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityCashDividendCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityCashDividendCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityCashDividendFpslTypedDict(TypedDict):
    r"""Number of shares loaned out via the FPSL program on record_date"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityCashDividendFpsl(BaseModel):
    r"""Number of shares loaned out via the FPSL program on record_date"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityFreeTypedDict(TypedDict):
    r"""Number of shares not loaned out via the FPSL program on record_date"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityFree(BaseModel):
    r"""Number of shares not loaned out via the FPSL program on record_date"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityCashDividendPaymentDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityCashDividendPaymentDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityCashDividendQuantityTypedDict(TypedDict):
    r"""When ex-date occurs before the record date, quantity will equal the settled date position balance on the position date of the event When ex-date occurs after the record date, quantity will equal the trade date position balance on the position date of the event"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityCashDividendQuantity(BaseModel):
    r"""When ex-date occurs before the record date, quantity will equal the settled date position balance on the position date of the event When ex-date occurs after the record date, quantity will equal the trade date position balance on the position date of the event"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityCashDividendRecordDateTypedDict(TypedDict):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityCashDividendRecordDate(BaseModel):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivitySettledTypedDict(TypedDict):
    r"""The accounts settled position for which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivitySettled(BaseModel):
    r"""The accounts settled position for which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivitySubtype(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The subtype for the corporate action event"""

    CORPORATEACTIONSUBTYPE_UNSPECIFIED = "CORPORATEACTIONSUBTYPE_UNSPECIFIED"
    ADDITIONAL_DIVIDEND = "ADDITIONAL_DIVIDEND"
    APPROXIMATE_RATE = "APPROXIMATE_RATE"
    DIVIDEND_ARREARS = "DIVIDEND_ARREARS"
    DIVIDEND_CANCELLED = "DIVIDEND_CANCELLED"
    DIVIDEND_PAYMENT_TAX_CLASSIFICATIONS = "DIVIDEND_PAYMENT_TAX_CLASSIFICATIONS"
    DIVIDEND_RESCINDED = "DIVIDEND_RESCINDED"
    ESTIMATED_RETURN_OF_CAPITAL = "ESTIMATED_RETURN_OF_CAPITAL"
    ESTIMATED_RETURN_OF_CAPITAL_PLUS_INCOME = "ESTIMATED_RETURN_OF_CAPITAL_PLUS_INCOME"
    EXTRA_DIVIDEND = "EXTRA_DIVIDEND"
    EXTRA_DIVIDEND_PLUS_INCOME = "EXTRA_DIVIDEND_PLUS_INCOME"
    FINAL_PAYMENT_TRANSFER_BOOKS_ARE_CLOSED = "FINAL_PAYMENT_TRANSFER_BOOKS_ARE_CLOSED"
    GROSS_RATE = "GROSS_RATE"
    INITIAL_DIVIDEND = "INITIAL_DIVIDEND"
    INITIAL_DIVIDEND_LONG_PERIOD = "INITIAL_DIVIDEND_LONG_PERIOD"
    INITIAL_DIVIDEND_SHORT_PERIOD = "INITIAL_DIVIDEND_SHORT_PERIOD"
    LIMITED_PARTNERSHIP_DISTRIBUTION = "LIMITED_PARTNERSHIP_DISTRIBUTION"
    LIQUIDATION = "LIQUIDATION"
    NET_RATE = "NET_RATE"
    OTHER = "OTHER"
    PROCEEDS_FROM_SALE_OF_RIGHTS = "PROCEEDS_FROM_SALE_OF_RIGHTS"
    REGULAR_DIVIDEND = "REGULAR_DIVIDEND"
    RETURN_OF_CAPITAL = "RETURN_OF_CAPITAL"
    RETURN_OF_CAPITAL_PLUS_INCOME = "RETURN_OF_CAPITAL_PLUS_INCOME"
    SPECIAL_DIVIDEND = "SPECIAL_DIVIDEND"
    SPECIAL_DIVIDEND_PLUS_INCOME = "SPECIAL_DIVIDEND_PLUS_INCOME"
    YEAR_END_DIVIDEND = "YEAR_END_DIVIDEND"
    YEAR_END_DIVIDEND_PLUS_INCOME = "YEAR_END_DIVIDEND_PLUS_INCOME"
    PARTIAL = "PARTIAL"
    FULL = "FULL"
    MATURITY = "MATURITY"
    TERMINATION = "TERMINATION"
    REDEMPTION_OF_WARRANTS = "REDEMPTION_OF_WARRANTS"


class ActivityCashDividendTypedDict(TypedDict):
    r"""Object containing for cash dividends"""

    cash_rate: NotRequired[Nullable[ActivityCashRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivityCashDividendCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    fpsl: NotRequired[Nullable[ActivityCashDividendFpslTypedDict]]
    r"""Number of shares loaned out via the FPSL program on record_date"""
    free: NotRequired[Nullable[ActivityFreeTypedDict]]
    r"""Number of shares not loaned out via the FPSL program on record_date"""
    long_term_gain: NotRequired[bool]
    r"""Can indicate the capital gain is eligible for preferential tax treatment"""
    payment_date: NotRequired[Nullable[ActivityCashDividendPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    qualified: NotRequired[bool]
    r"""If populated, can indicates whether the transaction may be taxed at a preferential rate"""
    quantity: NotRequired[Nullable[ActivityCashDividendQuantityTypedDict]]
    r"""When ex-date occurs before the record date, quantity will equal the settled date position balance on the position date of the event When ex-date occurs after the record date, quantity will equal the trade date position balance on the position date of the event"""
    record_date: NotRequired[Nullable[ActivityCashDividendRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""
    reinvested: NotRequired[bool]
    r"""Indicates whether the cash dividend was reinvested"""
    settled: NotRequired[Nullable[ActivitySettledTypedDict]]
    r"""The accounts settled position for which the corporate action was paid"""
    substitute_payment: NotRequired[bool]
    r"""Indicates that this portion of the dividend was paid on a position that is currently loaned out"""
    subtype: NotRequired[ActivitySubtype]
    r"""The subtype for the corporate action event"""


class ActivityCashDividend(BaseModel):
    r"""Object containing for cash dividends"""

    cash_rate: OptionalNullable[ActivityCashRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    corporate_action_general_information: OptionalNullable[
        ActivityCashDividendCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    fpsl: OptionalNullable[ActivityCashDividendFpsl] = UNSET
    r"""Number of shares loaned out via the FPSL program on record_date"""

    free: OptionalNullable[ActivityFree] = UNSET
    r"""Number of shares not loaned out via the FPSL program on record_date"""

    long_term_gain: Optional[bool] = None
    r"""Can indicate the capital gain is eligible for preferential tax treatment"""

    payment_date: OptionalNullable[ActivityCashDividendPaymentDate] = UNSET
    r"""The anticipated payment date at the depository"""

    qualified: Optional[bool] = None
    r"""If populated, can indicates whether the transaction may be taxed at a preferential rate"""

    quantity: OptionalNullable[ActivityCashDividendQuantity] = UNSET
    r"""When ex-date occurs before the record date, quantity will equal the settled date position balance on the position date of the event When ex-date occurs after the record date, quantity will equal the trade date position balance on the position date of the event"""

    record_date: OptionalNullable[ActivityCashDividendRecordDate] = UNSET
    r"""The date on which positions are recorded in order to calculate entitlement"""

    reinvested: Optional[bool] = None
    r"""Indicates whether the cash dividend was reinvested"""

    settled: OptionalNullable[ActivitySettled] = UNSET
    r"""The accounts settled position for which the corporate action was paid"""

    substitute_payment: Optional[bool] = None
    r"""Indicates that this portion of the dividend was paid on a position that is currently loaned out"""

    subtype: Annotated[
        Optional[ActivitySubtype], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The subtype for the corporate action event"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "fpsl",
            "free",
            "long_term_gain",
            "payment_date",
            "qualified",
            "quantity",
            "record_date",
            "reinvested",
            "settled",
            "substitute_payment",
            "subtype",
        ]
        nullable_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "fpsl",
            "free",
            "payment_date",
            "quantity",
            "record_date",
            "settled",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityCommissionTypedDict(TypedDict):
    r"""Contains information on the commissions charged by brokers or financial intermediaries for executing trades on behalf of clients"""


class ActivityCommission(BaseModel):
    r"""Contains information on the commissions charged by brokers or financial intermediaries for executing trades on behalf of clients"""


class ActivityConversionCashRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityConversionCashRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityConversionCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityConversionCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityStockRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityStockRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityConversionType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The subtype for the corporate action event"""

    EVENT_TYPE_UNSPECIFIED = "EVENT_TYPE_UNSPECIFIED"
    CASH = "CASH"
    STOCK = "STOCK"
    CASH_AND_STOCK = "CASH_AND_STOCK"


class ActivityConversionTypedDict(TypedDict):
    r"""Object containing metadata for conversions"""

    cash_rate: NotRequired[Nullable[ActivityConversionCashRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivityConversionCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    stock_rate: NotRequired[Nullable[ActivityStockRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""
    type: NotRequired[ActivityConversionType]
    r"""The subtype for the corporate action event"""


class ActivityConversion(BaseModel):
    r"""Object containing metadata for conversions"""

    cash_rate: OptionalNullable[ActivityConversionCashRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    corporate_action_general_information: OptionalNullable[
        ActivityConversionCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    stock_rate: OptionalNullable[ActivityStockRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    type: Annotated[
        Optional[ActivityConversionType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The subtype for the corporate action event"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "stock_rate",
            "type",
        ]
        nullable_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "stock_rate",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityCorporateActionMemoAdjustmentTypedDict(TypedDict):
    r"""Object containing information about corporate action memo adjustments"""

    corporate_action_id: NotRequired[str]
    r"""This field serves as a unique identifier for the specific corporate action linked to the memo adjustment"""
    corporate_action_type: NotRequired[str]
    r"""Used to capture the specific type of corporate action related to the memo adjustment"""


class ActivityCorporateActionMemoAdjustment(BaseModel):
    r"""Object containing information about corporate action memo adjustments"""

    corporate_action_id: Optional[str] = None
    r"""This field serves as a unique identifier for the specific corporate action linked to the memo adjustment"""

    corporate_action_type: Optional[str] = None
    r"""Used to capture the specific type of corporate action related to the memo adjustment"""


class ActivityCreditType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Further detail describing the type of credit"""

    CREDIT_TYPE_UNSPECIFIED = "CREDIT_TYPE_UNSPECIFIED"
    FULLY_PAID_STOCK_LOAN = "FULLY_PAID_STOCK_LOAN"
    WRITE_OFF = "WRITE_OFF"
    REIMBURSEMENT = "REIMBURSEMENT"
    PROMOTIONAL = "PROMOTIONAL"
    FDIC_INSURED_DEPOSIT_PROGRAM = "FDIC_INSURED_DEPOSIT_PROGRAM"
    ACCOUNT_TRANSFER_ADJUSTMENT = "ACCOUNT_TRANSFER_ADJUSTMENT"


class ActivityCreditTypedDict(TypedDict):
    r"""Object containing more information about the credit being paid"""

    additional_instructions: NotRequired[str]
    r"""Free form text field providing additional information about a transaction"""
    credit_type: NotRequired[ActivityCreditType]
    r"""Further detail describing the type of credit"""
    taxable: NotRequired[bool]
    r"""No longer applicable"""


class ActivityCredit(BaseModel):
    r"""Object containing more information about the credit being paid"""

    additional_instructions: Optional[str] = None
    r"""Free form text field providing additional information about a transaction"""

    credit_type: Annotated[
        Optional[ActivityCreditType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Further detail describing the type of credit"""

    taxable: Optional[bool] = None
    r"""No longer applicable"""


class ActivityContributionType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Enum Representing whether the deposit is a new contribution to a retirement account or a rollover from a different account"""

    CONTRIBUTION_TYPE_UNSPECIFIED = "CONTRIBUTION_TYPE_UNSPECIFIED"
    REGULAR = "REGULAR"
    EMPLOYEE = "EMPLOYEE"
    EMPLOYER = "EMPLOYER"
    RECHARACTERIZATION = "RECHARACTERIZATION"
    ROLLOVER_60_DAY = "ROLLOVER_60_DAY"
    ROLLOVER_DIRECT = "ROLLOVER_DIRECT"
    TRANSFER = "TRANSFER"
    TRUSTEE_FEE = "TRUSTEE_FEE"
    CONVERSION = "CONVERSION"
    REPAYMENT = "REPAYMENT"
    CONTRIBUTION_NON_REPORTABLE = "CONTRIBUTION_NON_REPORTABLE"


class ActivityDepositType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The mechanism by which funds were deposited"""

    EXTERNAL_MOVEMENT_TYPE_UNSPECIFIED = "EXTERNAL_MOVEMENT_TYPE_UNSPECIFIED"
    ACH = "ACH"
    CHECK = "CHECK"
    WIRE = "WIRE"
    PAYPAL = "PAYPAL"
    RTP = "RTP"
    ICT = "ICT"
    JOURNAL = "JOURNAL"


class ActivityDepositTypedDict(TypedDict):
    r"""Object containing more information about a deposit"""

    additional_instructions: NotRequired[str]
    r"""Free form text field providing additional information about a transaction"""
    contribution_type: NotRequired[ActivityContributionType]
    r"""Enum Representing whether the deposit is a new contribution to a retirement account or a rollover from a different account"""
    contribution_year: NotRequired[int]
    r"""Integer representing the tax year the contribution should be applied to"""
    fed_reference_number: NotRequired[str]
    r"""Unique tracking number provided to allow tracking a wire transfer from the initiating bank to the receiving bank"""
    originating_account_number: NotRequired[str]
    r"""Human readable account identifier for the account the assets were journaled from. To be populated when the Deposit type is Journal"""
    type: NotRequired[ActivityDepositType]
    r"""The mechanism by which funds were deposited"""


class ActivityDeposit(BaseModel):
    r"""Object containing more information about a deposit"""

    additional_instructions: Optional[str] = None
    r"""Free form text field providing additional information about a transaction"""

    contribution_type: Annotated[
        Optional[ActivityContributionType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Enum Representing whether the deposit is a new contribution to a retirement account or a rollover from a different account"""

    contribution_year: Optional[int] = None
    r"""Integer representing the tax year the contribution should be applied to"""

    fed_reference_number: Optional[str] = None
    r"""Unique tracking number provided to allow tracking a wire transfer from the initiating bank to the receiving bank"""

    originating_account_number: Optional[str] = None
    r"""Human readable account identifier for the account the assets were journaled from. To be populated when the Deposit type is Journal"""

    type: Annotated[
        Optional[ActivityDepositType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The mechanism by which funds were deposited"""


class ActivityDripAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Denotes whether the reinvestment is pending or complete"""

    DRIP_ACTION_UNSPECIFIED = "DRIP_ACTION_UNSPECIFIED"
    DRIP_PENDING = "DRIP_PENDING"
    DRIP_COMPLETE = "DRIP_COMPLETE"


class ActivityDripTypedDict(TypedDict):
    r"""Object containing more information about the drip allocations"""

    action: NotRequired[ActivityDripAction]
    r"""Denotes whether the reinvestment is pending or complete"""


class ActivityDrip(BaseModel):
    r"""Object containing more information about the drip allocations"""

    action: Annotated[
        Optional[ActivityDripAction], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Denotes whether the reinvestment is pending or complete"""


class ActivityExchangeCashRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityExchangeCashRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityExchangeCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityExchangeCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityExchangeStockRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityExchangeStockRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityExchangeType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Indicates whether the merger was for cash, stock, or both"""

    EVENT_TYPE_UNSPECIFIED = "EVENT_TYPE_UNSPECIFIED"
    CASH = "CASH"
    STOCK = "STOCK"
    CASH_AND_STOCK = "CASH_AND_STOCK"


class ActivityExchangeTypedDict(TypedDict):
    r"""The exchange where the trade was executed"""

    cash_rate: NotRequired[Nullable[ActivityExchangeCashRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivityExchangeCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    stock_rate: NotRequired[Nullable[ActivityExchangeStockRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""
    type: NotRequired[ActivityExchangeType]
    r"""Indicates whether the merger was for cash, stock, or both"""


class ActivityExchange(BaseModel):
    r"""The exchange where the trade was executed"""

    cash_rate: OptionalNullable[ActivityExchangeCashRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    corporate_action_general_information: OptionalNullable[
        ActivityExchangeCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    stock_rate: OptionalNullable[ActivityExchangeStockRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    type: Annotated[
        Optional[ActivityExchangeType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Indicates whether the merger was for cash, stock, or both"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "stock_rate",
            "type",
        ]
        nullable_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "stock_rate",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityFeeTypedDict(TypedDict):
    r"""Object containing metadata for fees"""

    additional_instructions: NotRequired[str]
    r"""Free form text field providing additional information about a transaction"""


class ActivityFee(BaseModel):
    r"""Object containing metadata for fees"""

    additional_instructions: Optional[str] = None
    r"""Free form text field providing additional information about a transaction"""


class ActivityFpslAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Denotes whether the shares are incoming or outgoing"""

    FPSL_ACTION_UNSPECIFIED = "FPSL_ACTION_UNSPECIFIED"
    ALLOCATE = "ALLOCATE"
    DEALLOCATE = "DEALLOCATE"


class ActivityFpslTypedDict(TypedDict):
    r"""Object containing more information about the fpsl allocations"""

    action: NotRequired[ActivityFpslAction]
    r"""Denotes whether the shares are incoming or outgoing"""


class ActivityFpsl(BaseModel):
    r"""Object containing more information about the fpsl allocations"""

    action: Annotated[
        Optional[ActivityFpslAction], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Denotes whether the shares are incoming or outgoing"""


class ActivityGrossAmountTypedDict(TypedDict):
    r"""The monetary value of an activity, exclusive of any fees (First money)"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityGrossAmount(BaseModel):
    r"""The monetary value of an activity, exclusive of any fees (First money)"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityInterestAccrualEndDateTypedDict(TypedDict):
    r"""Date on which interest accrues before the calculation is made for payment or charge"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityInterestAccrualEndDate(BaseModel):
    r"""Date on which interest accrues before the calculation is made for payment or charge"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityInterestAccrualStartDateTypedDict(TypedDict):
    r"""Date on which interest begins to accrue on a cash balance or borrowed funds"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityInterestAccrualStartDate(BaseModel):
    r"""Date on which interest begins to accrue on a cash balance or borrowed funds"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityInterestType(str, Enum, metaclass=utils.OpenEnumMeta):
    INTEREST_TYPE_UNSPECIFIED = "INTEREST_TYPE_UNSPECIFIED"
    CREDIT = "CREDIT"
    DEBIT = "DEBIT"


class ActivityInterestTypedDict(TypedDict):
    r"""Object containing metadata for margin interest"""

    interest_accrual_end_date: NotRequired[
        Nullable[ActivityInterestAccrualEndDateTypedDict]
    ]
    r"""Date on which interest accrues before the calculation is made for payment or charge"""
    interest_accrual_start_date: NotRequired[
        Nullable[ActivityInterestAccrualStartDateTypedDict]
    ]
    r"""Date on which interest begins to accrue on a cash balance or borrowed funds"""
    interest_type: NotRequired[ActivityInterestType]


class ActivityInterest(BaseModel):
    r"""Object containing metadata for margin interest"""

    interest_accrual_end_date: OptionalNullable[ActivityInterestAccrualEndDate] = UNSET
    r"""Date on which interest accrues before the calculation is made for payment or charge"""

    interest_accrual_start_date: OptionalNullable[
        ActivityInterestAccrualStartDate
    ] = UNSET
    r"""Date on which interest begins to accrue on a cash balance or borrowed funds"""

    interest_type: Annotated[
        Optional[ActivityInterestType], PlainValidator(validate_open_enum(False))
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "interest_accrual_end_date",
            "interest_accrual_start_date",
            "interest_type",
        ]
        nullable_fields = ["interest_accrual_end_date", "interest_accrual_start_date"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityInterestPaymentCashRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityInterestPaymentCashRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityInterestPaymentCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityInterestPaymentCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityInterestPaymentPaymentDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityInterestPaymentPaymentDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityInterestPaymentRecordDateTypedDict(TypedDict):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityInterestPaymentRecordDate(BaseModel):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityInterestPaymentSettledTypedDict(TypedDict):
    r"""The accounts settled position for which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityInterestPaymentSettled(BaseModel):
    r"""The accounts settled position for which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityInterestPaymentTypedDict(TypedDict):
    r"""Object containing metadata for interest payments"""

    cash_rate: NotRequired[Nullable[ActivityInterestPaymentCashRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivityInterestPaymentCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[ActivityInterestPaymentPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    record_date: NotRequired[Nullable[ActivityInterestPaymentRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""
    settled: NotRequired[Nullable[ActivityInterestPaymentSettledTypedDict]]
    r"""The accounts settled position for which the corporate action was paid"""


class ActivityInterestPayment(BaseModel):
    r"""Object containing metadata for interest payments"""

    cash_rate: OptionalNullable[ActivityInterestPaymentCashRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    corporate_action_general_information: OptionalNullable[
        ActivityInterestPaymentCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    payment_date: OptionalNullable[ActivityInterestPaymentPaymentDate] = UNSET
    r"""The anticipated payment date at the depository"""

    record_date: OptionalNullable[ActivityInterestPaymentRecordDate] = UNSET
    r"""The date on which positions are recorded in order to calculate entitlement"""

    settled: OptionalNullable[ActivityInterestPaymentSettled] = UNSET
    r"""The accounts settled position for which the corporate action was paid"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "payment_date",
            "record_date",
            "settled",
        ]
        nullable_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "payment_date",
            "record_date",
            "settled",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityLiquidationAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Denotes whether the shares are incoming or outgoing"""

    ACTION_UNSPECIFIED = "ACTION_UNSPECIFIED"
    INCOMING = "INCOMING"
    OUTGOING = "OUTGOING"
    CASH_IN_LIEU = "CASH_IN_LIEU"


class ActivityLiquidationCashRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityLiquidationCashRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityLiquidationCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityLiquidationCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityEffectiveDateTypedDict(TypedDict):
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityEffectiveDate(BaseModel):
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityLiquidationPaymentDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityLiquidationPaymentDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityLiquidationQuantityTypedDict(TypedDict):
    r"""The position on which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityLiquidationQuantity(BaseModel):
    r"""The position on which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityLiquidationRecordDateTypedDict(TypedDict):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityLiquidationRecordDate(BaseModel):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityLiquidationSettledTypedDict(TypedDict):
    r"""The accounts settled position for which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityLiquidationSettled(BaseModel):
    r"""The accounts settled position for which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityLiquidationSubtype(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The subtype for the corporate action event"""

    CORPORATEACTIONSUBTYPE_UNSPECIFIED = "CORPORATEACTIONSUBTYPE_UNSPECIFIED"
    ADDITIONAL_DIVIDEND = "ADDITIONAL_DIVIDEND"
    APPROXIMATE_RATE = "APPROXIMATE_RATE"
    DIVIDEND_ARREARS = "DIVIDEND_ARREARS"
    DIVIDEND_CANCELLED = "DIVIDEND_CANCELLED"
    DIVIDEND_PAYMENT_TAX_CLASSIFICATIONS = "DIVIDEND_PAYMENT_TAX_CLASSIFICATIONS"
    DIVIDEND_RESCINDED = "DIVIDEND_RESCINDED"
    ESTIMATED_RETURN_OF_CAPITAL = "ESTIMATED_RETURN_OF_CAPITAL"
    ESTIMATED_RETURN_OF_CAPITAL_PLUS_INCOME = "ESTIMATED_RETURN_OF_CAPITAL_PLUS_INCOME"
    EXTRA_DIVIDEND = "EXTRA_DIVIDEND"
    EXTRA_DIVIDEND_PLUS_INCOME = "EXTRA_DIVIDEND_PLUS_INCOME"
    FINAL_PAYMENT_TRANSFER_BOOKS_ARE_CLOSED = "FINAL_PAYMENT_TRANSFER_BOOKS_ARE_CLOSED"
    GROSS_RATE = "GROSS_RATE"
    INITIAL_DIVIDEND = "INITIAL_DIVIDEND"
    INITIAL_DIVIDEND_LONG_PERIOD = "INITIAL_DIVIDEND_LONG_PERIOD"
    INITIAL_DIVIDEND_SHORT_PERIOD = "INITIAL_DIVIDEND_SHORT_PERIOD"
    LIMITED_PARTNERSHIP_DISTRIBUTION = "LIMITED_PARTNERSHIP_DISTRIBUTION"
    LIQUIDATION = "LIQUIDATION"
    NET_RATE = "NET_RATE"
    OTHER = "OTHER"
    PROCEEDS_FROM_SALE_OF_RIGHTS = "PROCEEDS_FROM_SALE_OF_RIGHTS"
    REGULAR_DIVIDEND = "REGULAR_DIVIDEND"
    RETURN_OF_CAPITAL = "RETURN_OF_CAPITAL"
    RETURN_OF_CAPITAL_PLUS_INCOME = "RETURN_OF_CAPITAL_PLUS_INCOME"
    SPECIAL_DIVIDEND = "SPECIAL_DIVIDEND"
    SPECIAL_DIVIDEND_PLUS_INCOME = "SPECIAL_DIVIDEND_PLUS_INCOME"
    YEAR_END_DIVIDEND = "YEAR_END_DIVIDEND"
    YEAR_END_DIVIDEND_PLUS_INCOME = "YEAR_END_DIVIDEND_PLUS_INCOME"
    PARTIAL = "PARTIAL"
    FULL = "FULL"
    MATURITY = "MATURITY"
    TERMINATION = "TERMINATION"
    REDEMPTION_OF_WARRANTS = "REDEMPTION_OF_WARRANTS"


class ActivityLiquidationTypedDict(TypedDict):
    r"""Object containing metadata for liquidations"""

    action: NotRequired[ActivityLiquidationAction]
    r"""Denotes whether the shares are incoming or outgoing"""
    cash_rate: NotRequired[Nullable[ActivityLiquidationCashRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivityLiquidationCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    effective_date: NotRequired[Nullable[ActivityEffectiveDateTypedDict]]
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""
    payment_date: NotRequired[Nullable[ActivityLiquidationPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    quantity: NotRequired[Nullable[ActivityLiquidationQuantityTypedDict]]
    r"""The position on which the corporate action was paid"""
    record_date: NotRequired[Nullable[ActivityLiquidationRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""
    settled: NotRequired[Nullable[ActivityLiquidationSettledTypedDict]]
    r"""The accounts settled position for which the corporate action was paid"""
    subtype: NotRequired[ActivityLiquidationSubtype]
    r"""The subtype for the corporate action event"""


class ActivityLiquidation(BaseModel):
    r"""Object containing metadata for liquidations"""

    action: Annotated[
        Optional[ActivityLiquidationAction], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Denotes whether the shares are incoming or outgoing"""

    cash_rate: OptionalNullable[ActivityLiquidationCashRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    corporate_action_general_information: OptionalNullable[
        ActivityLiquidationCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    effective_date: OptionalNullable[ActivityEffectiveDate] = UNSET
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""

    payment_date: OptionalNullable[ActivityLiquidationPaymentDate] = UNSET
    r"""The anticipated payment date at the depository"""

    quantity: OptionalNullable[ActivityLiquidationQuantity] = UNSET
    r"""The position on which the corporate action was paid"""

    record_date: OptionalNullable[ActivityLiquidationRecordDate] = UNSET
    r"""The date on which positions are recorded in order to calculate entitlement"""

    settled: OptionalNullable[ActivityLiquidationSettled] = UNSET
    r"""The accounts settled position for which the corporate action was paid"""

    subtype: Annotated[
        Optional[ActivityLiquidationSubtype], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The subtype for the corporate action event"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "action",
            "cash_rate",
            "corporate_action_general_information",
            "effective_date",
            "payment_date",
            "quantity",
            "record_date",
            "settled",
            "subtype",
        ]
        nullable_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "effective_date",
            "payment_date",
            "quantity",
            "record_date",
            "settled",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityMaturityCashRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityMaturityCashRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityMaturityCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityMaturityCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityMaturityPaymentDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository."""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityMaturityPaymentDate(BaseModel):
    r"""The anticipated payment date at the depository."""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityMaturityQuantityTypedDict(TypedDict):
    r"""The trade position quantity used to calculate the disbursed amount"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityMaturityQuantity(BaseModel):
    r"""The trade position quantity used to calculate the disbursed amount"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityMaturityTypedDict(TypedDict):
    r"""Object containing metadata for maturity events"""

    cash_rate: NotRequired[Nullable[ActivityMaturityCashRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivityMaturityCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[ActivityMaturityPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository."""
    quantity: NotRequired[Nullable[ActivityMaturityQuantityTypedDict]]
    r"""The trade position quantity used to calculate the disbursed amount"""


class ActivityMaturity(BaseModel):
    r"""Object containing metadata for maturity events"""

    cash_rate: OptionalNullable[ActivityMaturityCashRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    corporate_action_general_information: OptionalNullable[
        ActivityMaturityCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    payment_date: OptionalNullable[ActivityMaturityPaymentDate] = UNSET
    r"""The anticipated payment date at the depository."""

    quantity: OptionalNullable[ActivityMaturityQuantity] = UNSET
    r"""The trade position quantity used to calculate the disbursed amount"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "payment_date",
            "quantity",
        ]
        nullable_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "payment_date",
            "quantity",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityMergerAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Denotes whether the shares are incoming or outgoing"""

    ACTION_UNSPECIFIED = "ACTION_UNSPECIFIED"
    INCOMING = "INCOMING"
    OUTGOING = "OUTGOING"
    CASH_IN_LIEU = "CASH_IN_LIEU"


class ActivityMergerCashRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityMergerCashRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityMergerCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityMergerCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityMergerEffectiveDateTypedDict(TypedDict):
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityMergerEffectiveDate(BaseModel):
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityMergerQuantityTypedDict(TypedDict):
    r"""The position on which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityMergerQuantity(BaseModel):
    r"""The position on which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityMergerStockRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityMergerStockRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityMergerType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The subtype for the corporate action event"""

    EVENT_TYPE_UNSPECIFIED = "EVENT_TYPE_UNSPECIFIED"
    CASH = "CASH"
    STOCK = "STOCK"
    CASH_AND_STOCK = "CASH_AND_STOCK"


class ActivityMergerTypedDict(TypedDict):
    r"""Object containing metadata for merger events"""

    action: NotRequired[ActivityMergerAction]
    r"""Denotes whether the shares are incoming or outgoing"""
    cash_rate: NotRequired[Nullable[ActivityMergerCashRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivityMergerCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    effective_date: NotRequired[Nullable[ActivityMergerEffectiveDateTypedDict]]
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""
    quantity: NotRequired[Nullable[ActivityMergerQuantityTypedDict]]
    r"""The position on which the corporate action was paid"""
    stock_rate: NotRequired[Nullable[ActivityMergerStockRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""
    type: NotRequired[ActivityMergerType]
    r"""The subtype for the corporate action event"""


class ActivityMerger(BaseModel):
    r"""Object containing metadata for merger events"""

    action: Annotated[
        Optional[ActivityMergerAction], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Denotes whether the shares are incoming or outgoing"""

    cash_rate: OptionalNullable[ActivityMergerCashRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    corporate_action_general_information: OptionalNullable[
        ActivityMergerCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    effective_date: OptionalNullable[ActivityMergerEffectiveDate] = UNSET
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""

    quantity: OptionalNullable[ActivityMergerQuantity] = UNSET
    r"""The position on which the corporate action was paid"""

    stock_rate: OptionalNullable[ActivityMergerStockRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    type: Annotated[
        Optional[ActivityMergerType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The subtype for the corporate action event"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "action",
            "cash_rate",
            "corporate_action_general_information",
            "effective_date",
            "quantity",
            "stock_rate",
            "type",
        ]
        nullable_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "effective_date",
            "quantity",
            "stock_rate",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityNameChangeAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Denotes whether the shares are incoming or outgoing"""

    ACTION_UNSPECIFIED = "ACTION_UNSPECIFIED"
    INCOMING = "INCOMING"
    OUTGOING = "OUTGOING"
    CASH_IN_LIEU = "CASH_IN_LIEU"


class ActivityNameChangeCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityNameChangeCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityNameChangeEffectiveDateTypedDict(TypedDict):
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityNameChangeEffectiveDate(BaseModel):
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityNameChangeQuantityTypedDict(TypedDict):
    r"""The position on which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityNameChangeQuantity(BaseModel):
    r"""The position on which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityNameChangeTypedDict(TypedDict):
    r"""Object containing metadata for name changes"""

    action: NotRequired[ActivityNameChangeAction]
    r"""Denotes whether the shares are incoming or outgoing"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivityNameChangeCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    effective_date: NotRequired[Nullable[ActivityNameChangeEffectiveDateTypedDict]]
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""
    quantity: NotRequired[Nullable[ActivityNameChangeQuantityTypedDict]]
    r"""The position on which the corporate action was paid"""


class ActivityNameChange(BaseModel):
    r"""Object containing metadata for name changes"""

    action: Annotated[
        Optional[ActivityNameChangeAction], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Denotes whether the shares are incoming or outgoing"""

    corporate_action_general_information: OptionalNullable[
        ActivityNameChangeCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    effective_date: OptionalNullable[ActivityNameChangeEffectiveDate] = UNSET
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""

    quantity: OptionalNullable[ActivityNameChangeQuantity] = UNSET
    r"""The position on which the corporate action was paid"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "action",
            "corporate_action_general_information",
            "effective_date",
            "quantity",
        ]
        nullable_fields = [
            "corporate_action_general_information",
            "effective_date",
            "quantity",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityNetAmountTypedDict(TypedDict):
    r"""The dollar amount of an activity, inclusive of fees, withholding, commisions, etc"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityNetAmount(BaseModel):
    r"""The dollar amount of an activity, inclusive of fees, withholding, commisions, etc"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class NextActivityProcessDateTypedDict(TypedDict):
    r"""the process date of the next activity(nil if the next_activity_id is an empty string)"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class NextActivityProcessDate(BaseModel):
    r"""the process date of the next activity(nil if the next_activity_id is an empty string)"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class NoneTTypedDict(TypedDict):
    r"""None"""


class NoneT(BaseModel):
    r"""None"""


class ActivityPaymentInKindCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityPaymentInKindCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityPaymentInKindPaymentDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityPaymentInKindPaymentDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityPaymentInKindRecordDateTypedDict(TypedDict):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityPaymentInKindRecordDate(BaseModel):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityPaymentInKindSettledTypedDict(TypedDict):
    r"""Corresponds to the position's settled quantity"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityPaymentInKindSettled(BaseModel):
    r"""Corresponds to the position's settled quantity"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityPaymentInKindStockRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityPaymentInKindStockRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityPaymentInKindTypedDict(TypedDict):
    r"""Object containing metadata for payment in kind"""

    corporate_action_general_information: NotRequired[
        Nullable[ActivityPaymentInKindCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[ActivityPaymentInKindPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    record_date: NotRequired[Nullable[ActivityPaymentInKindRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""
    settled: NotRequired[Nullable[ActivityPaymentInKindSettledTypedDict]]
    r"""Corresponds to the position's settled quantity"""
    stock_rate: NotRequired[Nullable[ActivityPaymentInKindStockRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""


class ActivityPaymentInKind(BaseModel):
    r"""Object containing metadata for payment in kind"""

    corporate_action_general_information: OptionalNullable[
        ActivityPaymentInKindCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    payment_date: OptionalNullable[ActivityPaymentInKindPaymentDate] = UNSET
    r"""The anticipated payment date at the depository"""

    record_date: OptionalNullable[ActivityPaymentInKindRecordDate] = UNSET
    r"""The date on which positions are recorded in order to calculate entitlement"""

    settled: OptionalNullable[ActivityPaymentInKindSettled] = UNSET
    r"""Corresponds to the position's settled quantity"""

    stock_rate: OptionalNullable[ActivityPaymentInKindStockRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "corporate_action_general_information",
            "payment_date",
            "record_date",
            "settled",
            "stock_rate",
        ]
        nullable_fields = [
            "corporate_action_general_information",
            "payment_date",
            "record_date",
            "settled",
            "stock_rate",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class PreviousProcessDateTypedDict(TypedDict):
    r"""When populated, the processing_date of the previous_activity_id"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class PreviousProcessDate(BaseModel):
    r"""When populated, the processing_date of the previous_activity_id"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityPriceTypedDict(TypedDict):
    r"""The monetary value paid for a given security in a trade Not populated on a currency only movement"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityPrice(BaseModel):
    r"""The monetary value paid for a given security in a trade Not populated on a currency only movement"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityProcessDateTypedDict(TypedDict):
    r"""The date that the activity was booked to the ledger"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityProcessDate(BaseModel):
    r"""The date that the activity was booked to the ledger"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityQuantityTypedDict(TypedDict):
    r"""The quantity of shares bought, sold, or moved for a given entry/activity Required if activity.state != PENDING"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityQuantity(BaseModel):
    r"""The quantity of shares bought, sold, or moved for a given entry/activity Required if activity.state != PENDING"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRedemptionFullAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Denotes whether the shares are incoming or outgoing"""

    ACTION_UNSPECIFIED = "ACTION_UNSPECIFIED"
    INCOMING = "INCOMING"
    OUTGOING = "OUTGOING"
    CASH_IN_LIEU = "CASH_IN_LIEU"


class ActivityRedemptionFullCashRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRedemptionFullCashRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRedemptionFullCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityRedemptionFullCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityRedemptionFullPaymentDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityRedemptionFullPaymentDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityRedemptionFullQuantityTypedDict(TypedDict):
    r"""The position on which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRedemptionFullQuantity(BaseModel):
    r"""The position on which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRedemptionFullSubtype(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The subtype for the corporate action event"""

    CORPORATEACTIONSUBTYPE_UNSPECIFIED = "CORPORATEACTIONSUBTYPE_UNSPECIFIED"
    ADDITIONAL_DIVIDEND = "ADDITIONAL_DIVIDEND"
    APPROXIMATE_RATE = "APPROXIMATE_RATE"
    DIVIDEND_ARREARS = "DIVIDEND_ARREARS"
    DIVIDEND_CANCELLED = "DIVIDEND_CANCELLED"
    DIVIDEND_PAYMENT_TAX_CLASSIFICATIONS = "DIVIDEND_PAYMENT_TAX_CLASSIFICATIONS"
    DIVIDEND_RESCINDED = "DIVIDEND_RESCINDED"
    ESTIMATED_RETURN_OF_CAPITAL = "ESTIMATED_RETURN_OF_CAPITAL"
    ESTIMATED_RETURN_OF_CAPITAL_PLUS_INCOME = "ESTIMATED_RETURN_OF_CAPITAL_PLUS_INCOME"
    EXTRA_DIVIDEND = "EXTRA_DIVIDEND"
    EXTRA_DIVIDEND_PLUS_INCOME = "EXTRA_DIVIDEND_PLUS_INCOME"
    FINAL_PAYMENT_TRANSFER_BOOKS_ARE_CLOSED = "FINAL_PAYMENT_TRANSFER_BOOKS_ARE_CLOSED"
    GROSS_RATE = "GROSS_RATE"
    INITIAL_DIVIDEND = "INITIAL_DIVIDEND"
    INITIAL_DIVIDEND_LONG_PERIOD = "INITIAL_DIVIDEND_LONG_PERIOD"
    INITIAL_DIVIDEND_SHORT_PERIOD = "INITIAL_DIVIDEND_SHORT_PERIOD"
    LIMITED_PARTNERSHIP_DISTRIBUTION = "LIMITED_PARTNERSHIP_DISTRIBUTION"
    LIQUIDATION = "LIQUIDATION"
    NET_RATE = "NET_RATE"
    OTHER = "OTHER"
    PROCEEDS_FROM_SALE_OF_RIGHTS = "PROCEEDS_FROM_SALE_OF_RIGHTS"
    REGULAR_DIVIDEND = "REGULAR_DIVIDEND"
    RETURN_OF_CAPITAL = "RETURN_OF_CAPITAL"
    RETURN_OF_CAPITAL_PLUS_INCOME = "RETURN_OF_CAPITAL_PLUS_INCOME"
    SPECIAL_DIVIDEND = "SPECIAL_DIVIDEND"
    SPECIAL_DIVIDEND_PLUS_INCOME = "SPECIAL_DIVIDEND_PLUS_INCOME"
    YEAR_END_DIVIDEND = "YEAR_END_DIVIDEND"
    YEAR_END_DIVIDEND_PLUS_INCOME = "YEAR_END_DIVIDEND_PLUS_INCOME"
    PARTIAL = "PARTIAL"
    FULL = "FULL"
    MATURITY = "MATURITY"
    TERMINATION = "TERMINATION"
    REDEMPTION_OF_WARRANTS = "REDEMPTION_OF_WARRANTS"


class ActivityRedemptionFullTypedDict(TypedDict):
    r"""Object containing more information about a redemption"""

    action: NotRequired[ActivityRedemptionFullAction]
    r"""Denotes whether the shares are incoming or outgoing"""
    cash_rate: NotRequired[Nullable[ActivityRedemptionFullCashRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivityRedemptionFullCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[ActivityRedemptionFullPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    quantity: NotRequired[Nullable[ActivityRedemptionFullQuantityTypedDict]]
    r"""The position on which the corporate action was paid"""
    subtype: NotRequired[ActivityRedemptionFullSubtype]
    r"""The subtype for the corporate action event"""


class ActivityRedemptionFull(BaseModel):
    r"""Object containing more information about a redemption"""

    action: Annotated[
        Optional[ActivityRedemptionFullAction],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Denotes whether the shares are incoming or outgoing"""

    cash_rate: OptionalNullable[ActivityRedemptionFullCashRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    corporate_action_general_information: OptionalNullable[
        ActivityRedemptionFullCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    payment_date: OptionalNullable[ActivityRedemptionFullPaymentDate] = UNSET
    r"""The anticipated payment date at the depository"""

    quantity: OptionalNullable[ActivityRedemptionFullQuantity] = UNSET
    r"""The position on which the corporate action was paid"""

    subtype: Annotated[
        Optional[ActivityRedemptionFullSubtype],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""The subtype for the corporate action event"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "action",
            "cash_rate",
            "corporate_action_general_information",
            "payment_date",
            "quantity",
            "subtype",
        ]
        nullable_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "payment_date",
            "quantity",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityRedemptionPartialAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Corresponds to whether the entry is incoming or outgoing"""

    ACTION_UNSPECIFIED = "ACTION_UNSPECIFIED"
    INCOMING = "INCOMING"
    OUTGOING = "OUTGOING"
    CASH_IN_LIEU = "CASH_IN_LIEU"


class ActivityRedemptionPartialCashRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRedemptionPartialCashRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRedemptionPartialCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityRedemptionPartialCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityRedemptionPartialPaymentDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityRedemptionPartialPaymentDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityRedemptionPartialQuantityTypedDict(TypedDict):
    r"""Corresponds to the position's trade quantity"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRedemptionPartialQuantity(BaseModel):
    r"""Corresponds to the position's trade quantity"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRedemptionPartialTypedDict(TypedDict):
    r"""Object containing metadata for partial redemption"""

    action: NotRequired[ActivityRedemptionPartialAction]
    r"""Corresponds to whether the entry is incoming or outgoing"""
    cash_rate: NotRequired[Nullable[ActivityRedemptionPartialCashRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivityRedemptionPartialCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[ActivityRedemptionPartialPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    quantity: NotRequired[Nullable[ActivityRedemptionPartialQuantityTypedDict]]
    r"""Corresponds to the position's trade quantity"""


class ActivityRedemptionPartial(BaseModel):
    r"""Object containing metadata for partial redemption"""

    action: Annotated[
        Optional[ActivityRedemptionPartialAction],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Corresponds to whether the entry is incoming or outgoing"""

    cash_rate: OptionalNullable[ActivityRedemptionPartialCashRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    corporate_action_general_information: OptionalNullable[
        ActivityRedemptionPartialCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    payment_date: OptionalNullable[ActivityRedemptionPartialPaymentDate] = UNSET
    r"""The anticipated payment date at the depository"""

    quantity: OptionalNullable[ActivityRedemptionPartialQuantity] = UNSET
    r"""Corresponds to the position's trade quantity"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "action",
            "cash_rate",
            "corporate_action_general_information",
            "payment_date",
            "quantity",
        ]
        nullable_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "payment_date",
            "quantity",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityReverseStockSplitAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Denotes whether the shares are incoming or outgoing"""

    ACTION_UNSPECIFIED = "ACTION_UNSPECIFIED"
    INCOMING = "INCOMING"
    OUTGOING = "OUTGOING"
    CASH_IN_LIEU = "CASH_IN_LIEU"


class ActivityReverseStockSplitCashRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityReverseStockSplitCashRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityReverseStockSplitCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityReverseStockSplitCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityReverseStockSplitEffectiveDateTypedDict(TypedDict):
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityReverseStockSplitEffectiveDate(BaseModel):
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityFactorDenominatorTypedDict(TypedDict):
    r"""The old rate of the security"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityFactorDenominator(BaseModel):
    r"""The old rate of the security"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityFactorNumeratorTypedDict(TypedDict):
    r"""The new rate of the security"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityFactorNumerator(BaseModel):
    r"""The new rate of the security"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityReverseStockSplitQuantityTypedDict(TypedDict):
    r"""The position on which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityReverseStockSplitQuantity(BaseModel):
    r"""The position on which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityReverseStockSplitTypedDict(TypedDict):
    r"""Object containing metadata for a reverse_stock_split"""

    action: NotRequired[ActivityReverseStockSplitAction]
    r"""Denotes whether the shares are incoming or outgoing"""
    cash_rate: NotRequired[Nullable[ActivityReverseStockSplitCashRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivityReverseStockSplitCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    effective_date: NotRequired[
        Nullable[ActivityReverseStockSplitEffectiveDateTypedDict]
    ]
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""
    factor_denominator: NotRequired[Nullable[ActivityFactorDenominatorTypedDict]]
    r"""The old rate of the security"""
    factor_numerator: NotRequired[Nullable[ActivityFactorNumeratorTypedDict]]
    r"""The new rate of the security"""
    quantity: NotRequired[Nullable[ActivityReverseStockSplitQuantityTypedDict]]
    r"""The position on which the corporate action was paid"""


class ActivityReverseStockSplit(BaseModel):
    r"""Object containing metadata for a reverse_stock_split"""

    action: Annotated[
        Optional[ActivityReverseStockSplitAction],
        PlainValidator(validate_open_enum(False)),
    ] = None
    r"""Denotes whether the shares are incoming or outgoing"""

    cash_rate: OptionalNullable[ActivityReverseStockSplitCashRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    corporate_action_general_information: OptionalNullable[
        ActivityReverseStockSplitCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    effective_date: OptionalNullable[ActivityReverseStockSplitEffectiveDate] = UNSET
    r"""Effective date as declared by the primary exchange that generally coincides with cessation of trading in the old security and commencement of trading in the new security"""

    factor_denominator: OptionalNullable[ActivityFactorDenominator] = UNSET
    r"""The old rate of the security"""

    factor_numerator: OptionalNullable[ActivityFactorNumerator] = UNSET
    r"""The new rate of the security"""

    quantity: OptionalNullable[ActivityReverseStockSplitQuantity] = UNSET
    r"""The position on which the corporate action was paid"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "action",
            "cash_rate",
            "corporate_action_general_information",
            "effective_date",
            "factor_denominator",
            "factor_numerator",
            "quantity",
        ]
        nullable_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "effective_date",
            "factor_denominator",
            "factor_numerator",
            "quantity",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityRightsDistributionCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityRightsDistributionCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityRightsDistributionPaymentDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityRightsDistributionPaymentDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityRightsDistributionRecordDateTypedDict(TypedDict):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityRightsDistributionRecordDate(BaseModel):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityRightsDistributionSettledTypedDict(TypedDict):
    r"""The accounts settled position for which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRightsDistributionSettled(BaseModel):
    r"""The accounts settled position for which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRightsDistributionTypedDict(TypedDict):
    r"""Object containing more information about a rights distribution"""

    corporate_action_general_information: NotRequired[
        Nullable[ActivityRightsDistributionCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[ActivityRightsDistributionPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    record_date: NotRequired[Nullable[ActivityRightsDistributionRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""
    settled: NotRequired[Nullable[ActivityRightsDistributionSettledTypedDict]]
    r"""The accounts settled position for which the corporate action was paid"""


class ActivityRightsDistribution(BaseModel):
    r"""Object containing more information about a rights distribution"""

    corporate_action_general_information: OptionalNullable[
        ActivityRightsDistributionCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    payment_date: OptionalNullable[ActivityRightsDistributionPaymentDate] = UNSET
    r"""The anticipated payment date at the depository"""

    record_date: OptionalNullable[ActivityRightsDistributionRecordDate] = UNSET
    r"""The date on which positions are recorded in order to calculate entitlement"""

    settled: OptionalNullable[ActivityRightsDistributionSettled] = UNSET
    r"""The accounts settled position for which the corporate action was paid"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "corporate_action_general_information",
            "payment_date",
            "record_date",
            "settled",
        ]
        nullable_fields = [
            "corporate_action_general_information",
            "payment_date",
            "record_date",
            "settled",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityRightsSubscriptionCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityRightsSubscriptionCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityRightsSubscriptionTypedDict(TypedDict):
    r"""Object containing metadata for rights subscriptions"""

    corporate_action_general_information: NotRequired[
        Nullable[ActivityRightsSubscriptionCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""


class ActivityRightsSubscription(BaseModel):
    r"""Object containing metadata for rights subscriptions"""

    corporate_action_general_information: OptionalNullable[
        ActivityRightsSubscriptionCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["corporate_action_general_information"]
        nullable_fields = ["corporate_action_general_information"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityRoundingAdjustmentTypedDict(TypedDict):
    r"""Object containing metadata for standalone rounding adjustments"""

    rounding_reason: NotRequired[str]
    r"""Free form text field providing reason for rounding"""


class ActivityRoundingAdjustment(BaseModel):
    r"""Object containing metadata for standalone rounding adjustments"""

    rounding_reason: Optional[str] = None
    r"""Free form text field providing reason for rounding"""


class RoundingAmountTypedDict(TypedDict):
    r"""the difference between the aggregation of gross_amount from the trade entries and the rounded gross_amount of the fully formed activity This amount can also be found as a rounding_adjustment entry"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class RoundingAmount(BaseModel):
    r"""the difference between the aggregation of gross_amount from the trade entries and the rounded gross_amount of the fully formed activity This amount can also be found as a rounding_adjustment entry"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivitySaleOfRightsCashRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivitySaleOfRightsCashRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivitySaleOfRightsCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivitySaleOfRightsCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivitySaleOfRightsPaymentDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivitySaleOfRightsPaymentDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivitySaleOfRightsRecordDateTypedDict(TypedDict):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivitySaleOfRightsRecordDate(BaseModel):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivitySaleOfRightsSettledTypedDict(TypedDict):
    r"""The accounts settled position for which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivitySaleOfRightsSettled(BaseModel):
    r"""The accounts settled position for which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivitySaleOfRightsTypedDict(TypedDict):
    r"""Object containing more information about a sale_of_rights"""

    cash_rate: NotRequired[Nullable[ActivitySaleOfRightsCashRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivitySaleOfRightsCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[ActivitySaleOfRightsPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    record_date: NotRequired[Nullable[ActivitySaleOfRightsRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""
    settled: NotRequired[Nullable[ActivitySaleOfRightsSettledTypedDict]]
    r"""The accounts settled position for which the corporate action was paid"""


class ActivitySaleOfRights(BaseModel):
    r"""Object containing more information about a sale_of_rights"""

    cash_rate: OptionalNullable[ActivitySaleOfRightsCashRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    corporate_action_general_information: OptionalNullable[
        ActivitySaleOfRightsCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    payment_date: OptionalNullable[ActivitySaleOfRightsPaymentDate] = UNSET
    r"""The anticipated payment date at the depository"""

    record_date: OptionalNullable[ActivitySaleOfRightsRecordDate] = UNSET
    r"""The date on which positions are recorded in order to calculate entitlement"""

    settled: OptionalNullable[ActivitySaleOfRightsSettled] = UNSET
    r"""The accounts settled position for which the corporate action was paid"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "payment_date",
            "record_date",
            "settled",
        ]
        nullable_fields = [
            "cash_rate",
            "corporate_action_general_information",
            "payment_date",
            "record_date",
            "settled",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivitySettleDateTypedDict(TypedDict):
    r"""The date a given activity will officially settle"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivitySettleDate(BaseModel):
    r"""The date a given activity will officially settle"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivitySide(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Denotes whether the trade is a buy or sell"""

    SIDE_UNSPECIFIED = "SIDE_UNSPECIFIED"
    BUY = "BUY"
    SELL = "SELL"


class ActivitySpinoffCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivitySpinoffCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityPayDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityPayDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivitySpinoffQuantityTypedDict(TypedDict):
    r"""The position on which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivitySpinoffQuantity(BaseModel):
    r"""The position on which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivitySpinoffRecordDateTypedDict(TypedDict):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivitySpinoffRecordDate(BaseModel):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivitySpinoffTypedDict(TypedDict):
    r"""Object containing metadata for spinoffs"""

    corporate_action_general_information: NotRequired[
        Nullable[ActivitySpinoffCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    pay_date: NotRequired[Nullable[ActivityPayDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    quantity: NotRequired[Nullable[ActivitySpinoffQuantityTypedDict]]
    r"""The position on which the corporate action was paid"""
    record_date: NotRequired[Nullable[ActivitySpinoffRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""


class ActivitySpinoff(BaseModel):
    r"""Object containing metadata for spinoffs"""

    corporate_action_general_information: OptionalNullable[
        ActivitySpinoffCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    pay_date: OptionalNullable[ActivityPayDate] = UNSET
    r"""The anticipated payment date at the depository"""

    quantity: OptionalNullable[ActivitySpinoffQuantity] = UNSET
    r"""The position on which the corporate action was paid"""

    record_date: OptionalNullable[ActivitySpinoffRecordDate] = UNSET
    r"""The date on which positions are recorded in order to calculate entitlement"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "corporate_action_general_information",
            "pay_date",
            "quantity",
            "record_date",
        ]
        nullable_fields = [
            "corporate_action_general_information",
            "pay_date",
            "quantity",
            "record_date",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityState(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The state of the activity"""

    ACTIVITY_STATE_UNSPECIFIED = "ACTIVITY_STATE_UNSPECIFIED"
    PENDING = "PENDING"
    CURRENT = "CURRENT"
    CANCELED = "CANCELED"
    REBOOKED = "REBOOKED"
    REBOOK = "REBOOK"
    CANCEL = "CANCEL"


class ActivityStockDividendCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityStockDividendCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityStockDividendPayDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityStockDividendPayDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityStockDividendQuantityTypedDict(TypedDict):
    r"""The position on which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityStockDividendQuantity(BaseModel):
    r"""The position on which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityStockDividendRecordDateTypedDict(TypedDict):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityStockDividendRecordDate(BaseModel):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityStockDividendTypedDict(TypedDict):
    r"""Object containing metadata for stock dividends"""

    corporate_action_general_information: NotRequired[
        Nullable[ActivityStockDividendCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    pay_date: NotRequired[Nullable[ActivityStockDividendPayDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    quantity: NotRequired[Nullable[ActivityStockDividendQuantityTypedDict]]
    r"""The position on which the corporate action was paid"""
    rate: NotRequired[Nullable[ActivityRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""
    record_date: NotRequired[Nullable[ActivityStockDividendRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""


class ActivityStockDividend(BaseModel):
    r"""Object containing metadata for stock dividends"""

    corporate_action_general_information: OptionalNullable[
        ActivityStockDividendCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    pay_date: OptionalNullable[ActivityStockDividendPayDate] = UNSET
    r"""The anticipated payment date at the depository"""

    quantity: OptionalNullable[ActivityStockDividendQuantity] = UNSET
    r"""The position on which the corporate action was paid"""

    rate: OptionalNullable[ActivityRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    record_date: OptionalNullable[ActivityStockDividendRecordDate] = UNSET
    r"""The date on which positions are recorded in order to calculate entitlement"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "corporate_action_general_information",
            "pay_date",
            "quantity",
            "rate",
            "record_date",
        ]
        nullable_fields = [
            "corporate_action_general_information",
            "pay_date",
            "quantity",
            "rate",
            "record_date",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityStockSplitCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityStockSplitCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityStockSplitFactorDenominatorTypedDict(TypedDict):
    r"""The old rate of the security"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityStockSplitFactorDenominator(BaseModel):
    r"""The old rate of the security"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityStockSplitFactorNumeratorTypedDict(TypedDict):
    r"""The new rate of the security"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityStockSplitFactorNumerator(BaseModel):
    r"""The new rate of the security"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityStockSplitPayDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityStockSplitPayDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityStockSplitQuantityTypedDict(TypedDict):
    r"""The position on which the corporate action was paid"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityStockSplitQuantity(BaseModel):
    r"""The position on which the corporate action was paid"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityStockSplitRecordDateTypedDict(TypedDict):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityStockSplitRecordDate(BaseModel):
    r"""The date on which positions are recorded in order to calculate entitlement"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityStockSplitTypedDict(TypedDict):
    r"""Object containing metadata for stock splits"""

    corporate_action_general_information: NotRequired[
        Nullable[ActivityStockSplitCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    factor_denominator: NotRequired[
        Nullable[ActivityStockSplitFactorDenominatorTypedDict]
    ]
    r"""The old rate of the security"""
    factor_numerator: NotRequired[Nullable[ActivityStockSplitFactorNumeratorTypedDict]]
    r"""The new rate of the security"""
    pay_date: NotRequired[Nullable[ActivityStockSplitPayDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    quantity: NotRequired[Nullable[ActivityStockSplitQuantityTypedDict]]
    r"""The position on which the corporate action was paid"""
    record_date: NotRequired[Nullable[ActivityStockSplitRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""


class ActivityStockSplit(BaseModel):
    r"""Object containing metadata for stock splits"""

    corporate_action_general_information: OptionalNullable[
        ActivityStockSplitCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    factor_denominator: OptionalNullable[ActivityStockSplitFactorDenominator] = UNSET
    r"""The old rate of the security"""

    factor_numerator: OptionalNullable[ActivityStockSplitFactorNumerator] = UNSET
    r"""The new rate of the security"""

    pay_date: OptionalNullable[ActivityStockSplitPayDate] = UNSET
    r"""The anticipated payment date at the depository"""

    quantity: OptionalNullable[ActivityStockSplitQuantity] = UNSET
    r"""The position on which the corporate action was paid"""

    record_date: OptionalNullable[ActivityStockSplitRecordDate] = UNSET
    r"""The date on which positions are recorded in order to calculate entitlement"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "corporate_action_general_information",
            "factor_denominator",
            "factor_numerator",
            "pay_date",
            "quantity",
            "record_date",
        ]
        nullable_fields = [
            "corporate_action_general_information",
            "factor_denominator",
            "factor_numerator",
            "pay_date",
            "quantity",
            "record_date",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivitySweepAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Indicates purchase or redemption of the sweep asset"""

    SWEEP_ACTION_UNSPECIFIED = "SWEEP_ACTION_UNSPECIFIED"
    PURCHASE = "PURCHASE"
    REDEMPTION = "REDEMPTION"


class ActivitySweepType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Sweep program that cash is being swept to/ from"""

    SWEEP_TYPE_UNSPECIFIED = "SWEEP_TYPE_UNSPECIFIED"
    FDIC = "FDIC"
    MONEY_MARKET = "MONEY_MARKET"


class ActivitySweepTypedDict(TypedDict):
    r"""Object containing metadata for sweeps"""

    action: NotRequired[ActivitySweepAction]
    r"""Indicates purchase or redemption of the sweep asset"""
    eod_redemption: NotRequired[bool]
    r"""Indicates the sweep was performed books were closed to prevent an investor account from carrying a negative cash balance overnight"""
    type: NotRequired[ActivitySweepType]
    r"""Sweep program that cash is being swept to/ from"""


class ActivitySweep(BaseModel):
    r"""Object containing metadata for sweeps"""

    action: Annotated[
        Optional[ActivitySweepAction], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Indicates purchase or redemption of the sweep asset"""

    eod_redemption: Optional[bool] = None
    r"""Indicates the sweep was performed books were closed to prevent an investor account from carrying a negative cash balance overnight"""

    type: Annotated[
        Optional[ActivitySweepType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Sweep program that cash is being swept to/ from"""


class ActivityTenderOfferCashRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityTenderOfferCashRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityTenderOfferCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityTenderOfferCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityTenderOfferTypedDict(TypedDict):
    r"""Object containing metadata for tender offers"""

    cash_rate: NotRequired[Nullable[ActivityTenderOfferCashRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""
    corporate_action_general_information: NotRequired[
        Nullable[ActivityTenderOfferCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""


class ActivityTenderOffer(BaseModel):
    r"""Object containing metadata for tender offers"""

    cash_rate: OptionalNullable[ActivityTenderOfferCashRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which cash will be disbursed to the shareholder"""

    corporate_action_general_information: OptionalNullable[
        ActivityTenderOfferCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["cash_rate", "corporate_action_general_information"]
        nullable_fields = ["cash_rate", "corporate_action_general_information"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityBrokerCapacity(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Used to calculate broadridge blotter code"""

    CAPACITY_UNSPECIFIED = "CAPACITY_UNSPECIFIED"
    AGENCY = "AGENCY"
    PRINCIPAL = "PRINCIPAL"
    MIXED = "MIXED"


class ActivityPrevailingMarketPriceTypedDict(TypedDict):
    r"""The price for the instrument that is prevailing in the market."""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityPrevailingMarketPrice(BaseModel):
    r"""The price for the instrument that is prevailing in the market."""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityPriceAdjustmentAmountTypedDict(TypedDict):
    r"""Total monetary value of the price_adjustment"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityPriceAdjustmentAmount(BaseModel):
    r"""Total monetary value of the price_adjustment"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityPriceAdjustmentPercentTypedDict(TypedDict):
    r"""The percent at which the price was adjusted. Expressed as a number from 0.00-100 (rounded to 2 decimals)"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityPriceAdjustmentPercent(BaseModel):
    r"""The percent at which the price was adjusted. Expressed as a number from 0.00-100 (rounded to 2 decimals)"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityPriceAdjustmentType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The type of price adjustment being applied by the broker to the net price of the security."""

    PRICE_ADJUSTMENT_TYPE_UNSPECIFIED = "PRICE_ADJUSTMENT_TYPE_UNSPECIFIED"
    MARKUP = "MARKUP"
    MARKDOWN = "MARKDOWN"
    SALES_LOAD = "SALES_LOAD"


class ActivityPriceAdjustmentRecordTypedDict(TypedDict):
    r"""Information about any price adjustments applied to the security"""

    price_adjustment_amount: NotRequired[
        Nullable[ActivityPriceAdjustmentAmountTypedDict]
    ]
    r"""Total monetary value of the price_adjustment"""
    price_adjustment_percent: NotRequired[
        Nullable[ActivityPriceAdjustmentPercentTypedDict]
    ]
    r"""The percent at which the price was adjusted. Expressed as a number from 0.00-100 (rounded to 2 decimals)"""
    price_adjustment_type: NotRequired[ActivityPriceAdjustmentType]
    r"""The type of price adjustment being applied by the broker to the net price of the security."""


class ActivityPriceAdjustmentRecord(BaseModel):
    r"""Information about any price adjustments applied to the security"""

    price_adjustment_amount: OptionalNullable[ActivityPriceAdjustmentAmount] = UNSET
    r"""Total monetary value of the price_adjustment"""

    price_adjustment_percent: OptionalNullable[ActivityPriceAdjustmentPercent] = UNSET
    r"""The percent at which the price was adjusted. Expressed as a number from 0.00-100 (rounded to 2 decimals)"""

    price_adjustment_type: Annotated[
        Optional[ActivityPriceAdjustmentType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The type of price adjustment being applied by the broker to the net price of the security."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "price_adjustment_amount",
            "price_adjustment_percent",
            "price_adjustment_type",
        ]
        nullable_fields = ["price_adjustment_amount", "price_adjustment_percent"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityTradeTypedDict(TypedDict):
    r"""Object containing metadata for a trade"""

    additional_instructions: NotRequired[List[str]]
    r"""Free form text field containing additional information for a trade"""
    alternate_order_id: NotRequired[str]
    r"""Max Length 100 characters. Alternate order id from the street used for FRAC trades"""
    booking_api_trade_allocation_id: NotRequired[str]
    r"""uuid assigned by the Booking API if a trade belongs to an allocation"""
    booking_api_trade_id: NotRequired[str]
    r"""uuid assigned by the Booking API to all trades"""
    broker: NotRequired[str]
    r"""Executing broker of the trade"""
    broker_capacity: NotRequired[ActivityBrokerCapacity]
    r"""Used to calculate broadridge blotter code"""
    client_memos: NotRequired[List[str]]
    r"""Free form text submitted by the client for internal purposes"""
    client_order_id: NotRequired[str]
    r"""32 characters. The client order ID from the order submitted"""
    exchange: NotRequired[str]
    r"""MIC code for the exchange"""
    execution_id: NotRequired[str]
    r"""Execution id from the street"""
    execution_only: NotRequired[bool]
    r"""Indicates whether Apex is the clearing broker for this trade. When false, indicates Apex is the clearing broker"""
    external_id: NotRequired[str]
    r"""Max Length 100 characters. External system id provided by a client"""
    fund_confirmation_number: NotRequired[str]
    r"""The confirmation number associated with a mutual fund trade"""
    gateway_client_order_id: NotRequired[str]
    r"""Max length 100 characters. Order id generated by trading-gateway (Trade-Ex) to uniquely identify all orders in their system. Used as the client_order_id on new order singles sent downstream of the trading-gateway"""
    internal_error: NotRequired[bool]
    r"""If set to true, indicates the trade should be omitted from client billing"""
    is_writeoff: NotRequired[bool]
    r"""Set on penny-for-the-lot trades"""
    lots: NotRequired[List[LotTypedDict]]
    r"""Repeated record containing information about the tax lots, if specified"""
    order_id: NotRequired[str]
    r"""Max Length 100 characters. Internally generated order id that is returned to client on exec reports"""
    prevailing_market_price: NotRequired[
        Nullable[ActivityPrevailingMarketPriceTypedDict]
    ]
    r"""The price for the instrument that is prevailing in the market."""
    price_adjustment_record: NotRequired[
        Nullable[ActivityPriceAdjustmentRecordTypedDict]
    ]
    r"""Information about any price adjustments applied to the security"""
    route: NotRequired[str]
    r"""Used to calculate broadridge blotter code"""
    special_instructions: NotRequired[List[str]]
    r"""The special instructions for a trade"""
    symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the particular issue"""
    when_issued: NotRequired[bool]
    r"""Indicates the trade was executed in a security that is not currently listed. When-issued securities are bought and sold before they are officially issued, allowing investors to speculate on their future value"""
    yield_records: NotRequired[List[YieldRecordTypedDict]]
    r"""The yields associated with a fixed income trade. only valid if the SecurityType is FIXED_INCOME."""


class ActivityTrade(BaseModel):
    r"""Object containing metadata for a trade"""

    additional_instructions: Optional[List[str]] = None
    r"""Free form text field containing additional information for a trade"""

    alternate_order_id: Optional[str] = None
    r"""Max Length 100 characters. Alternate order id from the street used for FRAC trades"""

    booking_api_trade_allocation_id: Optional[str] = None
    r"""uuid assigned by the Booking API if a trade belongs to an allocation"""

    booking_api_trade_id: Optional[str] = None
    r"""uuid assigned by the Booking API to all trades"""

    broker: Optional[str] = None
    r"""Executing broker of the trade"""

    broker_capacity: Annotated[
        Optional[ActivityBrokerCapacity], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Used to calculate broadridge blotter code"""

    client_memos: Optional[List[str]] = None
    r"""Free form text submitted by the client for internal purposes"""

    client_order_id: Optional[str] = None
    r"""32 characters. The client order ID from the order submitted"""

    exchange: Optional[str] = None
    r"""MIC code for the exchange"""

    execution_id: Optional[str] = None
    r"""Execution id from the street"""

    execution_only: Optional[bool] = None
    r"""Indicates whether Apex is the clearing broker for this trade. When false, indicates Apex is the clearing broker"""

    external_id: Optional[str] = None
    r"""Max Length 100 characters. External system id provided by a client"""

    fund_confirmation_number: Optional[str] = None
    r"""The confirmation number associated with a mutual fund trade"""

    gateway_client_order_id: Optional[str] = None
    r"""Max length 100 characters. Order id generated by trading-gateway (Trade-Ex) to uniquely identify all orders in their system. Used as the client_order_id on new order singles sent downstream of the trading-gateway"""

    internal_error: Optional[bool] = None
    r"""If set to true, indicates the trade should be omitted from client billing"""

    is_writeoff: Optional[bool] = None
    r"""Set on penny-for-the-lot trades"""

    lots: Optional[List[Lot]] = None
    r"""Repeated record containing information about the tax lots, if specified"""

    order_id: Optional[str] = None
    r"""Max Length 100 characters. Internally generated order id that is returned to client on exec reports"""

    prevailing_market_price: OptionalNullable[ActivityPrevailingMarketPrice] = UNSET
    r"""The price for the instrument that is prevailing in the market."""

    price_adjustment_record: OptionalNullable[ActivityPriceAdjustmentRecord] = UNSET
    r"""Information about any price adjustments applied to the security"""

    route: Optional[str] = None
    r"""Used to calculate broadridge blotter code"""

    special_instructions: Optional[List[str]] = None
    r"""The special instructions for a trade"""

    symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the particular issue"""

    when_issued: Optional[bool] = None
    r"""Indicates the trade was executed in a security that is not currently listed. When-issued securities are bought and sold before they are officially issued, allowing investors to speculate on their future value"""

    yield_records: Optional[List[YieldRecord]] = None
    r"""The yields associated with a fixed income trade. only valid if the SecurityType is FIXED_INCOME."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "additional_instructions",
            "alternate_order_id",
            "booking_api_trade_allocation_id",
            "booking_api_trade_id",
            "broker",
            "broker_capacity",
            "client_memos",
            "client_order_id",
            "exchange",
            "execution_id",
            "execution_only",
            "external_id",
            "fund_confirmation_number",
            "gateway_client_order_id",
            "internal_error",
            "is_writeoff",
            "lots",
            "order_id",
            "prevailing_market_price",
            "price_adjustment_record",
            "route",
            "special_instructions",
            "symbol_description",
            "when_issued",
            "yield_records",
        ]
        nullable_fields = ["prevailing_market_price", "price_adjustment_record"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityTransferType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Provides more granular detail on the purpose of transfer"""

    TRANSFER_TYPE_UNSPECIFIED = "TRANSFER_TYPE_UNSPECIFIED"
    TRANSFER_CONVERSION = "TRANSFER_CONVERSION"
    DECONVERSION = "DECONVERSION"
    MIGRATION = "MIGRATION"
    MANUAL_ADJUSTMENT = "MANUAL_ADJUSTMENT"


class ActivityTransferTypedDict(TypedDict):
    r"""Object containing metadata for transfers"""

    additional_instructions: NotRequired[str]
    r"""Free form text for additional sweep messages or instructions"""
    client_brokerage: NotRequired[str]
    r"""String field that can be populated with the broker dealer undergoing a clearing platform conversion. Used for activity description purposes"""
    transfer_type: NotRequired[ActivityTransferType]
    r"""Provides more granular detail on the purpose of transfer"""


class ActivityTransfer(BaseModel):
    r"""Object containing metadata for transfers"""

    additional_instructions: Optional[str] = None
    r"""Free form text for additional sweep messages or instructions"""

    client_brokerage: Optional[str] = None
    r"""String field that can be populated with the broker dealer undergoing a clearing platform conversion. Used for activity description purposes"""

    transfer_type: Annotated[
        Optional[ActivityTransferType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Provides more granular detail on the purpose of transfer"""


class ActivityType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The type of activity this is"""

    TYPE_UNSPECIFIED = "TYPE_UNSPECIFIED"
    TRADE = "TRADE"
    MOVEMENT = "MOVEMENT"
    MEMO = "MEMO"
    CORPORATE_ACTION = "CORPORATE_ACTION"


class ActivityUnitSplitCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityUnitSplitCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityUnitSplitStockRateTypedDict(TypedDict):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    value: NotRequired[str]
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityUnitSplitStockRate(BaseModel):
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    value: Optional[str] = None
    r"""The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details"""


class ActivityUnitSplitTypedDict(TypedDict):
    r"""Object containing metadata for unit splits"""

    corporate_action_general_information: NotRequired[
        Nullable[ActivityUnitSplitCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    stock_rate: NotRequired[Nullable[ActivityUnitSplitStockRateTypedDict]]
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""


class ActivityUnitSplit(BaseModel):
    r"""Object containing metadata for unit splits"""

    corporate_action_general_information: OptionalNullable[
        ActivityUnitSplitCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    stock_rate: OptionalNullable[ActivityUnitSplitStockRate] = UNSET
    r"""The rate (raw value, not a percentage, example: 50% will be .5 in this field) at which shares will be disbursed to the shareholder"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["corporate_action_general_information", "stock_rate"]
        nullable_fields = ["corporate_action_general_information", "stock_rate"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityWarrantExerciseCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityWarrantExerciseCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityWarrantExerciseTypedDict(TypedDict):
    r"""Object containing metadata for warrant exercises"""

    corporate_action_general_information: NotRequired[
        Nullable[ActivityWarrantExerciseCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""


class ActivityWarrantExercise(BaseModel):
    r"""Object containing metadata for warrant exercises"""

    corporate_action_general_information: OptionalNullable[
        ActivityWarrantExerciseCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["corporate_action_general_information"]
        nullable_fields = ["corporate_action_general_information"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityDistributionType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Categorizes the withdrawal to indicate whether special handling of the transaction is needed elsewhere"""

    DISTRIBUTION_TYPE_UNSPECIFIED = "DISTRIBUTION_TYPE_UNSPECIFIED"
    PREMATURE = "PREMATURE"
    DISABILITY = "DISABILITY"
    DEATH = "DEATH"
    NORMAL = "NORMAL"
    SOSEPP = "SOSEPP"
    ROLLOVER_TO_QUALIFIED_PLAN = "ROLLOVER_TO_QUALIFIED_PLAN"
    ROLLOVER_TO_IRA = "ROLLOVER_TO_IRA"
    DIST_TRANSFER = "DIST_TRANSFER"
    EXCESS_CONTRIBUTION_REMOVAL_BEFORE_TAX_DEADLINE = (
        "EXCESS_CONTRIBUTION_REMOVAL_BEFORE_TAX_DEADLINE"
    )
    EXCESS_CONTRIBUTION_REMOVAL_AFTER_TAX_DEADLINE = (
        "EXCESS_CONTRIBUTION_REMOVAL_AFTER_TAX_DEADLINE"
    )
    RECHARACTERIZATION_PRIOR_YEAR = "RECHARACTERIZATION_PRIOR_YEAR"
    RECHARACTERIZATION_CURRENT_YEAR = "RECHARACTERIZATION_CURRENT_YEAR"
    DIST_CONVERSION = "DIST_CONVERSION"
    MANAGEMENT_FEE = "MANAGEMENT_FEE"
    PREMATURE_SIMPLE_IRA_LESS_THAN_2_YEARS = "PREMATURE_SIMPLE_IRA_LESS_THAN_2_YEARS"
    NORMAL_ROTH_IRA_GREATER_THAN_5_YEARS = "NORMAL_ROTH_IRA_GREATER_THAN_5_YEARS"
    PLAN_LOAN_401_K = "PLAN_LOAN_401K"
    NET_INCOME_ATTRIBUTABLE = "NET_INCOME_ATTRIBUTABLE"
    REVOCATION = "REVOCATION"
    NON_REPORTABLE = "NON_REPORTABLE"


class ActivityRetirementType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The type of retirement account the withdrawal is being made from"""

    RETIREMENT_TYPE_UNSPECIFIED = "RETIREMENT_TYPE_UNSPECIFIED"
    IRA = "IRA"
    SEP = "SEP"
    SIMPLE = "SIMPLE"
    KEOGH = "KEOGH"
    ROTH = "ROTH"
    QP = "QP"
    ROLLOVER_IRA = "ROLLOVER_IRA"


class ActivityWithdrawalType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The mechanism by which the funds will be withdrawn"""

    EXTERNAL_MOVEMENT_TYPE_UNSPECIFIED = "EXTERNAL_MOVEMENT_TYPE_UNSPECIFIED"
    ACH = "ACH"
    CHECK = "CHECK"
    WIRE = "WIRE"
    PAYPAL = "PAYPAL"
    RTP = "RTP"
    ICT = "ICT"
    JOURNAL = "JOURNAL"


class ActivityWithdrawalTypedDict(TypedDict):
    r"""Object containing metadata for withdrawals"""

    additional_instructions: NotRequired[str]
    r"""Free form text for additional sweep messages or instructions"""
    advance: NotRequired[bool]
    r"""indicates whether the withdrawal is a cash advance"""
    closing_account: NotRequired[bool]
    r"""Indicates whether this withdrawal is intended to fully deplete and close an account"""
    conversion: NotRequired[bool]
    r"""Indicates whether this transaction is converting a retirement account to a ROTH IRA"""
    destination_account_number: NotRequired[str]
    r"""Human readable account identifier for the account the assets were journaled. To be populated when the Withdrawal type is Journal"""
    destination_institution: NotRequired[str]
    r"""Name of the firm which was the destination of funds out of the account"""
    distribution_type: NotRequired[ActivityDistributionType]
    r"""Categorizes the withdrawal to indicate whether special handling of the transaction is needed elsewhere"""
    distribution_year: NotRequired[int]
    r"""The tax year the withdrawal should be applied to (YYYY)"""
    fed_reference_number: NotRequired[str]
    r"""Unique tracking number provided to allow tracking a wire transfer from the initiating bank to the receiving bank"""
    futures_settlement: NotRequired[bool]
    r"""Indicates whether the transaction is for a futures related transaction"""
    micro: NotRequired[bool]
    r"""Indicates whether this transaction is a micro withdrawal to validate ACH Relationships"""
    originating_institution: NotRequired[str]
    r"""Name of the firm which was the source of funds into the account"""
    periodic: NotRequired[bool]
    r"""Indicates whether the transaction is a scheduled periodic withdrawal"""
    retirement_type: NotRequired[ActivityRetirementType]
    r"""The type of retirement account the withdrawal is being made from"""
    taxable: NotRequired[bool]
    r"""Indicates whether the transaction is taxable"""
    type: NotRequired[ActivityWithdrawalType]
    r"""The mechanism by which the funds will be withdrawn"""


class ActivityWithdrawal(BaseModel):
    r"""Object containing metadata for withdrawals"""

    additional_instructions: Optional[str] = None
    r"""Free form text for additional sweep messages or instructions"""

    advance: Optional[bool] = None
    r"""indicates whether the withdrawal is a cash advance"""

    closing_account: Optional[bool] = None
    r"""Indicates whether this withdrawal is intended to fully deplete and close an account"""

    conversion: Optional[bool] = None
    r"""Indicates whether this transaction is converting a retirement account to a ROTH IRA"""

    destination_account_number: Optional[str] = None
    r"""Human readable account identifier for the account the assets were journaled. To be populated when the Withdrawal type is Journal"""

    destination_institution: Optional[str] = None
    r"""Name of the firm which was the destination of funds out of the account"""

    distribution_type: Annotated[
        Optional[ActivityDistributionType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Categorizes the withdrawal to indicate whether special handling of the transaction is needed elsewhere"""

    distribution_year: Optional[int] = None
    r"""The tax year the withdrawal should be applied to (YYYY)"""

    fed_reference_number: Optional[str] = None
    r"""Unique tracking number provided to allow tracking a wire transfer from the initiating bank to the receiving bank"""

    futures_settlement: Optional[bool] = None
    r"""Indicates whether the transaction is for a futures related transaction"""

    micro: Optional[bool] = None
    r"""Indicates whether this transaction is a micro withdrawal to validate ACH Relationships"""

    originating_institution: Optional[str] = None
    r"""Name of the firm which was the source of funds into the account"""

    periodic: Optional[bool] = None
    r"""Indicates whether the transaction is a scheduled periodic withdrawal"""

    retirement_type: Annotated[
        Optional[ActivityRetirementType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The type of retirement account the withdrawal is being made from"""

    taxable: Optional[bool] = None
    r"""Indicates whether the transaction is taxable"""

    type: Annotated[
        Optional[ActivityWithdrawalType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The mechanism by which the funds will be withdrawn"""


class ActivityReview(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Denotes whether the withdrawal is pending or complete"""

    REVIEW_STATE_UNSPECIFIED = "REVIEW_STATE_UNSPECIFIED"
    REVIEW_STATE_PENDING = "REVIEW_STATE_PENDING"
    REVIEW_STATE_COMPLETE = "REVIEW_STATE_COMPLETE"


class ActivityWithdrawalPendingReviewTypedDict(TypedDict):
    r"""Object containing metadata for withdrawals pending review"""

    review: NotRequired[ActivityReview]
    r"""Denotes whether the withdrawal is pending or complete"""


class ActivityWithdrawalPendingReview(BaseModel):
    r"""Object containing metadata for withdrawals pending review"""

    review: Annotated[
        Optional[ActivityReview], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Denotes whether the withdrawal is pending or complete"""


class ActivityWithholdingTypedDict(TypedDict):
    r"""Object containing metadata for a withholding"""

    data: NotRequired[List[WithholdingDataTypedDict]]
    r"""Contains information about the tax withholdings associated with a 'parent' activity"""


class ActivityWithholding(BaseModel):
    r"""Object containing metadata for a withholding"""

    data: Optional[List[WithholdingData]] = None
    r"""Contains information about the tax withholdings associated with a 'parent' activity"""


class ActivityWorthlessCorporateActionGeneralInformationTypedDict(TypedDict):
    r"""Common fields for corporate actions"""

    corporate_action_id: NotRequired[str]
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""
    disbursed_asset_id: NotRequired[str]
    r"""Asset Id of the new security after the corporate action event is processed."""
    disbursed_cusip: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    disbursed_symbol_description: NotRequired[str]
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""
    target_asset_id: NotRequired[str]
    r"""Asset Id of the existing security before the corporate action event is processed."""
    target_cusip: NotRequired[str]
    r"""External Identifier of the existing security before the corporate action event is processed."""
    target_symbol_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityWorthlessCorporateActionGeneralInformation(BaseModel):
    r"""Common fields for corporate actions"""

    corporate_action_id: Optional[str] = None
    r"""A unique alphanumeric value that is assigned to uniquely identify each corporate action event."""

    disbursed_asset_id: Optional[str] = None
    r"""Asset Id of the new security after the corporate action event is processed."""

    disbursed_cusip: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    disbursed_symbol_description: Optional[str] = None
    r"""When populated, the name of the issuer of a security and additional descriptive information about the new security after the corporate action event is processed."""

    target_asset_id: Optional[str] = None
    r"""Asset Id of the existing security before the corporate action event is processed."""

    target_cusip: Optional[str] = None
    r"""External Identifier of the existing security before the corporate action event is processed."""

    target_symbol_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the existing security before the corporate action event is processed."""


class ActivityWorthlessEffectiveDateTypedDict(TypedDict):
    r"""Corresponds to corporateactions.announcement.effective_date"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityWorthlessEffectiveDate(BaseModel):
    r"""Corresponds to corporateactions.announcement.effective_date"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityWorthlessPaymentDateTypedDict(TypedDict):
    r"""The anticipated payment date at the depository"""

    day: NotRequired[int]
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""
    month: NotRequired[int]
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""
    year: NotRequired[int]
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityWorthlessPaymentDate(BaseModel):
    r"""The anticipated payment date at the depository"""

    day: Optional[int] = None
    r"""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""

    month: Optional[int] = None
    r"""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""

    year: Optional[int] = None
    r"""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""


class ActivityWorthlessTypedDict(TypedDict):
    r"""Object containing metadata for worthless events"""

    corporate_action_general_information: NotRequired[
        Nullable[ActivityWorthlessCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    effective_date: NotRequired[Nullable[ActivityWorthlessEffectiveDateTypedDict]]
    r"""Corresponds to corporateactions.announcement.effective_date"""
    payment_date: NotRequired[Nullable[ActivityWorthlessPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""


class ActivityWorthless(BaseModel):
    r"""Object containing metadata for worthless events"""

    corporate_action_general_information: OptionalNullable[
        ActivityWorthlessCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    effective_date: OptionalNullable[ActivityWorthlessEffectiveDate] = UNSET
    r"""Corresponds to corporateactions.announcement.effective_date"""

    payment_date: OptionalNullable[ActivityWorthlessPaymentDate] = UNSET
    r"""The anticipated payment date at the depository"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "corporate_action_general_information",
            "effective_date",
            "payment_date",
        ]
        nullable_fields = [
            "corporate_action_general_information",
            "effective_date",
            "payment_date",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ActivityTypedDict(TypedDict):
    r"""Activity is a representation of several ledger entries rolled up for easy correlation and usage"""

    acats_pending_out: NotRequired[Nullable[ActivityAcatsPendingOutTypedDict]]
    r"""Object containing metadata for pending outgoing acats memos"""
    account_id: NotRequired[str]
    r"""A globally unique identifier referencing a single account; this is the main identifier for an account used for machine-to-machine interactions"""
    account_memo: NotRequired[ActivityAccountMemo]
    r"""Indicates the memo location impacted by an entry"""
    account_transfer: NotRequired[Nullable[ActivityAccountTransferTypedDict]]
    r"""Object containing metadata for account transfer movements"""
    accrued_interest: NotRequired[List[AccruedInterestTypedDict]]
    r"""Any accrued interest that has been earned but not yet paid between the last interest payment and the date of the activity"""
    accrued_interest_desc: NotRequired[Nullable[AccruedInterestDescTypedDict]]
    r"""Contains information on the amount of interest that has been earned but not yet paid between the last interest payment and the date of the trade"""
    activity_date: NotRequired[Nullable[ActivityActivityDateTypedDict]]
    r"""The calendar date an activity took place"""
    activity_description: NotRequired[str]
    r"""The description for an activity. This may include special instructions, symbol description, etc when relavant"""
    activity_id: NotRequired[str]
    r"""Apex-generated unique activity identifier"""
    activity_time: NotRequired[Nullable[datetime]]
    r"""The time when the entry occurred as reported to Apex"""
    asset_description: NotRequired[str]
    r"""Name of the issuer of a security and additional descriptive information about the particular issue"""
    asset_id: NotRequired[str]
    r"""An Apex-provided, global identifier created on a per asset bases which provides connectivity across all areas Not populated on a currency only movement"""
    capital_gains: NotRequired[Nullable[ActivityCapitalGainsTypedDict]]
    r"""Object containing metadata for capital gains"""
    cash_dividend: NotRequired[Nullable[ActivityCashDividendTypedDict]]
    r"""Object containing for cash dividends"""
    commission: NotRequired[Nullable[ActivityCommissionTypedDict]]
    r"""Contains information on the commissions charged by brokers or financial intermediaries for executing trades on behalf of clients"""
    commissions: NotRequired[List[CommissionTypedDict]]
    r"""Any commissions associated with the activity"""
    conversion: NotRequired[Nullable[ActivityConversionTypedDict]]
    r"""Object containing metadata for conversions"""
    corporate_action_memo_adjustment: NotRequired[
        Nullable[ActivityCorporateActionMemoAdjustmentTypedDict]
    ]
    r"""Object containing information about corporate action memo adjustments"""
    correspondent_id: NotRequired[str]
    r"""A unique identifier referencing a Correspondent"""
    creation_time: NotRequired[Nullable[datetime]]
    r"""The date/time an activity was created in the ledger"""
    credit: NotRequired[Nullable[ActivityCreditTypedDict]]
    r"""Object containing more information about the credit being paid"""
    currency_asset_id: NotRequired[str]
    r"""Required if any currency field like `price, gross_amount, trade.markup, fee.amount` is provided. The currency's ascend asset_id"""
    currency_code: NotRequired[str]
    r"""The currency associated with the security Populated on a currency movement"""
    deposit: NotRequired[Nullable[ActivityDepositTypedDict]]
    r"""Object containing more information about a deposit"""
    drip: NotRequired[Nullable[ActivityDripTypedDict]]
    r"""Object containing more information about the drip allocations"""
    exchange: NotRequired[Nullable[ActivityExchangeTypedDict]]
    r"""The exchange where the trade was executed"""
    fee: NotRequired[Nullable[ActivityFeeTypedDict]]
    r"""Object containing metadata for fees"""
    fees: NotRequired[List[FeeTypedDict]]
    r"""Any fees associated with the activity"""
    fpsl: NotRequired[Nullable[ActivityFpslTypedDict]]
    r"""Object containing more information about the fpsl allocations"""
    generation: NotRequired[str]
    r"""For a given set of activity that are part of the same lineage the highest generation will be the most recent activity"""
    gross_amount: NotRequired[Nullable[ActivityGrossAmountTypedDict]]
    r"""The monetary value of an activity, exclusive of any fees (First money)"""
    interest: NotRequired[Nullable[ActivityInterestTypedDict]]
    r"""Object containing metadata for margin interest"""
    interest_payment: NotRequired[Nullable[ActivityInterestPaymentTypedDict]]
    r"""Object containing metadata for interest payments"""
    liquidation: NotRequired[Nullable[ActivityLiquidationTypedDict]]
    r"""Object containing metadata for liquidations"""
    maturity: NotRequired[Nullable[ActivityMaturityTypedDict]]
    r"""Object containing metadata for maturity events"""
    merger: NotRequired[Nullable[ActivityMergerTypedDict]]
    r"""Object containing metadata for merger events"""
    name: NotRequired[str]
    r"""accounts/{account_id}/activities/{activity_id}"""
    name_change: NotRequired[Nullable[ActivityNameChangeTypedDict]]
    r"""Object containing metadata for name changes"""
    net_amount: NotRequired[Nullable[ActivityNetAmountTypedDict]]
    r"""The dollar amount of an activity, inclusive of fees, withholding, commisions, etc"""
    next_activity_id: NotRequired[str]
    r"""can be an empty string if there is no next activity is populated when there is a modification resulting in a new activity"""
    next_activity_process_date: NotRequired[Nullable[NextActivityProcessDateTypedDict]]
    r"""the process date of the next activity(nil if the next_activity_id is an empty string)"""
    none: NotRequired[Nullable[NoneTTypedDict]]
    r"""None"""
    payment_in_kind: NotRequired[Nullable[ActivityPaymentInKindTypedDict]]
    r"""Object containing metadata for payment in kind"""
    previous_activity_id: NotRequired[str]
    r"""When populated, the activity_id of that precedes this one"""
    previous_process_date: NotRequired[Nullable[PreviousProcessDateTypedDict]]
    r"""When populated, the processing_date of the previous_activity_id"""
    price: NotRequired[Nullable[ActivityPriceTypedDict]]
    r"""The monetary value paid for a given security in a trade Not populated on a currency only movement"""
    process_date: NotRequired[Nullable[ActivityProcessDateTypedDict]]
    r"""The date that the activity was booked to the ledger"""
    quantity: NotRequired[Nullable[ActivityQuantityTypedDict]]
    r"""The quantity of shares bought, sold, or moved for a given entry/activity Required if activity.state != PENDING"""
    redemption_full: NotRequired[Nullable[ActivityRedemptionFullTypedDict]]
    r"""Object containing more information about a redemption"""
    redemption_partial: NotRequired[Nullable[ActivityRedemptionPartialTypedDict]]
    r"""Object containing metadata for partial redemption"""
    region_code: NotRequired[str]
    r"""Two character region code, complies with https://cldr.unicode.org/index"""
    reverse_stock_split: NotRequired[Nullable[ActivityReverseStockSplitTypedDict]]
    r"""Object containing metadata for a reverse_stock_split"""
    rights_distribution: NotRequired[Nullable[ActivityRightsDistributionTypedDict]]
    r"""Object containing more information about a rights distribution"""
    rights_subscription: NotRequired[Nullable[ActivityRightsSubscriptionTypedDict]]
    r"""Object containing metadata for rights subscriptions"""
    rounding_adjustment: NotRequired[Nullable[ActivityRoundingAdjustmentTypedDict]]
    r"""Object containing metadata for standalone rounding adjustments"""
    rounding_amount: NotRequired[Nullable[RoundingAmountTypedDict]]
    r"""the difference between the aggregation of gross_amount from the trade entries and the rounded gross_amount of the fully formed activity This amount can also be found as a rounding_adjustment entry"""
    rounding_reason: NotRequired[str]
    r"""Free form text field providing reason for rounding"""
    sale_of_rights: NotRequired[Nullable[ActivitySaleOfRightsTypedDict]]
    r"""Object containing more information about a sale_of_rights"""
    settle_date: NotRequired[Nullable[ActivitySettleDateTypedDict]]
    r"""The date a given activity will officially settle"""
    side: NotRequired[ActivitySide]
    r"""Denotes whether the trade is a buy or sell"""
    spinoff: NotRequired[Nullable[ActivitySpinoffTypedDict]]
    r"""Object containing metadata for spinoffs"""
    state: NotRequired[ActivityState]
    r"""The state of the activity"""
    stock_dividend: NotRequired[Nullable[ActivityStockDividendTypedDict]]
    r"""Object containing metadata for stock dividends"""
    stock_split: NotRequired[Nullable[ActivityStockSplitTypedDict]]
    r"""Object containing metadata for stock splits"""
    subtype_category: NotRequired[str]
    r"""String representation of the metadata object containing more information about an entry/ activity"""
    sweep: NotRequired[Nullable[ActivitySweepTypedDict]]
    r"""Object containing metadata for sweeps"""
    tender_offer: NotRequired[Nullable[ActivityTenderOfferTypedDict]]
    r"""Object containing metadata for tender offers"""
    trade: NotRequired[Nullable[ActivityTradeTypedDict]]
    r"""Object containing metadata for a trade"""
    transfer: NotRequired[Nullable[ActivityTransferTypedDict]]
    r"""Object containing metadata for transfers"""
    type: NotRequired[ActivityType]
    r"""The type of activity this is"""
    unit_split: NotRequired[Nullable[ActivityUnitSplitTypedDict]]
    r"""Object containing metadata for unit splits"""
    warrant_exercise: NotRequired[Nullable[ActivityWarrantExerciseTypedDict]]
    r"""Object containing metadata for warrant exercises"""
    withdrawal: NotRequired[Nullable[ActivityWithdrawalTypedDict]]
    r"""Object containing metadata for withdrawals"""
    withdrawal_pending_review: NotRequired[
        Nullable[ActivityWithdrawalPendingReviewTypedDict]
    ]
    r"""Object containing metadata for withdrawals pending review"""
    withholding: NotRequired[Nullable[ActivityWithholdingTypedDict]]
    r"""Object containing metadata for a withholding"""
    withholdings: NotRequired[List[WithholdingTypedDict]]
    r"""Any withholdings associated with the activity"""
    worthless: NotRequired[Nullable[ActivityWorthlessTypedDict]]
    r"""Object containing metadata for worthless events"""


class Activity(BaseModel):
    r"""Activity is a representation of several ledger entries rolled up for easy correlation and usage"""

    acats_pending_out: OptionalNullable[ActivityAcatsPendingOut] = UNSET
    r"""Object containing metadata for pending outgoing acats memos"""

    account_id: Optional[str] = None
    r"""A globally unique identifier referencing a single account; this is the main identifier for an account used for machine-to-machine interactions"""

    account_memo: Annotated[
        Optional[ActivityAccountMemo], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Indicates the memo location impacted by an entry"""

    account_transfer: OptionalNullable[ActivityAccountTransfer] = UNSET
    r"""Object containing metadata for account transfer movements"""

    accrued_interest: Optional[List[AccruedInterest]] = None
    r"""Any accrued interest that has been earned but not yet paid between the last interest payment and the date of the activity"""

    accrued_interest_desc: OptionalNullable[AccruedInterestDesc] = UNSET
    r"""Contains information on the amount of interest that has been earned but not yet paid between the last interest payment and the date of the trade"""

    activity_date: OptionalNullable[ActivityActivityDate] = UNSET
    r"""The calendar date an activity took place"""

    activity_description: Optional[str] = None
    r"""The description for an activity. This may include special instructions, symbol description, etc when relavant"""

    activity_id: Optional[str] = None
    r"""Apex-generated unique activity identifier"""

    activity_time: OptionalNullable[datetime] = UNSET
    r"""The time when the entry occurred as reported to Apex"""

    asset_description: Optional[str] = None
    r"""Name of the issuer of a security and additional descriptive information about the particular issue"""

    asset_id: Optional[str] = None
    r"""An Apex-provided, global identifier created on a per asset bases which provides connectivity across all areas Not populated on a currency only movement"""

    capital_gains: OptionalNullable[ActivityCapitalGains] = UNSET
    r"""Object containing metadata for capital gains"""

    cash_dividend: OptionalNullable[ActivityCashDividend] = UNSET
    r"""Object containing for cash dividends"""

    commission: OptionalNullable[ActivityCommission] = UNSET
    r"""Contains information on the commissions charged by brokers or financial intermediaries for executing trades on behalf of clients"""

    commissions: Optional[List[Commission]] = None
    r"""Any commissions associated with the activity"""

    conversion: OptionalNullable[ActivityConversion] = UNSET
    r"""Object containing metadata for conversions"""

    corporate_action_memo_adjustment: OptionalNullable[
        ActivityCorporateActionMemoAdjustment
    ] = UNSET
    r"""Object containing information about corporate action memo adjustments"""

    correspondent_id: Optional[str] = None
    r"""A unique identifier referencing a Correspondent"""

    creation_time: OptionalNullable[datetime] = UNSET
    r"""The date/time an activity was created in the ledger"""

    credit: OptionalNullable[ActivityCredit] = UNSET
    r"""Object containing more information about the credit being paid"""

    currency_asset_id: Optional[str] = None
    r"""Required if any currency field like `price, gross_amount, trade.markup, fee.amount` is provided. The currency's ascend asset_id"""

    currency_code: Optional[str] = None
    r"""The currency associated with the security Populated on a currency movement"""

    deposit: OptionalNullable[ActivityDeposit] = UNSET
    r"""Object containing more information about a deposit"""

    drip: OptionalNullable[ActivityDrip] = UNSET
    r"""Object containing more information about the drip allocations"""

    exchange: OptionalNullable[ActivityExchange] = UNSET
    r"""The exchange where the trade was executed"""

    fee: OptionalNullable[ActivityFee] = UNSET
    r"""Object containing metadata for fees"""

    fees: Optional[List[Fee]] = None
    r"""Any fees associated with the activity"""

    fpsl: OptionalNullable[ActivityFpsl] = UNSET
    r"""Object containing more information about the fpsl allocations"""

    generation: Optional[str] = None
    r"""For a given set of activity that are part of the same lineage the highest generation will be the most recent activity"""

    gross_amount: OptionalNullable[ActivityGrossAmount] = UNSET
    r"""The monetary value of an activity, exclusive of any fees (First money)"""

    interest: OptionalNullable[ActivityInterest] = UNSET
    r"""Object containing metadata for margin interest"""

    interest_payment: OptionalNullable[ActivityInterestPayment] = UNSET
    r"""Object containing metadata for interest payments"""

    liquidation: OptionalNullable[ActivityLiquidation] = UNSET
    r"""Object containing metadata for liquidations"""

    maturity: OptionalNullable[ActivityMaturity] = UNSET
    r"""Object containing metadata for maturity events"""

    merger: OptionalNullable[ActivityMerger] = UNSET
    r"""Object containing metadata for merger events"""

    name: Optional[str] = None
    r"""accounts/{account_id}/activities/{activity_id}"""

    name_change: OptionalNullable[ActivityNameChange] = UNSET
    r"""Object containing metadata for name changes"""

    net_amount: OptionalNullable[ActivityNetAmount] = UNSET
    r"""The dollar amount of an activity, inclusive of fees, withholding, commisions, etc"""

    next_activity_id: Optional[str] = None
    r"""can be an empty string if there is no next activity is populated when there is a modification resulting in a new activity"""

    next_activity_process_date: OptionalNullable[NextActivityProcessDate] = UNSET
    r"""the process date of the next activity(nil if the next_activity_id is an empty string)"""

    none: OptionalNullable[NoneT] = UNSET
    r"""None"""

    payment_in_kind: OptionalNullable[ActivityPaymentInKind] = UNSET
    r"""Object containing metadata for payment in kind"""

    previous_activity_id: Optional[str] = None
    r"""When populated, the activity_id of that precedes this one"""

    previous_process_date: OptionalNullable[PreviousProcessDate] = UNSET
    r"""When populated, the processing_date of the previous_activity_id"""

    price: OptionalNullable[ActivityPrice] = UNSET
    r"""The monetary value paid for a given security in a trade Not populated on a currency only movement"""

    process_date: OptionalNullable[ActivityProcessDate] = UNSET
    r"""The date that the activity was booked to the ledger"""

    quantity: OptionalNullable[ActivityQuantity] = UNSET
    r"""The quantity of shares bought, sold, or moved for a given entry/activity Required if activity.state != PENDING"""

    redemption_full: OptionalNullable[ActivityRedemptionFull] = UNSET
    r"""Object containing more information about a redemption"""

    redemption_partial: OptionalNullable[ActivityRedemptionPartial] = UNSET
    r"""Object containing metadata for partial redemption"""

    region_code: Optional[str] = None
    r"""Two character region code, complies with https://cldr.unicode.org/index"""

    reverse_stock_split: OptionalNullable[ActivityReverseStockSplit] = UNSET
    r"""Object containing metadata for a reverse_stock_split"""

    rights_distribution: OptionalNullable[ActivityRightsDistribution] = UNSET
    r"""Object containing more information about a rights distribution"""

    rights_subscription: OptionalNullable[ActivityRightsSubscription] = UNSET
    r"""Object containing metadata for rights subscriptions"""

    rounding_adjustment: OptionalNullable[ActivityRoundingAdjustment] = UNSET
    r"""Object containing metadata for standalone rounding adjustments"""

    rounding_amount: OptionalNullable[RoundingAmount] = UNSET
    r"""the difference between the aggregation of gross_amount from the trade entries and the rounded gross_amount of the fully formed activity This amount can also be found as a rounding_adjustment entry"""

    rounding_reason: Optional[str] = None
    r"""Free form text field providing reason for rounding"""

    sale_of_rights: OptionalNullable[ActivitySaleOfRights] = UNSET
    r"""Object containing more information about a sale_of_rights"""

    settle_date: OptionalNullable[ActivitySettleDate] = UNSET
    r"""The date a given activity will officially settle"""

    side: Annotated[
        Optional[ActivitySide], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Denotes whether the trade is a buy or sell"""

    spinoff: OptionalNullable[ActivitySpinoff] = UNSET
    r"""Object containing metadata for spinoffs"""

    state: Annotated[
        Optional[ActivityState], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The state of the activity"""

    stock_dividend: OptionalNullable[ActivityStockDividend] = UNSET
    r"""Object containing metadata for stock dividends"""

    stock_split: OptionalNullable[ActivityStockSplit] = UNSET
    r"""Object containing metadata for stock splits"""

    subtype_category: Optional[str] = None
    r"""String representation of the metadata object containing more information about an entry/ activity"""

    sweep: OptionalNullable[ActivitySweep] = UNSET
    r"""Object containing metadata for sweeps"""

    tender_offer: OptionalNullable[ActivityTenderOffer] = UNSET
    r"""Object containing metadata for tender offers"""

    trade: OptionalNullable[ActivityTrade] = UNSET
    r"""Object containing metadata for a trade"""

    transfer: OptionalNullable[ActivityTransfer] = UNSET
    r"""Object containing metadata for transfers"""

    type: Annotated[
        Optional[ActivityType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The type of activity this is"""

    unit_split: OptionalNullable[ActivityUnitSplit] = UNSET
    r"""Object containing metadata for unit splits"""

    warrant_exercise: OptionalNullable[ActivityWarrantExercise] = UNSET
    r"""Object containing metadata for warrant exercises"""

    withdrawal: OptionalNullable[ActivityWithdrawal] = UNSET
    r"""Object containing metadata for withdrawals"""

    withdrawal_pending_review: OptionalNullable[ActivityWithdrawalPendingReview] = UNSET
    r"""Object containing metadata for withdrawals pending review"""

    withholding: OptionalNullable[ActivityWithholding] = UNSET
    r"""Object containing metadata for a withholding"""

    withholdings: Optional[List[Withholding]] = None
    r"""Any withholdings associated with the activity"""

    worthless: OptionalNullable[ActivityWorthless] = UNSET
    r"""Object containing metadata for worthless events"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "acats_pending_out",
            "account_id",
            "account_memo",
            "account_transfer",
            "accrued_interest",
            "accrued_interest_desc",
            "activity_date",
            "activity_description",
            "activity_id",
            "activity_time",
            "asset_description",
            "asset_id",
            "capital_gains",
            "cash_dividend",
            "commission",
            "commissions",
            "conversion",
            "corporate_action_memo_adjustment",
            "correspondent_id",
            "creation_time",
            "credit",
            "currency_asset_id",
            "currency_code",
            "deposit",
            "drip",
            "exchange",
            "fee",
            "fees",
            "fpsl",
            "generation",
            "gross_amount",
            "interest",
            "interest_payment",
            "liquidation",
            "maturity",
            "merger",
            "name",
            "name_change",
            "net_amount",
            "next_activity_id",
            "next_activity_process_date",
            "none",
            "payment_in_kind",
            "previous_activity_id",
            "previous_process_date",
            "price",
            "process_date",
            "quantity",
            "redemption_full",
            "redemption_partial",
            "region_code",
            "reverse_stock_split",
            "rights_distribution",
            "rights_subscription",
            "rounding_adjustment",
            "rounding_amount",
            "rounding_reason",
            "sale_of_rights",
            "settle_date",
            "side",
            "spinoff",
            "state",
            "stock_dividend",
            "stock_split",
            "subtype_category",
            "sweep",
            "tender_offer",
            "trade",
            "transfer",
            "type",
            "unit_split",
            "warrant_exercise",
            "withdrawal",
            "withdrawal_pending_review",
            "withholding",
            "withholdings",
            "worthless",
        ]
        nullable_fields = [
            "acats_pending_out",
            "account_transfer",
            "accrued_interest_desc",
            "activity_date",
            "activity_time",
            "capital_gains",
            "cash_dividend",
            "commission",
            "conversion",
            "corporate_action_memo_adjustment",
            "creation_time",
            "credit",
            "deposit",
            "drip",
            "exchange",
            "fee",
            "fpsl",
            "gross_amount",
            "interest",
            "interest_payment",
            "liquidation",
            "maturity",
            "merger",
            "name_change",
            "net_amount",
            "next_activity_process_date",
            "none",
            "payment_in_kind",
            "previous_process_date",
            "price",
            "process_date",
            "quantity",
            "redemption_full",
            "redemption_partial",
            "reverse_stock_split",
            "rights_distribution",
            "rights_subscription",
            "rounding_adjustment",
            "rounding_amount",
            "sale_of_rights",
            "settle_date",
            "spinoff",
            "stock_dividend",
            "stock_split",
            "sweep",
            "tender_offer",
            "trade",
            "transfer",
            "unit_split",
            "warrant_exercise",
            "withdrawal",
            "withdrawal_pending_review",
            "withholding",
            "worthless",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m
