/* * 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"; /** * Indicators to determine what types of orders allowed to be traded */ export type AssetTradability = { /** * Indicates whether fractional quantities are allowed to be closed */ closeFractionalQuantityEnabled?: boolean | undefined; /** * Indicates whether notional quantities are allowed to be closed */ closeNotionalQuantityEnabled?: boolean | undefined; /** * Indicates whether whole quantities are allowed to be closed */ closeWholeQuantityEnabled?: boolean | undefined; /** * Indicates whether fractional quantities are allowed to be opened */ openFractionalQuantityEnabled?: boolean | undefined; /** * Indicates whether notional quantities are allowed to be opened */ openNotionalQuantityEnabled?: boolean | undefined; /** * Indicates whether whole quantities are allowed to be opened */ openWholeQuantityEnabled?: boolean | undefined; }; /** * Type of the asset */ export enum AssetTradingConfigAssetType { AssetTypeUnspecified = "ASSET_TYPE_UNSPECIFIED", Equity = "EQUITY", MutualFund = "MUTUAL_FUND", Option = "OPTION", Index = "INDEX", } /** * Type of the asset */ export type AssetTradingConfigAssetTypeOpen = OpenEnum< typeof AssetTradingConfigAssetType >; /** * Indicators on an asset who has Options */ export type OptionRootTradability = { /** * Indicates whether whole quantities are allowed to be closed for Options */ closeOptionsWholeQuantityEnabled?: boolean | undefined; /** * Indicates whether whole quantities are allowed to be opened for nonstandard Options */ openNonstandardOptionsWholeQuantityEnabled?: boolean | undefined; /** * Indicates whether whole quantities are allowed to be opened for standard Options */ openStandardOptionsWholeQuantityEnabled?: boolean | undefined; }; /** * The message describing asset trading config */ export type AssetTradingConfig = { /** * Unique identifier for the asset */ assetId?: string | undefined; /** * Indicators to determine what types of orders allowed to be traded */ assetTradability?: AssetTradability | null | undefined; /** * Type of the asset */ assetType?: AssetTradingConfigAssetTypeOpen | undefined; /** * Unique identifier for the correspondent */ correspondentId?: string | undefined; /** * Identifier assigned to a security by the CUSIP Service Bureau of Standard & Poor’s Corporation Population of this field is determined by whether the correspondent has access to the data */ cusip?: string | undefined; /** * Stands for the International Securities Identification Number Population of this field is determined by whether the correspondent has access to the data */ isin?: string | undefined; /** * correspondents/{correspondent_id}/assets/{asset_id}/tradingConfig */ name?: string | undefined; /** * Indicators on an asset who has Options */ optionRootTradability?: OptionRootTradability | null | undefined; /** * An arrangement of characters—usually letters and or numbers — usually representing securities on an exchange. The format of the symbol is determined by the asset type. */ symbol?: string | undefined; }; /** @internal */ export const AssetTradability$inboundSchema: z.ZodType< AssetTradability, z.ZodTypeDef, unknown > = z.object({ close_fractional_quantity_enabled: z.boolean().optional(), close_notional_quantity_enabled: z.boolean().optional(), close_whole_quantity_enabled: z.boolean().optional(), open_fractional_quantity_enabled: z.boolean().optional(), open_notional_quantity_enabled: z.boolean().optional(), open_whole_quantity_enabled: z.boolean().optional(), }).transform((v) => { return remap$(v, { "close_fractional_quantity_enabled": "closeFractionalQuantityEnabled", "close_notional_quantity_enabled": "closeNotionalQuantityEnabled", "close_whole_quantity_enabled": "closeWholeQuantityEnabled", "open_fractional_quantity_enabled": "openFractionalQuantityEnabled", "open_notional_quantity_enabled": "openNotionalQuantityEnabled", "open_whole_quantity_enabled": "openWholeQuantityEnabled", }); }); /** @internal */ export type AssetTradability$Outbound = { close_fractional_quantity_enabled?: boolean | undefined; close_notional_quantity_enabled?: boolean | undefined; close_whole_quantity_enabled?: boolean | undefined; open_fractional_quantity_enabled?: boolean | undefined; open_notional_quantity_enabled?: boolean | undefined; open_whole_quantity_enabled?: boolean | undefined; }; /** @internal */ export const AssetTradability$outboundSchema: z.ZodType< AssetTradability$Outbound, z.ZodTypeDef, AssetTradability > = z.object({ closeFractionalQuantityEnabled: z.boolean().optional(), closeNotionalQuantityEnabled: z.boolean().optional(), closeWholeQuantityEnabled: z.boolean().optional(), openFractionalQuantityEnabled: z.boolean().optional(), openNotionalQuantityEnabled: z.boolean().optional(), openWholeQuantityEnabled: z.boolean().optional(), }).transform((v) => { return remap$(v, { closeFractionalQuantityEnabled: "close_fractional_quantity_enabled", closeNotionalQuantityEnabled: "close_notional_quantity_enabled", closeWholeQuantityEnabled: "close_whole_quantity_enabled", openFractionalQuantityEnabled: "open_fractional_quantity_enabled", openNotionalQuantityEnabled: "open_notional_quantity_enabled", openWholeQuantityEnabled: "open_whole_quantity_enabled", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AssetTradability$ { /** @deprecated use `AssetTradability$inboundSchema` instead. */ export const inboundSchema = AssetTradability$inboundSchema; /** @deprecated use `AssetTradability$outboundSchema` instead. */ export const outboundSchema = AssetTradability$outboundSchema; /** @deprecated use `AssetTradability$Outbound` instead. */ export type Outbound = AssetTradability$Outbound; } export function assetTradabilityToJSON( assetTradability: AssetTradability, ): string { return JSON.stringify( AssetTradability$outboundSchema.parse(assetTradability), ); } export function assetTradabilityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AssetTradability$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AssetTradability' from JSON`, ); } /** @internal */ export const AssetTradingConfigAssetType$inboundSchema: z.ZodType< AssetTradingConfigAssetTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(AssetTradingConfigAssetType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const AssetTradingConfigAssetType$outboundSchema: z.ZodType< AssetTradingConfigAssetTypeOpen, z.ZodTypeDef, AssetTradingConfigAssetTypeOpen > = z.union([ z.nativeEnum(AssetTradingConfigAssetType), 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 AssetTradingConfigAssetType$ { /** @deprecated use `AssetTradingConfigAssetType$inboundSchema` instead. */ export const inboundSchema = AssetTradingConfigAssetType$inboundSchema; /** @deprecated use `AssetTradingConfigAssetType$outboundSchema` instead. */ export const outboundSchema = AssetTradingConfigAssetType$outboundSchema; } /** @internal */ export const OptionRootTradability$inboundSchema: z.ZodType< OptionRootTradability, z.ZodTypeDef, unknown > = z.object({ close_options_whole_quantity_enabled: z.boolean().optional(), open_nonstandard_options_whole_quantity_enabled: z.boolean().optional(), open_standard_options_whole_quantity_enabled: z.boolean().optional(), }).transform((v) => { return remap$(v, { "close_options_whole_quantity_enabled": "closeOptionsWholeQuantityEnabled", "open_nonstandard_options_whole_quantity_enabled": "openNonstandardOptionsWholeQuantityEnabled", "open_standard_options_whole_quantity_enabled": "openStandardOptionsWholeQuantityEnabled", }); }); /** @internal */ export type OptionRootTradability$Outbound = { close_options_whole_quantity_enabled?: boolean | undefined; open_nonstandard_options_whole_quantity_enabled?: boolean | undefined; open_standard_options_whole_quantity_enabled?: boolean | undefined; }; /** @internal */ export const OptionRootTradability$outboundSchema: z.ZodType< OptionRootTradability$Outbound, z.ZodTypeDef, OptionRootTradability > = z.object({ closeOptionsWholeQuantityEnabled: z.boolean().optional(), openNonstandardOptionsWholeQuantityEnabled: z.boolean().optional(), openStandardOptionsWholeQuantityEnabled: z.boolean().optional(), }).transform((v) => { return remap$(v, { closeOptionsWholeQuantityEnabled: "close_options_whole_quantity_enabled", openNonstandardOptionsWholeQuantityEnabled: "open_nonstandard_options_whole_quantity_enabled", openStandardOptionsWholeQuantityEnabled: "open_standard_options_whole_quantity_enabled", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionRootTradability$ { /** @deprecated use `OptionRootTradability$inboundSchema` instead. */ export const inboundSchema = OptionRootTradability$inboundSchema; /** @deprecated use `OptionRootTradability$outboundSchema` instead. */ export const outboundSchema = OptionRootTradability$outboundSchema; /** @deprecated use `OptionRootTradability$Outbound` instead. */ export type Outbound = OptionRootTradability$Outbound; } export function optionRootTradabilityToJSON( optionRootTradability: OptionRootTradability, ): string { return JSON.stringify( OptionRootTradability$outboundSchema.parse(optionRootTradability), ); } export function optionRootTradabilityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OptionRootTradability$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OptionRootTradability' from JSON`, ); } /** @internal */ export const AssetTradingConfig$inboundSchema: z.ZodType< AssetTradingConfig, z.ZodTypeDef, unknown > = z.object({ asset_id: z.string().optional(), asset_tradability: z.nullable(z.lazy(() => AssetTradability$inboundSchema)) .optional(), asset_type: AssetTradingConfigAssetType$inboundSchema.optional(), correspondent_id: z.string().optional(), cusip: z.string().optional(), isin: z.string().optional(), name: z.string().optional(), option_root_tradability: z.nullable( z.lazy(() => OptionRootTradability$inboundSchema), ).optional(), symbol: z.string().optional(), }).transform((v) => { return remap$(v, { "asset_id": "assetId", "asset_tradability": "assetTradability", "asset_type": "assetType", "correspondent_id": "correspondentId", "option_root_tradability": "optionRootTradability", }); }); /** @internal */ export type AssetTradingConfig$Outbound = { asset_id?: string | undefined; asset_tradability?: AssetTradability$Outbound | null | undefined; asset_type?: string | undefined; correspondent_id?: string | undefined; cusip?: string | undefined; isin?: string | undefined; name?: string | undefined; option_root_tradability?: OptionRootTradability$Outbound | null | undefined; symbol?: string | undefined; }; /** @internal */ export const AssetTradingConfig$outboundSchema: z.ZodType< AssetTradingConfig$Outbound, z.ZodTypeDef, AssetTradingConfig > = z.object({ assetId: z.string().optional(), assetTradability: z.nullable(z.lazy(() => AssetTradability$outboundSchema)) .optional(), assetType: AssetTradingConfigAssetType$outboundSchema.optional(), correspondentId: z.string().optional(), cusip: z.string().optional(), isin: z.string().optional(), name: z.string().optional(), optionRootTradability: z.nullable( z.lazy(() => OptionRootTradability$outboundSchema), ).optional(), symbol: z.string().optional(), }).transform((v) => { return remap$(v, { assetId: "asset_id", assetTradability: "asset_tradability", assetType: "asset_type", correspondentId: "correspondent_id", optionRootTradability: "option_root_tradability", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AssetTradingConfig$ { /** @deprecated use `AssetTradingConfig$inboundSchema` instead. */ export const inboundSchema = AssetTradingConfig$inboundSchema; /** @deprecated use `AssetTradingConfig$outboundSchema` instead. */ export const outboundSchema = AssetTradingConfig$outboundSchema; /** @deprecated use `AssetTradingConfig$Outbound` instead. */ export type Outbound = AssetTradingConfig$Outbound; } export function assetTradingConfigToJSON( assetTradingConfig: AssetTradingConfig, ): string { return JSON.stringify( AssetTradingConfig$outboundSchema.parse(assetTradingConfig), ); } export function assetTradingConfigFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AssetTradingConfig$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AssetTradingConfig' from JSON`, ); }