/* * 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 { BasketTradingExecutedPrice, BasketTradingExecutedPrice$inboundSchema, BasketTradingExecutedPrice$Outbound, BasketTradingExecutedPrice$outboundSchema, } from "./baskettradingexecutedprice.js"; import { BasketTradingExecutions, BasketTradingExecutions$inboundSchema, BasketTradingExecutions$Outbound, BasketTradingExecutions$outboundSchema, } from "./baskettradingexecutions.js"; /** * The type of the asset in this order */ export enum BasketOrderAssetType { AssetTypeUnspecified = "ASSET_TYPE_UNSPECIFIED", Equity = "EQUITY", MutualFund = "MUTUAL_FUND", } /** * The type of the asset in this order */ export type BasketOrderAssetTypeOpen = OpenEnum; /** * Output only field that is required for Equity Orders for any client who is having Apex do CAT reporting on their behalf. This field denotes the initiator of the cancel request. This field will be present when provided on the RemoveOrderRequest */ export enum BasketOrderCancelInitiator { InitiatorUnspecified = "INITIATOR_UNSPECIFIED", Firm = "FIRM", Client = "CLIENT", } /** * Output only field that is required for Equity Orders for any client who is having Apex do CAT reporting on their behalf. This field denotes the initiator of the cancel request. This field will be present when provided on the RemoveOrderRequest */ export type BasketOrderCancelInitiatorOpen = OpenEnum< typeof BasketOrderCancelInitiator >; /** * The product of order quantity & price, summed across all fills, reported in the currency specified in the order. (This will be rounded to 2 decimal places for USD currencies). Will be absent if an order has no fill information. */ export type BasketOrderCumulativeNotionalValue = { /** * 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; }; /** * Any reporting data provided by the SetExtraReportingData endpoint. */ export type BasketOrderExtraReportingData = { cancelConfirmedTime?: Date | null | undefined; }; /** * The summed quantity value across all fills in this order, up to a maximum of 5 decimal places. Will be absent if an order has no fill information. */ export type BasketOrderFilledQuantity = { /** * 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 identifier type of the asset being ordered. For Equities: only SYMBOL is supported For Mutual Funds: only SYMBOL and CUSIP are supported */ export enum BasketOrderIdentifierType { Symbol = "SYMBOL", Cusip = "CUSIP", Isin = "ISIN", } /** * The identifier type of the asset being ordered. For Equities: only SYMBOL is supported For Mutual Funds: only SYMBOL and CUSIP are supported */ export type BasketOrderIdentifierTypeOpen = OpenEnum< typeof BasketOrderIdentifierType >; /** * The maximum number of shares to be sold if this is a notional SELL order of an Equity asset type. (Prohibited for other side or asset_type inputs.) * * @remarks * * This will only be recognized for clients configured to bypass the short sale risk check. When specified, must be greater than 0 and can't exceed 5 decimal places. */ export type BasketOrderMaxSellQuantity = { /** * 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; }; /** * Notional quantity of the order, measured in USD. Maximum 2 decimal place precision. Either a quantity or notional_value MUST be specified (but not both). For Equities: currently not supported yet For Mutual Funds: Only supported for BUY orders. The order will be transacted at the full notional amount specified. */ export type BasketOrderNotionalValue = { /** * 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; }; /** * When an order has the REJECTED status, this will be populated with a system code describing the rejection. */ export enum BasketOrderOrderRejectedReason { OrderRejectReasonUnspecified = "ORDER_REJECT_REASON_UNSPECIFIED", BrokerOption = "BROKER_OPTION", UnknownSecurity = "UNKNOWN_SECURITY", ExchangeClosed = "EXCHANGE_CLOSED", TooLateToEnter = "TOO_LATE_TO_ENTER", UnknownOrder = "UNKNOWN_ORDER", DuplicateOrder = "DUPLICATE_ORDER", StaleOrder = "STALE_ORDER", BelowNotionalMinimum = "BELOW_NOTIONAL_MINIMUM", 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", SymbolNotTradeable = "SYMBOL_NOT_TRADEABLE", AboveNotionalMaximum = "ABOVE_NOTIONAL_MAXIMUM", AboveShareMaximum = "ABOVE_SHARE_MAXIMUM", MaxSellQuantityRequired = "MAX_SELL_QUANTITY_REQUIRED", MaxSellQuantityProhibited = "MAX_SELL_QUANTITY_PROHIBITED", StockTradesDisabled = "STOCK_TRADES_DISABLED", AssetNotSetUpToTrade = "ASSET_NOT_SET_UP_TO_TRADE", AnotherBasketOrderForAccountHasFailedRiskChecks = "ANOTHER_BASKET_ORDER_FOR_ACCOUNT_HAS_FAILED_RISK_CHECKS", InsufficientPosition = "INSUFFICIENT_POSITION", FailedBuyingPower = "FAILED_BUYING_POWER", RoundUpAmountTooSmall = "ROUND_UP_AMOUNT_TOO_SMALL", AssetNotSetUpForRoundUps = "ASSET_NOT_SET_UP_FOR_ROUND_UPS", } /** * When an order has the REJECTED status, this will be populated with a system code describing the rejection. */ export type BasketOrderOrderRejectedReasonOpen = OpenEnum< typeof BasketOrderOrderRejectedReason >; /** * The processing status of the order */ export enum BasketOrderOrderStatus { OrderStatusUnspecified = "ORDER_STATUS_UNSPECIFIED", PendingNew = "PENDING_NEW", New = "NEW", PartiallyFilled = "PARTIALLY_FILLED", Filled = "FILLED", Rejected = "REJECTED", RemovedBeforeSubmission = "REMOVED_BEFORE_SUBMISSION", } /** * The processing status of the order */ export type BasketOrderOrderStatusOpen = OpenEnum< typeof BasketOrderOrderStatus >; /** * The execution type of this order. */ export enum BasketOrderOrderType { OrderTypeUnspecified = "ORDER_TYPE_UNSPECIFIED", Market = "MARKET", } /** * The execution type of this order. */ export type BasketOrderOrderTypeOpen = OpenEnum; /** * Numeric quantity of the order. Either a quantity or notional_value MUST be specified (but not both). For Equities: Represents the number of shares, must be greater than zero and may not exceed 5 decimal places. For Mutual Funds: Only supported for SELL orders. Represents the number of shares, up to a maximum of 3 decimal places. */ export type BasketOrderQuantity = { /** * 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 side of this order. */ export enum BasketOrderSide { SideUnspecified = "SIDE_UNSPECIFIED", Buy = "BUY", Sell = "SELL", } /** * The side of this order. */ export type BasketOrderSideOpen = OpenEnum; export enum BasketOrderSpecialReportingInstructions { SpecialReportingInstructionsUnspecified = "SPECIAL_REPORTING_INSTRUCTIONS_UNSPECIFIED", Solicited = "SOLICITED", Unsolicited = "UNSOLICITED", RoundUp = "ROUND_UP", } export type BasketOrderSpecialReportingInstructionsOpen = OpenEnum< typeof BasketOrderSpecialReportingInstructions >; /** * Must be the value "DAY". Regulatory requirements dictate that the system capture the intended time_in_force, which is why this a mandatory field. */ export enum BasketOrderTimeInForce { TimeInForceUnspecified = "TIME_IN_FORCE_UNSPECIFIED", Day = "DAY", } /** * Must be the value "DAY". Regulatory requirements dictate that the system capture the intended time_in_force, which is why this a mandatory field. */ export type BasketOrderTimeInForceOpen = OpenEnum< typeof BasketOrderTimeInForce >; /** * The message describing an order that has been added to a basket */ export type BasketOrder = { /** * The identifier of the account transacting this order */ accountId?: string | undefined; /** * Apex Asset ID for this asset. This will not be returned in the initial CreateOrder response and will be available after an order completes validation. If the provided identifier does not match any Apex asset available for trading, an OrderRejectReason of "UNKNOWN_SECURITY" will be returned and the asset_id will not be set. */ assetId?: string | undefined; /** * The type of the asset in this order */ assetType?: BasketOrderAssetTypeOpen | undefined; /** * The average prices, as weighted averages, across all executions in this order. Will be absent if an order has no executions. * * @remarks * * When asset_type = EQUITY, there will be at most one value present, with a type of PRICE_PER_UNIT. This will have up to 4 decimal places for USD amounts less than $1, and a maximum of two for larger USD amounts. */ averagePrices?: Array | undefined; /** * System generated unique id for the basket order. */ basketOrderId?: string | undefined; /** * Output only field that is required for Equity Orders for any client who is having Apex do CAT reporting on their behalf. This field denotes the initiator of the cancel request. This field will be present when provided on the RemoveOrderRequest */ cancelInitiator?: BasketOrderCancelInitiatorOpen | undefined; /** * Output only field for Equity Orders related to CAT reporting on behalf of clients. This field will be present when provided on the RemoveOrderRequest */ clientCancelReceivedTime?: Date | null | undefined; /** * Output only field for Equity Orders related to CAT reporting on behalf of clients. This field will be present when provided on the RemoveOrderRequest */ clientCancelSentTime?: Date | null | undefined; /** * User-supplied unique order ID. Cannot be more than 40 characters long. */ clientOrderId?: string | undefined; /** * Time the order request was received by the client. Must be in the past. Timezone will default to UTC if not provided. */ clientOrderReceivedTime?: Date | null | undefined; /** * Time of the order creation */ createTime?: Date | null | undefined; /** * The product of order quantity & price, summed across all fills, reported in the currency specified in the order. (This will be rounded to 2 decimal places for USD currencies). Will be absent if an order has no fill information. */ cumulativeNotionalValue?: | BasketOrderCumulativeNotionalValue | null | undefined; /** * Defaults to "USD". Only "USD" is supported. Full list of currency codes is defined at: https://en.wikipedia.org/wiki/ISO_4217 */ currencyCode?: string | undefined; /** * The execution-level details that compose this order */ executions?: Array | undefined; /** * Any reporting data provided by the SetExtraReportingData endpoint. */ extraReportingData?: BasketOrderExtraReportingData | null | undefined; /** * The summed quantity value across all fills in this order, up to a maximum of 5 decimal places. Will be absent if an order has no fill information. */ filledQuantity?: BasketOrderFilledQuantity | null | undefined; /** * Identifier of the asset (of the type specified in `identifier_type`). */ identifier?: string | undefined; /** * The identifier type of the asset being ordered. For Equities: only SYMBOL is supported For Mutual Funds: only SYMBOL and CUSIP are supported */ identifierType?: BasketOrderIdentifierTypeOpen | undefined; /** * Time of the last order update */ lastUpdateTime?: Date | null | undefined; /** * The maximum number of shares to be sold if this is a notional SELL order of an Equity asset type. (Prohibited for other side or asset_type inputs.) * * @remarks * * This will only be recognized for clients configured to bypass the short sale risk check. When specified, must be greater than 0 and can't exceed 5 decimal places. */ maxSellQuantity?: BasketOrderMaxSellQuantity | null | undefined; /** * System generated name of the basket order. */ name?: string | undefined; /** * Notional quantity of the order, measured in USD. Maximum 2 decimal place precision. Either a quantity or notional_value MUST be specified (but not both). For Equities: currently not supported yet For Mutual Funds: Only supported for BUY orders. The order will be transacted at the full notional amount specified. */ notionalValue?: BasketOrderNotionalValue | null | undefined; /** * When an order has the REJECTED status, this will be populated with a system code describing the rejection. */ orderRejectedReason?: BasketOrderOrderRejectedReasonOpen | undefined; /** * The processing status of the order */ orderStatus?: BasketOrderOrderStatusOpen | undefined; /** * The execution type of this order. */ orderType?: BasketOrderOrderTypeOpen | undefined; /** * Numeric quantity of the order. Either a quantity or notional_value MUST be specified (but not both). For Equities: Represents the number of shares, must be greater than zero and may not exceed 5 decimal places. For Mutual Funds: Only supported for SELL orders. Represents the number of shares, up to a maximum of 3 decimal places. */ quantity?: BasketOrderQuantity | null | undefined; /** * The side of this order. */ side?: BasketOrderSideOpen | undefined; /** * Special Reporting Instructions to be applied to this order. Can include multiple Instructions. */ specialReportingInstructions?: | Array | undefined; /** * Must be the value "DAY". Regulatory requirements dictate that the system capture the intended time_in_force, which is why this a mandatory field. */ timeInForce?: BasketOrderTimeInForceOpen | undefined; }; /** @internal */ export const BasketOrderAssetType$inboundSchema: z.ZodType< BasketOrderAssetTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BasketOrderAssetType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BasketOrderAssetType$outboundSchema: z.ZodType< BasketOrderAssetTypeOpen, z.ZodTypeDef, BasketOrderAssetTypeOpen > = z.union([ z.nativeEnum(BasketOrderAssetType), 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 BasketOrderAssetType$ { /** @deprecated use `BasketOrderAssetType$inboundSchema` instead. */ export const inboundSchema = BasketOrderAssetType$inboundSchema; /** @deprecated use `BasketOrderAssetType$outboundSchema` instead. */ export const outboundSchema = BasketOrderAssetType$outboundSchema; } /** @internal */ export const BasketOrderCancelInitiator$inboundSchema: z.ZodType< BasketOrderCancelInitiatorOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BasketOrderCancelInitiator), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BasketOrderCancelInitiator$outboundSchema: z.ZodType< BasketOrderCancelInitiatorOpen, z.ZodTypeDef, BasketOrderCancelInitiatorOpen > = z.union([ z.nativeEnum(BasketOrderCancelInitiator), 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 BasketOrderCancelInitiator$ { /** @deprecated use `BasketOrderCancelInitiator$inboundSchema` instead. */ export const inboundSchema = BasketOrderCancelInitiator$inboundSchema; /** @deprecated use `BasketOrderCancelInitiator$outboundSchema` instead. */ export const outboundSchema = BasketOrderCancelInitiator$outboundSchema; } /** @internal */ export const BasketOrderCumulativeNotionalValue$inboundSchema: z.ZodType< BasketOrderCumulativeNotionalValue, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type BasketOrderCumulativeNotionalValue$Outbound = { value?: string | undefined; }; /** @internal */ export const BasketOrderCumulativeNotionalValue$outboundSchema: z.ZodType< BasketOrderCumulativeNotionalValue$Outbound, z.ZodTypeDef, BasketOrderCumulativeNotionalValue > = 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 BasketOrderCumulativeNotionalValue$ { /** @deprecated use `BasketOrderCumulativeNotionalValue$inboundSchema` instead. */ export const inboundSchema = BasketOrderCumulativeNotionalValue$inboundSchema; /** @deprecated use `BasketOrderCumulativeNotionalValue$outboundSchema` instead. */ export const outboundSchema = BasketOrderCumulativeNotionalValue$outboundSchema; /** @deprecated use `BasketOrderCumulativeNotionalValue$Outbound` instead. */ export type Outbound = BasketOrderCumulativeNotionalValue$Outbound; } export function basketOrderCumulativeNotionalValueToJSON( basketOrderCumulativeNotionalValue: BasketOrderCumulativeNotionalValue, ): string { return JSON.stringify( BasketOrderCumulativeNotionalValue$outboundSchema.parse( basketOrderCumulativeNotionalValue, ), ); } export function basketOrderCumulativeNotionalValueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BasketOrderCumulativeNotionalValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BasketOrderCumulativeNotionalValue' from JSON`, ); } /** @internal */ export const BasketOrderExtraReportingData$inboundSchema: z.ZodType< BasketOrderExtraReportingData, z.ZodTypeDef, unknown > = z.object({ cancel_confirmed_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "cancel_confirmed_time": "cancelConfirmedTime", }); }); /** @internal */ export type BasketOrderExtraReportingData$Outbound = { cancel_confirmed_time?: string | null | undefined; }; /** @internal */ export const BasketOrderExtraReportingData$outboundSchema: z.ZodType< BasketOrderExtraReportingData$Outbound, z.ZodTypeDef, BasketOrderExtraReportingData > = z.object({ cancelConfirmedTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), }).transform((v) => { return remap$(v, { cancelConfirmedTime: "cancel_confirmed_time", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BasketOrderExtraReportingData$ { /** @deprecated use `BasketOrderExtraReportingData$inboundSchema` instead. */ export const inboundSchema = BasketOrderExtraReportingData$inboundSchema; /** @deprecated use `BasketOrderExtraReportingData$outboundSchema` instead. */ export const outboundSchema = BasketOrderExtraReportingData$outboundSchema; /** @deprecated use `BasketOrderExtraReportingData$Outbound` instead. */ export type Outbound = BasketOrderExtraReportingData$Outbound; } export function basketOrderExtraReportingDataToJSON( basketOrderExtraReportingData: BasketOrderExtraReportingData, ): string { return JSON.stringify( BasketOrderExtraReportingData$outboundSchema.parse( basketOrderExtraReportingData, ), ); } export function basketOrderExtraReportingDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BasketOrderExtraReportingData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BasketOrderExtraReportingData' from JSON`, ); } /** @internal */ export const BasketOrderFilledQuantity$inboundSchema: z.ZodType< BasketOrderFilledQuantity, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type BasketOrderFilledQuantity$Outbound = { value?: string | undefined; }; /** @internal */ export const BasketOrderFilledQuantity$outboundSchema: z.ZodType< BasketOrderFilledQuantity$Outbound, z.ZodTypeDef, BasketOrderFilledQuantity > = 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 BasketOrderFilledQuantity$ { /** @deprecated use `BasketOrderFilledQuantity$inboundSchema` instead. */ export const inboundSchema = BasketOrderFilledQuantity$inboundSchema; /** @deprecated use `BasketOrderFilledQuantity$outboundSchema` instead. */ export const outboundSchema = BasketOrderFilledQuantity$outboundSchema; /** @deprecated use `BasketOrderFilledQuantity$Outbound` instead. */ export type Outbound = BasketOrderFilledQuantity$Outbound; } export function basketOrderFilledQuantityToJSON( basketOrderFilledQuantity: BasketOrderFilledQuantity, ): string { return JSON.stringify( BasketOrderFilledQuantity$outboundSchema.parse(basketOrderFilledQuantity), ); } export function basketOrderFilledQuantityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BasketOrderFilledQuantity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BasketOrderFilledQuantity' from JSON`, ); } /** @internal */ export const BasketOrderIdentifierType$inboundSchema: z.ZodType< BasketOrderIdentifierTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BasketOrderIdentifierType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BasketOrderIdentifierType$outboundSchema: z.ZodType< BasketOrderIdentifierTypeOpen, z.ZodTypeDef, BasketOrderIdentifierTypeOpen > = z.union([ z.nativeEnum(BasketOrderIdentifierType), 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 BasketOrderIdentifierType$ { /** @deprecated use `BasketOrderIdentifierType$inboundSchema` instead. */ export const inboundSchema = BasketOrderIdentifierType$inboundSchema; /** @deprecated use `BasketOrderIdentifierType$outboundSchema` instead. */ export const outboundSchema = BasketOrderIdentifierType$outboundSchema; } /** @internal */ export const BasketOrderMaxSellQuantity$inboundSchema: z.ZodType< BasketOrderMaxSellQuantity, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type BasketOrderMaxSellQuantity$Outbound = { value?: string | undefined; }; /** @internal */ export const BasketOrderMaxSellQuantity$outboundSchema: z.ZodType< BasketOrderMaxSellQuantity$Outbound, z.ZodTypeDef, BasketOrderMaxSellQuantity > = 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 BasketOrderMaxSellQuantity$ { /** @deprecated use `BasketOrderMaxSellQuantity$inboundSchema` instead. */ export const inboundSchema = BasketOrderMaxSellQuantity$inboundSchema; /** @deprecated use `BasketOrderMaxSellQuantity$outboundSchema` instead. */ export const outboundSchema = BasketOrderMaxSellQuantity$outboundSchema; /** @deprecated use `BasketOrderMaxSellQuantity$Outbound` instead. */ export type Outbound = BasketOrderMaxSellQuantity$Outbound; } export function basketOrderMaxSellQuantityToJSON( basketOrderMaxSellQuantity: BasketOrderMaxSellQuantity, ): string { return JSON.stringify( BasketOrderMaxSellQuantity$outboundSchema.parse(basketOrderMaxSellQuantity), ); } export function basketOrderMaxSellQuantityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BasketOrderMaxSellQuantity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BasketOrderMaxSellQuantity' from JSON`, ); } /** @internal */ export const BasketOrderNotionalValue$inboundSchema: z.ZodType< BasketOrderNotionalValue, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type BasketOrderNotionalValue$Outbound = { value?: string | undefined; }; /** @internal */ export const BasketOrderNotionalValue$outboundSchema: z.ZodType< BasketOrderNotionalValue$Outbound, z.ZodTypeDef, BasketOrderNotionalValue > = 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 BasketOrderNotionalValue$ { /** @deprecated use `BasketOrderNotionalValue$inboundSchema` instead. */ export const inboundSchema = BasketOrderNotionalValue$inboundSchema; /** @deprecated use `BasketOrderNotionalValue$outboundSchema` instead. */ export const outboundSchema = BasketOrderNotionalValue$outboundSchema; /** @deprecated use `BasketOrderNotionalValue$Outbound` instead. */ export type Outbound = BasketOrderNotionalValue$Outbound; } export function basketOrderNotionalValueToJSON( basketOrderNotionalValue: BasketOrderNotionalValue, ): string { return JSON.stringify( BasketOrderNotionalValue$outboundSchema.parse(basketOrderNotionalValue), ); } export function basketOrderNotionalValueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BasketOrderNotionalValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BasketOrderNotionalValue' from JSON`, ); } /** @internal */ export const BasketOrderOrderRejectedReason$inboundSchema: z.ZodType< BasketOrderOrderRejectedReasonOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BasketOrderOrderRejectedReason), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BasketOrderOrderRejectedReason$outboundSchema: z.ZodType< BasketOrderOrderRejectedReasonOpen, z.ZodTypeDef, BasketOrderOrderRejectedReasonOpen > = z.union([ z.nativeEnum(BasketOrderOrderRejectedReason), 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 BasketOrderOrderRejectedReason$ { /** @deprecated use `BasketOrderOrderRejectedReason$inboundSchema` instead. */ export const inboundSchema = BasketOrderOrderRejectedReason$inboundSchema; /** @deprecated use `BasketOrderOrderRejectedReason$outboundSchema` instead. */ export const outboundSchema = BasketOrderOrderRejectedReason$outboundSchema; } /** @internal */ export const BasketOrderOrderStatus$inboundSchema: z.ZodType< BasketOrderOrderStatusOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BasketOrderOrderStatus), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BasketOrderOrderStatus$outboundSchema: z.ZodType< BasketOrderOrderStatusOpen, z.ZodTypeDef, BasketOrderOrderStatusOpen > = z.union([ z.nativeEnum(BasketOrderOrderStatus), 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 BasketOrderOrderStatus$ { /** @deprecated use `BasketOrderOrderStatus$inboundSchema` instead. */ export const inboundSchema = BasketOrderOrderStatus$inboundSchema; /** @deprecated use `BasketOrderOrderStatus$outboundSchema` instead. */ export const outboundSchema = BasketOrderOrderStatus$outboundSchema; } /** @internal */ export const BasketOrderOrderType$inboundSchema: z.ZodType< BasketOrderOrderTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BasketOrderOrderType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BasketOrderOrderType$outboundSchema: z.ZodType< BasketOrderOrderTypeOpen, z.ZodTypeDef, BasketOrderOrderTypeOpen > = z.union([ z.nativeEnum(BasketOrderOrderType), 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 BasketOrderOrderType$ { /** @deprecated use `BasketOrderOrderType$inboundSchema` instead. */ export const inboundSchema = BasketOrderOrderType$inboundSchema; /** @deprecated use `BasketOrderOrderType$outboundSchema` instead. */ export const outboundSchema = BasketOrderOrderType$outboundSchema; } /** @internal */ export const BasketOrderQuantity$inboundSchema: z.ZodType< BasketOrderQuantity, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type BasketOrderQuantity$Outbound = { value?: string | undefined; }; /** @internal */ export const BasketOrderQuantity$outboundSchema: z.ZodType< BasketOrderQuantity$Outbound, z.ZodTypeDef, BasketOrderQuantity > = 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 BasketOrderQuantity$ { /** @deprecated use `BasketOrderQuantity$inboundSchema` instead. */ export const inboundSchema = BasketOrderQuantity$inboundSchema; /** @deprecated use `BasketOrderQuantity$outboundSchema` instead. */ export const outboundSchema = BasketOrderQuantity$outboundSchema; /** @deprecated use `BasketOrderQuantity$Outbound` instead. */ export type Outbound = BasketOrderQuantity$Outbound; } export function basketOrderQuantityToJSON( basketOrderQuantity: BasketOrderQuantity, ): string { return JSON.stringify( BasketOrderQuantity$outboundSchema.parse(basketOrderQuantity), ); } export function basketOrderQuantityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BasketOrderQuantity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BasketOrderQuantity' from JSON`, ); } /** @internal */ export const BasketOrderSide$inboundSchema: z.ZodType< BasketOrderSideOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BasketOrderSide), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BasketOrderSide$outboundSchema: z.ZodType< BasketOrderSideOpen, z.ZodTypeDef, BasketOrderSideOpen > = z.union([ z.nativeEnum(BasketOrderSide), 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 BasketOrderSide$ { /** @deprecated use `BasketOrderSide$inboundSchema` instead. */ export const inboundSchema = BasketOrderSide$inboundSchema; /** @deprecated use `BasketOrderSide$outboundSchema` instead. */ export const outboundSchema = BasketOrderSide$outboundSchema; } /** @internal */ export const BasketOrderSpecialReportingInstructions$inboundSchema: z.ZodType< BasketOrderSpecialReportingInstructionsOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BasketOrderSpecialReportingInstructions), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BasketOrderSpecialReportingInstructions$outboundSchema: z.ZodType< BasketOrderSpecialReportingInstructionsOpen, z.ZodTypeDef, BasketOrderSpecialReportingInstructionsOpen > = z.union([ z.nativeEnum(BasketOrderSpecialReportingInstructions), 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 BasketOrderSpecialReportingInstructions$ { /** @deprecated use `BasketOrderSpecialReportingInstructions$inboundSchema` instead. */ export const inboundSchema = BasketOrderSpecialReportingInstructions$inboundSchema; /** @deprecated use `BasketOrderSpecialReportingInstructions$outboundSchema` instead. */ export const outboundSchema = BasketOrderSpecialReportingInstructions$outboundSchema; } /** @internal */ export const BasketOrderTimeInForce$inboundSchema: z.ZodType< BasketOrderTimeInForceOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BasketOrderTimeInForce), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BasketOrderTimeInForce$outboundSchema: z.ZodType< BasketOrderTimeInForceOpen, z.ZodTypeDef, BasketOrderTimeInForceOpen > = z.union([ z.nativeEnum(BasketOrderTimeInForce), 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 BasketOrderTimeInForce$ { /** @deprecated use `BasketOrderTimeInForce$inboundSchema` instead. */ export const inboundSchema = BasketOrderTimeInForce$inboundSchema; /** @deprecated use `BasketOrderTimeInForce$outboundSchema` instead. */ export const outboundSchema = BasketOrderTimeInForce$outboundSchema; } /** @internal */ export const BasketOrder$inboundSchema: z.ZodType< BasketOrder, z.ZodTypeDef, unknown > = z.object({ account_id: z.string().optional(), asset_id: z.string().optional(), asset_type: BasketOrderAssetType$inboundSchema.optional(), average_prices: z.array(BasketTradingExecutedPrice$inboundSchema).optional(), basket_order_id: z.string().optional(), cancel_initiator: BasketOrderCancelInitiator$inboundSchema.optional(), client_cancel_received_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), client_cancel_sent_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), client_order_id: z.string().optional(), client_order_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(() => BasketOrderCumulativeNotionalValue$inboundSchema), ).optional(), currency_code: z.string().optional(), executions: z.array(BasketTradingExecutions$inboundSchema).optional(), extra_reporting_data: z.nullable( z.lazy(() => BasketOrderExtraReportingData$inboundSchema), ).optional(), filled_quantity: z.nullable( z.lazy(() => BasketOrderFilledQuantity$inboundSchema), ).optional(), identifier: z.string().optional(), identifier_type: BasketOrderIdentifierType$inboundSchema.optional(), last_update_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), max_sell_quantity: z.nullable( z.lazy(() => BasketOrderMaxSellQuantity$inboundSchema), ).optional(), name: z.string().optional(), notional_value: z.nullable( z.lazy(() => BasketOrderNotionalValue$inboundSchema), ).optional(), order_rejected_reason: BasketOrderOrderRejectedReason$inboundSchema .optional(), order_status: BasketOrderOrderStatus$inboundSchema.optional(), order_type: BasketOrderOrderType$inboundSchema.optional(), quantity: z.nullable(z.lazy(() => BasketOrderQuantity$inboundSchema)) .optional(), side: BasketOrderSide$inboundSchema.optional(), special_reporting_instructions: z.array( BasketOrderSpecialReportingInstructions$inboundSchema, ).optional(), time_in_force: BasketOrderTimeInForce$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "account_id": "accountId", "asset_id": "assetId", "asset_type": "assetType", "average_prices": "averagePrices", "basket_order_id": "basketOrderId", "cancel_initiator": "cancelInitiator", "client_cancel_received_time": "clientCancelReceivedTime", "client_cancel_sent_time": "clientCancelSentTime", "client_order_id": "clientOrderId", "client_order_received_time": "clientOrderReceivedTime", "create_time": "createTime", "cumulative_notional_value": "cumulativeNotionalValue", "currency_code": "currencyCode", "extra_reporting_data": "extraReportingData", "filled_quantity": "filledQuantity", "identifier_type": "identifierType", "last_update_time": "lastUpdateTime", "max_sell_quantity": "maxSellQuantity", "notional_value": "notionalValue", "order_rejected_reason": "orderRejectedReason", "order_status": "orderStatus", "order_type": "orderType", "special_reporting_instructions": "specialReportingInstructions", "time_in_force": "timeInForce", }); }); /** @internal */ export type BasketOrder$Outbound = { account_id?: string | undefined; asset_id?: string | undefined; asset_type?: string | undefined; average_prices?: Array | undefined; basket_order_id?: string | undefined; cancel_initiator?: string | undefined; client_cancel_received_time?: string | null | undefined; client_cancel_sent_time?: string | null | undefined; client_order_id?: string | undefined; client_order_received_time?: string | null | undefined; create_time?: string | null | undefined; cumulative_notional_value?: | BasketOrderCumulativeNotionalValue$Outbound | null | undefined; currency_code?: string | undefined; executions?: Array | undefined; extra_reporting_data?: | BasketOrderExtraReportingData$Outbound | null | undefined; filled_quantity?: BasketOrderFilledQuantity$Outbound | null | undefined; identifier?: string | undefined; identifier_type?: string | undefined; last_update_time?: string | null | undefined; max_sell_quantity?: BasketOrderMaxSellQuantity$Outbound | null | undefined; name?: string | undefined; notional_value?: BasketOrderNotionalValue$Outbound | null | undefined; order_rejected_reason?: string | undefined; order_status?: string | undefined; order_type?: string | undefined; quantity?: BasketOrderQuantity$Outbound | null | undefined; side?: string | undefined; special_reporting_instructions?: Array | undefined; time_in_force?: string | undefined; }; /** @internal */ export const BasketOrder$outboundSchema: z.ZodType< BasketOrder$Outbound, z.ZodTypeDef, BasketOrder > = z.object({ accountId: z.string().optional(), assetId: z.string().optional(), assetType: BasketOrderAssetType$outboundSchema.optional(), averagePrices: z.array(BasketTradingExecutedPrice$outboundSchema).optional(), basketOrderId: z.string().optional(), cancelInitiator: BasketOrderCancelInitiator$outboundSchema.optional(), clientCancelReceivedTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), clientCancelSentTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), clientOrderId: z.string().optional(), clientOrderReceivedTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), createTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), cumulativeNotionalValue: z.nullable( z.lazy(() => BasketOrderCumulativeNotionalValue$outboundSchema), ).optional(), currencyCode: z.string().optional(), executions: z.array(BasketTradingExecutions$outboundSchema).optional(), extraReportingData: z.nullable( z.lazy(() => BasketOrderExtraReportingData$outboundSchema), ).optional(), filledQuantity: z.nullable( z.lazy(() => BasketOrderFilledQuantity$outboundSchema), ).optional(), identifier: z.string().optional(), identifierType: BasketOrderIdentifierType$outboundSchema.optional(), lastUpdateTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), maxSellQuantity: z.nullable( z.lazy(() => BasketOrderMaxSellQuantity$outboundSchema), ).optional(), name: z.string().optional(), notionalValue: z.nullable( z.lazy(() => BasketOrderNotionalValue$outboundSchema), ).optional(), orderRejectedReason: BasketOrderOrderRejectedReason$outboundSchema.optional(), orderStatus: BasketOrderOrderStatus$outboundSchema.optional(), orderType: BasketOrderOrderType$outboundSchema.optional(), quantity: z.nullable(z.lazy(() => BasketOrderQuantity$outboundSchema)) .optional(), side: BasketOrderSide$outboundSchema.optional(), specialReportingInstructions: z.array( BasketOrderSpecialReportingInstructions$outboundSchema, ).optional(), timeInForce: BasketOrderTimeInForce$outboundSchema.optional(), }).transform((v) => { return remap$(v, { accountId: "account_id", assetId: "asset_id", assetType: "asset_type", averagePrices: "average_prices", basketOrderId: "basket_order_id", cancelInitiator: "cancel_initiator", clientCancelReceivedTime: "client_cancel_received_time", clientCancelSentTime: "client_cancel_sent_time", clientOrderId: "client_order_id", clientOrderReceivedTime: "client_order_received_time", createTime: "create_time", cumulativeNotionalValue: "cumulative_notional_value", currencyCode: "currency_code", extraReportingData: "extra_reporting_data", filledQuantity: "filled_quantity", identifierType: "identifier_type", lastUpdateTime: "last_update_time", maxSellQuantity: "max_sell_quantity", notionalValue: "notional_value", orderRejectedReason: "order_rejected_reason", orderStatus: "order_status", orderType: "order_type", 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 BasketOrder$ { /** @deprecated use `BasketOrder$inboundSchema` instead. */ export const inboundSchema = BasketOrder$inboundSchema; /** @deprecated use `BasketOrder$outboundSchema` instead. */ export const outboundSchema = BasketOrder$outboundSchema; /** @deprecated use `BasketOrder$Outbound` instead. */ export type Outbound = BasketOrder$Outbound; } export function basketOrderToJSON(basketOrder: BasketOrder): string { return JSON.stringify(BasketOrder$outboundSchema.parse(basketOrder)); } export function basketOrderFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BasketOrder$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BasketOrder' from JSON`, ); }