/* * 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"; export type GetFuturesPricesRequest = { /** * Future symbol */ symbol: string; /** * Contract year and month. _Default value_ : All * * @remarks * available contracts */ contract?: string | null | undefined; /** * Start of prices window (YYYY-MM-DD). The returned object will * * @remarks * contain the entire price history for every contract that traded between * `start_date` and `end_date`. Ignored if `contract` is specified. _Default * value_ : most recent date with prices */ startDate?: string | null | undefined; /** * End of prices window (YYYY-MM-DD). The returned object will * * @remarks * contain the entire price history for every contract that traded between * `start_date` and `end_date`. Ignored if `contract` is specified. _Default * value_ : most recent date with prices */ endDate?: string | null | undefined; /** * Return price data for currently active contracts * * @remarks * only. Set to false to also retrieve price data from expired * contracts. */ activeContractsOnly?: boolean | undefined; /** * The rollover date is the most recent date for which a given * * @remarks * contract was trading as the front month. This parameter specifies the method * used to determine the rollover date for contracts. Must be one of "hist_vol", * "max_vol", "first_notice", or "last_trade" (or left blank for no rollover * calculation). "first_notice" not available for all commodities, and defaults * to "last_trade". */ rolloverMethod?: string | undefined; /** * Back-adjust prices to account for calendar spread at contract * * @remarks * rollover dates. The method used is described here: * https://www.sierrachart.com/index.php?page=doc/ContinuousFuturesContractCharts.html#ContinuousFuturesContractDateRuleRolloverBackAdjusted */ backAdjust?: boolean | undefined; }; /** @internal */ export const GetFuturesPricesRequest$inboundSchema: z.ZodType< GetFuturesPricesRequest, z.ZodTypeDef, unknown > = z.object({ symbol: z.string(), contract: z.nullable(z.string()).optional(), start_date: z.nullable(z.string()).optional(), end_date: z.nullable(z.string()).optional(), active_contracts_only: z.boolean().default(true), rollover_method: z.string().default("hist_vol"), back_adjust: z.boolean().default(false), }).transform((v) => { return remap$(v, { "start_date": "startDate", "end_date": "endDate", "active_contracts_only": "activeContractsOnly", "rollover_method": "rolloverMethod", "back_adjust": "backAdjust", }); }); /** @internal */ export type GetFuturesPricesRequest$Outbound = { symbol: string; contract?: string | null | undefined; start_date?: string | null | undefined; end_date?: string | null | undefined; active_contracts_only: boolean; rollover_method: string; back_adjust: boolean; }; /** @internal */ export const GetFuturesPricesRequest$outboundSchema: z.ZodType< GetFuturesPricesRequest$Outbound, z.ZodTypeDef, GetFuturesPricesRequest > = z.object({ symbol: z.string(), contract: z.nullable(z.string()).optional(), startDate: z.nullable(z.string()).optional(), endDate: z.nullable(z.string()).optional(), activeContractsOnly: z.boolean().default(true), rolloverMethod: z.string().default("hist_vol"), backAdjust: z.boolean().default(false), }).transform((v) => { return remap$(v, { startDate: "start_date", endDate: "end_date", activeContractsOnly: "active_contracts_only", rolloverMethod: "rollover_method", backAdjust: "back_adjust", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetFuturesPricesRequest$ { /** @deprecated use `GetFuturesPricesRequest$inboundSchema` instead. */ export const inboundSchema = GetFuturesPricesRequest$inboundSchema; /** @deprecated use `GetFuturesPricesRequest$outboundSchema` instead. */ export const outboundSchema = GetFuturesPricesRequest$outboundSchema; /** @deprecated use `GetFuturesPricesRequest$Outbound` instead. */ export type Outbound = GetFuturesPricesRequest$Outbound; } export function getFuturesPricesRequestToJSON( getFuturesPricesRequest: GetFuturesPricesRequest, ): string { return JSON.stringify( GetFuturesPricesRequest$outboundSchema.parse(getFuturesPricesRequest), ); } export function getFuturesPricesRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetFuturesPricesRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetFuturesPricesRequest' from JSON`, ); }