UNPKG

kalshi-typescript

Version:

Official TypeScript SDK for the Kalshi API

314 lines (313 loc) 21.1 kB
"use strict"; /* 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.6.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetFCMPositionsSettlementStatusEnum = exports.GetFCMOrdersStatusEnum = exports.FcmApi = exports.FcmApiFactory = exports.FcmApiFp = exports.FcmApiAxiosParamCreator = void 0; const axios_1 = require("axios"); // URLSearchParams not necessarily used // @ts-ignore const url_1 = require("url"); // Some imports not used depending on template conditions // @ts-ignore const common_1 = require("../common"); // @ts-ignore const base_1 = require("../base"); /** * FcmApi - axios parameter creator */ const FcmApiAxiosParamCreator = function (configuration) { return { /** * Endpoint for FCM members to get orders filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering orders by subtrader ID. * @summary Get FCM Orders * @param {string} subtraderId Restricts the response to orders for a specific subtrader (FCM members only) * @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} [eventTicker] Event ticker of desired positions. Multiple event tickers can be provided as a comma-separated list (maximum 10). * @param {string} [ticker] Filter by market ticker * @param {number} [minTs] Restricts the response to orders after a timestamp, formatted as a Unix Timestamp * @param {number} [maxTs] Restricts the response to orders before a timestamp, formatted as a Unix Timestamp * @param {GetFCMOrdersStatusEnum} [status] Restricts the response to orders that have a certain status * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100 * @param {*} [options] Override http request option. * @throws {RequiredError} */ getFCMOrders: (subtraderId_1, cursor_1, eventTicker_1, ticker_1, minTs_1, maxTs_1, status_1, limit_1, ...args_1) => __awaiter(this, [subtraderId_1, cursor_1, eventTicker_1, ticker_1, minTs_1, maxTs_1, status_1, limit_1, ...args_1], void 0, function* (subtraderId, cursor, eventTicker, ticker, minTs, maxTs, status, limit, options = {}) { // verify required parameter 'subtraderId' is not null or undefined (0, common_1.assertParamExists)('getFCMOrders', 'subtraderId', subtraderId); const localVarPath = `/fcm/orders`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new url_1.URL(localVarPath, common_1.DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); const localVarHeaderParameter = {}; const localVarQueryParameter = {}; // authentication kalshiAccessSignature required yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "KALSHI-ACCESS-SIGNATURE", configuration); // authentication kalshiAccessKey required yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "KALSHI-ACCESS-KEY", configuration); // authentication kalshiAccessTimestamp required yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "KALSHI-ACCESS-TIMESTAMP", configuration); if (subtraderId !== undefined) { localVarQueryParameter['subtrader_id'] = subtraderId; } if (cursor !== undefined) { localVarQueryParameter['cursor'] = cursor; } if (eventTicker !== undefined) { localVarQueryParameter['event_ticker'] = eventTicker; } if (ticker !== undefined) { localVarQueryParameter['ticker'] = ticker; } if (minTs !== undefined) { localVarQueryParameter['min_ts'] = minTs; } if (maxTs !== undefined) { localVarQueryParameter['max_ts'] = maxTs; } if (status !== undefined) { localVarQueryParameter['status'] = status; } if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); return { url: (0, common_1.toPathString)(localVarUrlObj), options: localVarRequestOptions, }; }), /** * Endpoint for FCM members to get market positions filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering positions by subtrader ID. * @summary Get FCM Positions * @param {string} subtraderId Restricts the response to positions for a specific subtrader (FCM members only) * @param {string} [ticker] Ticker of desired positions * @param {string} [eventTicker] Event ticker of desired positions * @param {string} [countFilter] Restricts the positions to those with any of following fields with non-zero values, as a comma separated list * @param {GetFCMPositionsSettlementStatusEnum} [settlementStatus] Settlement status of the markets to return. Defaults to unsettled * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100 * @param {string} [cursor] The Cursor represents a pointer to the next page of records in the pagination * @param {*} [options] Override http request option. * @throws {RequiredError} */ getFCMPositions: (subtraderId_1, ticker_1, eventTicker_1, countFilter_1, settlementStatus_1, limit_1, cursor_1, ...args_1) => __awaiter(this, [subtraderId_1, ticker_1, eventTicker_1, countFilter_1, settlementStatus_1, limit_1, cursor_1, ...args_1], void 0, function* (subtraderId, ticker, eventTicker, countFilter, settlementStatus, limit, cursor, options = {}) { // verify required parameter 'subtraderId' is not null or undefined (0, common_1.assertParamExists)('getFCMPositions', 'subtraderId', subtraderId); const localVarPath = `/fcm/positions`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new url_1.URL(localVarPath, common_1.DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); const localVarHeaderParameter = {}; const localVarQueryParameter = {}; // authentication kalshiAccessSignature required yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "KALSHI-ACCESS-SIGNATURE", configuration); // authentication kalshiAccessKey required yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "KALSHI-ACCESS-KEY", configuration); // authentication kalshiAccessTimestamp required yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "KALSHI-ACCESS-TIMESTAMP", configuration); if (subtraderId !== undefined) { localVarQueryParameter['subtrader_id'] = subtraderId; } if (ticker !== undefined) { localVarQueryParameter['ticker'] = ticker; } if (eventTicker !== undefined) { localVarQueryParameter['event_ticker'] = eventTicker; } if (countFilter !== undefined) { localVarQueryParameter['count_filter'] = countFilter; } if (settlementStatus !== undefined) { localVarQueryParameter['settlement_status'] = settlementStatus; } if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } if (cursor !== undefined) { localVarQueryParameter['cursor'] = cursor; } (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); return { url: (0, common_1.toPathString)(localVarUrlObj), options: localVarRequestOptions, }; }), }; }; exports.FcmApiAxiosParamCreator = FcmApiAxiosParamCreator; /** * FcmApi - functional programming interface */ const FcmApiFp = function (configuration) { const localVarAxiosParamCreator = (0, exports.FcmApiAxiosParamCreator)(configuration); return { /** * Endpoint for FCM members to get orders filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering orders by subtrader ID. * @summary Get FCM Orders * @param {string} subtraderId Restricts the response to orders for a specific subtrader (FCM members only) * @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} [eventTicker] Event ticker of desired positions. Multiple event tickers can be provided as a comma-separated list (maximum 10). * @param {string} [ticker] Filter by market ticker * @param {number} [minTs] Restricts the response to orders after a timestamp, formatted as a Unix Timestamp * @param {number} [maxTs] Restricts the response to orders before a timestamp, formatted as a Unix Timestamp * @param {GetFCMOrdersStatusEnum} [status] Restricts the response to orders that have a certain status * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100 * @param {*} [options] Override http request option. * @throws {RequiredError} */ getFCMOrders(subtraderId, cursor, eventTicker, ticker, minTs, maxTs, status, limit, options) { return __awaiter(this, void 0, void 0, function* () { var _a; const localVarAxiosArgs = yield localVarAxiosParamCreator.getFCMOrders(subtraderId, cursor, eventTicker, ticker, minTs, maxTs, status, limit, options); const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0; const localVarOperationServerBasePath = undefined; return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }); }, /** * Endpoint for FCM members to get market positions filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering positions by subtrader ID. * @summary Get FCM Positions * @param {string} subtraderId Restricts the response to positions for a specific subtrader (FCM members only) * @param {string} [ticker] Ticker of desired positions * @param {string} [eventTicker] Event ticker of desired positions * @param {string} [countFilter] Restricts the positions to those with any of following fields with non-zero values, as a comma separated list * @param {GetFCMPositionsSettlementStatusEnum} [settlementStatus] Settlement status of the markets to return. Defaults to unsettled * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100 * @param {string} [cursor] The Cursor represents a pointer to the next page of records in the pagination * @param {*} [options] Override http request option. * @throws {RequiredError} */ getFCMPositions(subtraderId, ticker, eventTicker, countFilter, settlementStatus, limit, cursor, options) { return __awaiter(this, void 0, void 0, function* () { var _a; const localVarAxiosArgs = yield localVarAxiosParamCreator.getFCMPositions(subtraderId, ticker, eventTicker, countFilter, settlementStatus, limit, cursor, options); const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0; const localVarOperationServerBasePath = undefined; return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }); }, }; }; exports.FcmApiFp = FcmApiFp; /** * FcmApi - factory interface */ const FcmApiFactory = function (configuration, basePath, axios) { const localVarFp = (0, exports.FcmApiFp)(configuration); return { /** * Endpoint for FCM members to get orders filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering orders by subtrader ID. * @summary Get FCM Orders * @param {string} subtraderId Restricts the response to orders for a specific subtrader (FCM members only) * @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} [eventTicker] Event ticker of desired positions. Multiple event tickers can be provided as a comma-separated list (maximum 10). * @param {string} [ticker] Filter by market ticker * @param {number} [minTs] Restricts the response to orders after a timestamp, formatted as a Unix Timestamp * @param {number} [maxTs] Restricts the response to orders before a timestamp, formatted as a Unix Timestamp * @param {GetFCMOrdersStatusEnum} [status] Restricts the response to orders that have a certain status * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100 * @param {*} [options] Override http request option. * @throws {RequiredError} */ getFCMOrders(subtraderId, cursor, eventTicker, ticker, minTs, maxTs, status, limit, options) { return localVarFp.getFCMOrders(subtraderId, cursor, eventTicker, ticker, minTs, maxTs, status, limit, options).then((request) => request(axios, basePath)); }, /** * Endpoint for FCM members to get market positions filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering positions by subtrader ID. * @summary Get FCM Positions * @param {string} subtraderId Restricts the response to positions for a specific subtrader (FCM members only) * @param {string} [ticker] Ticker of desired positions * @param {string} [eventTicker] Event ticker of desired positions * @param {string} [countFilter] Restricts the positions to those with any of following fields with non-zero values, as a comma separated list * @param {GetFCMPositionsSettlementStatusEnum} [settlementStatus] Settlement status of the markets to return. Defaults to unsettled * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100 * @param {string} [cursor] The Cursor represents a pointer to the next page of records in the pagination * @param {*} [options] Override http request option. * @throws {RequiredError} */ getFCMPositions(subtraderId, ticker, eventTicker, countFilter, settlementStatus, limit, cursor, options) { return localVarFp.getFCMPositions(subtraderId, ticker, eventTicker, countFilter, settlementStatus, limit, cursor, options).then((request) => request(axios, basePath)); }, }; }; exports.FcmApiFactory = FcmApiFactory; /** * FcmApi - object-oriented interface */ class FcmApi extends base_1.BaseAPI { /** * Endpoint for FCM members to get orders filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering orders by subtrader ID. * @summary Get FCM Orders * @param {string} subtraderId Restricts the response to orders for a specific subtrader (FCM members only) * @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} [eventTicker] Event ticker of desired positions. Multiple event tickers can be provided as a comma-separated list (maximum 10). * @param {string} [ticker] Filter by market ticker * @param {number} [minTs] Restricts the response to orders after a timestamp, formatted as a Unix Timestamp * @param {number} [maxTs] Restricts the response to orders before a timestamp, formatted as a Unix Timestamp * @param {GetFCMOrdersStatusEnum} [status] Restricts the response to orders that have a certain status * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100 * @param {*} [options] Override http request option. * @throws {RequiredError} */ getFCMOrders(subtraderId, cursor, eventTicker, ticker, minTs, maxTs, status, limit, options) { return (0, exports.FcmApiFp)(this.configuration).getFCMOrders(subtraderId, cursor, eventTicker, ticker, minTs, maxTs, status, limit, options).then((request) => request(this.axios, this.basePath)); } /** * Endpoint for FCM members to get market positions filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering positions by subtrader ID. * @summary Get FCM Positions * @param {string} subtraderId Restricts the response to positions for a specific subtrader (FCM members only) * @param {string} [ticker] Ticker of desired positions * @param {string} [eventTicker] Event ticker of desired positions * @param {string} [countFilter] Restricts the positions to those with any of following fields with non-zero values, as a comma separated list * @param {GetFCMPositionsSettlementStatusEnum} [settlementStatus] Settlement status of the markets to return. Defaults to unsettled * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100 * @param {string} [cursor] The Cursor represents a pointer to the next page of records in the pagination * @param {*} [options] Override http request option. * @throws {RequiredError} */ getFCMPositions(subtraderId, ticker, eventTicker, countFilter, settlementStatus, limit, cursor, options) { return (0, exports.FcmApiFp)(this.configuration).getFCMPositions(subtraderId, ticker, eventTicker, countFilter, settlementStatus, limit, cursor, options).then((request) => request(this.axios, this.basePath)); } } exports.FcmApi = FcmApi; exports.GetFCMOrdersStatusEnum = { Resting: 'resting', Canceled: 'canceled', Executed: 'executed' }; exports.GetFCMPositionsSettlementStatusEnum = { All: 'all', Unsettled: 'unsettled', Settled: 'settled' };