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

from __future__ import annotations
from .lot import Lot, LotTypedDict
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 AcatsPendingOutTypedDict(TypedDict):
    r"""Object containing metadata for pending outgoing acats"""

    acats_control_number: NotRequired[str]
    r"""the unique transfer Identifier assigned by NSCC"""
    additional_instructions: NotRequired[str]
    r"""Free form text field"""


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

    acats_control_number: Optional[str] = None
    r"""the unique transfer Identifier assigned by NSCC"""

    additional_instructions: Optional[str] = None
    r"""Free form text field"""


class AccountMemo(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 Action(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Indicates whether the account transfer is incoming or outgoing"""

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


class Method(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 AccountTransferTypedDict(TypedDict):
    r"""Object containing metadata for account transfers"""

    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"""the unique transfer Identifier assigned by NSCC"""
    action: NotRequired[Action]
    r"""Indicates whether the account transfer is incoming or outgoing"""
    additional_instructions: NotRequired[str]
    r"""Free form text field"""
    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[Method]
    r"""the method used for the account transfer"""


class AccountTransfer(BaseModel):
    r"""Object containing metadata for account transfers"""

    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"""the unique transfer Identifier assigned by NSCC"""

    action: Annotated[
        Optional[Action], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Indicates whether the account transfer is incoming or outgoing"""

    additional_instructions: Optional[str] = None
    r"""Free form text field"""

    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[Method], PlainValidator(validate_open_enum(False))
    ] = None
    r"""the method used for the account transfer"""


class EntryAccruedInterestTypedDict(TypedDict):
    r"""Indicates that the entry references accrued interest that has been earned but not yet paid between the last interest payment and the date of the trade"""


class EntryAccruedInterest(BaseModel):
    r"""Indicates that the entry references accrued interest that has been earned but not yet paid between the last interest payment and the date of the trade"""


class CorporateActionGeneralInformationTypedDict(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 CorporateActionGeneralInformation(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 AcquisitionTypedDict(TypedDict):
    r"""Object containing metadata for acquisition events"""

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


class Acquisition(BaseModel):
    r"""Object containing metadata for acquisition events"""

    corporate_action_general_information: OptionalNullable[
        CorporateActionGeneralInformation
    ] = 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 ActivityDateTypedDict(TypedDict):
    r"""The calendar date an activity took place For Trade entries, the activity date reflects the trade date of the market in which the trade was executed For Cash entries, this reflects the banking day the cash will be moved"""

    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 ActivityDate(BaseModel):
    r"""The calendar date an activity took place For Trade entries, the activity date reflects the trade date of the market in which the trade was executed For Cash entries, this reflects the banking day the cash will be moved"""

    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 CashRateTypedDict(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 CashRate(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 EntryCorporateActionGeneralInformationTypedDict(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 EntryCorporateActionGeneralInformation(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 PaymentDateTypedDict(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 PaymentDate(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 EntryCapitalGainsQuantityTypedDict(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 EntryCapitalGainsQuantity(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 RecordDateTypedDict(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 RecordDate(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 CapitalGainsTypedDict(TypedDict):
    r"""Object containing metadata for capital gains"""

    cash_rate: NotRequired[Nullable[CashRateTypedDict]]
    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[EntryCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    long_term_gain: NotRequired[bool]
    r"""Corresponds to corporateactions.announcement.capital_gains"""
    payment_date: NotRequired[Nullable[PaymentDateTypedDict]]
    r"""The anticipated payment date at the depository."""
    qualified: NotRequired[bool]
    r"""Identifies whether dividend income is potentially qualified for the lower maximum individual federal tax rate under the Jobs and Growth Tax Relief Reconciliation Act of 2003."""
    quantity: NotRequired[Nullable[EntryCapitalGainsQuantityTypedDict]]
    r"""Corresponds to the position's trade quantity"""
    record_date: NotRequired[Nullable[RecordDateTypedDict]]
    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 CapitalGains(BaseModel):
    r"""Object containing metadata for capital gains"""

    cash_rate: OptionalNullable[CashRate] = 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[
        EntryCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    long_term_gain: Optional[bool] = None
    r"""Corresponds to corporateactions.announcement.capital_gains"""

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

    qualified: Optional[bool] = None
    r"""Identifies whether dividend income is potentially qualified for the lower maximum individual federal tax rate under the Jobs and Growth Tax Relief Reconciliation Act of 2003."""

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

    record_date: OptionalNullable[RecordDate] = 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 = [
            "cash_rate",
            "corporate_action_general_information",
            "long_term_gain",
            "payment_date",
            "qualified",
            "quantity",
            "record_date",
            "reinvested",
        ]
        nullable_fields = [
            "cash_rate",
            "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 EntryCashRateTypedDict(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 EntryCashRate(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 EntryCashDividendCorporateActionGeneralInformationTypedDict(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 EntryCashDividendCorporateActionGeneralInformation(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 EntryFpslTypedDict(TypedDict):
    r"""Corresponds to the raw bucket value that denotes a position is allocated to the \"fpsl\" memo location"""

    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 EntryFpsl(BaseModel):
    r"""Corresponds to the raw bucket value that denotes a position is allocated to the \"fpsl\" memo location"""

    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 EntryFreeTypedDict(TypedDict):
    r"""Corresponds to the raw bucket value that denotes a position is allocated to the \"free\" memo location"""

    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 EntryFree(BaseModel):
    r"""Corresponds to the raw bucket value that denotes a position is allocated to the \"free\" memo location"""

    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 EntryPaymentDateTypedDict(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 EntryPaymentDate(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 EntryCashDividendQuantityTypedDict(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 EntryCashDividendQuantity(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 EntryRecordDateTypedDict(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 EntryRecordDate(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 EntryCashDividendSettledTypedDict(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 EntryCashDividendSettled(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 Subtype(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Corresponds to the subtype of corporaction type"""

    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 CashDividendTypedDict(TypedDict):
    r"""Object containing for cash dividends"""

    cash_rate: NotRequired[Nullable[EntryCashRateTypedDict]]
    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[EntryCashDividendCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    fpsl: NotRequired[Nullable[EntryFpslTypedDict]]
    r"""Corresponds to the raw bucket value that denotes a position is allocated to the \"fpsl\" memo location"""
    free: NotRequired[Nullable[EntryFreeTypedDict]]
    r"""Corresponds to the raw bucket value that denotes a position is allocated to the \"free\" memo location"""
    long_term_gain: NotRequired[bool]
    r"""Corresponds to corporateactions.announcement.capital_gains"""
    payment_date: NotRequired[Nullable[EntryPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository."""
    qualified: NotRequired[bool]
    r"""Identifies whether dividend income is potentially qualified for the lower maximum individual federal tax rate under the Jobs and Growth Tax Relief Reconciliation Act of 2003."""
    quantity: NotRequired[Nullable[EntryCashDividendQuantityTypedDict]]
    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[EntryRecordDateTypedDict]]
    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[EntryCashDividendSettledTypedDict]]
    r"""Corresponds to the position's settled quantity"""
    substitute_payment: NotRequired[bool]
    r"""Indicates whether the corporate action event is a substitute payment"""
    subtype: NotRequired[Subtype]
    r"""Corresponds to the subtype of corporaction type"""


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

    cash_rate: OptionalNullable[EntryCashRate] = 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[
        EntryCashDividendCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    fpsl: OptionalNullable[EntryFpsl] = UNSET
    r"""Corresponds to the raw bucket value that denotes a position is allocated to the \"fpsl\" memo location"""

    free: OptionalNullable[EntryFree] = UNSET
    r"""Corresponds to the raw bucket value that denotes a position is allocated to the \"free\" memo location"""

    long_term_gain: Optional[bool] = None
    r"""Corresponds to corporateactions.announcement.capital_gains"""

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

    qualified: Optional[bool] = None
    r"""Identifies whether dividend income is potentially qualified for the lower maximum individual federal tax rate under the Jobs and Growth Tax Relief Reconciliation Act of 2003."""

    quantity: OptionalNullable[EntryCashDividendQuantity] = 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[EntryRecordDate] = 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[EntryCashDividendSettled] = UNSET
    r"""Corresponds to the position's settled quantity"""

    substitute_payment: Optional[bool] = None
    r"""Indicates whether the corporate action event is a substitute payment"""

    subtype: Annotated[
        Optional[Subtype], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Corresponds to the subtype of corporaction type"""

    @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 EntryCommissionTypedDict(TypedDict):
    r"""Indicates that the entry references commission charged by brokers or financial intermediaries for executing financial transactions on behalf of clients"""


class EntryCommission(BaseModel):
    r"""Indicates that the entry references commission charged by brokers or financial intermediaries for executing financial transactions on behalf of clients"""


class EntryConversionCashRateTypedDict(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 EntryConversionCashRate(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 EntryConversionCorporateActionGeneralInformationTypedDict(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 EntryConversionCorporateActionGeneralInformation(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 StockRateTypedDict(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 StockRate(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 EntryConversionType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Corresponds to whether the event is CASH | STOCK | CASH_AND_STOCK"""

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


class ConversionTypedDict(TypedDict):
    r"""Object containing metadata for conversions (Conversion of securities into another form of securities)"""

    cash_rate: NotRequired[Nullable[EntryConversionCashRateTypedDict]]
    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[EntryConversionCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    stock_rate: NotRequired[Nullable[StockRateTypedDict]]
    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[EntryConversionType]
    r"""Corresponds to whether the event is CASH | STOCK | CASH_AND_STOCK"""


class Conversion(BaseModel):
    r"""Object containing metadata for conversions (Conversion of securities into another form of securities)"""

    cash_rate: OptionalNullable[EntryConversionCashRate] = 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[
        EntryConversionCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    stock_rate: OptionalNullable[StockRate] = 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[EntryConversionType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Corresponds to whether the event is CASH | STOCK | CASH_AND_STOCK"""

    @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 CorporateActionMemoAdjustmentTypedDict(TypedDict):
    r"""Object containing metadata for memo locations that have been adjusted due to a corporate action"""

    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 CorporateActionMemoAdjustment(BaseModel):
    r"""Object containing metadata for memo locations that have been adjusted due to a corporate action"""

    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 CreditType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Provides more details on 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 CreditTypedDict(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[CreditType]
    r"""Provides more details on the type of credit"""
    taxable: NotRequired[bool]
    r"""Indicates whether the credit is taxable"""


class Credit(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[CreditType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Provides more details on the type of credit"""

    taxable: Optional[bool] = None
    r"""Indicates whether the credit is taxable"""


class EntryDeliveryCorporateActionGeneralInformationTypedDict(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 EntryDeliveryCorporateActionGeneralInformation(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 DeliveryTypedDict(TypedDict):
    r"""Object containing metadata for delivery events"""

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


class Delivery(BaseModel):
    r"""Object containing metadata for delivery events"""

    corporate_action_general_information: OptionalNullable[
        EntryDeliveryCorporateActionGeneralInformation
    ] = 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 ContributionType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Provides detail on the contribution reason if the deposit is made to a retirement 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 EntryDepositType(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 DepositTypedDict(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[ContributionType]
    r"""Provides detail on the contribution reason if the deposit is made to a retirement 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[EntryDepositType]
    r"""The mechanism by which funds were deposited"""


class Deposit(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[ContributionType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Provides detail on the contribution reason if the deposit is made to a retirement 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[EntryDepositType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The mechanism by which funds were deposited"""


class EntryAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Indicates whether the drip memo activity is reserving cash (DRIP_PENDING) or removing the reservation after a successful reinvestment trade"""

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


class DripTypedDict(TypedDict):
    r"""Object containing metadata for reserving cash until the DRIP trades are executed"""

    action: NotRequired[EntryAction]
    r"""Indicates whether the drip memo activity is reserving cash (DRIP_PENDING) or removing the reservation after a successful reinvestment trade"""


class Drip(BaseModel):
    r"""Object containing metadata for reserving cash until the DRIP trades are executed"""

    action: Annotated[
        Optional[EntryAction], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Indicates whether the drip memo activity is reserving cash (DRIP_PENDING) or removing the reservation after a successful reinvestment trade"""


class EntryExchangeCashRateTypedDict(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 EntryExchangeCashRate(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 EntryExchangeCorporateActionGeneralInformationTypedDict(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 EntryExchangeCorporateActionGeneralInformation(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 EntryStockRateTypedDict(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 EntryStockRate(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 EntryExchangeType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Corresponds to whether the event is CASH | STOCK | CASH_AND_STOCK"""

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


class ExchangeTypedDict(TypedDict):
    r"""Object containing metadata for exchanges"""

    cash_rate: NotRequired[Nullable[EntryExchangeCashRateTypedDict]]
    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[EntryExchangeCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    stock_rate: NotRequired[Nullable[EntryStockRateTypedDict]]
    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[EntryExchangeType]
    r"""Corresponds to whether the event is CASH | STOCK | CASH_AND_STOCK"""


class Exchange(BaseModel):
    r"""Object containing metadata for exchanges"""

    cash_rate: OptionalNullable[EntryExchangeCashRate] = 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[
        EntryExchangeCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    stock_rate: OptionalNullable[EntryStockRate] = 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[EntryExchangeType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Corresponds to whether the event is CASH | STOCK | CASH_AND_STOCK"""

    @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 EntryFeeType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Enum providing additional information about the type of fee being charged"""

    FEE_TYPE_UNSPECIFIED = "FEE_TYPE_UNSPECIFIED"
    CLIENT_CLEARING = "CLIENT_CLEARING"
    LIQUIDITY = "LIQUIDITY"
    GENERAL_PURPOSE = "GENERAL_PURPOSE"
    COMMISSION = "COMMISSION"
    ORF = "ORF"
    TAF = "TAF"
    SEC = "SEC"
    ACCOUNT_CLOSING = "ACCOUNT_CLOSING"
    ACCOUNT_IRA = "ACCOUNT_IRA"
    ACH_RETURN = "ACH_RETURN"
    ADVISORY = "ADVISORY"
    CHECK_FEE = "CHECK_FEE"
    EXCHANGE = "EXCHANGE"
    MANAGEMENT = "MANAGEMENT"
    OVERNIGHT = "OVERNIGHT"
    PLATFORM = "PLATFORM"
    STATEMENT = "STATEMENT"
    STOP_PAYMENT = "STOP_PAYMENT"
    WIRE_FEE = "WIRE_FEE"
    INACTIVITY = "INACTIVITY"
    AMA_SERVICE = "AMA_SERVICE"
    NOTICE_OF_CHANGE = "NOTICE_OF_CHANGE"
    ACCOUNT_TRANSFER = "ACCOUNT_TRANSFER"
    AGENCY_PROCESSING = "AGENCY_PROCESSING"
    RTP_FEE = "RTP_FEE"
    DOMESTIC_WIRE_DEPOSIT_FEE = "DOMESTIC_WIRE_DEPOSIT_FEE"
    DOMESTIC_WIRE_WITHDRAWAL_FEE = "DOMESTIC_WIRE_WITHDRAWAL_FEE"
    INTERNATIONAL_WIRE_DEPOSIT_FEE = "INTERNATIONAL_WIRE_DEPOSIT_FEE"
    INTERNATIONAL_WIRE_WITHDRAWAL_FEE = "INTERNATIONAL_WIRE_WITHDRAWAL_FEE"
    BROKER_FEE = "BROKER_FEE"


class EntryFeeTypedDict(TypedDict):
    r"""Object containing more information about the fee being charged"""

    additional_instructions: NotRequired[str]
    r"""Free form text field providing additional information about a transaction"""
    type: NotRequired[EntryFeeType]
    r"""Enum providing additional information about the type of fee being charged"""


class EntryFee(BaseModel):
    r"""Object containing more information about the fee being charged"""

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

    type: Annotated[
        Optional[EntryFeeType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Enum providing additional information about the type of fee being charged"""


class EntryFlipBrokerCapacity(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Used to calculate broadridge blotter code"""

    CAPACITY_UNSPECIFIED = "CAPACITY_UNSPECIFIED"
    AGENCY = "AGENCY"
    PRINCIPAL = "PRINCIPAL"
    MIXED = "MIXED"


class EntryFlipPrevailingMarketPriceTypedDict(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 EntryFlipPrevailingMarketPrice(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 EntryPriceAdjustmentAmountTypedDict(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 EntryPriceAdjustmentAmount(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 EntryPriceAdjustmentPercentTypedDict(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 EntryPriceAdjustmentPercent(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 EntryPriceAdjustmentType(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 EntryPriceAdjustmentRecordTypedDict(TypedDict):
    r"""Information about any price adjustments applied to the security"""

    price_adjustment_amount: NotRequired[Nullable[EntryPriceAdjustmentAmountTypedDict]]
    r"""Total monetary value of the price_adjustment"""
    price_adjustment_percent: NotRequired[
        Nullable[EntryPriceAdjustmentPercentTypedDict]
    ]
    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[EntryPriceAdjustmentType]
    r"""The type of price adjustment being applied by the broker to the net price of the security."""


class EntryPriceAdjustmentRecord(BaseModel):
    r"""Information about any price adjustments applied to the security"""

    price_adjustment_amount: OptionalNullable[EntryPriceAdjustmentAmount] = UNSET
    r"""Total monetary value of the price_adjustment"""

    price_adjustment_percent: OptionalNullable[EntryPriceAdjustmentPercent] = 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[EntryPriceAdjustmentType], 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 DetailTypedDict(TypedDict):
    r"""Provides additional details for trades"""

    additional_instructions: NotRequired[List[str]]
    r"""To be populated by the submitter of the trade detail"""
    alternate_order_id: NotRequired[str]
    r"""Max Length 50 characters. Alternate order id from the street used for FRAC trades"""
    booking_api_booking_execution_id: NotRequired[str]
    r"""base64 encoded value assigned by the Booking API to all executions"""
    booking_api_trade_allocation_id: NotRequired[str]
    r"""base64 encoded value assigned by the Booking API if a trade belongs to an allocation"""
    booking_api_trade_id: NotRequired[str]
    r"""base64 encoded value assigned by the Booking API to all trades"""
    broker: NotRequired[str]
    r"""Executing broker of the trade"""
    broker_capacity: NotRequired[EntryFlipBrokerCapacity]
    r"""Used to calculate broadridge blotter code"""
    client_memo: NotRequired[str]
    r"""client usage area (intact). len 20"""
    client_order_id: NotRequired[str]
    r"""Max Length 50 characters. Client provided order id present in exec reports"""
    exchange: NotRequired[str]
    r"""MIC code for the exchange"""
    execution_id: NotRequired[str]
    r"""Max Length 50 characters. Execution id from the street"""
    execution_only: NotRequired[bool]
    r"""Indicates whether Apex is the clearing broker for this trade"""
    external_id: NotRequired[str]
    r"""Max Length 50 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"""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"""Trade lots"""
    market: NotRequired[str]
    r"""\"MMAP\" for multi market average price, \"UNKN\" for unknown"""
    order_id: NotRequired[str]
    r"""Max Length 50 characters. Internally generated order id that is returned to client on exec reports"""
    prevailing_market_price: NotRequired[
        Nullable[EntryFlipPrevailingMarketPriceTypedDict]
    ]
    r"""The price for the instrument that is prevailing in the market."""
    price_adjustment_record: NotRequired[Nullable[EntryPriceAdjustmentRecordTypedDict]]
    r"""Information about any price adjustments applied to the security"""
    route: NotRequired[str]
    r"""The execution route Apex used for this trade"""
    special_instructions: NotRequired[List[str]]
    r"""Special instructions for the trade"""
    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 Detail(BaseModel):
    r"""Provides additional details for trades"""

    additional_instructions: Optional[List[str]] = None
    r"""To be populated by the submitter of the trade detail"""

    alternate_order_id: Optional[str] = None
    r"""Max Length 50 characters. Alternate order id from the street used for FRAC trades"""

    booking_api_booking_execution_id: Optional[str] = None
    r"""base64 encoded value assigned by the Booking API to all executions"""

    booking_api_trade_allocation_id: Optional[str] = None
    r"""base64 encoded value assigned by the Booking API if a trade belongs to an allocation"""

    booking_api_trade_id: Optional[str] = None
    r"""base64 encoded value assigned by the Booking API to all trades"""

    broker: Optional[str] = None
    r"""Executing broker of the trade"""

    broker_capacity: Annotated[
        Optional[EntryFlipBrokerCapacity], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Used to calculate broadridge blotter code"""

    client_memo: Optional[str] = None
    r"""client usage area (intact). len 20"""

    client_order_id: Optional[str] = None
    r"""Max Length 50 characters. Client provided order id present in exec reports"""

    exchange: Optional[str] = None
    r"""MIC code for the exchange"""

    execution_id: Optional[str] = None
    r"""Max Length 50 characters. Execution id from the street"""

    execution_only: Optional[bool] = None
    r"""Indicates whether Apex is the clearing broker for this trade"""

    external_id: Optional[str] = None
    r"""Max Length 50 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"""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"""Trade lots"""

    market: Optional[str] = None
    r"""\"MMAP\" for multi market average price, \"UNKN\" for unknown"""

    order_id: Optional[str] = None
    r"""Max Length 50 characters. Internally generated order id that is returned to client on exec reports"""

    prevailing_market_price: OptionalNullable[EntryFlipPrevailingMarketPrice] = UNSET
    r"""The price for the instrument that is prevailing in the market."""

    price_adjustment_record: OptionalNullable[EntryPriceAdjustmentRecord] = UNSET
    r"""Information about any price adjustments applied to the security"""

    route: Optional[str] = None
    r"""The execution route Apex used for this trade"""

    special_instructions: Optional[List[str]] = None
    r"""Special instructions for the trade"""

    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_booking_execution_id",
            "booking_api_trade_allocation_id",
            "booking_api_trade_id",
            "broker",
            "broker_capacity",
            "client_memo",
            "client_order_id",
            "exchange",
            "execution_id",
            "execution_only",
            "external_id",
            "fund_confirmation_number",
            "gateway_client_order_id",
            "internal_error",
            "is_writeoff",
            "lots",
            "market",
            "order_id",
            "prevailing_market_price",
            "price_adjustment_record",
            "route",
            "special_instructions",
            "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 FlipTypedDict(TypedDict):
    r"""Object containing metadata for a Flip"""

    detail: NotRequired[Nullable[DetailTypedDict]]
    r"""Provides additional details for trades"""


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

    detail: OptionalNullable[Detail] = UNSET
    r"""Provides additional details for trades"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["detail"]
        nullable_fields = ["detail"]
        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 EntryFpslAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Indicates whether shares are being allocated or deallocated"""

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


class FpslTypedDict(TypedDict):
    r"""Object containing metadata for fully paid stock lending entries"""

    action: NotRequired[EntryFpslAction]
    r"""Indicates whether shares are being allocated or deallocated"""


class Fpsl(BaseModel):
    r"""Object containing metadata for fully paid stock lending entries"""

    action: Annotated[
        Optional[EntryFpslAction], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Indicates whether shares are being allocated or deallocated"""


class GrossAmountTypedDict(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 GrossAmount(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 InterestAccrualEndDateTypedDict(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 InterestAccrualEndDate(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 InterestAccrualStartDateTypedDict(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 InterestAccrualStartDate(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 InterestType(str, Enum, metaclass=utils.OpenEnumMeta):
    INTEREST_TYPE_UNSPECIFIED = "INTEREST_TYPE_UNSPECIFIED"
    CREDIT = "CREDIT"
    DEBIT = "DEBIT"


class InterestTypedDict(TypedDict):
    r"""Object containing metadata for Margin interest"""

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


class Interest(BaseModel):
    r"""Object containing metadata for Margin interest"""

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

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

    interest_type: Annotated[
        Optional[InterestType], 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 EntryInterestPaymentCashRateTypedDict(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 EntryInterestPaymentCashRate(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 EntryInterestPaymentCorporateActionGeneralInformationTypedDict(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 EntryInterestPaymentCorporateActionGeneralInformation(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 EntryInterestPaymentPaymentDateTypedDict(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 EntryInterestPaymentPaymentDate(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 EntryInterestPaymentRecordDateTypedDict(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 EntryInterestPaymentRecordDate(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 EntrySettledTypedDict(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 EntrySettled(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 InterestPaymentTypedDict(TypedDict):
    r"""Object containing metadata for interest payments"""

    cash_rate: NotRequired[Nullable[EntryInterestPaymentCashRateTypedDict]]
    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[EntryInterestPaymentCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[EntryInterestPaymentPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    record_date: NotRequired[Nullable[EntryInterestPaymentRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""
    settled: NotRequired[Nullable[EntrySettledTypedDict]]
    r"""Corresponds to the position's settled quantity"""


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

    cash_rate: OptionalNullable[EntryInterestPaymentCashRate] = 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[
        EntryInterestPaymentCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

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

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

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

    @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 EntryLiquidationAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Corresponds to whether the entry is incoming outgoing"""

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


class EntryLiquidationCashRateTypedDict(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 EntryLiquidationCashRate(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 EntryLiquidationCorporateActionGeneralInformationTypedDict(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 EntryLiquidationCorporateActionGeneralInformation(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 EntryEffectiveDateTypedDict(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 EntryEffectiveDate(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 EntryLiquidationPaymentDateTypedDict(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 EntryLiquidationPaymentDate(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 EntryLiquidationQuantityTypedDict(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 EntryLiquidationQuantity(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 EntryLiquidationRecordDateTypedDict(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 EntryLiquidationRecordDate(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 EntryLiquidationSettledTypedDict(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 EntryLiquidationSettled(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 EntrySubtype(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Corresponds to the subtype of corporaction type"""

    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 LiquidationTypedDict(TypedDict):
    r"""Object containing metadata for liquidations"""

    action: NotRequired[EntryLiquidationAction]
    r"""Corresponds to whether the entry is incoming outgoing"""
    cash_rate: NotRequired[Nullable[EntryLiquidationCashRateTypedDict]]
    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[EntryLiquidationCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    effective_date: NotRequired[Nullable[EntryEffectiveDateTypedDict]]
    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[EntryLiquidationPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository."""
    quantity: NotRequired[Nullable[EntryLiquidationQuantityTypedDict]]
    r"""Corresponds to the position's trade quantity"""
    record_date: NotRequired[Nullable[EntryLiquidationRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""
    settled: NotRequired[Nullable[EntryLiquidationSettledTypedDict]]
    r"""Corresponds to the position's settled quantity"""
    subtype: NotRequired[EntrySubtype]
    r"""Corresponds to the subtype of corporaction type"""


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

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

    cash_rate: OptionalNullable[EntryLiquidationCashRate] = 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[
        EntryLiquidationCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    effective_date: OptionalNullable[EntryEffectiveDate] = 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[EntryLiquidationPaymentDate] = UNSET
    r"""The anticipated payment date at the depository."""

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

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

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

    subtype: Annotated[
        Optional[EntrySubtype], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Corresponds to the subtype of corporaction type"""

    @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 EntryMaturityCashRateTypedDict(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 EntryMaturityCashRate(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 EntryMaturityCorporateActionGeneralInformationTypedDict(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 EntryMaturityCorporateActionGeneralInformation(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 EntryMaturityPaymentDateTypedDict(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 EntryMaturityPaymentDate(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 EntryMaturityQuantityTypedDict(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 EntryMaturityQuantity(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 MaturityTypedDict(TypedDict):
    r"""Object containing metadata for maturity events"""

    cash_rate: NotRequired[Nullable[EntryMaturityCashRateTypedDict]]
    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[EntryMaturityCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[EntryMaturityPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository."""
    quantity: NotRequired[Nullable[EntryMaturityQuantityTypedDict]]
    r"""The trade position quantity used to calculate the disbursed amount"""


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

    cash_rate: OptionalNullable[EntryMaturityCashRate] = 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[
        EntryMaturityCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

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

    quantity: OptionalNullable[EntryMaturityQuantity] = 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 EntryMergerAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Corresponds to whether the entry is incoming outgoing"""

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


class EntryMergerCashRateTypedDict(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 EntryMergerCashRate(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 EntryMergerCorporateActionGeneralInformationTypedDict(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 EntryMergerCorporateActionGeneralInformation(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 EntryMergerEffectiveDateTypedDict(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 EntryMergerEffectiveDate(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 EntryMergerQuantityTypedDict(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 EntryMergerQuantity(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 EntryMergerStockRateTypedDict(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 EntryMergerStockRate(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 EntryMergerType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Corresponds to whether the event is CASH | STOCK | CASH_AND_STOCK"""

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


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

    action: NotRequired[EntryMergerAction]
    r"""Corresponds to whether the entry is incoming outgoing"""
    cash_rate: NotRequired[Nullable[EntryMergerCashRateTypedDict]]
    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[EntryMergerCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    effective_date: NotRequired[Nullable[EntryMergerEffectiveDateTypedDict]]
    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[EntryMergerQuantityTypedDict]]
    r"""Corresponds to the position's trade quantity"""
    stock_rate: NotRequired[Nullable[EntryMergerStockRateTypedDict]]
    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[EntryMergerType]
    r"""Corresponds to whether the event is CASH | STOCK | CASH_AND_STOCK"""


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

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

    cash_rate: OptionalNullable[EntryMergerCashRate] = 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[
        EntryMergerCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

    effective_date: OptionalNullable[EntryMergerEffectiveDate] = 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[EntryMergerQuantity] = UNSET
    r"""Corresponds to the position's trade quantity"""

    stock_rate: OptionalNullable[EntryMergerStockRate] = 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[EntryMergerType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Corresponds to whether the event is CASH | STOCK | CASH_AND_STOCK"""

    @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 EntryNameChangeAction(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Corresponds to whether the entry is incoming outgoing"""

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


class EntryNameChangeCorporateActionGeneralInformationTypedDict(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 EntryNameChangeCorporateActionGeneralInformation(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 EntryNameChangeEffectiveDateTypedDict(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 EntryNameChangeEffectiveDate(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 EntryNameChangeQuantityTypedDict(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 EntryNameChangeQuantity(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 NameChangeTypedDict(TypedDict):
    r"""Object containing metadata for name changes"""

    action: NotRequired[EntryNameChangeAction]
    r"""Corresponds to whether the entry is incoming outgoing"""
    corporate_action_general_information: NotRequired[
        Nullable[EntryNameChangeCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    effective_date: NotRequired[Nullable[EntryNameChangeEffectiveDateTypedDict]]
    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[EntryNameChangeQuantityTypedDict]]
    r"""Corresponds to the position's settled quantity"""


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

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

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

    effective_date: OptionalNullable[EntryNameChangeEffectiveDate] = 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[EntryNameChangeQuantity] = UNSET
    r"""Corresponds to the position's settled quantity"""

    @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 OriginalProcessDateTypedDict(TypedDict):
    r"""The original entry process date; stable across reversals and corrections; use for maintaining lineage of entries through multiple corrections/reversals"""

    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 OriginalProcessDate(BaseModel):
    r"""The original entry process date; stable across reversals and corrections; use for maintaining lineage of entries through multiple corrections/reversals"""

    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 EntryPaymentInKindCorporateActionGeneralInformationTypedDict(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 EntryPaymentInKindCorporateActionGeneralInformation(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 EntryPaymentInKindPaymentDateTypedDict(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 EntryPaymentInKindPaymentDate(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 EntryPaymentInKindRecordDateTypedDict(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 EntryPaymentInKindRecordDate(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 EntryPaymentInKindSettledTypedDict(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 EntryPaymentInKindSettled(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 EntryPaymentInKindStockRateTypedDict(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 EntryPaymentInKindStockRate(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 PaymentInKindTypedDict(TypedDict):
    r"""Object containing metadata for PaymentInKind"""

    corporate_action_general_information: NotRequired[
        Nullable[EntryPaymentInKindCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[EntryPaymentInKindPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    record_date: NotRequired[Nullable[EntryPaymentInKindRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""
    settled: NotRequired[Nullable[EntryPaymentInKindSettledTypedDict]]
    r"""Corresponds to the position's settled quantity"""
    stock_rate: NotRequired[Nullable[EntryPaymentInKindStockRateTypedDict]]
    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 PaymentInKind(BaseModel):
    r"""Object containing metadata for PaymentInKind"""

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

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

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

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

    stock_rate: OptionalNullable[EntryPaymentInKindStockRate] = 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 EntryPriceTypedDict(TypedDict):
    r"""The monetary value paid for a given security in a trade Required, except for currency movements"""

    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 EntryPrice(BaseModel):
    r"""The monetary value paid for a given security in a trade Required, except for currency movements"""

    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 EntryProcessDateTypedDict(TypedDict):
    r"""The date that the entry was booked on"""

    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 EntryProcessDate(BaseModel):
    r"""The date that the entry was booked on"""

    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 EntryQuantityTypedDict(TypedDict):
    r"""The quantity of shares bought, sold, or moved. For entries/ activities involving Fixed Income assets, quantity is expressed as par value Required for trades and memos, optional for movements."""

    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 EntryQuantity(BaseModel):
    r"""The quantity of shares bought, sold, or moved. For entries/ activities involving Fixed Income assets, quantity is expressed as par value Required for trades and memos, optional for movements."""

    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 ReceiveTypedDict(TypedDict):
    r"""Object containing metadata for receive events"""


class Receive(BaseModel):
    r"""Object containing metadata for receive events"""


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

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


class EntryRedemptionFullCashRateTypedDict(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 EntryRedemptionFullCashRate(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 EntryRedemptionFullCorporateActionGeneralInformationTypedDict(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 EntryRedemptionFullCorporateActionGeneralInformation(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 EntryRedemptionFullPaymentDateTypedDict(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 EntryRedemptionFullPaymentDate(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 EntryRedemptionFullQuantityTypedDict(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 EntryRedemptionFullQuantity(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 EntryRedemptionFullSubtype(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Corresponds to the subtype of corporaction type"""

    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 RedemptionFullTypedDict(TypedDict):
    r"""Object containing more information about a redemption"""

    action: NotRequired[EntryRedemptionFullAction]
    r"""Corresponds to whether the entry is incoming outgoing"""
    cash_rate: NotRequired[Nullable[EntryRedemptionFullCashRateTypedDict]]
    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[EntryRedemptionFullCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[EntryRedemptionFullPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository."""
    quantity: NotRequired[Nullable[EntryRedemptionFullQuantityTypedDict]]
    r"""Corresponds to the position's trade quantity"""
    subtype: NotRequired[EntryRedemptionFullSubtype]
    r"""Corresponds to the subtype of corporaction type"""


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

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

    cash_rate: OptionalNullable[EntryRedemptionFullCashRate] = 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[
        EntryRedemptionFullCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

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

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

    subtype: Annotated[
        Optional[EntryRedemptionFullSubtype], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Corresponds to the subtype of corporaction type"""

    @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 EntryRedemptionPartialAction(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 EntryRedemptionPartialCashRateTypedDict(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 EntryRedemptionPartialCashRate(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 EntryRedemptionPartialCorporateActionGeneralInformationTypedDict(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 EntryRedemptionPartialCorporateActionGeneralInformation(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 EntryRedemptionPartialPaymentDateTypedDict(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 EntryRedemptionPartialPaymentDate(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 EntryRedemptionPartialQuantityTypedDict(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 EntryRedemptionPartialQuantity(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 RedemptionPartialTypedDict(TypedDict):
    r"""Object containing metadata for partial redemption"""

    action: NotRequired[EntryRedemptionPartialAction]
    r"""Corresponds to whether the entry is incoming or outgoing"""
    cash_rate: NotRequired[Nullable[EntryRedemptionPartialCashRateTypedDict]]
    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[EntryRedemptionPartialCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[EntryRedemptionPartialPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""
    quantity: NotRequired[Nullable[EntryRedemptionPartialQuantityTypedDict]]
    r"""Corresponds to the position's trade quantity"""


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

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

    cash_rate: OptionalNullable[EntryRedemptionPartialCashRate] = 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[
        EntryRedemptionPartialCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

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

    quantity: OptionalNullable[EntryRedemptionPartialQuantity] = 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 EntryReverseStockSplitAction(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 EntryReverseStockSplitCorporateActionGeneralInformationTypedDict(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 EntryReverseStockSplitCorporateActionGeneralInformation(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 EntryReverseStockSplitEffectiveDateTypedDict(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 EntryReverseStockSplitEffectiveDate(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 FactorDenominatorTypedDict(TypedDict):
    r"""The previous rate of the security before the distribution"""

    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 FactorDenominator(BaseModel):
    r"""The previous rate of the security before the distribution"""

    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 FactorNumeratorTypedDict(TypedDict):
    r"""The rate of the security distribution"""

    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 FactorNumerator(BaseModel):
    r"""The rate of the security distribution"""

    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 EntryReverseStockSplitQuantityTypedDict(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 EntryReverseStockSplitQuantity(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 EntryReverseStockSplitStockRateTypedDict(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 EntryReverseStockSplitStockRate(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 ReverseStockSplitTypedDict(TypedDict):
    r"""Object containing metadata for a reverse_stock_split"""

    action: NotRequired[EntryReverseStockSplitAction]
    r"""Corresponds to whether the entry is incoming or outgoing"""
    corporate_action_general_information: NotRequired[
        Nullable[EntryReverseStockSplitCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    effective_date: NotRequired[Nullable[EntryReverseStockSplitEffectiveDateTypedDict]]
    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[FactorDenominatorTypedDict]]
    r"""The previous rate of the security before the distribution"""
    factor_numerator: NotRequired[Nullable[FactorNumeratorTypedDict]]
    r"""The rate of the security distribution"""
    quantity: NotRequired[Nullable[EntryReverseStockSplitQuantityTypedDict]]
    r"""Corresponds to the position's trade quantity"""
    stock_rate: NotRequired[Nullable[EntryReverseStockSplitStockRateTypedDict]]
    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 ReverseStockSplit(BaseModel):
    r"""Object containing metadata for a reverse_stock_split"""

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

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

    effective_date: OptionalNullable[EntryReverseStockSplitEffectiveDate] = 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[FactorDenominator] = UNSET
    r"""The previous rate of the security before the distribution"""

    factor_numerator: OptionalNullable[FactorNumerator] = UNSET
    r"""The rate of the security distribution"""

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

    stock_rate: OptionalNullable[EntryReverseStockSplitStockRate] = 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 = [
            "action",
            "corporate_action_general_information",
            "effective_date",
            "factor_denominator",
            "factor_numerator",
            "quantity",
            "stock_rate",
        ]
        nullable_fields = [
            "corporate_action_general_information",
            "effective_date",
            "factor_denominator",
            "factor_numerator",
            "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 EntryRightsDistributionCorporateActionGeneralInformationTypedDict(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 EntryRightsDistributionCorporateActionGeneralInformation(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 EntryRightsDistributionPaymentDateTypedDict(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 EntryRightsDistributionPaymentDate(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 EntryRightsDistributionRecordDateTypedDict(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 EntryRightsDistributionRecordDate(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 EntryRightsDistributionSettledTypedDict(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 EntryRightsDistributionSettled(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 RightsDistributionTypedDict(TypedDict):
    r"""Object containing more information about a rights distribution"""

    corporate_action_general_information: NotRequired[
        Nullable[EntryRightsDistributionCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[EntryRightsDistributionPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository."""
    record_date: NotRequired[Nullable[EntryRightsDistributionRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""
    settled: NotRequired[Nullable[EntryRightsDistributionSettledTypedDict]]
    r"""Corresponds to the position's settled quantity"""


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

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

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

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

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

    @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 EntryRightsSubscriptionCorporateActionGeneralInformationTypedDict(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 EntryRightsSubscriptionCorporateActionGeneralInformation(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 RightsSubscriptionTypedDict(TypedDict):
    r"""Object containing metadata for rights subscriptions"""

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


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

    corporate_action_general_information: OptionalNullable[
        EntryRightsSubscriptionCorporateActionGeneralInformation
    ] = 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 RoundingAdjustmentTypedDict(TypedDict):
    r"""Object containing metadata for rounding"""

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


class RoundingAdjustment(BaseModel):
    r"""Object containing metadata for rounding"""

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


class EntrySaleOfRightsCashRateTypedDict(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 EntrySaleOfRightsCashRate(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 EntrySaleOfRightsCorporateActionGeneralInformationTypedDict(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 EntrySaleOfRightsCorporateActionGeneralInformation(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 EntrySaleOfRightsPaymentDateTypedDict(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 EntrySaleOfRightsPaymentDate(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 EntrySaleOfRightsRecordDateTypedDict(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 EntrySaleOfRightsRecordDate(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 EntrySaleOfRightsSettledTypedDict(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 EntrySaleOfRightsSettled(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 SaleOfRightsTypedDict(TypedDict):
    r"""Object containing more information about a sale_of_rights"""

    cash_rate: NotRequired[Nullable[EntrySaleOfRightsCashRateTypedDict]]
    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[EntrySaleOfRightsCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    payment_date: NotRequired[Nullable[EntrySaleOfRightsPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository."""
    record_date: NotRequired[Nullable[EntrySaleOfRightsRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""
    settled: NotRequired[Nullable[EntrySaleOfRightsSettledTypedDict]]
    r"""Corresponds to the position's settled quantity"""


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

    cash_rate: OptionalNullable[EntrySaleOfRightsCashRate] = 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[
        EntrySaleOfRightsCorporateActionGeneralInformation
    ] = UNSET
    r"""Common fields for corporate actions"""

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

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

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

    @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 SettleDateTypedDict(TypedDict):
    r"""The date a given entry/ 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 SettleDate(BaseModel):
    r"""The date a given entry/ 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 EntrySide(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Denotes whether the trade is a buy or sell"""

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


class SideModifier(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Additional information about a trade Should be populated if possible for trades; the side modifier for the trade"""

    SIDE_MODIFIER_UNSPECIFIED = "SIDE_MODIFIER_UNSPECIFIED"
    SHORT = "SHORT"
    SHORT_EXEMPT = "SHORT_EXEMPT"
    SHORT_COVER = "SHORT_COVER"
    OPEN = "OPEN"
    CLOSE = "CLOSE"


class EntrySpinOffCorporateActionGeneralInformationTypedDict(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 EntrySpinOffCorporateActionGeneralInformation(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 PayDateTypedDict(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 PayDate(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 EntrySpinOffQuantityTypedDict(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 EntrySpinOffQuantity(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 EntrySpinOffRateTypedDict(TypedDict):
    r"""The rate 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 EntrySpinOffRate(BaseModel):
    r"""The rate 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 EntrySpinOffRecordDateTypedDict(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 EntrySpinOffRecordDate(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 SpinOffTypedDict(TypedDict):
    r"""Object containing metadata for spinoffs"""

    corporate_action_general_information: NotRequired[
        Nullable[EntrySpinOffCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    pay_date: NotRequired[Nullable[PayDateTypedDict]]
    r"""The anticipated payment date at the depository."""
    quantity: NotRequired[Nullable[EntrySpinOffQuantityTypedDict]]
    r"""Corresponds to the position's settled quantity"""
    rate: NotRequired[Nullable[EntrySpinOffRateTypedDict]]
    r"""The rate at which shares will be disbursed to the shareholder"""
    record_date: NotRequired[Nullable[EntrySpinOffRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""


class SpinOff(BaseModel):
    r"""Object containing metadata for spinoffs"""

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

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

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

    rate: OptionalNullable[EntrySpinOffRate] = UNSET
    r"""The rate at which shares will be disbursed to the shareholder"""

    record_date: OptionalNullable[EntrySpinOffRecordDate] = 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 EntryState(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Set to be NEW for BookEntries, other statuses will be assigned via ModifyActivities; the state of the entry"""

    ENTRY_STATE_UNSPECIFIED = "ENTRY_STATE_UNSPECIFIED"
    NEW = "NEW"
    REVERSAL = "REVERSAL"
    CORRECTION = "CORRECTION"


class EntryStockDividendCorporateActionGeneralInformationTypedDict(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 EntryStockDividendCorporateActionGeneralInformation(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 EntryPayDateTypedDict(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 EntryPayDate(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 EntryStockDividendQuantityTypedDict(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 EntryStockDividendQuantity(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 EntryRateTypedDict(TypedDict):
    r"""The rate 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 EntryRate(BaseModel):
    r"""The rate 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 EntryStockDividendRecordDateTypedDict(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 EntryStockDividendRecordDate(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 StockDividendTypedDict(TypedDict):
    r"""Object containing metadata for stock dividends"""

    corporate_action_general_information: NotRequired[
        Nullable[EntryStockDividendCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    pay_date: NotRequired[Nullable[EntryPayDateTypedDict]]
    r"""The anticipated payment date at the depository."""
    quantity: NotRequired[Nullable[EntryStockDividendQuantityTypedDict]]
    r"""Corresponds to the position's settled quantity"""
    rate: NotRequired[Nullable[EntryRateTypedDict]]
    r"""The rate at which shares will be disbursed to the shareholder"""
    record_date: NotRequired[Nullable[EntryStockDividendRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""


class StockDividend(BaseModel):
    r"""Object containing metadata for stock dividends"""

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

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

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

    rate: OptionalNullable[EntryRate] = UNSET
    r"""The rate at which shares will be disbursed to the shareholder"""

    record_date: OptionalNullable[EntryStockDividendRecordDate] = 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 EntryStockSplitCorporateActionGeneralInformationTypedDict(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 EntryStockSplitCorporateActionGeneralInformation(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 EntryFactorDenominatorTypedDict(TypedDict):
    r"""The previous rate of the security before the distribution"""

    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 EntryFactorDenominator(BaseModel):
    r"""The previous rate of the security before the distribution"""

    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 EntryFactorNumeratorTypedDict(TypedDict):
    r"""The rate of the security distribution"""

    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 EntryFactorNumerator(BaseModel):
    r"""The rate of the security distribution"""

    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 EntryStockSplitPayDateTypedDict(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 EntryStockSplitPayDate(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 EntryStockSplitQuantityTypedDict(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 EntryStockSplitQuantity(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 EntryStockSplitRecordDateTypedDict(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 EntryStockSplitRecordDate(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 StockSplitTypedDict(TypedDict):
    r"""Object containing metadata for stock splits"""

    corporate_action_general_information: NotRequired[
        Nullable[EntryStockSplitCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    factor_denominator: NotRequired[Nullable[EntryFactorDenominatorTypedDict]]
    r"""The previous rate of the security before the distribution"""
    factor_numerator: NotRequired[Nullable[EntryFactorNumeratorTypedDict]]
    r"""The rate of the security distribution"""
    pay_date: NotRequired[Nullable[EntryStockSplitPayDateTypedDict]]
    r"""The anticipated payment date at the depository."""
    quantity: NotRequired[Nullable[EntryStockSplitQuantityTypedDict]]
    r"""Corresponds to the position's trade quantity"""
    record_date: NotRequired[Nullable[EntryStockSplitRecordDateTypedDict]]
    r"""The date on which positions are recorded in order to calculate entitlement"""


class StockSplit(BaseModel):
    r"""Object containing metadata for stock splits"""

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

    factor_denominator: OptionalNullable[EntryFactorDenominator] = UNSET
    r"""The previous rate of the security before the distribution"""

    factor_numerator: OptionalNullable[EntryFactorNumerator] = UNSET
    r"""The rate of the security distribution"""

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

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

    record_date: OptionalNullable[EntryStockSplitRecordDate] = 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 EntrySweepAction(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 EntrySweepType(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 SweepTypedDict(TypedDict):
    r"""Object containing metadata for sweeps"""

    action: NotRequired[EntrySweepAction]
    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[EntrySweepType]
    r"""Sweep program that cash is being swept to/ from"""


class Sweep(BaseModel):
    r"""Object containing metadata for sweeps"""

    action: Annotated[
        Optional[EntrySweepAction], 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[EntrySweepType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Sweep program that cash is being swept to/ from"""


class EntryTenderOfferCashRateTypedDict(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 EntryTenderOfferCashRate(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 EntryTenderOfferCorporateActionGeneralInformationTypedDict(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 EntryTenderOfferCorporateActionGeneralInformation(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 TenderOfferTypedDict(TypedDict):
    r"""Object containing metadata for tender offers"""

    cash_rate: NotRequired[Nullable[EntryTenderOfferCashRateTypedDict]]
    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[EntryTenderOfferCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""


class TenderOffer(BaseModel):
    r"""Object containing metadata for tender offers"""

    cash_rate: OptionalNullable[EntryTenderOfferCashRate] = 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[
        EntryTenderOfferCorporateActionGeneralInformation
    ] = 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 EntryBrokerCapacity(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Used to calculate broadridge blotter code"""

    CAPACITY_UNSPECIFIED = "CAPACITY_UNSPECIFIED"
    AGENCY = "AGENCY"
    PRINCIPAL = "PRINCIPAL"
    MIXED = "MIXED"


class EntryPrevailingMarketPriceTypedDict(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 EntryPrevailingMarketPrice(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 PriceAdjustmentAmountTypedDict(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 PriceAdjustmentAmount(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 PriceAdjustmentPercentTypedDict(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 PriceAdjustmentPercent(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 PriceAdjustmentType(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 PriceAdjustmentRecordTypedDict(TypedDict):
    r"""Information about any price adjustments applied to the security"""

    price_adjustment_amount: NotRequired[Nullable[PriceAdjustmentAmountTypedDict]]
    r"""Total monetary value of the price_adjustment"""
    price_adjustment_percent: NotRequired[Nullable[PriceAdjustmentPercentTypedDict]]
    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[PriceAdjustmentType]
    r"""The type of price adjustment being applied by the broker to the net price of the security."""


class PriceAdjustmentRecord(BaseModel):
    r"""Information about any price adjustments applied to the security"""

    price_adjustment_amount: OptionalNullable[PriceAdjustmentAmount] = UNSET
    r"""Total monetary value of the price_adjustment"""

    price_adjustment_percent: OptionalNullable[PriceAdjustmentPercent] = 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[PriceAdjustmentType], 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 TradeTypedDict(TypedDict):
    r"""Object containing metadata for trades"""

    additional_instructions: NotRequired[List[str]]
    r"""To be populated by the submitter of the trade detail"""
    alternate_order_id: NotRequired[str]
    r"""Max Length 50 characters. Alternate order id from the street used for FRAC trades"""
    booking_api_booking_execution_id: NotRequired[str]
    r"""base64 encoded value assigned by the Booking API to all executions"""
    booking_api_trade_allocation_id: NotRequired[str]
    r"""base64 encoded value assigned by the Booking API if a trade belongs to an allocation"""
    booking_api_trade_id: NotRequired[str]
    r"""base64 encoded value assigned by the Booking API to all trades"""
    broker: NotRequired[str]
    r"""Executing broker of the trade"""
    broker_capacity: NotRequired[EntryBrokerCapacity]
    r"""Used to calculate broadridge blotter code"""
    client_memo: NotRequired[str]
    r"""client usage area (intact). len 20"""
    client_order_id: NotRequired[str]
    r"""Max Length 50 characters. Client provided order id present in exec reports"""
    exchange: NotRequired[str]
    r"""MIC code for the exchange"""
    execution_id: NotRequired[str]
    r"""Max Length 50 characters. Execution id from the street"""
    execution_only: NotRequired[bool]
    r"""Indicates whether Apex is the clearing broker for this trade"""
    external_id: NotRequired[str]
    r"""Max Length 50 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"""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"""Trade lots"""
    market: NotRequired[str]
    r"""\"MMAP\" for multi market average price, \"UNKN\" for unknown"""
    order_id: NotRequired[str]
    r"""Max Length 50 characters. Internally generated order id that is returned to client on exec reports"""
    prevailing_market_price: NotRequired[Nullable[EntryPrevailingMarketPriceTypedDict]]
    r"""The price for the instrument that is prevailing in the market."""
    price_adjustment_record: NotRequired[Nullable[PriceAdjustmentRecordTypedDict]]
    r"""Information about any price adjustments applied to the security"""
    route: NotRequired[str]
    r"""The execution route Apex used for this trade"""
    special_instructions: NotRequired[List[str]]
    r"""Special instructions for the trade"""
    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 Trade(BaseModel):
    r"""Object containing metadata for trades"""

    additional_instructions: Optional[List[str]] = None
    r"""To be populated by the submitter of the trade detail"""

    alternate_order_id: Optional[str] = None
    r"""Max Length 50 characters. Alternate order id from the street used for FRAC trades"""

    booking_api_booking_execution_id: Optional[str] = None
    r"""base64 encoded value assigned by the Booking API to all executions"""

    booking_api_trade_allocation_id: Optional[str] = None
    r"""base64 encoded value assigned by the Booking API if a trade belongs to an allocation"""

    booking_api_trade_id: Optional[str] = None
    r"""base64 encoded value assigned by the Booking API to all trades"""

    broker: Optional[str] = None
    r"""Executing broker of the trade"""

    broker_capacity: Annotated[
        Optional[EntryBrokerCapacity], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Used to calculate broadridge blotter code"""

    client_memo: Optional[str] = None
    r"""client usage area (intact). len 20"""

    client_order_id: Optional[str] = None
    r"""Max Length 50 characters. Client provided order id present in exec reports"""

    exchange: Optional[str] = None
    r"""MIC code for the exchange"""

    execution_id: Optional[str] = None
    r"""Max Length 50 characters. Execution id from the street"""

    execution_only: Optional[bool] = None
    r"""Indicates whether Apex is the clearing broker for this trade"""

    external_id: Optional[str] = None
    r"""Max Length 50 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"""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"""Trade lots"""

    market: Optional[str] = None
    r"""\"MMAP\" for multi market average price, \"UNKN\" for unknown"""

    order_id: Optional[str] = None
    r"""Max Length 50 characters. Internally generated order id that is returned to client on exec reports"""

    prevailing_market_price: OptionalNullable[EntryPrevailingMarketPrice] = UNSET
    r"""The price for the instrument that is prevailing in the market."""

    price_adjustment_record: OptionalNullable[PriceAdjustmentRecord] = UNSET
    r"""Information about any price adjustments applied to the security"""

    route: Optional[str] = None
    r"""The execution route Apex used for this trade"""

    special_instructions: Optional[List[str]] = None
    r"""Special instructions for the trade"""

    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_booking_execution_id",
            "booking_api_trade_allocation_id",
            "booking_api_trade_id",
            "broker",
            "broker_capacity",
            "client_memo",
            "client_order_id",
            "exchange",
            "execution_id",
            "execution_only",
            "external_id",
            "fund_confirmation_number",
            "gateway_client_order_id",
            "internal_error",
            "is_writeoff",
            "lots",
            "market",
            "order_id",
            "prevailing_market_price",
            "price_adjustment_record",
            "route",
            "special_instructions",
            "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 EntryTransferType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Provides more detail on the type of transfer"""

    TRANSFER_TYPE_UNSPECIFIED = "TRANSFER_TYPE_UNSPECIFIED"
    TRANSFER_CONVERSION = "TRANSFER_CONVERSION"
    DECONVERSION = "DECONVERSION"
    MIGRATION = "MIGRATION"
    MANUAL_ADJUSTMENT = "MANUAL_ADJUSTMENT"


class TransferTypedDict(TypedDict):
    r"""Object containing metadata for transfers"""

    additional_instructions: NotRequired[str]
    r"""Free form text field"""
    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[EntryTransferType]
    r"""Provides more detail on the type of transfer"""


class Transfer(BaseModel):
    r"""Object containing metadata for transfers"""

    additional_instructions: Optional[str] = None
    r"""Free form text field"""

    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[EntryTransferType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Provides more detail on the type of transfer"""


class EntryType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The Type of the entry; determines the set of mandatory fields as well as informing downstream processes how to handle this record"""

    TYPE_UNSPECIFIED = "TYPE_UNSPECIFIED"
    TRADE = "TRADE"
    MOVEMENT = "MOVEMENT"
    MEMO = "MEMO"
    CORPORATE_ACTION = "CORPORATE_ACTION"


class EntryUnitSplitCorporateActionGeneralInformationTypedDict(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 EntryUnitSplitCorporateActionGeneralInformation(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 EntryUnitSplitStockRateTypedDict(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 EntryUnitSplitStockRate(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 UnitSplitTypedDict(TypedDict):
    r"""Object containing metadata for unit splits"""

    corporate_action_general_information: NotRequired[
        Nullable[EntryUnitSplitCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    stock_rate: NotRequired[Nullable[EntryUnitSplitStockRateTypedDict]]
    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 UnitSplit(BaseModel):
    r"""Object containing metadata for unit splits"""

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

    stock_rate: OptionalNullable[EntryUnitSplitStockRate] = 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 EntryWarrantExerciseCorporateActionGeneralInformationTypedDict(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 EntryWarrantExerciseCorporateActionGeneralInformation(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 WarrantExerciseTypedDict(TypedDict):
    r"""Object containing metadata for warrant exercises"""

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


class WarrantExercise(BaseModel):
    r"""Object containing metadata for warrant exercises"""

    corporate_action_general_information: OptionalNullable[
        EntryWarrantExerciseCorporateActionGeneralInformation
    ] = 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 DistributionType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Provides information on the reason for the distribution from a retirement account"""

    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 RetirementType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Used for descriptive purposes only. Indicates the type of retirement account"""

    RETIREMENT_TYPE_UNSPECIFIED = "RETIREMENT_TYPE_UNSPECIFIED"
    IRA = "IRA"
    SEP = "SEP"
    SIMPLE = "SIMPLE"
    KEOGH = "KEOGH"
    ROTH = "ROTH"
    QP = "QP"
    ROLLOVER_IRA = "ROLLOVER_IRA"


class EntryWithdrawalType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Provides information on the method through which a deposit/ withdrawal was initiated"""

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


class WithdrawalTypedDict(TypedDict):
    r"""Object containing metadata for withdrawals"""

    additional_instructions: NotRequired[str]
    r"""Free form text field"""
    closing_account: NotRequired[bool]
    r"""Indicates the withdrawal was part of an account closure"""
    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"""If populated, provides information on the institution the funds have been sent to"""
    distribution_type: NotRequired[DistributionType]
    r"""Provides information on the reason for the distribution from a retirement account"""
    distribution_year: NotRequired[int]
    r"""tax year associated with the distribution"""
    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_institution: NotRequired[str]
    r"""If populated, provides information on the institution where the funds originated"""
    periodic: NotRequired[bool]
    retirement_type: NotRequired[RetirementType]
    r"""Used for descriptive purposes only. Indicates the type of retirement account"""
    type: NotRequired[EntryWithdrawalType]
    r"""Provides information on the method through which a deposit/ withdrawal was initiated"""


class Withdrawal(BaseModel):
    r"""Object containing metadata for withdrawals"""

    additional_instructions: Optional[str] = None
    r"""Free form text field"""

    closing_account: Optional[bool] = None
    r"""Indicates the withdrawal was part of an account closure"""

    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"""If populated, provides information on the institution the funds have been sent to"""

    distribution_type: Annotated[
        Optional[DistributionType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Provides information on the reason for the distribution from a retirement account"""

    distribution_year: Optional[int] = None
    r"""tax year associated with the distribution"""

    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_institution: Optional[str] = None
    r"""If populated, provides information on the institution where the funds originated"""

    periodic: Optional[bool] = None

    retirement_type: Annotated[
        Optional[RetirementType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Used for descriptive purposes only. Indicates the type of retirement account"""

    type: Annotated[
        Optional[EntryWithdrawalType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Provides information on the method through which a deposit/ withdrawal was initiated"""


class Review(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""Indicates the state of the withdrawal review"""

    REVIEW_STATE_UNSPECIFIED = "REVIEW_STATE_UNSPECIFIED"
    REVIEW_STATE_PENDING = "REVIEW_STATE_PENDING"
    REVIEW_STATE_COMPLETE = "REVIEW_STATE_COMPLETE"


class WithdrawalPendingReviewTypedDict(TypedDict):
    r"""Object containing metadata about withdrawals that have been requested, but have not posted"""

    review: NotRequired[Review]
    r"""Indicates the state of the withdrawal review"""


class WithdrawalPendingReview(BaseModel):
    r"""Object containing metadata about withdrawals that have been requested, but have not posted"""

    review: Annotated[
        Optional[Review], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Indicates the state of the withdrawal review"""


class EntryWithholdingRateTypedDict(TypedDict):
    r"""the rate will be converted to a percentage in the activity description"""

    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 EntryWithholdingRate(BaseModel):
    r"""the rate will be converted to a percentage in the activity description"""

    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 EntryWithholdingState(str, Enum, metaclass=utils.OpenEnumMeta):
    WITHHOLDING_STATE_UNSPECIFIED = "WITHHOLDING_STATE_UNSPECIFIED"
    CA = "CA"
    ME = "ME"
    VT = "VT"
    AL = "AL"
    AK = "AK"
    AZ = "AZ"
    AR = "AR"
    CO = "CO"
    CT = "CT"
    DE = "DE"
    FL = "FL"
    GA = "GA"
    HI = "HI"
    ID = "ID"
    IL = "IL"
    IN = "IN"
    IA = "IA"
    KS = "KS"
    KY = "KY"
    LA = "LA"
    MD = "MD"
    MA = "MA"
    MI = "MI"
    MN = "MN"
    MS = "MS"
    MO = "MO"
    MT = "MT"
    NE = "NE"
    NV = "NV"
    NH = "NH"
    NJ = "NJ"
    NM = "NM"
    NY = "NY"
    NC = "NC"
    ND = "ND"
    OH = "OH"
    OK = "OK"
    OR = "OR"
    PA = "PA"
    RI = "RI"
    SC = "SC"
    SD = "SD"
    TN = "TN"
    TX = "TX"
    UT = "UT"
    VA = "VA"
    WA = "WA"
    WV = "WV"
    WI = "WI"
    WY = "WY"


class EntryWithholdingType(str, Enum, metaclass=utils.OpenEnumMeta):
    r"""The type of withholding"""

    WITHHOLDING_TYPE_UNSPECIFIED = "WITHHOLDING_TYPE_UNSPECIFIED"
    FEDERAL = "FEDERAL"
    STATE = "STATE"
    FOREIGN_SECURITY = "FOREIGN_SECURITY"
    FEDERAL_IRA = "FEDERAL_IRA"
    STATE_IRA = "STATE_IRA"
    NON_RESIDENT_ALIEN = "NON_RESIDENT_ALIEN"


class EntryWithholdingTypedDict(TypedDict):
    r"""Object containing metadata for tax withholdings"""

    rate: NotRequired[Nullable[EntryWithholdingRateTypedDict]]
    r"""the rate will be converted to a percentage in the activity description"""
    region_code: NotRequired[str]
    r"""Two character region code, complies with https://cldr.unicode.org/index"""
    state: NotRequired[EntryWithholdingState]
    tax_year: NotRequired[int]
    r"""The tax year associated with the withholding"""
    type: NotRequired[EntryWithholdingType]
    r"""The type of withholding"""


class EntryWithholding(BaseModel):
    r"""Object containing metadata for tax withholdings"""

    rate: OptionalNullable[EntryWithholdingRate] = UNSET
    r"""the rate will be converted to a percentage in the activity description"""

    region_code: Optional[str] = None
    r"""Two character region code, complies with https://cldr.unicode.org/index"""

    state: Annotated[
        Optional[EntryWithholdingState], PlainValidator(validate_open_enum(False))
    ] = None

    tax_year: Optional[int] = None
    r"""The tax year associated with the withholding"""

    type: Annotated[
        Optional[EntryWithholdingType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The type of withholding"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["rate", "region_code", "state", "tax_year", "type"]
        nullable_fields = ["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 EntryWorthlessCorporateActionGeneralInformationTypedDict(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 EntryWorthlessCorporateActionGeneralInformation(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 EntryWorthlessEffectiveDateTypedDict(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 EntryWorthlessEffectiveDate(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 EntryWorthlessPaymentDateTypedDict(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 EntryWorthlessPaymentDate(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 WorthlessTypedDict(TypedDict):
    r"""Object containing metadata for worthless events"""

    corporate_action_general_information: NotRequired[
        Nullable[EntryWorthlessCorporateActionGeneralInformationTypedDict]
    ]
    r"""Common fields for corporate actions"""
    effective_date: NotRequired[Nullable[EntryWorthlessEffectiveDateTypedDict]]
    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[EntryWorthlessPaymentDateTypedDict]]
    r"""The anticipated payment date at the depository"""


class Worthless(BaseModel):
    r"""Object containing metadata for worthless events"""

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

    effective_date: OptionalNullable[EntryWorthlessEffectiveDate] = 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[EntryWorthlessPaymentDate] = 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 EntryTypedDict(TypedDict):
    r"""Entry is a single sided ledger booking that serves as the core ledger component; it is sparsely populated based on the entry type and the goal of the entry"""

    acats_pending_out: NotRequired[Nullable[AcatsPendingOutTypedDict]]
    r"""Object containing metadata for pending outgoing acats"""
    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[AccountMemo]
    r"""Indicates the memo location impacted by an entry"""
    account_transfer: NotRequired[Nullable[AccountTransferTypedDict]]
    r"""Object containing metadata for account transfers"""
    accrued_interest: NotRequired[Nullable[EntryAccruedInterestTypedDict]]
    r"""Indicates that the entry references accrued interest that has been earned but not yet paid between the last interest payment and the date of the trade"""
    acquisition: NotRequired[Nullable[AcquisitionTypedDict]]
    r"""Object containing metadata for acquisition events"""
    activity_date: NotRequired[Nullable[ActivityDateTypedDict]]
    r"""The calendar date an activity took place For Trade entries, the activity date reflects the trade date of the market in which the trade was executed For Cash entries, this reflects the banking day the cash will be moved"""
    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_id: NotRequired[str]
    r"""An Apex-provided, global identifier created on a per asset bases which provides connectivity across all areas Required, except for currency movements which should instead have a currency_asset_id."""
    capital_gains: NotRequired[Nullable[CapitalGainsTypedDict]]
    r"""Object containing metadata for capital gains"""
    cash_dividend: NotRequired[Nullable[CashDividendTypedDict]]
    r"""Object containing for cash dividends"""
    commission: NotRequired[Nullable[EntryCommissionTypedDict]]
    r"""Indicates that the entry references commission charged by brokers or financial intermediaries for executing financial transactions on behalf of clients"""
    conversion: NotRequired[Nullable[ConversionTypedDict]]
    r"""Object containing metadata for conversions (Conversion of securities into another form of securities)"""
    corporate_action_memo_adjustment: NotRequired[
        Nullable[CorporateActionMemoAdjustmentTypedDict]
    ]
    r"""Object containing metadata for memo locations that have been adjusted due to a corporate action"""
    credit: NotRequired[Nullable[CreditTypedDict]]
    r"""Object containing more information about the credit being paid"""
    currency_asset_id: NotRequired[str]
    r"""The asset_id of the currency that all monetary values relate to Required for currency movements"""
    delivery: NotRequired[Nullable[DeliveryTypedDict]]
    r"""Object containing metadata for delivery events"""
    deposit: NotRequired[Nullable[DepositTypedDict]]
    r"""Object containing more information about a deposit"""
    description: NotRequired[str]
    r"""A plain text description of the entry; will not be available to search on or build other features off of"""
    drip: NotRequired[Nullable[DripTypedDict]]
    r"""Object containing metadata for reserving cash until the DRIP trades are executed"""
    entry_id: NotRequired[str]
    r"""The unique id of the entry"""
    exchange: NotRequired[Nullable[ExchangeTypedDict]]
    r"""Object containing metadata for exchanges"""
    fee: NotRequired[Nullable[EntryFeeTypedDict]]
    r"""Object containing more information about the fee being charged"""
    flip: NotRequired[Nullable[FlipTypedDict]]
    r"""Object containing metadata for a Flip"""
    fpsl: NotRequired[Nullable[FpslTypedDict]]
    r"""Object containing metadata for fully paid stock lending entries"""
    gross_amount: NotRequired[Nullable[GrossAmountTypedDict]]
    r"""The monetary value of an activity, exclusive of any fees (First money)"""
    interest: NotRequired[Nullable[InterestTypedDict]]
    r"""Object containing metadata for Margin interest"""
    interest_payment: NotRequired[Nullable[InterestPaymentTypedDict]]
    r"""Object containing metadata for interest payments"""
    liquidation: NotRequired[Nullable[LiquidationTypedDict]]
    r"""Object containing metadata for liquidations"""
    maturity: NotRequired[Nullable[MaturityTypedDict]]
    r"""Object containing metadata for maturity events"""
    merger: NotRequired[Nullable[MergerTypedDict]]
    r"""Object containing metadata for merger events"""
    name: NotRequired[str]
    r"""accounts/{account_id}/entries/{entry_id}"""
    name_change: NotRequired[Nullable[NameChangeTypedDict]]
    r"""Object containing metadata for name changes"""
    original_id: NotRequired[str]
    r"""The original entry id; stable across reversals and corrections; use for maintaining lineage of entries through multiple corrections/reversals"""
    original_process_date: NotRequired[Nullable[OriginalProcessDateTypedDict]]
    r"""The original entry process date; stable across reversals and corrections; use for maintaining lineage of entries through multiple corrections/reversals"""
    payment_in_kind: NotRequired[Nullable[PaymentInKindTypedDict]]
    r"""Object containing metadata for PaymentInKind"""
    price: NotRequired[Nullable[EntryPriceTypedDict]]
    r"""The monetary value paid for a given security in a trade Required, except for currency movements"""
    process_date: NotRequired[Nullable[EntryProcessDateTypedDict]]
    r"""The date that the entry was booked on"""
    quantity: NotRequired[Nullable[EntryQuantityTypedDict]]
    r"""The quantity of shares bought, sold, or moved. For entries/ activities involving Fixed Income assets, quantity is expressed as par value Required for trades and memos, optional for movements."""
    receive: NotRequired[Nullable[ReceiveTypedDict]]
    r"""Object containing metadata for receive events"""
    redemption_full: NotRequired[Nullable[RedemptionFullTypedDict]]
    r"""Object containing more information about a redemption"""
    redemption_partial: NotRequired[Nullable[RedemptionPartialTypedDict]]
    r"""Object containing metadata for partial redemption"""
    reverse_stock_split: NotRequired[Nullable[ReverseStockSplitTypedDict]]
    r"""Object containing metadata for a reverse_stock_split"""
    reversed_entry_id: NotRequired[str]
    r"""The entry_id of the original entry; only populated on entries with a status of \"Reversal\" """
    rights_distribution: NotRequired[Nullable[RightsDistributionTypedDict]]
    r"""Object containing more information about a rights distribution"""
    rights_subscription: NotRequired[Nullable[RightsSubscriptionTypedDict]]
    r"""Object containing metadata for rights subscriptions"""
    rounding_adjustment: NotRequired[Nullable[RoundingAdjustmentTypedDict]]
    r"""Object containing metadata for rounding"""
    sale_of_rights: NotRequired[Nullable[SaleOfRightsTypedDict]]
    r"""Object containing more information about a sale_of_rights"""
    settle_date: NotRequired[Nullable[SettleDateTypedDict]]
    r"""The date a given entry/ activity will officially settle"""
    side: NotRequired[EntrySide]
    r"""Denotes whether the trade is a buy or sell"""
    side_modifier: NotRequired[SideModifier]
    r"""Additional information about a trade Should be populated if possible for trades; the side modifier for the trade"""
    spin_off: NotRequired[Nullable[SpinOffTypedDict]]
    r"""Object containing metadata for spinoffs"""
    state: NotRequired[EntryState]
    r"""Set to be NEW for BookEntries, other statuses will be assigned via ModifyActivities; the state of the entry"""
    stock_dividend: NotRequired[Nullable[StockDividendTypedDict]]
    r"""Object containing metadata for stock dividends"""
    stock_split: NotRequired[Nullable[StockSplitTypedDict]]
    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[SweepTypedDict]]
    r"""Object containing metadata for sweeps"""
    tender_offer: NotRequired[Nullable[TenderOfferTypedDict]]
    r"""Object containing metadata for tender offers"""
    trade: NotRequired[Nullable[TradeTypedDict]]
    r"""Object containing metadata for trades"""
    transfer: NotRequired[Nullable[TransferTypedDict]]
    r"""Object containing metadata for transfers"""
    type: NotRequired[EntryType]
    r"""The Type of the entry; determines the set of mandatory fields as well as informing downstream processes how to handle this record"""
    unit_split: NotRequired[Nullable[UnitSplitTypedDict]]
    r"""Object containing metadata for unit splits"""
    warrant_exercise: NotRequired[Nullable[WarrantExerciseTypedDict]]
    r"""Object containing metadata for warrant exercises"""
    withdrawal: NotRequired[Nullable[WithdrawalTypedDict]]
    r"""Object containing metadata for withdrawals"""
    withdrawal_pending_review: NotRequired[Nullable[WithdrawalPendingReviewTypedDict]]
    r"""Object containing metadata about withdrawals that have been requested, but have not posted"""
    withholding: NotRequired[Nullable[EntryWithholdingTypedDict]]
    r"""Object containing metadata for tax withholdings"""
    worthless: NotRequired[Nullable[WorthlessTypedDict]]
    r"""Object containing metadata for worthless events"""


class Entry(BaseModel):
    r"""Entry is a single sided ledger booking that serves as the core ledger component; it is sparsely populated based on the entry type and the goal of the entry"""

    acats_pending_out: OptionalNullable[AcatsPendingOut] = UNSET
    r"""Object containing metadata for pending outgoing acats"""

    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[AccountMemo], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Indicates the memo location impacted by an entry"""

    account_transfer: OptionalNullable[AccountTransfer] = UNSET
    r"""Object containing metadata for account transfers"""

    accrued_interest: OptionalNullable[EntryAccruedInterest] = UNSET
    r"""Indicates that the entry references accrued interest that has been earned but not yet paid between the last interest payment and the date of the trade"""

    acquisition: OptionalNullable[Acquisition] = UNSET
    r"""Object containing metadata for acquisition events"""

    activity_date: OptionalNullable[ActivityDate] = UNSET
    r"""The calendar date an activity took place For Trade entries, the activity date reflects the trade date of the market in which the trade was executed For Cash entries, this reflects the banking day the cash will be moved"""

    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_id: Optional[str] = None
    r"""An Apex-provided, global identifier created on a per asset bases which provides connectivity across all areas Required, except for currency movements which should instead have a currency_asset_id."""

    capital_gains: OptionalNullable[CapitalGains] = UNSET
    r"""Object containing metadata for capital gains"""

    cash_dividend: OptionalNullable[CashDividend] = UNSET
    r"""Object containing for cash dividends"""

    commission: OptionalNullable[EntryCommission] = UNSET
    r"""Indicates that the entry references commission charged by brokers or financial intermediaries for executing financial transactions on behalf of clients"""

    conversion: OptionalNullable[Conversion] = UNSET
    r"""Object containing metadata for conversions (Conversion of securities into another form of securities)"""

    corporate_action_memo_adjustment: OptionalNullable[
        CorporateActionMemoAdjustment
    ] = UNSET
    r"""Object containing metadata for memo locations that have been adjusted due to a corporate action"""

    credit: OptionalNullable[Credit] = UNSET
    r"""Object containing more information about the credit being paid"""

    currency_asset_id: Optional[str] = None
    r"""The asset_id of the currency that all monetary values relate to Required for currency movements"""

    delivery: OptionalNullable[Delivery] = UNSET
    r"""Object containing metadata for delivery events"""

    deposit: OptionalNullable[Deposit] = UNSET
    r"""Object containing more information about a deposit"""

    description: Optional[str] = None
    r"""A plain text description of the entry; will not be available to search on or build other features off of"""

    drip: OptionalNullable[Drip] = UNSET
    r"""Object containing metadata for reserving cash until the DRIP trades are executed"""

    entry_id: Optional[str] = None
    r"""The unique id of the entry"""

    exchange: OptionalNullable[Exchange] = UNSET
    r"""Object containing metadata for exchanges"""

    fee: OptionalNullable[EntryFee] = UNSET
    r"""Object containing more information about the fee being charged"""

    flip: OptionalNullable[Flip] = UNSET
    r"""Object containing metadata for a Flip"""

    fpsl: OptionalNullable[Fpsl] = UNSET
    r"""Object containing metadata for fully paid stock lending entries"""

    gross_amount: OptionalNullable[GrossAmount] = UNSET
    r"""The monetary value of an activity, exclusive of any fees (First money)"""

    interest: OptionalNullable[Interest] = UNSET
    r"""Object containing metadata for Margin interest"""

    interest_payment: OptionalNullable[InterestPayment] = UNSET
    r"""Object containing metadata for interest payments"""

    liquidation: OptionalNullable[Liquidation] = UNSET
    r"""Object containing metadata for liquidations"""

    maturity: OptionalNullable[Maturity] = UNSET
    r"""Object containing metadata for maturity events"""

    merger: OptionalNullable[Merger] = UNSET
    r"""Object containing metadata for merger events"""

    name: Optional[str] = None
    r"""accounts/{account_id}/entries/{entry_id}"""

    name_change: OptionalNullable[NameChange] = UNSET
    r"""Object containing metadata for name changes"""

    original_id: Optional[str] = None
    r"""The original entry id; stable across reversals and corrections; use for maintaining lineage of entries through multiple corrections/reversals"""

    original_process_date: OptionalNullable[OriginalProcessDate] = UNSET
    r"""The original entry process date; stable across reversals and corrections; use for maintaining lineage of entries through multiple corrections/reversals"""

    payment_in_kind: OptionalNullable[PaymentInKind] = UNSET
    r"""Object containing metadata for PaymentInKind"""

    price: OptionalNullable[EntryPrice] = UNSET
    r"""The monetary value paid for a given security in a trade Required, except for currency movements"""

    process_date: OptionalNullable[EntryProcessDate] = UNSET
    r"""The date that the entry was booked on"""

    quantity: OptionalNullable[EntryQuantity] = UNSET
    r"""The quantity of shares bought, sold, or moved. For entries/ activities involving Fixed Income assets, quantity is expressed as par value Required for trades and memos, optional for movements."""

    receive: OptionalNullable[Receive] = UNSET
    r"""Object containing metadata for receive events"""

    redemption_full: OptionalNullable[RedemptionFull] = UNSET
    r"""Object containing more information about a redemption"""

    redemption_partial: OptionalNullable[RedemptionPartial] = UNSET
    r"""Object containing metadata for partial redemption"""

    reverse_stock_split: OptionalNullable[ReverseStockSplit] = UNSET
    r"""Object containing metadata for a reverse_stock_split"""

    reversed_entry_id: Optional[str] = None
    r"""The entry_id of the original entry; only populated on entries with a status of \"Reversal\" """

    rights_distribution: OptionalNullable[RightsDistribution] = UNSET
    r"""Object containing more information about a rights distribution"""

    rights_subscription: OptionalNullable[RightsSubscription] = UNSET
    r"""Object containing metadata for rights subscriptions"""

    rounding_adjustment: OptionalNullable[RoundingAdjustment] = UNSET
    r"""Object containing metadata for rounding"""

    sale_of_rights: OptionalNullable[SaleOfRights] = UNSET
    r"""Object containing more information about a sale_of_rights"""

    settle_date: OptionalNullable[SettleDate] = UNSET
    r"""The date a given entry/ activity will officially settle"""

    side: Annotated[
        Optional[EntrySide], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Denotes whether the trade is a buy or sell"""

    side_modifier: Annotated[
        Optional[SideModifier], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Additional information about a trade Should be populated if possible for trades; the side modifier for the trade"""

    spin_off: OptionalNullable[SpinOff] = UNSET
    r"""Object containing metadata for spinoffs"""

    state: Annotated[
        Optional[EntryState], PlainValidator(validate_open_enum(False))
    ] = None
    r"""Set to be NEW for BookEntries, other statuses will be assigned via ModifyActivities; the state of the entry"""

    stock_dividend: OptionalNullable[StockDividend] = UNSET
    r"""Object containing metadata for stock dividends"""

    stock_split: OptionalNullable[StockSplit] = 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[Sweep] = UNSET
    r"""Object containing metadata for sweeps"""

    tender_offer: OptionalNullable[TenderOffer] = UNSET
    r"""Object containing metadata for tender offers"""

    trade: OptionalNullable[Trade] = UNSET
    r"""Object containing metadata for trades"""

    transfer: OptionalNullable[Transfer] = UNSET
    r"""Object containing metadata for transfers"""

    type: Annotated[
        Optional[EntryType], PlainValidator(validate_open_enum(False))
    ] = None
    r"""The Type of the entry; determines the set of mandatory fields as well as informing downstream processes how to handle this record"""

    unit_split: OptionalNullable[UnitSplit] = UNSET
    r"""Object containing metadata for unit splits"""

    warrant_exercise: OptionalNullable[WarrantExercise] = UNSET
    r"""Object containing metadata for warrant exercises"""

    withdrawal: OptionalNullable[Withdrawal] = UNSET
    r"""Object containing metadata for withdrawals"""

    withdrawal_pending_review: OptionalNullable[WithdrawalPendingReview] = UNSET
    r"""Object containing metadata about withdrawals that have been requested, but have not posted"""

    withholding: OptionalNullable[EntryWithholding] = UNSET
    r"""Object containing metadata for tax withholdings"""

    worthless: OptionalNullable[Worthless] = 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",
            "acquisition",
            "activity_date",
            "activity_id",
            "activity_time",
            "asset_id",
            "capital_gains",
            "cash_dividend",
            "commission",
            "conversion",
            "corporate_action_memo_adjustment",
            "credit",
            "currency_asset_id",
            "delivery",
            "deposit",
            "description",
            "drip",
            "entry_id",
            "exchange",
            "fee",
            "flip",
            "fpsl",
            "gross_amount",
            "interest",
            "interest_payment",
            "liquidation",
            "maturity",
            "merger",
            "name",
            "name_change",
            "original_id",
            "original_process_date",
            "payment_in_kind",
            "price",
            "process_date",
            "quantity",
            "receive",
            "redemption_full",
            "redemption_partial",
            "reverse_stock_split",
            "reversed_entry_id",
            "rights_distribution",
            "rights_subscription",
            "rounding_adjustment",
            "sale_of_rights",
            "settle_date",
            "side",
            "side_modifier",
            "spin_off",
            "state",
            "stock_dividend",
            "stock_split",
            "subtype_category",
            "sweep",
            "tender_offer",
            "trade",
            "transfer",
            "type",
            "unit_split",
            "warrant_exercise",
            "withdrawal",
            "withdrawal_pending_review",
            "withholding",
            "worthless",
        ]
        nullable_fields = [
            "acats_pending_out",
            "account_transfer",
            "accrued_interest",
            "acquisition",
            "activity_date",
            "activity_time",
            "capital_gains",
            "cash_dividend",
            "commission",
            "conversion",
            "corporate_action_memo_adjustment",
            "credit",
            "delivery",
            "deposit",
            "drip",
            "exchange",
            "fee",
            "flip",
            "fpsl",
            "gross_amount",
            "interest",
            "interest_payment",
            "liquidation",
            "maturity",
            "merger",
            "name_change",
            "original_process_date",
            "payment_in_kind",
            "price",
            "process_date",
            "quantity",
            "receive",
            "redemption_full",
            "redemption_partial",
            "reverse_stock_split",
            "rights_distribution",
            "rights_subscription",
            "rounding_adjustment",
            "sale_of_rights",
            "settle_date",
            "spin_off",
            "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
