/* * 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 { DateCreate, DateCreate$inboundSchema, DateCreate$Outbound, DateCreate$outboundSchema, } from "./datecreate.js"; import { DecimalCreate, DecimalCreate$inboundSchema, DecimalCreate$Outbound, DecimalCreate$outboundSchema, } from "./decimalcreate.js"; import { FeeCreate, FeeCreate$inboundSchema, FeeCreate$Outbound, FeeCreate$outboundSchema, } from "./feecreate.js"; import { OptionOrderLegCreate, OptionOrderLegCreate$inboundSchema, OptionOrderLegCreate$Outbound, OptionOrderLegCreate$outboundSchema, } from "./optionorderlegcreate.js"; /** * The capacity in which the broker is acting for this option order. */ export enum OptionOrderCreateBrokerCapacity { BrokerCapacityUnspecified = "BROKER_CAPACITY_UNSPECIFIED", Agency = "AGENCY", Principal = "PRINCIPAL", } /** * The capacity in which the broker is acting for this option order. */ export type OptionOrderCreateBrokerCapacityOpen = OpenEnum< typeof OptionOrderCreateBrokerCapacity >; /** * The execution type of this option order. */ export enum OptionOrderCreateOrderType { OrderTypeUnspecified = "ORDER_TYPE_UNSPECIFIED", Limit = "LIMIT", } /** * The execution type of this option order. */ export type OptionOrderCreateOrderTypeOpen = OpenEnum< typeof OptionOrderCreateOrderType >; /** * 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 PriceDirection { 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 PriceDirectionOpen = OpenEnum; export enum OptionOrderCreateSpecialReportingInstructions { 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 OptionOrderCreateSpecialReportingInstructionsOpen = OpenEnum< typeof OptionOrderCreateSpecialReportingInstructions >; /** * 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 OptionOrderCreateTimeInForce { 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 OptionOrderCreateTimeInForceOpen = OpenEnum< typeof OptionOrderCreateTimeInForce >; /** * The message describing an option order */ export type OptionOrderCreate = { /** * The capacity in which the broker is acting for this option order. */ brokerCapacity: OptionOrderCreateBrokerCapacityOpen; /** * User-supplied unique option order ID. Cannot be more than 40 characters long. */ clientOrderId: string; /** * Required for any client who is having Apex do CAT reporting on their behalf. */ clientReceivedTime?: Date | null | undefined; /** * Only "USD" is supported. Full list of currency codes is defined at: https://en.wikipedia.org/wiki/ISO_4217 */ currencyCode: string; /** * Fees that will be applied to this option order. */ fees?: Array | 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; /** * A representation of a decimal value, such as 2.5. Clients may convert values into language-native decimal formats, such as Java's [BigDecimal][] or Python's [decimal.Decimal][]. * * @remarks * * [BigDecimal]: * https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html * [decimal.Decimal]: https://docs.python.org/3/library/decimal.html */ limitPrice: DecimalCreate; /** * Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * * @remarks * * * A full date, with non-zero year, month, and day values * A month and day value, with a zero year, such as an anniversary * A year on its own, with zero month and day values * A year and month value, with a zero day, such as a credit card expiration date * * Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and `google.protobuf.Timestamp`. */ orderDate: DateCreate; /** * The execution type of this option order. */ orderType: OptionOrderCreateOrderTypeOpen; /** * 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: PriceDirectionOpen; /** * A representation of a decimal value, such as 2.5. Clients may convert values into language-native decimal formats, such as Java's [BigDecimal][] or Python's [decimal.Decimal][]. * * @remarks * * [BigDecimal]: * https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html * [decimal.Decimal]: https://docs.python.org/3/library/decimal.html */ quantity: DecimalCreate; /** * 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: OptionOrderCreateTimeInForceOpen; }; /** @internal */ export const OptionOrderCreateBrokerCapacity$inboundSchema: z.ZodType< OptionOrderCreateBrokerCapacityOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderCreateBrokerCapacity), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderCreateBrokerCapacity$outboundSchema: z.ZodType< OptionOrderCreateBrokerCapacityOpen, z.ZodTypeDef, OptionOrderCreateBrokerCapacityOpen > = z.union([ z.nativeEnum(OptionOrderCreateBrokerCapacity), 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 OptionOrderCreateBrokerCapacity$ { /** @deprecated use `OptionOrderCreateBrokerCapacity$inboundSchema` instead. */ export const inboundSchema = OptionOrderCreateBrokerCapacity$inboundSchema; /** @deprecated use `OptionOrderCreateBrokerCapacity$outboundSchema` instead. */ export const outboundSchema = OptionOrderCreateBrokerCapacity$outboundSchema; } /** @internal */ export const OptionOrderCreateOrderType$inboundSchema: z.ZodType< OptionOrderCreateOrderTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderCreateOrderType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderCreateOrderType$outboundSchema: z.ZodType< OptionOrderCreateOrderTypeOpen, z.ZodTypeDef, OptionOrderCreateOrderTypeOpen > = z.union([ z.nativeEnum(OptionOrderCreateOrderType), 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 OptionOrderCreateOrderType$ { /** @deprecated use `OptionOrderCreateOrderType$inboundSchema` instead. */ export const inboundSchema = OptionOrderCreateOrderType$inboundSchema; /** @deprecated use `OptionOrderCreateOrderType$outboundSchema` instead. */ export const outboundSchema = OptionOrderCreateOrderType$outboundSchema; } /** @internal */ export const PriceDirection$inboundSchema: z.ZodType< PriceDirectionOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(PriceDirection), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const PriceDirection$outboundSchema: z.ZodType< PriceDirectionOpen, z.ZodTypeDef, PriceDirectionOpen > = z.union([ z.nativeEnum(PriceDirection), 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 PriceDirection$ { /** @deprecated use `PriceDirection$inboundSchema` instead. */ export const inboundSchema = PriceDirection$inboundSchema; /** @deprecated use `PriceDirection$outboundSchema` instead. */ export const outboundSchema = PriceDirection$outboundSchema; } /** @internal */ export const OptionOrderCreateSpecialReportingInstructions$inboundSchema: z.ZodType< OptionOrderCreateSpecialReportingInstructionsOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderCreateSpecialReportingInstructions), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderCreateSpecialReportingInstructions$outboundSchema: z.ZodType< OptionOrderCreateSpecialReportingInstructionsOpen, z.ZodTypeDef, OptionOrderCreateSpecialReportingInstructionsOpen > = z.union([ z.nativeEnum(OptionOrderCreateSpecialReportingInstructions), 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 OptionOrderCreateSpecialReportingInstructions$ { /** @deprecated use `OptionOrderCreateSpecialReportingInstructions$inboundSchema` instead. */ export const inboundSchema = OptionOrderCreateSpecialReportingInstructions$inboundSchema; /** @deprecated use `OptionOrderCreateSpecialReportingInstructions$outboundSchema` instead. */ export const outboundSchema = OptionOrderCreateSpecialReportingInstructions$outboundSchema; } /** @internal */ export const OptionOrderCreateTimeInForce$inboundSchema: z.ZodType< OptionOrderCreateTimeInForceOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderCreateTimeInForce), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderCreateTimeInForce$outboundSchema: z.ZodType< OptionOrderCreateTimeInForceOpen, z.ZodTypeDef, OptionOrderCreateTimeInForceOpen > = z.union([ z.nativeEnum(OptionOrderCreateTimeInForce), 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 OptionOrderCreateTimeInForce$ { /** @deprecated use `OptionOrderCreateTimeInForce$inboundSchema` instead. */ export const inboundSchema = OptionOrderCreateTimeInForce$inboundSchema; /** @deprecated use `OptionOrderCreateTimeInForce$outboundSchema` instead. */ export const outboundSchema = OptionOrderCreateTimeInForce$outboundSchema; } /** @internal */ export const OptionOrderCreate$inboundSchema: z.ZodType< OptionOrderCreate, z.ZodTypeDef, unknown > = z.object({ broker_capacity: OptionOrderCreateBrokerCapacity$inboundSchema, client_order_id: z.string(), client_received_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), currency_code: z.string(), fees: z.array(FeeCreate$inboundSchema).optional(), legs: z.array(OptionOrderLegCreate$inboundSchema), limit_price: DecimalCreate$inboundSchema, order_date: DateCreate$inboundSchema, order_type: OptionOrderCreateOrderType$inboundSchema, price_direction: PriceDirection$inboundSchema, quantity: DecimalCreate$inboundSchema, special_reporting_instructions: z.array( OptionOrderCreateSpecialReportingInstructions$inboundSchema, ).optional(), time_in_force: OptionOrderCreateTimeInForce$inboundSchema, }).transform((v) => { return remap$(v, { "broker_capacity": "brokerCapacity", "client_order_id": "clientOrderId", "client_received_time": "clientReceivedTime", "currency_code": "currencyCode", "limit_price": "limitPrice", "order_date": "orderDate", "order_type": "orderType", "price_direction": "priceDirection", "special_reporting_instructions": "specialReportingInstructions", "time_in_force": "timeInForce", }); }); /** @internal */ export type OptionOrderCreate$Outbound = { broker_capacity: string; client_order_id: string; client_received_time?: string | null | undefined; currency_code: string; fees?: Array | undefined; legs: Array; limit_price: DecimalCreate$Outbound; order_date: DateCreate$Outbound; order_type: string; price_direction: string; quantity: DecimalCreate$Outbound; special_reporting_instructions?: Array | undefined; time_in_force: string; }; /** @internal */ export const OptionOrderCreate$outboundSchema: z.ZodType< OptionOrderCreate$Outbound, z.ZodTypeDef, OptionOrderCreate > = z.object({ brokerCapacity: OptionOrderCreateBrokerCapacity$outboundSchema, clientOrderId: z.string(), clientReceivedTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), currencyCode: z.string(), fees: z.array(FeeCreate$outboundSchema).optional(), legs: z.array(OptionOrderLegCreate$outboundSchema), limitPrice: DecimalCreate$outboundSchema, orderDate: DateCreate$outboundSchema, orderType: OptionOrderCreateOrderType$outboundSchema, priceDirection: PriceDirection$outboundSchema, quantity: DecimalCreate$outboundSchema, specialReportingInstructions: z.array( OptionOrderCreateSpecialReportingInstructions$outboundSchema, ).optional(), timeInForce: OptionOrderCreateTimeInForce$outboundSchema, }).transform((v) => { return remap$(v, { brokerCapacity: "broker_capacity", clientOrderId: "client_order_id", clientReceivedTime: "client_received_time", currencyCode: "currency_code", limitPrice: "limit_price", orderDate: "order_date", 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 OptionOrderCreate$ { /** @deprecated use `OptionOrderCreate$inboundSchema` instead. */ export const inboundSchema = OptionOrderCreate$inboundSchema; /** @deprecated use `OptionOrderCreate$outboundSchema` instead. */ export const outboundSchema = OptionOrderCreate$outboundSchema; /** @deprecated use `OptionOrderCreate$Outbound` instead. */ export type Outbound = OptionOrderCreate$Outbound; } export function optionOrderCreateToJSON( optionOrderCreate: OptionOrderCreate, ): string { return JSON.stringify( OptionOrderCreate$outboundSchema.parse(optionOrderCreate), ); } export function optionOrderCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OptionOrderCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OptionOrderCreate' from JSON`, ); }