/* * 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"; /** * The type of the asset in this option order leg. Orders with only a single leg may only contain an OPTION asset type. Orders with multiple legs must contain at least one OPTION leg, and no more than one EQUITY leg. */ export enum OptionOrderLegCreateAssetType { Equity = "EQUITY", Option = "OPTION", } /** * The type of the asset in this option order leg. Orders with only a single leg may only contain an OPTION asset type. Orders with multiple legs must contain at least one OPTION leg, and no more than one EQUITY leg. */ export type OptionOrderLegCreateAssetTypeOpen = OpenEnum< typeof OptionOrderLegCreateAssetType >; /** * The format of the identifier value used to look up the security. When `asset_type` is OPTION, the identifier_type must be OSI. */ export enum OptionOrderLegCreateIdentifierType { LegIdentifierTypeUnspecified = "LEG_IDENTIFIER_TYPE_UNSPECIFIED", Osi = "OSI", } /** * The format of the identifier value used to look up the security. When `asset_type` is OPTION, the identifier_type must be OSI. */ export type OptionOrderLegCreateIdentifierTypeOpen = OpenEnum< typeof OptionOrderLegCreateIdentifierType >; /** * The side of the option order to be sent to the market. */ export enum OptionOrderLegCreateSide { SideUnspecified = "SIDE_UNSPECIFIED", Buy = "BUY", Sell = "SELL", } /** * The side of the option order to be sent to the market. */ export type OptionOrderLegCreateSideOpen = OpenEnum< typeof OptionOrderLegCreateSide >; /** * The open/close modification of the side, signaling whether this option order leg intends to OPEN a new position, or to CLOSE an existing one. */ export enum SideModifier { SideModifierUnspecified = "SIDE_MODIFIER_UNSPECIFIED", Open = "OPEN", Close = "CLOSE", } /** * The open/close modification of the side, signaling whether this option order leg intends to OPEN a new position, or to CLOSE an existing one. */ export type SideModifierOpen = OpenEnum; /** * The message describing an option order leg. */ export type OptionOrderLegCreate = { /** * The type of the asset in this option order leg. Orders with only a single leg may only contain an OPTION asset type. Orders with multiple legs must contain at least one OPTION leg, and no more than one EQUITY leg. */ assetType: OptionOrderLegCreateAssetTypeOpen; /** * The identifier of the asset, in the format specified by `identifier_type`. When `identifier_type` is OSI, this field must be a valid OSI identifier, which is between 16 and 21 characters. (This value must not contain any spaces between the symbol and expiry date.) When `identifier_type` is SYMBOL, this field must contain the ticker value of the security, which is between 1 and 6 characters and must conform the same input constraints called out in the non-options single option order API. */ identifier: string; /** * The format of the identifier value used to look up the security. When `asset_type` is OPTION, the identifier_type must be OSI. */ identifierType: OptionOrderLegCreateIdentifierTypeOpen; /** * This specifies the quantity of security to be ordered in this leg. For a single-leg order, this value must be 1 (one). For a multi-leg order, this value must be greater than zero, and the total number of shares or contracts ordered at the market will be `order.quantity * leg.ratio_quantity`. */ ratioQuantity: number; /** * The side of the option order to be sent to the market. */ side: OptionOrderLegCreateSideOpen; /** * The open/close modification of the side, signaling whether this option order leg intends to OPEN a new position, or to CLOSE an existing one. */ sideModifier: SideModifierOpen; }; /** @internal */ export const OptionOrderLegCreateAssetType$inboundSchema: z.ZodType< OptionOrderLegCreateAssetTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderLegCreateAssetType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderLegCreateAssetType$outboundSchema: z.ZodType< OptionOrderLegCreateAssetTypeOpen, z.ZodTypeDef, OptionOrderLegCreateAssetTypeOpen > = z.union([ z.nativeEnum(OptionOrderLegCreateAssetType), 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 OptionOrderLegCreateAssetType$ { /** @deprecated use `OptionOrderLegCreateAssetType$inboundSchema` instead. */ export const inboundSchema = OptionOrderLegCreateAssetType$inboundSchema; /** @deprecated use `OptionOrderLegCreateAssetType$outboundSchema` instead. */ export const outboundSchema = OptionOrderLegCreateAssetType$outboundSchema; } /** @internal */ export const OptionOrderLegCreateIdentifierType$inboundSchema: z.ZodType< OptionOrderLegCreateIdentifierTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderLegCreateIdentifierType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderLegCreateIdentifierType$outboundSchema: z.ZodType< OptionOrderLegCreateIdentifierTypeOpen, z.ZodTypeDef, OptionOrderLegCreateIdentifierTypeOpen > = z.union([ z.nativeEnum(OptionOrderLegCreateIdentifierType), 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 OptionOrderLegCreateIdentifierType$ { /** @deprecated use `OptionOrderLegCreateIdentifierType$inboundSchema` instead. */ export const inboundSchema = OptionOrderLegCreateIdentifierType$inboundSchema; /** @deprecated use `OptionOrderLegCreateIdentifierType$outboundSchema` instead. */ export const outboundSchema = OptionOrderLegCreateIdentifierType$outboundSchema; } /** @internal */ export const OptionOrderLegCreateSide$inboundSchema: z.ZodType< OptionOrderLegCreateSideOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionOrderLegCreateSide), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionOrderLegCreateSide$outboundSchema: z.ZodType< OptionOrderLegCreateSideOpen, z.ZodTypeDef, OptionOrderLegCreateSideOpen > = z.union([ z.nativeEnum(OptionOrderLegCreateSide), 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 OptionOrderLegCreateSide$ { /** @deprecated use `OptionOrderLegCreateSide$inboundSchema` instead. */ export const inboundSchema = OptionOrderLegCreateSide$inboundSchema; /** @deprecated use `OptionOrderLegCreateSide$outboundSchema` instead. */ export const outboundSchema = OptionOrderLegCreateSide$outboundSchema; } /** @internal */ export const SideModifier$inboundSchema: z.ZodType< SideModifierOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(SideModifier), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const SideModifier$outboundSchema: z.ZodType< SideModifierOpen, z.ZodTypeDef, SideModifierOpen > = z.union([ z.nativeEnum(SideModifier), 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 SideModifier$ { /** @deprecated use `SideModifier$inboundSchema` instead. */ export const inboundSchema = SideModifier$inboundSchema; /** @deprecated use `SideModifier$outboundSchema` instead. */ export const outboundSchema = SideModifier$outboundSchema; } /** @internal */ export const OptionOrderLegCreate$inboundSchema: z.ZodType< OptionOrderLegCreate, z.ZodTypeDef, unknown > = z.object({ asset_type: OptionOrderLegCreateAssetType$inboundSchema, identifier: z.string(), identifier_type: OptionOrderLegCreateIdentifierType$inboundSchema, ratio_quantity: z.number().int(), side: OptionOrderLegCreateSide$inboundSchema, side_modifier: SideModifier$inboundSchema, }).transform((v) => { return remap$(v, { "asset_type": "assetType", "identifier_type": "identifierType", "ratio_quantity": "ratioQuantity", "side_modifier": "sideModifier", }); }); /** @internal */ export type OptionOrderLegCreate$Outbound = { asset_type: string; identifier: string; identifier_type: string; ratio_quantity: number; side: string; side_modifier: string; }; /** @internal */ export const OptionOrderLegCreate$outboundSchema: z.ZodType< OptionOrderLegCreate$Outbound, z.ZodTypeDef, OptionOrderLegCreate > = z.object({ assetType: OptionOrderLegCreateAssetType$outboundSchema, identifier: z.string(), identifierType: OptionOrderLegCreateIdentifierType$outboundSchema, ratioQuantity: z.number().int(), side: OptionOrderLegCreateSide$outboundSchema, sideModifier: SideModifier$outboundSchema, }).transform((v) => { return remap$(v, { assetType: "asset_type", identifierType: "identifier_type", ratioQuantity: "ratio_quantity", sideModifier: "side_modifier", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionOrderLegCreate$ { /** @deprecated use `OptionOrderLegCreate$inboundSchema` instead. */ export const inboundSchema = OptionOrderLegCreate$inboundSchema; /** @deprecated use `OptionOrderLegCreate$outboundSchema` instead. */ export const outboundSchema = OptionOrderLegCreate$outboundSchema; /** @deprecated use `OptionOrderLegCreate$Outbound` instead. */ export type Outbound = OptionOrderLegCreate$Outbound; } export function optionOrderLegCreateToJSON( optionOrderLegCreate: OptionOrderLegCreate, ): string { return JSON.stringify( OptionOrderLegCreate$outboundSchema.parse(optionOrderLegCreate), ); } export function optionOrderLegCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OptionOrderLegCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OptionOrderLegCreate' from JSON`, ); }