/* * 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 { BondYieldCreate, BondYieldCreate$inboundSchema, BondYieldCreate$Outbound, BondYieldCreate$outboundSchema, } from "./bondyieldcreate.js"; import { DecimalCreate, DecimalCreate$inboundSchema, DecimalCreate$Outbound, DecimalCreate$outboundSchema, } from "./decimalcreate.js"; import { PriceAdjustmentCreate, PriceAdjustmentCreate$inboundSchema, PriceAdjustmentCreate$Outbound, PriceAdjustmentCreate$outboundSchema, } from "./priceadjustmentcreate.js"; /** * An execution represents a partial-fill or a fill that is part of an order. Executions are children to a Trade, which collectively represents an entire order made by a client. */ export type ExecutionCreate = { /** * 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 */ accruedInterestAmount?: DecimalCreate | undefined; /** * The yield associated with an individual fill of a fixed income trade. Required for FIXED_INCOME trades. Not allowed for trades of other instrument types. */ bondYield?: Array | undefined; /** * 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 */ commissionAmount?: DecimalCreate | undefined; /** * Timestamp of when the execution took place. If settlement_date is not provided, this field will be converted into Eastern Time and used to calculate settlement_date. */ executionTime: Date | null; /** * Used to generate execution_id, should be unique on the day for each source_application caller. */ externalId: string; /** * 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 */ grossAmount?: DecimalCreate | undefined; /** * Caller provided but can be used for booking-service to note original trade details when booking into the error account or using the error asset. */ memo?: string | undefined; /** * 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 */ prevailingMarketPrice?: DecimalCreate | undefined; /** * 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 */ price: DecimalCreate; /** * Price adjustment that will be applied to the net price of the security. */ priceAdjustment?: PriceAdjustmentCreate | undefined; /** * 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; /** * Street-level execution id, unique by day per execution venue. */ streetExecutionId?: string | undefined; }; /** @internal */ export const ExecutionCreate$inboundSchema: z.ZodType< ExecutionCreate, z.ZodTypeDef, unknown > = z.object({ accrued_interest_amount: DecimalCreate$inboundSchema.optional(), bond_yield: z.array(BondYieldCreate$inboundSchema).optional(), commission_amount: DecimalCreate$inboundSchema.optional(), execution_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), external_id: z.string(), gross_amount: DecimalCreate$inboundSchema.optional(), memo: z.string().optional(), prevailing_market_price: DecimalCreate$inboundSchema.optional(), price: DecimalCreate$inboundSchema, price_adjustment: PriceAdjustmentCreate$inboundSchema.optional(), quantity: DecimalCreate$inboundSchema, street_execution_id: z.string().optional(), }).transform((v) => { return remap$(v, { "accrued_interest_amount": "accruedInterestAmount", "bond_yield": "bondYield", "commission_amount": "commissionAmount", "execution_time": "executionTime", "external_id": "externalId", "gross_amount": "grossAmount", "prevailing_market_price": "prevailingMarketPrice", "price_adjustment": "priceAdjustment", "street_execution_id": "streetExecutionId", }); }); /** @internal */ export type ExecutionCreate$Outbound = { accrued_interest_amount?: DecimalCreate$Outbound | undefined; bond_yield?: Array | undefined; commission_amount?: DecimalCreate$Outbound | undefined; execution_time: string | null; external_id: string; gross_amount?: DecimalCreate$Outbound | undefined; memo?: string | undefined; prevailing_market_price?: DecimalCreate$Outbound | undefined; price: DecimalCreate$Outbound; price_adjustment?: PriceAdjustmentCreate$Outbound | undefined; quantity: DecimalCreate$Outbound; street_execution_id?: string | undefined; }; /** @internal */ export const ExecutionCreate$outboundSchema: z.ZodType< ExecutionCreate$Outbound, z.ZodTypeDef, ExecutionCreate > = z.object({ accruedInterestAmount: DecimalCreate$outboundSchema.optional(), bondYield: z.array(BondYieldCreate$outboundSchema).optional(), commissionAmount: DecimalCreate$outboundSchema.optional(), executionTime: z.nullable(z.date().transform(v => v.toISOString())), externalId: z.string(), grossAmount: DecimalCreate$outboundSchema.optional(), memo: z.string().optional(), prevailingMarketPrice: DecimalCreate$outboundSchema.optional(), price: DecimalCreate$outboundSchema, priceAdjustment: PriceAdjustmentCreate$outboundSchema.optional(), quantity: DecimalCreate$outboundSchema, streetExecutionId: z.string().optional(), }).transform((v) => { return remap$(v, { accruedInterestAmount: "accrued_interest_amount", bondYield: "bond_yield", commissionAmount: "commission_amount", executionTime: "execution_time", externalId: "external_id", grossAmount: "gross_amount", prevailingMarketPrice: "prevailing_market_price", priceAdjustment: "price_adjustment", streetExecutionId: "street_execution_id", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ExecutionCreate$ { /** @deprecated use `ExecutionCreate$inboundSchema` instead. */ export const inboundSchema = ExecutionCreate$inboundSchema; /** @deprecated use `ExecutionCreate$outboundSchema` instead. */ export const outboundSchema = ExecutionCreate$outboundSchema; /** @deprecated use `ExecutionCreate$Outbound` instead. */ export type Outbound = ExecutionCreate$Outbound; } export function executionCreateToJSON( executionCreate: ExecutionCreate, ): string { return JSON.stringify(ExecutionCreate$outboundSchema.parse(executionCreate)); } export function executionCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExecutionCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExecutionCreate' from JSON`, ); }