/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { BasketTradingExecutedPrice, BasketTradingExecutedPrice$inboundSchema, BasketTradingExecutedPrice$Outbound, BasketTradingExecutedPrice$outboundSchema, } from "./baskettradingexecutedprice.js"; /** * The quantity of the order. For Equities: measured in shares. For Fixed Income assets: measured in the face value of the currency of the order. */ export type BasketTradingExecutionsQuantity = { /** * 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; }; /** * Details of an individual execution within an order */ export type BasketTradingExecutions = { /** * The prices at which the order was executed. For Equities: there will be one price measured in PRICE_PER_UNIT (using the order currency). For Fixed Income assets: there will always be an entry measured in the PERCENTAGE_OF_PAR (100 X cost / total par value), and there may be additional entries measured in yield. */ executedPrices?: Array | undefined; /** * The timestamp that this fill was transacted at the market */ executedTime?: Date | null | undefined; /** * The quantity of the order. For Equities: measured in shares. For Fixed Income assets: measured in the face value of the currency of the order. */ quantity?: BasketTradingExecutionsQuantity | null | undefined; }; /** @internal */ export const BasketTradingExecutionsQuantity$inboundSchema: z.ZodType< BasketTradingExecutionsQuantity, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type BasketTradingExecutionsQuantity$Outbound = { value?: string | undefined; }; /** @internal */ export const BasketTradingExecutionsQuantity$outboundSchema: z.ZodType< BasketTradingExecutionsQuantity$Outbound, z.ZodTypeDef, BasketTradingExecutionsQuantity > = 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 BasketTradingExecutionsQuantity$ { /** @deprecated use `BasketTradingExecutionsQuantity$inboundSchema` instead. */ export const inboundSchema = BasketTradingExecutionsQuantity$inboundSchema; /** @deprecated use `BasketTradingExecutionsQuantity$outboundSchema` instead. */ export const outboundSchema = BasketTradingExecutionsQuantity$outboundSchema; /** @deprecated use `BasketTradingExecutionsQuantity$Outbound` instead. */ export type Outbound = BasketTradingExecutionsQuantity$Outbound; } export function basketTradingExecutionsQuantityToJSON( basketTradingExecutionsQuantity: BasketTradingExecutionsQuantity, ): string { return JSON.stringify( BasketTradingExecutionsQuantity$outboundSchema.parse( basketTradingExecutionsQuantity, ), ); } export function basketTradingExecutionsQuantityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BasketTradingExecutionsQuantity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BasketTradingExecutionsQuantity' from JSON`, ); } /** @internal */ export const BasketTradingExecutions$inboundSchema: z.ZodType< BasketTradingExecutions, z.ZodTypeDef, unknown > = z.object({ executed_prices: z.array(BasketTradingExecutedPrice$inboundSchema).optional(), executed_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), quantity: z.nullable( z.lazy(() => BasketTradingExecutionsQuantity$inboundSchema), ).optional(), }).transform((v) => { return remap$(v, { "executed_prices": "executedPrices", "executed_time": "executedTime", }); }); /** @internal */ export type BasketTradingExecutions$Outbound = { executed_prices?: Array | undefined; executed_time?: string | null | undefined; quantity?: BasketTradingExecutionsQuantity$Outbound | null | undefined; }; /** @internal */ export const BasketTradingExecutions$outboundSchema: z.ZodType< BasketTradingExecutions$Outbound, z.ZodTypeDef, BasketTradingExecutions > = z.object({ executedPrices: z.array(BasketTradingExecutedPrice$outboundSchema).optional(), executedTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), quantity: z.nullable( z.lazy(() => BasketTradingExecutionsQuantity$outboundSchema), ).optional(), }).transform((v) => { return remap$(v, { executedPrices: "executed_prices", executedTime: "executed_time", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BasketTradingExecutions$ { /** @deprecated use `BasketTradingExecutions$inboundSchema` instead. */ export const inboundSchema = BasketTradingExecutions$inboundSchema; /** @deprecated use `BasketTradingExecutions$outboundSchema` instead. */ export const outboundSchema = BasketTradingExecutions$outboundSchema; /** @deprecated use `BasketTradingExecutions$Outbound` instead. */ export type Outbound = BasketTradingExecutions$Outbound; } export function basketTradingExecutionsToJSON( basketTradingExecutions: BasketTradingExecutions, ): string { return JSON.stringify( BasketTradingExecutions$outboundSchema.parse(basketTradingExecutions), ); } export function basketTradingExecutionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BasketTradingExecutions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BasketTradingExecutions' from JSON`, ); }