kalshi-typescript
Version:
OpenAPI client for kalshi-typescript
717 lines (642 loc) • 45.8 kB
text/typescript
/* tslint:disable */
/* eslint-disable */
/**
* Kalshi Trade API Manual Endpoints
* Manually defined OpenAPI spec for endpoints being migrated to spec-first approach
*
* The version of the OpenAPI document: 3.11.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// URLSearchParams not necessarily used
// @ts-ignore
import { URL, URLSearchParams } from 'url';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError } from '../base';
// @ts-ignore
import type { ErrorResponse } from '../models';
// @ts-ignore
import type { GetFillsResponse } from '../models';
// @ts-ignore
import type { GetHistoricalCutoffResponse } from '../models';
// @ts-ignore
import type { GetMarketCandlesticksHistoricalResponse } from '../models';
// @ts-ignore
import type { GetMarketResponse } from '../models';
// @ts-ignore
import type { GetMarketsResponse } from '../models';
// @ts-ignore
import type { GetOrdersResponse } from '../models';
// @ts-ignore
import type { GetTradesResponse } from '../models';
/**
* HistoricalApi - axios parameter creator
*/
export const HistoricalApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
* Endpoint for getting all historical fills for the member. A fill is when a trade you have is matched.
* @summary Get Historical Fills
* @param {string} [ticker] Filter by market ticker
* @param {number} [maxTs] Filter items before this Unix timestamp
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 200.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getFillsHistorical: async (ticker?: string, maxTs?: number, limit?: number, cursor?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/historical/fills`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication kalshiAccessSignature required
await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-SIGNATURE", configuration)
// authentication kalshiAccessKey required
await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-KEY", configuration)
// authentication kalshiAccessTimestamp required
await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-TIMESTAMP", configuration)
if (ticker !== undefined) {
localVarQueryParameter['ticker'] = ticker;
}
if (maxTs !== undefined) {
localVarQueryParameter['max_ts'] = maxTs;
}
if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}
if (cursor !== undefined) {
localVarQueryParameter['cursor'] = cursor;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Returns the cutoff timestamps that define the boundary between **live** and **historical** data. ## Cutoff fields - `market_settled_ts` : Markets that **settled** before this timestamp, and their candlesticks, must be accessed via `GET /historical/markets` and `GET /historical/markets/{ticker}/candlesticks`. - `trades_created_ts` : Trades that were **filled** before this timestamp must be accessed via `GET /historical/fills`. - `orders_updated_ts` : Orders that were **canceled or fully executed** before this timestamp must be accessed via `GET /historical/orders`. Resting (active) orders are always available in `GET /portfolio/orders`.
* @summary Get Historical Cutoff Timestamps
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getHistoricalCutoff: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/historical/cutoff`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Endpoint for getting data about a specific market by its ticker from the historical database.
* @summary Get Historical Market
* @param {string} ticker Market ticker
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getHistoricalMarket: async (ticker: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'ticker' is not null or undefined
assertParamExists('getHistoricalMarket', 'ticker', ticker)
const localVarPath = `/historical/markets/{ticker}`
.replace(`{${"ticker"}}`, encodeURIComponent(String(ticker)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Endpoint for getting markets that have been archived to the historical database. Filters are mutually exclusive.
* @summary Get Historical Markets
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 1000.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {string} [tickers] Filter by specific market tickers. Comma-separated list of market tickers to retrieve.
* @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported.
* @param {GetHistoricalMarketsMveFilterEnum} [mveFilter] Filter by multivariate events (combos). By default, MVE markets are included.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getHistoricalMarkets: async (limit?: number, cursor?: string, tickers?: string, eventTicker?: string, mveFilter?: GetHistoricalMarketsMveFilterEnum, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/historical/markets`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}
if (cursor !== undefined) {
localVarQueryParameter['cursor'] = cursor;
}
if (tickers !== undefined) {
localVarQueryParameter['tickers'] = tickers;
}
if (eventTicker !== undefined) {
localVarQueryParameter['event_ticker'] = eventTicker;
}
if (mveFilter !== undefined) {
localVarQueryParameter['mve_filter'] = mveFilter;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Endpoint for getting orders that have been archived to the historical database.
* @summary Get Historical Orders
* @param {string} [ticker] Filter by market ticker
* @param {number} [maxTs] Filter items before this Unix timestamp
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 200.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getHistoricalOrders: async (ticker?: string, maxTs?: number, limit?: number, cursor?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/historical/orders`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication kalshiAccessSignature required
await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-SIGNATURE", configuration)
// authentication kalshiAccessKey required
await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-KEY", configuration)
// authentication kalshiAccessTimestamp required
await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-TIMESTAMP", configuration)
if (ticker !== undefined) {
localVarQueryParameter['ticker'] = ticker;
}
if (maxTs !== undefined) {
localVarQueryParameter['max_ts'] = maxTs;
}
if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}
if (cursor !== undefined) {
localVarQueryParameter['cursor'] = cursor;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Endpoint for fetching historical candlestick data for markets that have been archived from the live data set. Time period length of each candlestick in minutes. Valid values: 1 (1 minute), 60 (1 hour), 1440 (1 day).
* @summary Get Historical Market Candlesticks
* @param {string} ticker Market ticker - unique identifier for the specific market
* @param {number} startTs Start timestamp (Unix timestamp). Candlesticks will include those ending on or after this time.
* @param {number} endTs End timestamp (Unix timestamp). Candlesticks will include those ending on or before this time.
* @param {GetMarketCandlesticksHistoricalPeriodIntervalEnum} periodInterval Time period length of each candlestick in minutes. Valid values are 1 (1 minute), 60 (1 hour), or 1440 (1 day).
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getMarketCandlesticksHistorical: async (ticker: string, startTs: number, endTs: number, periodInterval: GetMarketCandlesticksHistoricalPeriodIntervalEnum, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'ticker' is not null or undefined
assertParamExists('getMarketCandlesticksHistorical', 'ticker', ticker)
// verify required parameter 'startTs' is not null or undefined
assertParamExists('getMarketCandlesticksHistorical', 'startTs', startTs)
// verify required parameter 'endTs' is not null or undefined
assertParamExists('getMarketCandlesticksHistorical', 'endTs', endTs)
// verify required parameter 'periodInterval' is not null or undefined
assertParamExists('getMarketCandlesticksHistorical', 'periodInterval', periodInterval)
const localVarPath = `/historical/markets/{ticker}/candlesticks`
.replace(`{${"ticker"}}`, encodeURIComponent(String(ticker)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (startTs !== undefined) {
localVarQueryParameter['start_ts'] = startTs;
}
if (endTs !== undefined) {
localVarQueryParameter['end_ts'] = endTs;
}
if (periodInterval !== undefined) {
localVarQueryParameter['period_interval'] = periodInterval;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Endpoint for getting all historical trades for all markets. Trades that were filled before the historical cutoff are available via this endpoint. See [Historical Data](https://kalshi.com/docs/getting_started/historical_data) for details.
* @summary Get Historical Trades
* @param {string} [ticker] Filter by market ticker
* @param {number} [minTs] Filter items after this Unix timestamp
* @param {number} [maxTs] Filter items before this Unix timestamp
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 1000.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getTradesHistorical: async (ticker?: string, minTs?: number, maxTs?: number, limit?: number, cursor?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/historical/trades`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (ticker !== undefined) {
localVarQueryParameter['ticker'] = ticker;
}
if (minTs !== undefined) {
localVarQueryParameter['min_ts'] = minTs;
}
if (maxTs !== undefined) {
localVarQueryParameter['max_ts'] = maxTs;
}
if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}
if (cursor !== undefined) {
localVarQueryParameter['cursor'] = cursor;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
}
};
/**
* HistoricalApi - functional programming interface
*/
export const HistoricalApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = HistoricalApiAxiosParamCreator(configuration)
return {
/**
* Endpoint for getting all historical fills for the member. A fill is when a trade you have is matched.
* @summary Get Historical Fills
* @param {string} [ticker] Filter by market ticker
* @param {number} [maxTs] Filter items before this Unix timestamp
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 200.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getFillsHistorical(ticker?: string, maxTs?: number, limit?: number, cursor?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetFillsResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getFillsHistorical(ticker, maxTs, limit, cursor, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath: string | undefined = undefined;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* Returns the cutoff timestamps that define the boundary between **live** and **historical** data. ## Cutoff fields - `market_settled_ts` : Markets that **settled** before this timestamp, and their candlesticks, must be accessed via `GET /historical/markets` and `GET /historical/markets/{ticker}/candlesticks`. - `trades_created_ts` : Trades that were **filled** before this timestamp must be accessed via `GET /historical/fills`. - `orders_updated_ts` : Orders that were **canceled or fully executed** before this timestamp must be accessed via `GET /historical/orders`. Resting (active) orders are always available in `GET /portfolio/orders`.
* @summary Get Historical Cutoff Timestamps
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getHistoricalCutoff(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetHistoricalCutoffResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getHistoricalCutoff(options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath: string | undefined = undefined;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* Endpoint for getting data about a specific market by its ticker from the historical database.
* @summary Get Historical Market
* @param {string} ticker Market ticker
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getHistoricalMarket(ticker: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetMarketResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getHistoricalMarket(ticker, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath: string | undefined = undefined;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* Endpoint for getting markets that have been archived to the historical database. Filters are mutually exclusive.
* @summary Get Historical Markets
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 1000.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {string} [tickers] Filter by specific market tickers. Comma-separated list of market tickers to retrieve.
* @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported.
* @param {GetHistoricalMarketsMveFilterEnum} [mveFilter] Filter by multivariate events (combos). By default, MVE markets are included.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getHistoricalMarkets(limit?: number, cursor?: string, tickers?: string, eventTicker?: string, mveFilter?: GetHistoricalMarketsMveFilterEnum, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetMarketsResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getHistoricalMarkets(limit, cursor, tickers, eventTicker, mveFilter, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath: string | undefined = undefined;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* Endpoint for getting orders that have been archived to the historical database.
* @summary Get Historical Orders
* @param {string} [ticker] Filter by market ticker
* @param {number} [maxTs] Filter items before this Unix timestamp
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 200.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getHistoricalOrders(ticker?: string, maxTs?: number, limit?: number, cursor?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetOrdersResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getHistoricalOrders(ticker, maxTs, limit, cursor, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath: string | undefined = undefined;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* Endpoint for fetching historical candlestick data for markets that have been archived from the live data set. Time period length of each candlestick in minutes. Valid values: 1 (1 minute), 60 (1 hour), 1440 (1 day).
* @summary Get Historical Market Candlesticks
* @param {string} ticker Market ticker - unique identifier for the specific market
* @param {number} startTs Start timestamp (Unix timestamp). Candlesticks will include those ending on or after this time.
* @param {number} endTs End timestamp (Unix timestamp). Candlesticks will include those ending on or before this time.
* @param {GetMarketCandlesticksHistoricalPeriodIntervalEnum} periodInterval Time period length of each candlestick in minutes. Valid values are 1 (1 minute), 60 (1 hour), or 1440 (1 day).
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getMarketCandlesticksHistorical(ticker: string, startTs: number, endTs: number, periodInterval: GetMarketCandlesticksHistoricalPeriodIntervalEnum, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetMarketCandlesticksHistoricalResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getMarketCandlesticksHistorical(ticker, startTs, endTs, periodInterval, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath: string | undefined = undefined;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* Endpoint for getting all historical trades for all markets. Trades that were filled before the historical cutoff are available via this endpoint. See [Historical Data](https://kalshi.com/docs/getting_started/historical_data) for details.
* @summary Get Historical Trades
* @param {string} [ticker] Filter by market ticker
* @param {number} [minTs] Filter items after this Unix timestamp
* @param {number} [maxTs] Filter items before this Unix timestamp
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 1000.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getTradesHistorical(ticker?: string, minTs?: number, maxTs?: number, limit?: number, cursor?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetTradesResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getTradesHistorical(ticker, minTs, maxTs, limit, cursor, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath: string | undefined = undefined;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* HistoricalApi - factory interface
*/
export const HistoricalApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = HistoricalApiFp(configuration)
return {
/**
* Endpoint for getting all historical fills for the member. A fill is when a trade you have is matched.
* @summary Get Historical Fills
* @param {string} [ticker] Filter by market ticker
* @param {number} [maxTs] Filter items before this Unix timestamp
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 200.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getFillsHistorical(ticker?: string, maxTs?: number, limit?: number, cursor?: string, options?: RawAxiosRequestConfig): AxiosPromise<GetFillsResponse> {
return localVarFp.getFillsHistorical(ticker, maxTs, limit, cursor, options).then((request) => request(axios, basePath));
},
/**
* Returns the cutoff timestamps that define the boundary between **live** and **historical** data. ## Cutoff fields - `market_settled_ts` : Markets that **settled** before this timestamp, and their candlesticks, must be accessed via `GET /historical/markets` and `GET /historical/markets/{ticker}/candlesticks`. - `trades_created_ts` : Trades that were **filled** before this timestamp must be accessed via `GET /historical/fills`. - `orders_updated_ts` : Orders that were **canceled or fully executed** before this timestamp must be accessed via `GET /historical/orders`. Resting (active) orders are always available in `GET /portfolio/orders`.
* @summary Get Historical Cutoff Timestamps
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getHistoricalCutoff(options?: RawAxiosRequestConfig): AxiosPromise<GetHistoricalCutoffResponse> {
return localVarFp.getHistoricalCutoff(options).then((request) => request(axios, basePath));
},
/**
* Endpoint for getting data about a specific market by its ticker from the historical database.
* @summary Get Historical Market
* @param {string} ticker Market ticker
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getHistoricalMarket(ticker: string, options?: RawAxiosRequestConfig): AxiosPromise<GetMarketResponse> {
return localVarFp.getHistoricalMarket(ticker, options).then((request) => request(axios, basePath));
},
/**
* Endpoint for getting markets that have been archived to the historical database. Filters are mutually exclusive.
* @summary Get Historical Markets
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 1000.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {string} [tickers] Filter by specific market tickers. Comma-separated list of market tickers to retrieve.
* @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported.
* @param {GetHistoricalMarketsMveFilterEnum} [mveFilter] Filter by multivariate events (combos). By default, MVE markets are included.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getHistoricalMarkets(limit?: number, cursor?: string, tickers?: string, eventTicker?: string, mveFilter?: GetHistoricalMarketsMveFilterEnum, options?: RawAxiosRequestConfig): AxiosPromise<GetMarketsResponse> {
return localVarFp.getHistoricalMarkets(limit, cursor, tickers, eventTicker, mveFilter, options).then((request) => request(axios, basePath));
},
/**
* Endpoint for getting orders that have been archived to the historical database.
* @summary Get Historical Orders
* @param {string} [ticker] Filter by market ticker
* @param {number} [maxTs] Filter items before this Unix timestamp
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 200.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getHistoricalOrders(ticker?: string, maxTs?: number, limit?: number, cursor?: string, options?: RawAxiosRequestConfig): AxiosPromise<GetOrdersResponse> {
return localVarFp.getHistoricalOrders(ticker, maxTs, limit, cursor, options).then((request) => request(axios, basePath));
},
/**
* Endpoint for fetching historical candlestick data for markets that have been archived from the live data set. Time period length of each candlestick in minutes. Valid values: 1 (1 minute), 60 (1 hour), 1440 (1 day).
* @summary Get Historical Market Candlesticks
* @param {string} ticker Market ticker - unique identifier for the specific market
* @param {number} startTs Start timestamp (Unix timestamp). Candlesticks will include those ending on or after this time.
* @param {number} endTs End timestamp (Unix timestamp). Candlesticks will include those ending on or before this time.
* @param {GetMarketCandlesticksHistoricalPeriodIntervalEnum} periodInterval Time period length of each candlestick in minutes. Valid values are 1 (1 minute), 60 (1 hour), or 1440 (1 day).
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getMarketCandlesticksHistorical(ticker: string, startTs: number, endTs: number, periodInterval: GetMarketCandlesticksHistoricalPeriodIntervalEnum, options?: RawAxiosRequestConfig): AxiosPromise<GetMarketCandlesticksHistoricalResponse> {
return localVarFp.getMarketCandlesticksHistorical(ticker, startTs, endTs, periodInterval, options).then((request) => request(axios, basePath));
},
/**
* Endpoint for getting all historical trades for all markets. Trades that were filled before the historical cutoff are available via this endpoint. See [Historical Data](https://kalshi.com/docs/getting_started/historical_data) for details.
* @summary Get Historical Trades
* @param {string} [ticker] Filter by market ticker
* @param {number} [minTs] Filter items after this Unix timestamp
* @param {number} [maxTs] Filter items before this Unix timestamp
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 1000.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getTradesHistorical(ticker?: string, minTs?: number, maxTs?: number, limit?: number, cursor?: string, options?: RawAxiosRequestConfig): AxiosPromise<GetTradesResponse> {
return localVarFp.getTradesHistorical(ticker, minTs, maxTs, limit, cursor, options).then((request) => request(axios, basePath));
},
};
};
/**
* HistoricalApi - object-oriented interface
*/
export class HistoricalApi extends BaseAPI {
/**
* Endpoint for getting all historical fills for the member. A fill is when a trade you have is matched.
* @summary Get Historical Fills
* @param {string} [ticker] Filter by market ticker
* @param {number} [maxTs] Filter items before this Unix timestamp
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 200.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public getFillsHistorical(ticker?: string, maxTs?: number, limit?: number, cursor?: string, options?: RawAxiosRequestConfig) {
return HistoricalApiFp(this.configuration).getFillsHistorical(ticker, maxTs, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}
/**
* Returns the cutoff timestamps that define the boundary between **live** and **historical** data. ## Cutoff fields - `market_settled_ts` : Markets that **settled** before this timestamp, and their candlesticks, must be accessed via `GET /historical/markets` and `GET /historical/markets/{ticker}/candlesticks`. - `trades_created_ts` : Trades that were **filled** before this timestamp must be accessed via `GET /historical/fills`. - `orders_updated_ts` : Orders that were **canceled or fully executed** before this timestamp must be accessed via `GET /historical/orders`. Resting (active) orders are always available in `GET /portfolio/orders`.
* @summary Get Historical Cutoff Timestamps
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public getHistoricalCutoff(options?: RawAxiosRequestConfig) {
return HistoricalApiFp(this.configuration).getHistoricalCutoff(options).then((request) => request(this.axios, this.basePath));
}
/**
* Endpoint for getting data about a specific market by its ticker from the historical database.
* @summary Get Historical Market
* @param {string} ticker Market ticker
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public getHistoricalMarket(ticker: string, options?: RawAxiosRequestConfig) {
return HistoricalApiFp(this.configuration).getHistoricalMarket(ticker, options).then((request) => request(this.axios, this.basePath));
}
/**
* Endpoint for getting markets that have been archived to the historical database. Filters are mutually exclusive.
* @summary Get Historical Markets
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 1000.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {string} [tickers] Filter by specific market tickers. Comma-separated list of market tickers to retrieve.
* @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported.
* @param {GetHistoricalMarketsMveFilterEnum} [mveFilter] Filter by multivariate events (combos). By default, MVE markets are included.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public getHistoricalMarkets(limit?: number, cursor?: string, tickers?: string, eventTicker?: string, mveFilter?: GetHistoricalMarketsMveFilterEnum, options?: RawAxiosRequestConfig) {
return HistoricalApiFp(this.configuration).getHistoricalMarkets(limit, cursor, tickers, eventTicker, mveFilter, options).then((request) => request(this.axios, this.basePath));
}
/**
* Endpoint for getting orders that have been archived to the historical database.
* @summary Get Historical Orders
* @param {string} [ticker] Filter by market ticker
* @param {number} [maxTs] Filter items before this Unix timestamp
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 200.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public getHistoricalOrders(ticker?: string, maxTs?: number, limit?: number, cursor?: string, options?: RawAxiosRequestConfig) {
return HistoricalApiFp(this.configuration).getHistoricalOrders(ticker, maxTs, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}
/**
* Endpoint for fetching historical candlestick data for markets that have been archived from the live data set. Time period length of each candlestick in minutes. Valid values: 1 (1 minute), 60 (1 hour), 1440 (1 day).
* @summary Get Historical Market Candlesticks
* @param {string} ticker Market ticker - unique identifier for the specific market
* @param {number} startTs Start timestamp (Unix timestamp). Candlesticks will include those ending on or after this time.
* @param {number} endTs End timestamp (Unix timestamp). Candlesticks will include those ending on or before this time.
* @param {GetMarketCandlesticksHistoricalPeriodIntervalEnum} periodInterval Time period length of each candlestick in minutes. Valid values are 1 (1 minute), 60 (1 hour), or 1440 (1 day).
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public getMarketCandlesticksHistorical(ticker: string, startTs: number, endTs: number, periodInterval: GetMarketCandlesticksHistoricalPeriodIntervalEnum, options?: RawAxiosRequestConfig) {
return HistoricalApiFp(this.configuration).getMarketCandlesticksHistorical(ticker, startTs, endTs, periodInterval, options).then((request) => request(this.axios, this.basePath));
}
/**
* Endpoint for getting all historical trades for all markets. Trades that were filled before the historical cutoff are available via this endpoint. See [Historical Data](https://kalshi.com/docs/getting_started/historical_data) for details.
* @summary Get Historical Trades
* @param {string} [ticker] Filter by market ticker
* @param {number} [minTs] Filter items after this Unix timestamp
* @param {number} [maxTs] Filter items before this Unix timestamp
* @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 1000.
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public getTradesHistorical(ticker?: string, minTs?: number, maxTs?: number, limit?: number, cursor?: string, options?: RawAxiosRequestConfig) {
return HistoricalApiFp(this.configuration).getTradesHistorical(ticker, minTs, maxTs, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}
}
export const GetHistoricalMarketsMveFilterEnum = {
Exclude: 'exclude'
} as const;
export type GetHistoricalMarketsMveFilterEnum = typeof GetHistoricalMarketsMveFilterEnum[keyof typeof GetHistoricalMarketsMveFilterEnum];
export const GetMarketCandlesticksHistoricalPeriodIntervalEnum = {
NUMBER_1: 1,
NUMBER_60: 60,
NUMBER_1440: 1440
} as const;
export type GetMarketCandlesticksHistoricalPeriodIntervalEnum = typeof GetMarketCandlesticksHistoricalPeriodIntervalEnum[keyof typeof GetMarketCandlesticksHistoricalPeriodIntervalEnum];