/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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 limit price which must be greater than zero if provided. For equity orders in the USD currency, up to 2 decimal places are allowed for prices above $1 and up to 4 decimal places for prices at or below $1. For fixed income orders this is expressed as a percentage of par, which allows up to 5 decimal places in the USD currency. */ export type BasketTradingExecutedPricePrice = { /** * 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 type of this price, which must be PRICE_PER_UNIT for equity orders */ export enum BasketTradingExecutedPriceType { PricePerUnit = "PRICE_PER_UNIT", } /** * The type of this price, which must be PRICE_PER_UNIT for equity orders */ export type BasketTradingExecutedPriceTypeOpen = OpenEnum< typeof BasketTradingExecutedPriceType >; /** * An average price definition */ export type BasketTradingExecutedPrice = { /** * The limit price which must be greater than zero if provided. For equity orders in the USD currency, up to 2 decimal places are allowed for prices above $1 and up to 4 decimal places for prices at or below $1. For fixed income orders this is expressed as a percentage of par, which allows up to 5 decimal places in the USD currency. */ price?: BasketTradingExecutedPricePrice | null | undefined; /** * The type of this price, which must be PRICE_PER_UNIT for equity orders */ type?: BasketTradingExecutedPriceTypeOpen | undefined; }; /** @internal */ export const BasketTradingExecutedPricePrice$inboundSchema: z.ZodType< BasketTradingExecutedPricePrice, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type BasketTradingExecutedPricePrice$Outbound = { value?: string | undefined; }; /** @internal */ export const BasketTradingExecutedPricePrice$outboundSchema: z.ZodType< BasketTradingExecutedPricePrice$Outbound, z.ZodTypeDef, BasketTradingExecutedPricePrice > = 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 BasketTradingExecutedPricePrice$ { /** @deprecated use `BasketTradingExecutedPricePrice$inboundSchema` instead. */ export const inboundSchema = BasketTradingExecutedPricePrice$inboundSchema; /** @deprecated use `BasketTradingExecutedPricePrice$outboundSchema` instead. */ export const outboundSchema = BasketTradingExecutedPricePrice$outboundSchema; /** @deprecated use `BasketTradingExecutedPricePrice$Outbound` instead. */ export type Outbound = BasketTradingExecutedPricePrice$Outbound; } export function basketTradingExecutedPricePriceToJSON( basketTradingExecutedPricePrice: BasketTradingExecutedPricePrice, ): string { return JSON.stringify( BasketTradingExecutedPricePrice$outboundSchema.parse( basketTradingExecutedPricePrice, ), ); } export function basketTradingExecutedPricePriceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BasketTradingExecutedPricePrice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BasketTradingExecutedPricePrice' from JSON`, ); } /** @internal */ export const BasketTradingExecutedPriceType$inboundSchema: z.ZodType< BasketTradingExecutedPriceTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BasketTradingExecutedPriceType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BasketTradingExecutedPriceType$outboundSchema: z.ZodType< BasketTradingExecutedPriceTypeOpen, z.ZodTypeDef, BasketTradingExecutedPriceTypeOpen > = z.union([ z.nativeEnum(BasketTradingExecutedPriceType), 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 BasketTradingExecutedPriceType$ { /** @deprecated use `BasketTradingExecutedPriceType$inboundSchema` instead. */ export const inboundSchema = BasketTradingExecutedPriceType$inboundSchema; /** @deprecated use `BasketTradingExecutedPriceType$outboundSchema` instead. */ export const outboundSchema = BasketTradingExecutedPriceType$outboundSchema; } /** @internal */ export const BasketTradingExecutedPrice$inboundSchema: z.ZodType< BasketTradingExecutedPrice, z.ZodTypeDef, unknown > = z.object({ price: z.nullable(z.lazy(() => BasketTradingExecutedPricePrice$inboundSchema)) .optional(), type: BasketTradingExecutedPriceType$inboundSchema.optional(), }); /** @internal */ export type BasketTradingExecutedPrice$Outbound = { price?: BasketTradingExecutedPricePrice$Outbound | null | undefined; type?: string | undefined; }; /** @internal */ export const BasketTradingExecutedPrice$outboundSchema: z.ZodType< BasketTradingExecutedPrice$Outbound, z.ZodTypeDef, BasketTradingExecutedPrice > = z.object({ price: z.nullable( z.lazy(() => BasketTradingExecutedPricePrice$outboundSchema), ).optional(), type: BasketTradingExecutedPriceType$outboundSchema.optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BasketTradingExecutedPrice$ { /** @deprecated use `BasketTradingExecutedPrice$inboundSchema` instead. */ export const inboundSchema = BasketTradingExecutedPrice$inboundSchema; /** @deprecated use `BasketTradingExecutedPrice$outboundSchema` instead. */ export const outboundSchema = BasketTradingExecutedPrice$outboundSchema; /** @deprecated use `BasketTradingExecutedPrice$Outbound` instead. */ export type Outbound = BasketTradingExecutedPrice$Outbound; } export function basketTradingExecutedPriceToJSON( basketTradingExecutedPrice: BasketTradingExecutedPrice, ): string { return JSON.stringify( BasketTradingExecutedPrice$outboundSchema.parse(basketTradingExecutedPrice), ); } export function basketTradingExecutedPriceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BasketTradingExecutedPrice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BasketTradingExecutedPrice' from JSON`, ); }