/* * 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 8 decimal places in the USD currency. */ export type Price = { /** * 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, or PERCENTAGE_OF_PAR for fixed income orders. */ export enum TradingExecutedPriceType { PricePerUnit = "PRICE_PER_UNIT", PercentageOfPar = "PERCENTAGE_OF_PAR", YieldToWorst = "YIELD_TO_WORST", YieldToMaturity = "YIELD_TO_MATURITY", } /** * The type of this price, which must be PRICE_PER_UNIT for equity orders, or PERCENTAGE_OF_PAR for fixed income orders. */ export type TradingExecutedPriceTypeOpen = OpenEnum< typeof TradingExecutedPriceType >; /** * An average price definition */ export type TradingExecutedPrice = { /** * 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 8 decimal places in the USD currency. */ price?: Price | null | undefined; /** * The type of this price, which must be PRICE_PER_UNIT for equity orders, or PERCENTAGE_OF_PAR for fixed income orders. */ type?: TradingExecutedPriceTypeOpen | undefined; }; /** @internal */ export const Price$inboundSchema: z.ZodType = z .object({ value: z.string().optional(), }); /** @internal */ export type Price$Outbound = { value?: string | undefined; }; /** @internal */ export const Price$outboundSchema: z.ZodType< Price$Outbound, z.ZodTypeDef, Price > = 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 Price$ { /** @deprecated use `Price$inboundSchema` instead. */ export const inboundSchema = Price$inboundSchema; /** @deprecated use `Price$outboundSchema` instead. */ export const outboundSchema = Price$outboundSchema; /** @deprecated use `Price$Outbound` instead. */ export type Outbound = Price$Outbound; } export function priceToJSON(price: Price): string { return JSON.stringify(Price$outboundSchema.parse(price)); } export function priceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Price$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Price' from JSON`, ); } /** @internal */ export const TradingExecutedPriceType$inboundSchema: z.ZodType< TradingExecutedPriceTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(TradingExecutedPriceType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const TradingExecutedPriceType$outboundSchema: z.ZodType< TradingExecutedPriceTypeOpen, z.ZodTypeDef, TradingExecutedPriceTypeOpen > = z.union([ z.nativeEnum(TradingExecutedPriceType), 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 TradingExecutedPriceType$ { /** @deprecated use `TradingExecutedPriceType$inboundSchema` instead. */ export const inboundSchema = TradingExecutedPriceType$inboundSchema; /** @deprecated use `TradingExecutedPriceType$outboundSchema` instead. */ export const outboundSchema = TradingExecutedPriceType$outboundSchema; } /** @internal */ export const TradingExecutedPrice$inboundSchema: z.ZodType< TradingExecutedPrice, z.ZodTypeDef, unknown > = z.object({ price: z.nullable(z.lazy(() => Price$inboundSchema)).optional(), type: TradingExecutedPriceType$inboundSchema.optional(), }); /** @internal */ export type TradingExecutedPrice$Outbound = { price?: Price$Outbound | null | undefined; type?: string | undefined; }; /** @internal */ export const TradingExecutedPrice$outboundSchema: z.ZodType< TradingExecutedPrice$Outbound, z.ZodTypeDef, TradingExecutedPrice > = z.object({ price: z.nullable(z.lazy(() => Price$outboundSchema)).optional(), type: TradingExecutedPriceType$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 TradingExecutedPrice$ { /** @deprecated use `TradingExecutedPrice$inboundSchema` instead. */ export const inboundSchema = TradingExecutedPrice$inboundSchema; /** @deprecated use `TradingExecutedPrice$outboundSchema` instead. */ export const outboundSchema = TradingExecutedPrice$outboundSchema; /** @deprecated use `TradingExecutedPrice$Outbound` instead. */ export type Outbound = TradingExecutedPrice$Outbound; } export function tradingExecutedPriceToJSON( tradingExecutedPrice: TradingExecutedPrice, ): string { return JSON.stringify( TradingExecutedPrice$outboundSchema.parse(tradingExecutedPrice), ); } export function tradingExecutedPriceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TradingExecutedPrice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TradingExecutedPrice' from JSON`, ); }