/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { catchUnrecognizedEnum, OpenEnum, Unrecognized, } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { OptionOrderLeg, OptionOrderLeg$inboundSchema, OptionOrderLeg$Outbound, OptionOrderLeg$outboundSchema, } from "./optionorderleg.js"; import { TradingFee, TradingFee$inboundSchema, TradingFee$Outbound, TradingFee$outboundSchema, } from "./tradingfee.js"; /** * The capacity in which the broker is acting for this option order. */ export enum OptionOrderBrokerCapacity { BrokerCapacityUnspecified = "BROKER_CAPACITY_UNSPECIFIED", Agency = "AGENCY", Principal = "PRINCIPAL", } /** * The capacity in which the broker is acting for this option order. */ export type OptionOrderBrokerCapacityOpen = OpenEnum< typeof OptionOrderBrokerCapacity >; /** * Used to denote when a cancel request has been rejected. */ export enum OptionOrderCancelRejectedReason { CancelRejectReasonUnspecified = "CANCEL_REJECT_REASON_UNSPECIFIED", TooLateToCancel = "TOO_LATE_TO_CANCEL", CancellationUnknownOrder = "CANCELLATION_UNKNOWN_ORDER", BrokerExchangeOption = "BROKER_EXCHANGE_OPTION", OrderAlreadyInPendingCancelOrPendingReplaceStatus = "ORDER_ALREADY_IN_PENDING_CANCEL_OR_PENDING_REPLACE_STATUS", Duplicate = "DUPLICATE", CancellationSystemError = "CANCELLATION_SYSTEM_ERROR", OrderAlreadyCanceled = "ORDER_ALREADY_CANCELED", CancellationMisconfiguredClient = "CANCELLATION_MISCONFIGURED_CLIENT", } /** * Used to denote when a cancel request has been rejected. */ export type OptionOrderCancelRejectedReasonOpen = OpenEnum< typeof OptionOrderCancelRejectedReason >; /** * This represents the absolute value of the notional amount (without fees) transacted across all of this legs. If present, this will always a positive number, or zero. This field will be empty if there are no leg executions. */ export type OptionOrderCumulativeNotionalValue = { /** * 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 */ value?: string | undefined; }; /** * This represents the direction of the total filled notional value, which will be present if the `cumulative_notional_value` is also present. If there are no executions, this value will be absent. When the summed notional value of all CREDIT legs exceeds that of the DEBIT legs a CREDIT will be reported here; otherwise a DEBIT will be reported. */ export enum CumulativeNotionalValueDirection { DebitCreditTypeUnspecified = "DEBIT_CREDIT_TYPE_UNSPECIFIED", Debit = "DEBIT", Credit = "CREDIT", } /** * This represents the direction of the total filled notional value, which will be present if the `cumulative_notional_value` is also present. If there are no executions, this value will be absent. When the summed notional value of all CREDIT legs exceeds that of the DEBIT legs a CREDIT will be reported here; otherwise a DEBIT will be reported. */ export type CumulativeNotionalValueDirectionOpen = OpenEnum< typeof CumulativeNotionalValueDirection >; /** * The limit price for this option order. For single-leg option orders, this is the price per contract which the filled order must match or beat. For multi-leg orders, this represents the amortized "price per unit" that must be matched or beat. (E.g. with a limit price of a $4 DEBIT, and an order with 2 legs that includes one leg buy 100 shares of SBX and another leg to sell 1 contract of SBX, then the fills will be guaranteed to result in no more than a $400--4 USD X 100 shares/contract--total debit against the ordering account.) */ export type OptionOrderLimitPrice = { /** * 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 */ value?: string | undefined; }; /** * The date on which the option order will go to the market: must be "today". Option orders will only be accepted during normal trading hours. */ export type OptionOrderOrderDate = { /** * 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. */ day?: number | undefined; /** * Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day. */ month?: number | undefined; /** * Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year. */ year?: number | undefined; }; /** * When an option order has the REJECTED status, this will be populated with a system code describing the rejection. */ export enum OptionOrderOrderRejectedReason { OrderRejectReasonUnspecified = "ORDER_REJECT_REASON_UNSPECIFIED", BrokerOption = "BROKER_OPTION", UnknownSecurity = "UNKNOWN_SECURITY", ExchangeClosed = "EXCHANGE_CLOSED", OrderExceedsLimit = "ORDER_EXCEEDS_LIMIT", TooLateToEnter = "TOO_LATE_TO_ENTER", UnknownOrder = "UNKNOWN_ORDER", DuplicateOrder = "DUPLICATE_ORDER", StaleOrder = "STALE_ORDER", BelowNotionalMinimum = "BELOW_NOTIONAL_MINIMUM", OrderDateUnavailable = "ORDER_DATE_UNAVAILABLE", AggressiveLimitPrice = "AGGRESSIVE_LIMIT_PRICE", AccountNotEntitled = "ACCOUNT_NOT_ENTITLED", SystemError = "SYSTEM_ERROR", BlockingCorporateAction = "BLOCKING_CORPORATE_ACTION", UnavailablePriceQuote = "UNAVAILABLE_PRICE_QUOTE", ExecutionMisconfiguredClient = "EXECUTION_MISCONFIGURED_CLIENT", NotionalQuantityNotAllowedForSecurity = "NOTIONAL_QUANTITY_NOT_ALLOWED_FOR_SECURITY", FractionalQuantityNotAllowedForSecurity = "FRACTIONAL_QUANTITY_NOT_ALLOWED_FOR_SECURITY", OnlyFractionalSellOrWholeOrdersAllowedForSecurity = "ONLY_FRACTIONAL_SELL_OR_WHOLE_ORDERS_ALLOWED_FOR_SECURITY", AboveNotionalMaximum = "ABOVE_NOTIONAL_MAXIMUM", AboveShareMaximum = "ABOVE_SHARE_MAXIMUM", FailedBuyingPower = "FAILED_BUYING_POWER", InsufficientPosition = "INSUFFICIENT_POSITION", TradesDisabledForAssetType = "TRADES_DISABLED_FOR_ASSET_TYPE", CommissionNotAllowedForNonBrokerDealer = "COMMISSION_NOT_ALLOWED_FOR_NON_BROKER_DEALER", AssetNotSetUpToTrade = "ASSET_NOT_SET_UP_TO_TRADE", InvalidOrderQuantity = "INVALID_ORDER_QUANTITY", ClientReceivedTimeRequired = "CLIENT_RECEIVED_TIME_REQUIRED", UnsupportedPriceValue = "UNSUPPORTED_PRICE_VALUE", } /** * When an option order has the REJECTED status, this will be populated with a system code describing the rejection. */ export type OptionOrderOrderRejectedReasonOpen = OpenEnum< typeof OptionOrderOrderRejectedReason >; /** * The processing status of the option order */ export enum OptionOrderOrderStatus { OrderStatusUnspecified = "ORDER_STATUS_UNSPECIFIED", PendingNew = "PENDING_NEW", New = "NEW", PendingQueued = "PENDING_QUEUED", Queued = "QUEUED", PartiallyFilled = "PARTIALLY_FILLED", Filled = "FILLED", PendingCancel = "PENDING_CANCEL", Canceled = "CANCELED", Rejected = "REJECTED", } /** * The processing status of the option order */ export type OptionOrderOrderStatusOpen = OpenEnum< typeof OptionOrderOrderStatus >; /** * The execution type of this option order. */ export enum OptionOrderOrderType { OrderTypeUnspecified = "ORDER_TYPE_UNSPECIFIED", Limit = "LIMIT", } /** * The execution type of this option order. */ export type OptionOrderOrderTypeOpen = OpenEnum; /** * The direction of the price, which indicates whether the entire option order should result in a credit to the account placing the order, or a debit from the account placing the order. */ export enum OptionOrderPriceDirection { DebitCreditTypeUnspecified = "DEBIT_CREDIT_TYPE_UNSPECIFIED", Debit = "DEBIT", Credit = "CREDIT", } /** * The direction of the price, which indicates whether the entire option order should result in a credit to the account placing the order, or a debit from the account placing the order. */ export type OptionOrderPriceDirectionOpen = OpenEnum< typeof OptionOrderPriceDirection >; /** * The quantity of the option order to be placed. The `ratio_quantity` of each leg will be multiplied by this value to determine the total number of units being ordered within each leg. (E.g. if a quantity of 3 is specified, and a leg with a `ratio_quantity` of 2 is specified, then the total number of contracts being ordered by that leg will be 6.) */ export type OptionOrderQuantity = { /** * 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 */ value?: string | undefined; }; export enum OptionOrderSpecialReportingInstructions { SpecialReportingInstructionsUnspecified = "SPECIAL_REPORTING_INSTRUCTIONS_UNSPECIFIED", CustomerDirected = "CUSTOMER_DIRECTED", WithDividend = "WITH_DIVIDEND", WithRights = "WITH_RIGHTS", DiscretionExercised = "DISCRETION_EXERCISED", DiscretionNotExercised = "DISCRETION_NOT_EXERCISED", BrokerDealerOrder = "BROKER_DEALER_ORDER", FullyRegistered = "FULLY_REGISTERED", OddlotDiffOnRequest = "ODDLOT_DIFF_ON_REQUEST", ProspectusEnclosed = "PROSPECTUS_ENCLOSED", ProspectusSeparateMail = "PROSPECTUS_SEPARATE_MAIL", Solicited = "SOLICITED", Unsolicited = "UNSOLICITED", XDividend = "X_DIVIDEND", ActingAsPrincipal = "ACTING_AS_PRINCIPAL", AveragePrice = "AVERAGE_PRICE", BrokerLiquidation = "BROKER_LIQUIDATION", InternetOrder = "INTERNET_ORDER", MarginSellout = "MARGIN_SELLOUT", NegativeNetProceed = "NEGATIVE_NET_PROCEED", RisklessPrincipal = "RISKLESS_PRINCIPAL", ThirdMarket = "THIRD_MARKET", SuppressTraceReporting = "SUPPRESS_TRACE_REPORTING", WhenDistributed = "WHEN_DISTRIBUTED", RoundUp = "ROUND_UP", CatParentAlgo = "CAT_PARENT_ALGO", CatParentGtc = "CAT_PARENT_GTC", } export type OptionOrderSpecialReportingInstructionsOpen = OpenEnum< typeof OptionOrderSpecialReportingInstructions >; /** * Must be the value "DAY". Regulatory requirements dictate the system captures the intended time_in_force, which is why this a mandatory field. */ export enum OptionOrderTimeInForce { TimeInForceUnspecified = "TIME_IN_FORCE_UNSPECIFIED", Day = "DAY", } /** * Must be the value "DAY". Regulatory requirements dictate the system captures the intended time_in_force, which is why this a mandatory field. */ export type OptionOrderTimeInForceOpen = OpenEnum< typeof OptionOrderTimeInForce >; /** * The message describing an option order */ export type OptionOrder = { /** * The identifier of the account transacting this option order */ accountId?: string | undefined; /** * The capacity in which the broker is acting for this option order. */ brokerCapacity?: OptionOrderBrokerCapacityOpen | undefined; /** * Used to explain why an option order is canceled */ cancelReason?: string | undefined; /** * Used to denote when a cancel request has been rejected. */ cancelRejectedReason?: OptionOrderCancelRejectedReasonOpen | undefined; /** * User-supplied unique option order ID. Cannot be more than 40 characters long. */ clientOrderId?: string | undefined; /** * Required for any client who is having Apex do CAT reporting on their behalf. */ clientReceivedTime?: Date | null | undefined; /** * Time of the option order creation */ createTime?: Date | null | undefined; /** * This represents the absolute value of the notional amount (without fees) transacted across all of this legs. If present, this will always a positive number, or zero. This field will be empty if there are no leg executions. */ cumulativeNotionalValue?: | OptionOrderCumulativeNotionalValue | null | undefined; /** * This represents the direction of the total filled notional value, which will be present if the `cumulative_notional_value` is also present. If there are no executions, this value will be absent. When the summed notional value of all CREDIT legs exceeds that of the DEBIT legs a CREDIT will be reported here; otherwise a DEBIT will be reported. */ cumulativeNotionalValueDirection?: | CumulativeNotionalValueDirectionOpen | undefined; /** * Only "USD" is supported. Full list of currency codes is defined at: https://en.wikipedia.org/wiki/ISO_4217 */ currencyCode?: string | undefined; /** * Fees that will be applied to this option order. */ fees?: Array | undefined; /** * Time of the last option order update */ lastUpdateTime?: Date | null | undefined; /** * The legs of this option order. Only a single leg is allowed to be specified, and it must be for an OPTION security. */ legs?: Array | undefined; /** * The limit price for this option order. For single-leg option orders, this is the price per contract which the filled order must match or beat. For multi-leg orders, this represents the amortized "price per unit" that must be matched or beat. (E.g. with a limit price of a $4 DEBIT, and an order with 2 legs that includes one leg buy 100 shares of SBX and another leg to sell 1 contract of SBX, then the fills will be guaranteed to result in no more than a $400--4 USD X 100 shares/contract--total debit against the ordering account.) */ limitPrice?: OptionOrderLimitPrice | null | undefined; /** * System generated name of the option order. */ name?: string | undefined; /** * System generated unique id for the option order. */ optionOrderId?: string | undefined; /** * The date on which the option order will go to the market: must be "today". Option orders will only be accepted during normal trading hours. */ orderDate?: OptionOrderOrderDate | null | undefined; /** * When an option order has the REJECTED status, this will be populated with a system code describing the rejection. */ orderRejectedReason?: OptionOrderOrderRejectedReasonOpen | undefined; /** * The processing status of the option order */ orderStatus?: OptionOrderOrderStatusOpen | undefined; /** * The execution type of this option order. */ orderType?: OptionOrderOrderTypeOpen | undefined; /** * The direction of the price, which indicates whether the entire option order should result in a credit to the account placing the order, or a debit from the account placing the order. */ priceDirection?: OptionOrderPriceDirectionOpen | undefined; /** * The quantity of the option order to be placed. The `ratio_quantity` of each leg will be multiplied by this value to determine the total number of units being ordered within each leg. (E.g. if a quantity of 3 is specified, and a leg with a `ratio_quantity` of 2 is specified, then the total number of contracts being ordered by that leg will be 6.) */ quantity?: OptionOrderQuantity | null | undefined; /** * Special Reporting Instructions to be applied to this option order. Can include multiple Instructions. */ specialReportingInstructions?: | Array | undefined; /** * Must be the value "DAY". Regulatory requirements dictate the system captures the intended time_in_force, which is why this a mandatory field. */ timeInForce?: OptionOrderTimeInForceOpen | undefined; }; /** @internal */ export const OptionOrderBrokerCapacity$inboundSchema: z.ZodType< OptionOrderBrokerCapacityOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderBrokerCapacity), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderBrokerCapacity$outboundSchema: z.ZodType< OptionOrderBrokerCapacityOpen, z.ZodTypeDef, OptionOrderBrokerCapacityOpen > = z.union([ z.nativeEnum(OptionOrderBrokerCapacity), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderBrokerCapacity$ { /** @deprecated use `OptionOrderBrokerCapacity$inboundSchema` instead. */ export const inboundSchema = OptionOrderBrokerCapacity$inboundSchema; /** @deprecated use `OptionOrderBrokerCapacity$outboundSchema` instead. */ export const outboundSchema = OptionOrderBrokerCapacity$outboundSchema; } /** @internal */ export const OptionOrderCancelRejectedReason$inboundSchema: z.ZodType< OptionOrderCancelRejectedReasonOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderCancelRejectedReason), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderCancelRejectedReason$outboundSchema: z.ZodType< OptionOrderCancelRejectedReasonOpen, z.ZodTypeDef, OptionOrderCancelRejectedReasonOpen > = z.union([ z.nativeEnum(OptionOrderCancelRejectedReason), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderCancelRejectedReason$ { /** @deprecated use `OptionOrderCancelRejectedReason$inboundSchema` instead. */ export const inboundSchema = OptionOrderCancelRejectedReason$inboundSchema; /** @deprecated use `OptionOrderCancelRejectedReason$outboundSchema` instead. */ export const outboundSchema = OptionOrderCancelRejectedReason$outboundSchema; } /** @internal */ export const OptionOrderCumulativeNotionalValue$inboundSchema: z.ZodType< OptionOrderCumulativeNotionalValue, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type OptionOrderCumulativeNotionalValue$Outbound = { value?: string | undefined; }; /** @internal */ export const OptionOrderCumulativeNotionalValue$outboundSchema: z.ZodType< OptionOrderCumulativeNotionalValue$Outbound, z.ZodTypeDef, OptionOrderCumulativeNotionalValue > = z.object({ value: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderCumulativeNotionalValue$ { /** @deprecated use `OptionOrderCumulativeNotionalValue$inboundSchema` instead. */ export const inboundSchema = OptionOrderCumulativeNotionalValue$inboundSchema; /** @deprecated use `OptionOrderCumulativeNotionalValue$outboundSchema` instead. */ export const outboundSchema = OptionOrderCumulativeNotionalValue$outboundSchema; /** @deprecated use `OptionOrderCumulativeNotionalValue$Outbound` instead. */ export type Outbound = OptionOrderCumulativeNotionalValue$Outbound; } export function optionOrderCumulativeNotionalValueToJSON( optionOrderCumulativeNotionalValue: OptionOrderCumulativeNotionalValue, ): string { return JSON.stringify( OptionOrderCumulativeNotionalValue$outboundSchema.parse( optionOrderCumulativeNotionalValue, ), ); } export function optionOrderCumulativeNotionalValueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OptionOrderCumulativeNotionalValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OptionOrderCumulativeNotionalValue' from JSON`, ); } /** @internal */ export const CumulativeNotionalValueDirection$inboundSchema: z.ZodType< CumulativeNotionalValueDirectionOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(CumulativeNotionalValueDirection), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const CumulativeNotionalValueDirection$outboundSchema: z.ZodType< CumulativeNotionalValueDirectionOpen, z.ZodTypeDef, CumulativeNotionalValueDirectionOpen > = z.union([ z.nativeEnum(CumulativeNotionalValueDirection), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CumulativeNotionalValueDirection$ { /** @deprecated use `CumulativeNotionalValueDirection$inboundSchema` instead. */ export const inboundSchema = CumulativeNotionalValueDirection$inboundSchema; /** @deprecated use `CumulativeNotionalValueDirection$outboundSchema` instead. */ export const outboundSchema = CumulativeNotionalValueDirection$outboundSchema; } /** @internal */ export const OptionOrderLimitPrice$inboundSchema: z.ZodType< OptionOrderLimitPrice, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type OptionOrderLimitPrice$Outbound = { value?: string | undefined; }; /** @internal */ export const OptionOrderLimitPrice$outboundSchema: z.ZodType< OptionOrderLimitPrice$Outbound, z.ZodTypeDef, OptionOrderLimitPrice > = z.object({ value: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderLimitPrice$ { /** @deprecated use `OptionOrderLimitPrice$inboundSchema` instead. */ export const inboundSchema = OptionOrderLimitPrice$inboundSchema; /** @deprecated use `OptionOrderLimitPrice$outboundSchema` instead. */ export const outboundSchema = OptionOrderLimitPrice$outboundSchema; /** @deprecated use `OptionOrderLimitPrice$Outbound` instead. */ export type Outbound = OptionOrderLimitPrice$Outbound; } export function optionOrderLimitPriceToJSON( optionOrderLimitPrice: OptionOrderLimitPrice, ): string { return JSON.stringify( OptionOrderLimitPrice$outboundSchema.parse(optionOrderLimitPrice), ); } export function optionOrderLimitPriceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OptionOrderLimitPrice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OptionOrderLimitPrice' from JSON`, ); } /** @internal */ export const OptionOrderOrderDate$inboundSchema: z.ZodType< OptionOrderOrderDate, z.ZodTypeDef, unknown > = z.object({ day: z.number().int().optional(), month: z.number().int().optional(), year: z.number().int().optional(), }); /** @internal */ export type OptionOrderOrderDate$Outbound = { day?: number | undefined; month?: number | undefined; year?: number | undefined; }; /** @internal */ export const OptionOrderOrderDate$outboundSchema: z.ZodType< OptionOrderOrderDate$Outbound, z.ZodTypeDef, OptionOrderOrderDate > = z.object({ day: z.number().int().optional(), month: z.number().int().optional(), year: z.number().int().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderOrderDate$ { /** @deprecated use `OptionOrderOrderDate$inboundSchema` instead. */ export const inboundSchema = OptionOrderOrderDate$inboundSchema; /** @deprecated use `OptionOrderOrderDate$outboundSchema` instead. */ export const outboundSchema = OptionOrderOrderDate$outboundSchema; /** @deprecated use `OptionOrderOrderDate$Outbound` instead. */ export type Outbound = OptionOrderOrderDate$Outbound; } export function optionOrderOrderDateToJSON( optionOrderOrderDate: OptionOrderOrderDate, ): string { return JSON.stringify( OptionOrderOrderDate$outboundSchema.parse(optionOrderOrderDate), ); } export function optionOrderOrderDateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OptionOrderOrderDate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OptionOrderOrderDate' from JSON`, ); } /** @internal */ export const OptionOrderOrderRejectedReason$inboundSchema: z.ZodType< OptionOrderOrderRejectedReasonOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderOrderRejectedReason), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderOrderRejectedReason$outboundSchema: z.ZodType< OptionOrderOrderRejectedReasonOpen, z.ZodTypeDef, OptionOrderOrderRejectedReasonOpen > = z.union([ z.nativeEnum(OptionOrderOrderRejectedReason), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderOrderRejectedReason$ { /** @deprecated use `OptionOrderOrderRejectedReason$inboundSchema` instead. */ export const inboundSchema = OptionOrderOrderRejectedReason$inboundSchema; /** @deprecated use `OptionOrderOrderRejectedReason$outboundSchema` instead. */ export const outboundSchema = OptionOrderOrderRejectedReason$outboundSchema; } /** @internal */ export const OptionOrderOrderStatus$inboundSchema: z.ZodType< OptionOrderOrderStatusOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderOrderStatus), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderOrderStatus$outboundSchema: z.ZodType< OptionOrderOrderStatusOpen, z.ZodTypeDef, OptionOrderOrderStatusOpen > = z.union([ z.nativeEnum(OptionOrderOrderStatus), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderOrderStatus$ { /** @deprecated use `OptionOrderOrderStatus$inboundSchema` instead. */ export const inboundSchema = OptionOrderOrderStatus$inboundSchema; /** @deprecated use `OptionOrderOrderStatus$outboundSchema` instead. */ export const outboundSchema = OptionOrderOrderStatus$outboundSchema; } /** @internal */ export const OptionOrderOrderType$inboundSchema: z.ZodType< OptionOrderOrderTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderOrderType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderOrderType$outboundSchema: z.ZodType< OptionOrderOrderTypeOpen, z.ZodTypeDef, OptionOrderOrderTypeOpen > = z.union([ z.nativeEnum(OptionOrderOrderType), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderOrderType$ { /** @deprecated use `OptionOrderOrderType$inboundSchema` instead. */ export const inboundSchema = OptionOrderOrderType$inboundSchema; /** @deprecated use `OptionOrderOrderType$outboundSchema` instead. */ export const outboundSchema = OptionOrderOrderType$outboundSchema; } /** @internal */ export const OptionOrderPriceDirection$inboundSchema: z.ZodType< OptionOrderPriceDirectionOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderPriceDirection), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderPriceDirection$outboundSchema: z.ZodType< OptionOrderPriceDirectionOpen, z.ZodTypeDef, OptionOrderPriceDirectionOpen > = z.union([ z.nativeEnum(OptionOrderPriceDirection), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderPriceDirection$ { /** @deprecated use `OptionOrderPriceDirection$inboundSchema` instead. */ export const inboundSchema = OptionOrderPriceDirection$inboundSchema; /** @deprecated use `OptionOrderPriceDirection$outboundSchema` instead. */ export const outboundSchema = OptionOrderPriceDirection$outboundSchema; } /** @internal */ export const OptionOrderQuantity$inboundSchema: z.ZodType< OptionOrderQuantity, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type OptionOrderQuantity$Outbound = { value?: string | undefined; }; /** @internal */ export const OptionOrderQuantity$outboundSchema: z.ZodType< OptionOrderQuantity$Outbound, z.ZodTypeDef, OptionOrderQuantity > = z.object({ value: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderQuantity$ { /** @deprecated use `OptionOrderQuantity$inboundSchema` instead. */ export const inboundSchema = OptionOrderQuantity$inboundSchema; /** @deprecated use `OptionOrderQuantity$outboundSchema` instead. */ export const outboundSchema = OptionOrderQuantity$outboundSchema; /** @deprecated use `OptionOrderQuantity$Outbound` instead. */ export type Outbound = OptionOrderQuantity$Outbound; } export function optionOrderQuantityToJSON( optionOrderQuantity: OptionOrderQuantity, ): string { return JSON.stringify( OptionOrderQuantity$outboundSchema.parse(optionOrderQuantity), ); } export function optionOrderQuantityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OptionOrderQuantity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OptionOrderQuantity' from JSON`, ); } /** @internal */ export const OptionOrderSpecialReportingInstructions$inboundSchema: z.ZodType< OptionOrderSpecialReportingInstructionsOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderSpecialReportingInstructions), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderSpecialReportingInstructions$outboundSchema: z.ZodType< OptionOrderSpecialReportingInstructionsOpen, z.ZodTypeDef, OptionOrderSpecialReportingInstructionsOpen > = z.union([ z.nativeEnum(OptionOrderSpecialReportingInstructions), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderSpecialReportingInstructions$ { /** @deprecated use `OptionOrderSpecialReportingInstructions$inboundSchema` instead. */ export const inboundSchema = OptionOrderSpecialReportingInstructions$inboundSchema; /** @deprecated use `OptionOrderSpecialReportingInstructions$outboundSchema` instead. */ export const outboundSchema = OptionOrderSpecialReportingInstructions$outboundSchema; } /** @internal */ export const OptionOrderTimeInForce$inboundSchema: z.ZodType< OptionOrderTimeInForceOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderTimeInForce), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderTimeInForce$outboundSchema: z.ZodType< OptionOrderTimeInForceOpen, z.ZodTypeDef, OptionOrderTimeInForceOpen > = z.union([ z.nativeEnum(OptionOrderTimeInForce), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderTimeInForce$ { /** @deprecated use `OptionOrderTimeInForce$inboundSchema` instead. */ export const inboundSchema = OptionOrderTimeInForce$inboundSchema; /** @deprecated use `OptionOrderTimeInForce$outboundSchema` instead. */ export const outboundSchema = OptionOrderTimeInForce$outboundSchema; } /** @internal */ export const OptionOrder$inboundSchema: z.ZodType< OptionOrder, z.ZodTypeDef, unknown > = z.object({ account_id: z.string().optional(), broker_capacity: OptionOrderBrokerCapacity$inboundSchema.optional(), cancel_reason: z.string().optional(), cancel_rejected_reason: OptionOrderCancelRejectedReason$inboundSchema .optional(), client_order_id: z.string().optional(), client_received_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), create_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), cumulative_notional_value: z.nullable( z.lazy(() => OptionOrderCumulativeNotionalValue$inboundSchema), ).optional(), cumulative_notional_value_direction: CumulativeNotionalValueDirection$inboundSchema.optional(), currency_code: z.string().optional(), fees: z.array(TradingFee$inboundSchema).optional(), last_update_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), legs: z.array(OptionOrderLeg$inboundSchema).optional(), limit_price: z.nullable(z.lazy(() => OptionOrderLimitPrice$inboundSchema)) .optional(), name: z.string().optional(), option_order_id: z.string().optional(), order_date: z.nullable(z.lazy(() => OptionOrderOrderDate$inboundSchema)) .optional(), order_rejected_reason: OptionOrderOrderRejectedReason$inboundSchema .optional(), order_status: OptionOrderOrderStatus$inboundSchema.optional(), order_type: OptionOrderOrderType$inboundSchema.optional(), price_direction: OptionOrderPriceDirection$inboundSchema.optional(), quantity: z.nullable(z.lazy(() => OptionOrderQuantity$inboundSchema)) .optional(), special_reporting_instructions: z.array( OptionOrderSpecialReportingInstructions$inboundSchema, ).optional(), time_in_force: OptionOrderTimeInForce$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "account_id": "accountId", "broker_capacity": "brokerCapacity", "cancel_reason": "cancelReason", "cancel_rejected_reason": "cancelRejectedReason", "client_order_id": "clientOrderId", "client_received_time": "clientReceivedTime", "create_time": "createTime", "cumulative_notional_value": "cumulativeNotionalValue", "cumulative_notional_value_direction": "cumulativeNotionalValueDirection", "currency_code": "currencyCode", "last_update_time": "lastUpdateTime", "limit_price": "limitPrice", "option_order_id": "optionOrderId", "order_date": "orderDate", "order_rejected_reason": "orderRejectedReason", "order_status": "orderStatus", "order_type": "orderType", "price_direction": "priceDirection", "special_reporting_instructions": "specialReportingInstructions", "time_in_force": "timeInForce", }); }); /** @internal */ export type OptionOrder$Outbound = { account_id?: string | undefined; broker_capacity?: string | undefined; cancel_reason?: string | undefined; cancel_rejected_reason?: string | undefined; client_order_id?: string | undefined; client_received_time?: string | null | undefined; create_time?: string | null | undefined; cumulative_notional_value?: | OptionOrderCumulativeNotionalValue$Outbound | null | undefined; cumulative_notional_value_direction?: string | undefined; currency_code?: string | undefined; fees?: Array | undefined; last_update_time?: string | null | undefined; legs?: Array | undefined; limit_price?: OptionOrderLimitPrice$Outbound | null | undefined; name?: string | undefined; option_order_id?: string | undefined; order_date?: OptionOrderOrderDate$Outbound | null | undefined; order_rejected_reason?: string | undefined; order_status?: string | undefined; order_type?: string | undefined; price_direction?: string | undefined; quantity?: OptionOrderQuantity$Outbound | null | undefined; special_reporting_instructions?: Array | undefined; time_in_force?: string | undefined; }; /** @internal */ export const OptionOrder$outboundSchema: z.ZodType< OptionOrder$Outbound, z.ZodTypeDef, OptionOrder > = z.object({ accountId: z.string().optional(), brokerCapacity: OptionOrderBrokerCapacity$outboundSchema.optional(), cancelReason: z.string().optional(), cancelRejectedReason: OptionOrderCancelRejectedReason$outboundSchema .optional(), clientOrderId: z.string().optional(), clientReceivedTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), createTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), cumulativeNotionalValue: z.nullable( z.lazy(() => OptionOrderCumulativeNotionalValue$outboundSchema), ).optional(), cumulativeNotionalValueDirection: CumulativeNotionalValueDirection$outboundSchema.optional(), currencyCode: z.string().optional(), fees: z.array(TradingFee$outboundSchema).optional(), lastUpdateTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), legs: z.array(OptionOrderLeg$outboundSchema).optional(), limitPrice: z.nullable(z.lazy(() => OptionOrderLimitPrice$outboundSchema)) .optional(), name: z.string().optional(), optionOrderId: z.string().optional(), orderDate: z.nullable(z.lazy(() => OptionOrderOrderDate$outboundSchema)) .optional(), orderRejectedReason: OptionOrderOrderRejectedReason$outboundSchema.optional(), orderStatus: OptionOrderOrderStatus$outboundSchema.optional(), orderType: OptionOrderOrderType$outboundSchema.optional(), priceDirection: OptionOrderPriceDirection$outboundSchema.optional(), quantity: z.nullable(z.lazy(() => OptionOrderQuantity$outboundSchema)) .optional(), specialReportingInstructions: z.array( OptionOrderSpecialReportingInstructions$outboundSchema, ).optional(), timeInForce: OptionOrderTimeInForce$outboundSchema.optional(), }).transform((v) => { return remap$(v, { accountId: "account_id", brokerCapacity: "broker_capacity", cancelReason: "cancel_reason", cancelRejectedReason: "cancel_rejected_reason", clientOrderId: "client_order_id", clientReceivedTime: "client_received_time", createTime: "create_time", cumulativeNotionalValue: "cumulative_notional_value", cumulativeNotionalValueDirection: "cumulative_notional_value_direction", currencyCode: "currency_code", lastUpdateTime: "last_update_time", limitPrice: "limit_price", optionOrderId: "option_order_id", orderDate: "order_date", orderRejectedReason: "order_rejected_reason", orderStatus: "order_status", orderType: "order_type", priceDirection: "price_direction", specialReportingInstructions: "special_reporting_instructions", timeInForce: "time_in_force", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrder$ { /** @deprecated use `OptionOrder$inboundSchema` instead. */ export const inboundSchema = OptionOrder$inboundSchema; /** @deprecated use `OptionOrder$outboundSchema` instead. */ export const outboundSchema = OptionOrder$outboundSchema; /** @deprecated use `OptionOrder$Outbound` instead. */ export type Outbound = OptionOrder$Outbound; } export function optionOrderToJSON(optionOrder: OptionOrder): string { return JSON.stringify(OptionOrder$outboundSchema.parse(optionOrder)); } export function optionOrderFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OptionOrder$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OptionOrder' from JSON`, ); }