/* * 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"; /** * The account_equity in USD returned from the request. */ export type AccountEquityAmount = { /** * 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 buying_power of the account in USD returned from the request. */ export type BuyingPowerAmount = { /** * 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 day_trade_buying_power_issued_amount is the day trade buying power of the account in USD, returned from the request. If the is_day_trade_buying_power_allowed boolean is true this will be set from day_trade_buying_power_issued value returned from the margins calculator, or else if it is false it will be set from buying_power_issued value returned from the margins calculator. */ export type DayTradeBuyingPowerAmount = { /** * 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 position_market_value in USD returned from the request. */ export type PositionMarketValueAmount = { /** * 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 total_excess_amount is the total equity in the account minus the requirements in USD, returned from the request. */ export type TotalExcessAmount = { /** * 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 total_requirements_amount is the total requirement amount for positions held in the account in USD, returned from the request. */ export type TotalRequirementsAmount = { /** * 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; }; /** * Margin Requirements fields returned from the request. */ export type Requirements = { /** * The total_excess_amount is the total equity in the account minus the requirements in USD, returned from the request. */ totalExcessAmount?: TotalExcessAmount | null | undefined; /** * The total_requirements_amount is the total requirement amount for positions held in the account in USD, returned from the request. */ totalRequirementsAmount?: TotalRequirementsAmount | null | undefined; }; /** * The sma_amount is the special memorandum account amount in USD, returned from the request. This will only be populated for margin accounts and is the margin equity minus the RegT requirements. */ export type SmaAmount = { /** * 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; }; /** * Response for GetBuyingPower */ export type BuyingPower = { /** * The account_equity in USD returned from the request. */ accountEquityAmount?: AccountEquityAmount | null | undefined; /** * The account ID returned from the request. */ accountId?: string | undefined; /** * The buying_power of the account in USD returned from the request. */ buyingPowerAmount?: BuyingPowerAmount | null | undefined; /** * The day_trade_buying_power_issued_amount is the day trade buying power of the account in USD, returned from the request. If the is_day_trade_buying_power_allowed boolean is true this will be set from day_trade_buying_power_issued value returned from the margins calculator, or else if it is false it will be set from buying_power_issued value returned from the margins calculator. */ dayTradeBuyingPowerAmount?: DayTradeBuyingPowerAmount | null | undefined; /** * The is_day_trade_buying_power_allowed boolean will be true if the account is a Margin account, PDT is true and SOD Account equity >= $25,000, otherwise it will be false. */ isDayTradeBuyingPowerAllowed?: boolean | undefined; /** * The service generated name of the BuyingPower Format: accounts/{account_id}/buyingPower */ name?: string | undefined; /** * The position_market_value in USD returned from the request. */ positionMarketValueAmount?: PositionMarketValueAmount | null | undefined; /** * Margin Requirements fields returned from the request. */ requirements?: Requirements | null | undefined; /** * The sma_amount is the special memorandum account amount in USD, returned from the request. This will only be populated for margin accounts and is the margin equity minus the RegT requirements. */ smaAmount?: SmaAmount | null | undefined; }; /** @internal */ export const AccountEquityAmount$inboundSchema: z.ZodType< AccountEquityAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type AccountEquityAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const AccountEquityAmount$outboundSchema: z.ZodType< AccountEquityAmount$Outbound, z.ZodTypeDef, AccountEquityAmount > = 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 AccountEquityAmount$ { /** @deprecated use `AccountEquityAmount$inboundSchema` instead. */ export const inboundSchema = AccountEquityAmount$inboundSchema; /** @deprecated use `AccountEquityAmount$outboundSchema` instead. */ export const outboundSchema = AccountEquityAmount$outboundSchema; /** @deprecated use `AccountEquityAmount$Outbound` instead. */ export type Outbound = AccountEquityAmount$Outbound; } export function accountEquityAmountToJSON( accountEquityAmount: AccountEquityAmount, ): string { return JSON.stringify( AccountEquityAmount$outboundSchema.parse(accountEquityAmount), ); } export function accountEquityAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AccountEquityAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AccountEquityAmount' from JSON`, ); } /** @internal */ export const BuyingPowerAmount$inboundSchema: z.ZodType< BuyingPowerAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type BuyingPowerAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const BuyingPowerAmount$outboundSchema: z.ZodType< BuyingPowerAmount$Outbound, z.ZodTypeDef, BuyingPowerAmount > = 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 BuyingPowerAmount$ { /** @deprecated use `BuyingPowerAmount$inboundSchema` instead. */ export const inboundSchema = BuyingPowerAmount$inboundSchema; /** @deprecated use `BuyingPowerAmount$outboundSchema` instead. */ export const outboundSchema = BuyingPowerAmount$outboundSchema; /** @deprecated use `BuyingPowerAmount$Outbound` instead. */ export type Outbound = BuyingPowerAmount$Outbound; } export function buyingPowerAmountToJSON( buyingPowerAmount: BuyingPowerAmount, ): string { return JSON.stringify( BuyingPowerAmount$outboundSchema.parse(buyingPowerAmount), ); } export function buyingPowerAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BuyingPowerAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BuyingPowerAmount' from JSON`, ); } /** @internal */ export const DayTradeBuyingPowerAmount$inboundSchema: z.ZodType< DayTradeBuyingPowerAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type DayTradeBuyingPowerAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const DayTradeBuyingPowerAmount$outboundSchema: z.ZodType< DayTradeBuyingPowerAmount$Outbound, z.ZodTypeDef, DayTradeBuyingPowerAmount > = 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 DayTradeBuyingPowerAmount$ { /** @deprecated use `DayTradeBuyingPowerAmount$inboundSchema` instead. */ export const inboundSchema = DayTradeBuyingPowerAmount$inboundSchema; /** @deprecated use `DayTradeBuyingPowerAmount$outboundSchema` instead. */ export const outboundSchema = DayTradeBuyingPowerAmount$outboundSchema; /** @deprecated use `DayTradeBuyingPowerAmount$Outbound` instead. */ export type Outbound = DayTradeBuyingPowerAmount$Outbound; } export function dayTradeBuyingPowerAmountToJSON( dayTradeBuyingPowerAmount: DayTradeBuyingPowerAmount, ): string { return JSON.stringify( DayTradeBuyingPowerAmount$outboundSchema.parse(dayTradeBuyingPowerAmount), ); } export function dayTradeBuyingPowerAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DayTradeBuyingPowerAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DayTradeBuyingPowerAmount' from JSON`, ); } /** @internal */ export const PositionMarketValueAmount$inboundSchema: z.ZodType< PositionMarketValueAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type PositionMarketValueAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const PositionMarketValueAmount$outboundSchema: z.ZodType< PositionMarketValueAmount$Outbound, z.ZodTypeDef, PositionMarketValueAmount > = 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 PositionMarketValueAmount$ { /** @deprecated use `PositionMarketValueAmount$inboundSchema` instead. */ export const inboundSchema = PositionMarketValueAmount$inboundSchema; /** @deprecated use `PositionMarketValueAmount$outboundSchema` instead. */ export const outboundSchema = PositionMarketValueAmount$outboundSchema; /** @deprecated use `PositionMarketValueAmount$Outbound` instead. */ export type Outbound = PositionMarketValueAmount$Outbound; } export function positionMarketValueAmountToJSON( positionMarketValueAmount: PositionMarketValueAmount, ): string { return JSON.stringify( PositionMarketValueAmount$outboundSchema.parse(positionMarketValueAmount), ); } export function positionMarketValueAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PositionMarketValueAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PositionMarketValueAmount' from JSON`, ); } /** @internal */ export const TotalExcessAmount$inboundSchema: z.ZodType< TotalExcessAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type TotalExcessAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const TotalExcessAmount$outboundSchema: z.ZodType< TotalExcessAmount$Outbound, z.ZodTypeDef, TotalExcessAmount > = 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 TotalExcessAmount$ { /** @deprecated use `TotalExcessAmount$inboundSchema` instead. */ export const inboundSchema = TotalExcessAmount$inboundSchema; /** @deprecated use `TotalExcessAmount$outboundSchema` instead. */ export const outboundSchema = TotalExcessAmount$outboundSchema; /** @deprecated use `TotalExcessAmount$Outbound` instead. */ export type Outbound = TotalExcessAmount$Outbound; } export function totalExcessAmountToJSON( totalExcessAmount: TotalExcessAmount, ): string { return JSON.stringify( TotalExcessAmount$outboundSchema.parse(totalExcessAmount), ); } export function totalExcessAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TotalExcessAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TotalExcessAmount' from JSON`, ); } /** @internal */ export const TotalRequirementsAmount$inboundSchema: z.ZodType< TotalRequirementsAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type TotalRequirementsAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const TotalRequirementsAmount$outboundSchema: z.ZodType< TotalRequirementsAmount$Outbound, z.ZodTypeDef, TotalRequirementsAmount > = 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 TotalRequirementsAmount$ { /** @deprecated use `TotalRequirementsAmount$inboundSchema` instead. */ export const inboundSchema = TotalRequirementsAmount$inboundSchema; /** @deprecated use `TotalRequirementsAmount$outboundSchema` instead. */ export const outboundSchema = TotalRequirementsAmount$outboundSchema; /** @deprecated use `TotalRequirementsAmount$Outbound` instead. */ export type Outbound = TotalRequirementsAmount$Outbound; } export function totalRequirementsAmountToJSON( totalRequirementsAmount: TotalRequirementsAmount, ): string { return JSON.stringify( TotalRequirementsAmount$outboundSchema.parse(totalRequirementsAmount), ); } export function totalRequirementsAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TotalRequirementsAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TotalRequirementsAmount' from JSON`, ); } /** @internal */ export const Requirements$inboundSchema: z.ZodType< Requirements, z.ZodTypeDef, unknown > = z.object({ total_excess_amount: z.nullable(z.lazy(() => TotalExcessAmount$inboundSchema)) .optional(), total_requirements_amount: z.nullable( z.lazy(() => TotalRequirementsAmount$inboundSchema), ).optional(), }).transform((v) => { return remap$(v, { "total_excess_amount": "totalExcessAmount", "total_requirements_amount": "totalRequirementsAmount", }); }); /** @internal */ export type Requirements$Outbound = { total_excess_amount?: TotalExcessAmount$Outbound | null | undefined; total_requirements_amount?: | TotalRequirementsAmount$Outbound | null | undefined; }; /** @internal */ export const Requirements$outboundSchema: z.ZodType< Requirements$Outbound, z.ZodTypeDef, Requirements > = z.object({ totalExcessAmount: z.nullable(z.lazy(() => TotalExcessAmount$outboundSchema)) .optional(), totalRequirementsAmount: z.nullable( z.lazy(() => TotalRequirementsAmount$outboundSchema), ).optional(), }).transform((v) => { return remap$(v, { totalExcessAmount: "total_excess_amount", totalRequirementsAmount: "total_requirements_amount", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Requirements$ { /** @deprecated use `Requirements$inboundSchema` instead. */ export const inboundSchema = Requirements$inboundSchema; /** @deprecated use `Requirements$outboundSchema` instead. */ export const outboundSchema = Requirements$outboundSchema; /** @deprecated use `Requirements$Outbound` instead. */ export type Outbound = Requirements$Outbound; } export function requirementsToJSON(requirements: Requirements): string { return JSON.stringify(Requirements$outboundSchema.parse(requirements)); } export function requirementsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Requirements$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Requirements' from JSON`, ); } /** @internal */ export const SmaAmount$inboundSchema: z.ZodType< SmaAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type SmaAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const SmaAmount$outboundSchema: z.ZodType< SmaAmount$Outbound, z.ZodTypeDef, SmaAmount > = 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 SmaAmount$ { /** @deprecated use `SmaAmount$inboundSchema` instead. */ export const inboundSchema = SmaAmount$inboundSchema; /** @deprecated use `SmaAmount$outboundSchema` instead. */ export const outboundSchema = SmaAmount$outboundSchema; /** @deprecated use `SmaAmount$Outbound` instead. */ export type Outbound = SmaAmount$Outbound; } export function smaAmountToJSON(smaAmount: SmaAmount): string { return JSON.stringify(SmaAmount$outboundSchema.parse(smaAmount)); } export function smaAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SmaAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SmaAmount' from JSON`, ); } /** @internal */ export const BuyingPower$inboundSchema: z.ZodType< BuyingPower, z.ZodTypeDef, unknown > = z.object({ account_equity_amount: z.nullable( z.lazy(() => AccountEquityAmount$inboundSchema), ).optional(), account_id: z.string().optional(), buying_power_amount: z.nullable(z.lazy(() => BuyingPowerAmount$inboundSchema)) .optional(), day_trade_buying_power_amount: z.nullable( z.lazy(() => DayTradeBuyingPowerAmount$inboundSchema), ).optional(), is_day_trade_buying_power_allowed: z.boolean().optional(), name: z.string().optional(), position_market_value_amount: z.nullable( z.lazy(() => PositionMarketValueAmount$inboundSchema), ).optional(), requirements: z.nullable(z.lazy(() => Requirements$inboundSchema)).optional(), sma_amount: z.nullable(z.lazy(() => SmaAmount$inboundSchema)).optional(), }).transform((v) => { return remap$(v, { "account_equity_amount": "accountEquityAmount", "account_id": "accountId", "buying_power_amount": "buyingPowerAmount", "day_trade_buying_power_amount": "dayTradeBuyingPowerAmount", "is_day_trade_buying_power_allowed": "isDayTradeBuyingPowerAllowed", "position_market_value_amount": "positionMarketValueAmount", "sma_amount": "smaAmount", }); }); /** @internal */ export type BuyingPower$Outbound = { account_equity_amount?: AccountEquityAmount$Outbound | null | undefined; account_id?: string | undefined; buying_power_amount?: BuyingPowerAmount$Outbound | null | undefined; day_trade_buying_power_amount?: | DayTradeBuyingPowerAmount$Outbound | null | undefined; is_day_trade_buying_power_allowed?: boolean | undefined; name?: string | undefined; position_market_value_amount?: | PositionMarketValueAmount$Outbound | null | undefined; requirements?: Requirements$Outbound | null | undefined; sma_amount?: SmaAmount$Outbound | null | undefined; }; /** @internal */ export const BuyingPower$outboundSchema: z.ZodType< BuyingPower$Outbound, z.ZodTypeDef, BuyingPower > = z.object({ accountEquityAmount: z.nullable( z.lazy(() => AccountEquityAmount$outboundSchema), ).optional(), accountId: z.string().optional(), buyingPowerAmount: z.nullable(z.lazy(() => BuyingPowerAmount$outboundSchema)) .optional(), dayTradeBuyingPowerAmount: z.nullable( z.lazy(() => DayTradeBuyingPowerAmount$outboundSchema), ).optional(), isDayTradeBuyingPowerAllowed: z.boolean().optional(), name: z.string().optional(), positionMarketValueAmount: z.nullable( z.lazy(() => PositionMarketValueAmount$outboundSchema), ).optional(), requirements: z.nullable(z.lazy(() => Requirements$outboundSchema)) .optional(), smaAmount: z.nullable(z.lazy(() => SmaAmount$outboundSchema)).optional(), }).transform((v) => { return remap$(v, { accountEquityAmount: "account_equity_amount", accountId: "account_id", buyingPowerAmount: "buying_power_amount", dayTradeBuyingPowerAmount: "day_trade_buying_power_amount", isDayTradeBuyingPowerAllowed: "is_day_trade_buying_power_allowed", positionMarketValueAmount: "position_market_value_amount", smaAmount: "sma_amount", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BuyingPower$ { /** @deprecated use `BuyingPower$inboundSchema` instead. */ export const inboundSchema = BuyingPower$inboundSchema; /** @deprecated use `BuyingPower$outboundSchema` instead. */ export const outboundSchema = BuyingPower$outboundSchema; /** @deprecated use `BuyingPower$Outbound` instead. */ export type Outbound = BuyingPower$Outbound; } export function buyingPowerToJSON(buyingPower: BuyingPower): string { return JSON.stringify(BuyingPower$outboundSchema.parse(buyingPower)); } export function buyingPowerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BuyingPower$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BuyingPower' from JSON`, ); }