/* 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.36.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 { ApplySubaccountTransferRequest } from '../models'; // @ts-ignore import type { CreateSubaccountRequest } from '../models'; // @ts-ignore import type { CreateSubaccountResponse } from '../models'; // @ts-ignore import type { ErrorResponse } from '../models'; // @ts-ignore import type { GetBalanceResponse } from '../models'; // @ts-ignore import type { GetCreditHistoryResponse } from '../models'; // @ts-ignore import type { GetDepositsResponse } from '../models'; // @ts-ignore import type { GetFillsResponse } from '../models'; // @ts-ignore import type { GetIntraExchangeInstanceTransferResponse } from '../models'; // @ts-ignore import type { GetIntraExchangeInstanceTransfersResponse } from '../models'; // @ts-ignore import type { GetPortfolioRestingOrderTotalValueResponse } from '../models'; // @ts-ignore import type { GetPositionsResponse } from '../models'; // @ts-ignore import type { GetSettlementsResponse } from '../models'; // @ts-ignore import type { GetSubaccountBalancesResponse } from '../models'; // @ts-ignore import type { GetSubaccountNettingResponse } from '../models'; // @ts-ignore import type { GetSubaccountTransfersResponse } from '../models'; // @ts-ignore import type { GetTargetBalanceAllocationResponse } from '../models'; // @ts-ignore import type { GetWithdrawalsResponse } from '../models'; // @ts-ignore import type { IntraExchangeInstanceTransferRequest } from '../models'; // @ts-ignore import type { IntraExchangeInstanceTransferResponse } from '../models'; // @ts-ignore import type { SetTargetBalanceAllocationRequest } from '../models'; // @ts-ignore import type { UpdateSubaccountNettingRequest } from '../models'; /** * PortfolioApi - axios parameter creator */ export const PortfolioApiAxiosParamCreator = function (configuration?: Configuration) { return { /** * Transfers funds between the authenticated user\'s subaccounts. Use 0 for the primary account, or 1-63 for numbered subaccounts. Set exchange_index to apply the transfer on a specific exchange shard (defaults to 0). * @summary Transfer Between Subaccounts * @param {ApplySubaccountTransferRequest} applySubaccountTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ applySubaccountTransfer: async (applySubaccountTransferRequest: ApplySubaccountTransferRequest, options: RawAxiosRequestConfig = {}): Promise => { // verify required parameter 'applySubaccountTransferRequest' is not null or undefined assertParamExists('applySubaccountTransfer', 'applySubaccountTransferRequest', applySubaccountTransferRequest) const localVarPath = `/portfolio/subaccounts/transfer`; // 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: 'POST', ...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) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(applySubaccountTransferRequest, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Creates a new subaccount for the authenticated user. This endpoint is available to all users on the Advanced API tier and above. Subaccounts are numbered sequentially starting from 1. Maximum 63 numbered subaccounts per user (64 including the primary account). * @summary Create Subaccount * @param {CreateSubaccountRequest} [createSubaccountRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ createSubaccount: async (createSubaccountRequest?: CreateSubaccountRequest, options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/subaccounts`; // 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: 'POST', ...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) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(createSubaccountRequest, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Returns the balance and portfolio value for a member. Both values include all exchange indexes unless `exchange_index` is provided. Pass `subaccount` to use a subaccount instead of the primary account. This endpoint also accepts API keys with the \'read::portfolio_balance\' scope. For per-subaccount balances, use `GET /portfolio/subaccounts/balances`. It returns existing subaccount and exchange index pairs, so its entry count can differ from `balance_breakdown`. The breakdown uses portfolio valuation snapshots; separate requests may reflect different stages of transfer processing. **Rate limit:** this endpoint has its own bucket, separate from the Read budget. Basic and Advanced tiers may call it **1 time per second**; all higher tiers may call it **5 times per second**. The bucket holds one second of budget, so there is no burst. Calls to this endpoint do not draw down the Read budget, and other reads do not draw down this bucket. Balance only changes on fills, settlements and transfers, so react to those (for example the user fills websocket channel) instead of polling this endpoint. * @summary Get Balance * @param {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). Defaults to 0. Subaccount-restricted API keys default to their locked subaccount and must omit this parameter or pass their locked subaccount. * @param {number} [exchangeIndex] Exchange index used to scope the balance and portfolio value. If omitted, both include all exchange indexes. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getBalance: async (subaccount?: number, exchangeIndex?: number, options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/balance`; // 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 (subaccount !== undefined) { localVarQueryParameter['subaccount'] = subaccount; } if (exchangeIndex !== undefined) { localVarQueryParameter['exchange_index'] = exchangeIndex; } setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Returns the authenticated member\'s credit history, newest first. Filters apply to credit creation time: `min_ts` is inclusive and `max_ts` is exclusive. * @summary Get Credit History * @param {number} [limit] Number of results per page. Defaults to 100. * @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 {number} [minTs] Filter items after this Unix timestamp * @param {number} [maxTs] Filter items before this Unix timestamp * @param {*} [options] Override http request option. * @throws {RequiredError} */ getCreditHistory: async (limit?: number, cursor?: string, minTs?: number, maxTs?: number, options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/credit_history`; // 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 (limit !== undefined) { localVarQueryParameter['limit'] = limit; } if (cursor !== undefined) { localVarQueryParameter['cursor'] = cursor; } if (minTs !== undefined) { localVarQueryParameter['min_ts'] = minTs; } if (maxTs !== undefined) { localVarQueryParameter['max_ts'] = maxTs; } 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 the member\'s deposit history. * @summary Get Deposits * @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 500. * @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} */ getDeposits: async (limit?: number, cursor?: string, options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/deposits`; // 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 (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 getting all fills for the member. A fill is when a trade you have is matched. Registered partners may also use a user OAuth access token with the explicitly granted read::compliance_partner scope. Fills that occurred before the historical cutoff are only available via `GET /historical/fills`. See [Historical Data](https://docs.kalshi.com/getting_started/historical_data) for details. * @summary Get Fills * @param {string} [ticker] Filter by market ticker. Accepts a comma-separated list of up to 100 market tickers. * @param {string} [orderId] Filter by order ID * @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. * @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 {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). If omitted, defaults to all subaccounts. * @param {number} [exchangeIndex] Filter results by exchange shard. Omit to return results from all exchange shards. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getFills: async (ticker?: string, orderId?: string, minTs?: number, maxTs?: number, limit?: number, cursor?: string, subaccount?: number, exchangeIndex?: number, options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/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) // authentication kalshiOauthAccessToken required // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration) if (ticker !== undefined) { localVarQueryParameter['ticker'] = ticker; } if (orderId !== undefined) { localVarQueryParameter['order_id'] = orderId; } 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; } if (subaccount !== undefined) { localVarQueryParameter['subaccount'] = subaccount; } if (exchangeIndex !== undefined) { localVarQueryParameter['exchange_index'] = exchangeIndex; } 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 a single intra-account transfer by id. * @summary Get Intra Account Transfer * @param {string} transferId Transfer id returned by creation endpoint * @param {*} [options] Override http request option. * @throws {RequiredError} */ getIntraExchangeInstanceTransfer: async (transferId: string, options: RawAxiosRequestConfig = {}): Promise => { // verify required parameter 'transferId' is not null or undefined assertParamExists('getIntraExchangeInstanceTransfer', 'transferId', transferId) const localVarPath = `/portfolio/intra_exchange_instance_transfers/{transfer_id}` .replace(`{${"transfer_id"}}`, encodeURIComponent(String(transferId))); // 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) 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 intra-exchange account transfer history. * @summary Get Intra Account Transfers * @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 500. * @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} */ getIntraExchangeInstanceTransfers: async (limit?: number, cursor?: string, options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/intra_exchange_instance_transfers`; // 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 (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 getting the total value, in cents, of resting orders. This endpoint is only intended for use by FCM members (rare). Note: If you\'re uncertain about this endpoint, it likely does not apply to you. * @summary Get Total Resting Order Value * @param {*} [options] Override http request option. * @throws {RequiredError} */ getPortfolioRestingOrderTotalValue: async (options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/summary/total_resting_order_value`; // 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) setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Returns unsettled positions by default, including closed markets awaiting determination or settlement. These may retain non-zero quantities and cost basis. Check the market\'s `status` via `GET /markets/{ticker}` for trading status. Set `settlement_status=settled` for unarchived settled positions or `all` for both states. These results paginate by event ticker; cursors are specific to settlement status. Archived positions are available via `GET /historical/positions`. Use `count_filter=position` for non-zero net holdings, including closed, unsettled markets. Without a count filter, results may include fully exited positions with trading history, realized P&L or fees. Registered partners may also use a user OAuth access token with the explicitly granted read::compliance_partner scope. * @summary Get Positions * @param {string} [cursor] The Cursor represents a pointer to the next page of records in the pagination. Use the value returned from the previous response to get the next page. * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100. * @param {string} [countFilter] Comma-separated filters combined with OR: `position` (non-zero net contracts), `total_traded` (any contracts traded, including fully exited positions). Omit for no count filter. * @param {GetPositionsSettlementStatusEnum} [settlementStatus] Filters settlement state, not trading status: `unsettled` (default), `settled` (not yet archived), or `all` (both live states). * @param {string} [ticker] Filter by market ticker * @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported. * @param {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). Defaults to 0. Subaccount-restricted API keys default to their locked subaccount and must omit this parameter or pass their locked subaccount. * @param {number} [exchangeIndex] Filter results by exchange shard. Omit to return results from all exchange shards. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getPositions: async (cursor?: string, limit?: number, countFilter?: string, settlementStatus?: GetPositionsSettlementStatusEnum, ticker?: string, eventTicker?: string, subaccount?: number, exchangeIndex?: number, options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/positions`; // 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) // authentication kalshiOauthAccessToken required // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration) if (cursor !== undefined) { localVarQueryParameter['cursor'] = cursor; } if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } if (countFilter !== undefined) { localVarQueryParameter['count_filter'] = countFilter; } if (settlementStatus !== undefined) { localVarQueryParameter['settlement_status'] = settlementStatus; } if (ticker !== undefined) { localVarQueryParameter['ticker'] = ticker; } if (eventTicker !== undefined) { localVarQueryParameter['event_ticker'] = eventTicker; } if (subaccount !== undefined) { localVarQueryParameter['subaccount'] = subaccount; } if (exchangeIndex !== undefined) { localVarQueryParameter['exchange_index'] = exchangeIndex; } setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Returns settlement records still in the live data set. Archived positions are available via `GET /historical/positions`, which has different fields; this endpoint does not return archived settlement records. Resource-bound MCP OAuth tokens may read the owner\'s settlements with read::mcp_portfolio. * @summary Get Settlements * @param {number} [limit] Number of results per page. Defaults to 100. * @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} [ticker] Filter by market ticker * @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported. * @param {number} [minTs] Filter items after this Unix timestamp * @param {number} [maxTs] Filter items before this Unix timestamp * @param {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). If omitted, defaults to all subaccounts. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getSettlements: async (limit?: number, cursor?: string, ticker?: string, eventTicker?: string, minTs?: number, maxTs?: number, subaccount?: number, options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/settlements`; // 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) // authentication kalshiOauthAccessToken required // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration) if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } if (cursor !== undefined) { localVarQueryParameter['cursor'] = cursor; } if (ticker !== undefined) { localVarQueryParameter['ticker'] = ticker; } if (eventTicker !== undefined) { localVarQueryParameter['event_ticker'] = eventTicker; } if (minTs !== undefined) { localVarQueryParameter['min_ts'] = minTs; } if (maxTs !== undefined) { localVarQueryParameter['max_ts'] = maxTs; } if (subaccount !== undefined) { localVarQueryParameter['subaccount'] = subaccount; } setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Returns balances for all subaccounts, including the primary account. Only existing subaccount and exchange index pairs are returned, including pairs with a zero balance. A pair can exist before it is funded. For an API key restricted to a subaccount, returns only that subaccount\'s balances. * @summary Get All Subaccount Balances * @param {*} [options] Override http request option. * @throws {RequiredError} */ getSubaccountBalances: async (options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/subaccounts/balances`; // 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) setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Gets the netting enabled settings for all subaccounts. * @summary Get Subaccount Netting * @param {*} [options] Override http request option. * @throws {RequiredError} */ getSubaccountNetting: async (options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/subaccounts/netting`; // 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) setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Gets a paginated list of all transfers between subaccounts for the authenticated user. * @summary Get Subaccount Transfers * @param {number} [limit] Number of results per page. Defaults to 100. * @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} */ getSubaccountTransfers: async (limit?: number, cursor?: string, options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/subaccounts/transfers`; // 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 (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, }; }, /** * Retrieves the caller\'s target balance allocation across exchange indexes. * @summary Get Target Balance Allocation * @param {*} [options] Override http request option. * @throws {RequiredError} */ getTargetBalanceAllocation: async (options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/target_balance_allocation`; // 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) 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 the member\'s withdrawal history. * @summary Get Withdrawals * @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 500. * @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} */ getWithdrawals: async (limit?: number, cursor?: string, options: RawAxiosRequestConfig = {}): Promise => { const localVarPath = `/portfolio/withdrawals`; // 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 (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, }; }, /** * Transfers funds within the same account. Subaccount-restricted API keys can only transfer between `event_contract` exchange indices, with `source_subaccount` and `destination_subaccount` both set to the key\'s subaccount. When `source_exchange_shard` and `destination_exchange_shard` are the same, Kalshi treats the request as a subaccount transfer. The returned transfer ID appears in the subaccount transfer history. Cross-exchange-index subaccount transfers run in up to three non-atomic steps. If a later step fails, completed steps are not undone, so funds may remain in the primary account on the source or destination exchange index. * @summary Intra Account Transfer * @param {IntraExchangeInstanceTransferRequest} intraExchangeInstanceTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ intraExchangeInstanceTransfer: async (intraExchangeInstanceTransferRequest: IntraExchangeInstanceTransferRequest, options: RawAxiosRequestConfig = {}): Promise => { // verify required parameter 'intraExchangeInstanceTransferRequest' is not null or undefined assertParamExists('intraExchangeInstanceTransfer', 'intraExchangeInstanceTransferRequest', intraExchangeInstanceTransferRequest) const localVarPath = `/portfolio/intra_exchange_instance_transfer`; // 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: 'POST', ...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) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(intraExchangeInstanceTransferRequest, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Replaces the caller\'s target balance allocation across exchange indexes. Percentages must total 100. Passing an empty allocations array disables automatic rebalancing. * @summary Set Target Balance Allocation * @param {SetTargetBalanceAllocationRequest} setTargetBalanceAllocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ setTargetBalanceAllocation: async (setTargetBalanceAllocationRequest: SetTargetBalanceAllocationRequest, options: RawAxiosRequestConfig = {}): Promise => { // verify required parameter 'setTargetBalanceAllocationRequest' is not null or undefined assertParamExists('setTargetBalanceAllocation', 'setTargetBalanceAllocationRequest', setTargetBalanceAllocationRequest) const localVarPath = `/portfolio/target_balance_allocation`; // 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: 'POST', ...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) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(setTargetBalanceAllocationRequest, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Updates the netting enabled setting for a specific subaccount. Use 0 for the primary account, or 1-63 for numbered subaccounts. * @summary Update Subaccount Netting * @param {UpdateSubaccountNettingRequest} updateSubaccountNettingRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ updateSubaccountNetting: async (updateSubaccountNettingRequest: UpdateSubaccountNettingRequest, options: RawAxiosRequestConfig = {}): Promise => { // verify required parameter 'updateSubaccountNettingRequest' is not null or undefined assertParamExists('updateSubaccountNetting', 'updateSubaccountNettingRequest', updateSubaccountNettingRequest) const localVarPath = `/portfolio/subaccounts/netting`; // 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: 'PUT', ...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) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(updateSubaccountNettingRequest, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, } }; /** * PortfolioApi - functional programming interface */ export const PortfolioApiFp = function(configuration?: Configuration) { const localVarAxiosParamCreator = PortfolioApiAxiosParamCreator(configuration) return { /** * Transfers funds between the authenticated user\'s subaccounts. Use 0 for the primary account, or 1-63 for numbered subaccounts. Set exchange_index to apply the transfer on a specific exchange shard (defaults to 0). * @summary Transfer Between Subaccounts * @param {ApplySubaccountTransferRequest} applySubaccountTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ async applySubaccountTransfer(applySubaccountTransferRequest: ApplySubaccountTransferRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.applySubaccountTransfer(applySubaccountTransferRequest, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Creates a new subaccount for the authenticated user. This endpoint is available to all users on the Advanced API tier and above. Subaccounts are numbered sequentially starting from 1. Maximum 63 numbered subaccounts per user (64 including the primary account). * @summary Create Subaccount * @param {CreateSubaccountRequest} [createSubaccountRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ async createSubaccount(createSubaccountRequest?: CreateSubaccountRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.createSubaccount(createSubaccountRequest, 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 balance and portfolio value for a member. Both values include all exchange indexes unless `exchange_index` is provided. Pass `subaccount` to use a subaccount instead of the primary account. This endpoint also accepts API keys with the \'read::portfolio_balance\' scope. For per-subaccount balances, use `GET /portfolio/subaccounts/balances`. It returns existing subaccount and exchange index pairs, so its entry count can differ from `balance_breakdown`. The breakdown uses portfolio valuation snapshots; separate requests may reflect different stages of transfer processing. **Rate limit:** this endpoint has its own bucket, separate from the Read budget. Basic and Advanced tiers may call it **1 time per second**; all higher tiers may call it **5 times per second**. The bucket holds one second of budget, so there is no burst. Calls to this endpoint do not draw down the Read budget, and other reads do not draw down this bucket. Balance only changes on fills, settlements and transfers, so react to those (for example the user fills websocket channel) instead of polling this endpoint. * @summary Get Balance * @param {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). Defaults to 0. Subaccount-restricted API keys default to their locked subaccount and must omit this parameter or pass their locked subaccount. * @param {number} [exchangeIndex] Exchange index used to scope the balance and portfolio value. If omitted, both include all exchange indexes. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getBalance(subaccount?: number, exchangeIndex?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getBalance(subaccount, exchangeIndex, 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 authenticated member\'s credit history, newest first. Filters apply to credit creation time: `min_ts` is inclusive and `max_ts` is exclusive. * @summary Get Credit History * @param {number} [limit] Number of results per page. Defaults to 100. * @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 {number} [minTs] Filter items after this Unix timestamp * @param {number} [maxTs] Filter items before this Unix timestamp * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getCreditHistory(limit?: number, cursor?: string, minTs?: number, maxTs?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getCreditHistory(limit, cursor, minTs, maxTs, 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 the member\'s deposit history. * @summary Get Deposits * @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 500. * @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 getDeposits(limit?: number, cursor?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getDeposits(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 getting all fills for the member. A fill is when a trade you have is matched. Registered partners may also use a user OAuth access token with the explicitly granted read::compliance_partner scope. Fills that occurred before the historical cutoff are only available via `GET /historical/fills`. See [Historical Data](https://docs.kalshi.com/getting_started/historical_data) for details. * @summary Get Fills * @param {string} [ticker] Filter by market ticker. Accepts a comma-separated list of up to 100 market tickers. * @param {string} [orderId] Filter by order ID * @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. * @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 {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). If omitted, defaults to all subaccounts. * @param {number} [exchangeIndex] Filter results by exchange shard. Omit to return results from all exchange shards. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getFills(ticker?: string, orderId?: string, minTs?: number, maxTs?: number, limit?: number, cursor?: string, subaccount?: number, exchangeIndex?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getFills(ticker, orderId, minTs, maxTs, limit, cursor, subaccount, exchangeIndex, 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 a single intra-account transfer by id. * @summary Get Intra Account Transfer * @param {string} transferId Transfer id returned by creation endpoint * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getIntraExchangeInstanceTransfer(transferId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getIntraExchangeInstanceTransfer(transferId, 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 intra-exchange account transfer history. * @summary Get Intra Account Transfers * @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 500. * @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 getIntraExchangeInstanceTransfers(limit?: number, cursor?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getIntraExchangeInstanceTransfers(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 getting the total value, in cents, of resting orders. This endpoint is only intended for use by FCM members (rare). Note: If you\'re uncertain about this endpoint, it likely does not apply to you. * @summary Get Total Resting Order Value * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getPortfolioRestingOrderTotalValue(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getPortfolioRestingOrderTotalValue(options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Returns unsettled positions by default, including closed markets awaiting determination or settlement. These may retain non-zero quantities and cost basis. Check the market\'s `status` via `GET /markets/{ticker}` for trading status. Set `settlement_status=settled` for unarchived settled positions or `all` for both states. These results paginate by event ticker; cursors are specific to settlement status. Archived positions are available via `GET /historical/positions`. Use `count_filter=position` for non-zero net holdings, including closed, unsettled markets. Without a count filter, results may include fully exited positions with trading history, realized P&L or fees. Registered partners may also use a user OAuth access token with the explicitly granted read::compliance_partner scope. * @summary Get Positions * @param {string} [cursor] The Cursor represents a pointer to the next page of records in the pagination. Use the value returned from the previous response to get the next page. * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100. * @param {string} [countFilter] Comma-separated filters combined with OR: `position` (non-zero net contracts), `total_traded` (any contracts traded, including fully exited positions). Omit for no count filter. * @param {GetPositionsSettlementStatusEnum} [settlementStatus] Filters settlement state, not trading status: `unsettled` (default), `settled` (not yet archived), or `all` (both live states). * @param {string} [ticker] Filter by market ticker * @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported. * @param {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). Defaults to 0. Subaccount-restricted API keys default to their locked subaccount and must omit this parameter or pass their locked subaccount. * @param {number} [exchangeIndex] Filter results by exchange shard. Omit to return results from all exchange shards. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getPositions(cursor?: string, limit?: number, countFilter?: string, settlementStatus?: GetPositionsSettlementStatusEnum, ticker?: string, eventTicker?: string, subaccount?: number, exchangeIndex?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getPositions(cursor, limit, countFilter, settlementStatus, ticker, eventTicker, subaccount, exchangeIndex, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Returns settlement records still in the live data set. Archived positions are available via `GET /historical/positions`, which has different fields; this endpoint does not return archived settlement records. Resource-bound MCP OAuth tokens may read the owner\'s settlements with read::mcp_portfolio. * @summary Get Settlements * @param {number} [limit] Number of results per page. Defaults to 100. * @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} [ticker] Filter by market ticker * @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported. * @param {number} [minTs] Filter items after this Unix timestamp * @param {number} [maxTs] Filter items before this Unix timestamp * @param {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). If omitted, defaults to all subaccounts. * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getSettlements(limit?: number, cursor?: string, ticker?: string, eventTicker?: string, minTs?: number, maxTs?: number, subaccount?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getSettlements(limit, cursor, ticker, eventTicker, minTs, maxTs, subaccount, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Returns balances for all subaccounts, including the primary account. Only existing subaccount and exchange index pairs are returned, including pairs with a zero balance. A pair can exist before it is funded. For an API key restricted to a subaccount, returns only that subaccount\'s balances. * @summary Get All Subaccount Balances * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getSubaccountBalances(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getSubaccountBalances(options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Gets the netting enabled settings for all subaccounts. * @summary Get Subaccount Netting * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getSubaccountNetting(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getSubaccountNetting(options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Gets a paginated list of all transfers between subaccounts for the authenticated user. * @summary Get Subaccount Transfers * @param {number} [limit] Number of results per page. Defaults to 100. * @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 getSubaccountTransfers(limit?: number, cursor?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getSubaccountTransfers(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); }, /** * Retrieves the caller\'s target balance allocation across exchange indexes. * @summary Get Target Balance Allocation * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getTargetBalanceAllocation(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getTargetBalanceAllocation(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 the member\'s withdrawal history. * @summary Get Withdrawals * @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 500. * @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 getWithdrawals(limit?: number, cursor?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.getWithdrawals(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); }, /** * Transfers funds within the same account. Subaccount-restricted API keys can only transfer between `event_contract` exchange indices, with `source_subaccount` and `destination_subaccount` both set to the key\'s subaccount. When `source_exchange_shard` and `destination_exchange_shard` are the same, Kalshi treats the request as a subaccount transfer. The returned transfer ID appears in the subaccount transfer history. Cross-exchange-index subaccount transfers run in up to three non-atomic steps. If a later step fails, completed steps are not undone, so funds may remain in the primary account on the source or destination exchange index. * @summary Intra Account Transfer * @param {IntraExchangeInstanceTransferRequest} intraExchangeInstanceTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ async intraExchangeInstanceTransfer(intraExchangeInstanceTransferRequest: IntraExchangeInstanceTransferRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.intraExchangeInstanceTransfer(intraExchangeInstanceTransferRequest, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Replaces the caller\'s target balance allocation across exchange indexes. Percentages must total 100. Passing an empty allocations array disables automatic rebalancing. * @summary Set Target Balance Allocation * @param {SetTargetBalanceAllocationRequest} setTargetBalanceAllocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ async setTargetBalanceAllocation(setTargetBalanceAllocationRequest: SetTargetBalanceAllocationRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.setTargetBalanceAllocation(setTargetBalanceAllocationRequest, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Updates the netting enabled setting for a specific subaccount. Use 0 for the primary account, or 1-63 for numbered subaccounts. * @summary Update Subaccount Netting * @param {UpdateSubaccountNettingRequest} updateSubaccountNettingRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ async updateSubaccountNetting(updateSubaccountNettingRequest: UpdateSubaccountNettingRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.updateSubaccountNetting(updateSubaccountNettingRequest, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath: string | undefined = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, } }; /** * PortfolioApi - factory interface */ export const PortfolioApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { const localVarFp = PortfolioApiFp(configuration) return { /** * Transfers funds between the authenticated user\'s subaccounts. Use 0 for the primary account, or 1-63 for numbered subaccounts. Set exchange_index to apply the transfer on a specific exchange shard (defaults to 0). * @summary Transfer Between Subaccounts * @param {ApplySubaccountTransferRequest} applySubaccountTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ applySubaccountTransfer(applySubaccountTransferRequest: ApplySubaccountTransferRequest, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.applySubaccountTransfer(applySubaccountTransferRequest, options).then((request) => request(axios, basePath)); }, /** * Creates a new subaccount for the authenticated user. This endpoint is available to all users on the Advanced API tier and above. Subaccounts are numbered sequentially starting from 1. Maximum 63 numbered subaccounts per user (64 including the primary account). * @summary Create Subaccount * @param {CreateSubaccountRequest} [createSubaccountRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ createSubaccount(createSubaccountRequest?: CreateSubaccountRequest, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.createSubaccount(createSubaccountRequest, options).then((request) => request(axios, basePath)); }, /** * Returns the balance and portfolio value for a member. Both values include all exchange indexes unless `exchange_index` is provided. Pass `subaccount` to use a subaccount instead of the primary account. This endpoint also accepts API keys with the \'read::portfolio_balance\' scope. For per-subaccount balances, use `GET /portfolio/subaccounts/balances`. It returns existing subaccount and exchange index pairs, so its entry count can differ from `balance_breakdown`. The breakdown uses portfolio valuation snapshots; separate requests may reflect different stages of transfer processing. **Rate limit:** this endpoint has its own bucket, separate from the Read budget. Basic and Advanced tiers may call it **1 time per second**; all higher tiers may call it **5 times per second**. The bucket holds one second of budget, so there is no burst. Calls to this endpoint do not draw down the Read budget, and other reads do not draw down this bucket. Balance only changes on fills, settlements and transfers, so react to those (for example the user fills websocket channel) instead of polling this endpoint. * @summary Get Balance * @param {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). Defaults to 0. Subaccount-restricted API keys default to their locked subaccount and must omit this parameter or pass their locked subaccount. * @param {number} [exchangeIndex] Exchange index used to scope the balance and portfolio value. If omitted, both include all exchange indexes. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getBalance(subaccount?: number, exchangeIndex?: number, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getBalance(subaccount, exchangeIndex, options).then((request) => request(axios, basePath)); }, /** * Returns the authenticated member\'s credit history, newest first. Filters apply to credit creation time: `min_ts` is inclusive and `max_ts` is exclusive. * @summary Get Credit History * @param {number} [limit] Number of results per page. Defaults to 100. * @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 {number} [minTs] Filter items after this Unix timestamp * @param {number} [maxTs] Filter items before this Unix timestamp * @param {*} [options] Override http request option. * @throws {RequiredError} */ getCreditHistory(limit?: number, cursor?: string, minTs?: number, maxTs?: number, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getCreditHistory(limit, cursor, minTs, maxTs, options).then((request) => request(axios, basePath)); }, /** * Endpoint for getting the member\'s deposit history. * @summary Get Deposits * @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 500. * @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} */ getDeposits(limit?: number, cursor?: string, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getDeposits(limit, cursor, options).then((request) => request(axios, basePath)); }, /** * Endpoint for getting all fills for the member. A fill is when a trade you have is matched. Registered partners may also use a user OAuth access token with the explicitly granted read::compliance_partner scope. Fills that occurred before the historical cutoff are only available via `GET /historical/fills`. See [Historical Data](https://docs.kalshi.com/getting_started/historical_data) for details. * @summary Get Fills * @param {string} [ticker] Filter by market ticker. Accepts a comma-separated list of up to 100 market tickers. * @param {string} [orderId] Filter by order ID * @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. * @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 {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). If omitted, defaults to all subaccounts. * @param {number} [exchangeIndex] Filter results by exchange shard. Omit to return results from all exchange shards. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getFills(ticker?: string, orderId?: string, minTs?: number, maxTs?: number, limit?: number, cursor?: string, subaccount?: number, exchangeIndex?: number, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getFills(ticker, orderId, minTs, maxTs, limit, cursor, subaccount, exchangeIndex, options).then((request) => request(axios, basePath)); }, /** * Endpoint for getting a single intra-account transfer by id. * @summary Get Intra Account Transfer * @param {string} transferId Transfer id returned by creation endpoint * @param {*} [options] Override http request option. * @throws {RequiredError} */ getIntraExchangeInstanceTransfer(transferId: string, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getIntraExchangeInstanceTransfer(transferId, options).then((request) => request(axios, basePath)); }, /** * Endpoint for fetching intra-exchange account transfer history. * @summary Get Intra Account Transfers * @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 500. * @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} */ getIntraExchangeInstanceTransfers(limit?: number, cursor?: string, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getIntraExchangeInstanceTransfers(limit, cursor, options).then((request) => request(axios, basePath)); }, /** * Endpoint for getting the total value, in cents, of resting orders. This endpoint is only intended for use by FCM members (rare). Note: If you\'re uncertain about this endpoint, it likely does not apply to you. * @summary Get Total Resting Order Value * @param {*} [options] Override http request option. * @throws {RequiredError} */ getPortfolioRestingOrderTotalValue(options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getPortfolioRestingOrderTotalValue(options).then((request) => request(axios, basePath)); }, /** * Returns unsettled positions by default, including closed markets awaiting determination or settlement. These may retain non-zero quantities and cost basis. Check the market\'s `status` via `GET /markets/{ticker}` for trading status. Set `settlement_status=settled` for unarchived settled positions or `all` for both states. These results paginate by event ticker; cursors are specific to settlement status. Archived positions are available via `GET /historical/positions`. Use `count_filter=position` for non-zero net holdings, including closed, unsettled markets. Without a count filter, results may include fully exited positions with trading history, realized P&L or fees. Registered partners may also use a user OAuth access token with the explicitly granted read::compliance_partner scope. * @summary Get Positions * @param {string} [cursor] The Cursor represents a pointer to the next page of records in the pagination. Use the value returned from the previous response to get the next page. * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100. * @param {string} [countFilter] Comma-separated filters combined with OR: `position` (non-zero net contracts), `total_traded` (any contracts traded, including fully exited positions). Omit for no count filter. * @param {GetPositionsSettlementStatusEnum} [settlementStatus] Filters settlement state, not trading status: `unsettled` (default), `settled` (not yet archived), or `all` (both live states). * @param {string} [ticker] Filter by market ticker * @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported. * @param {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). Defaults to 0. Subaccount-restricted API keys default to their locked subaccount and must omit this parameter or pass their locked subaccount. * @param {number} [exchangeIndex] Filter results by exchange shard. Omit to return results from all exchange shards. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getPositions(cursor?: string, limit?: number, countFilter?: string, settlementStatus?: GetPositionsSettlementStatusEnum, ticker?: string, eventTicker?: string, subaccount?: number, exchangeIndex?: number, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getPositions(cursor, limit, countFilter, settlementStatus, ticker, eventTicker, subaccount, exchangeIndex, options).then((request) => request(axios, basePath)); }, /** * Returns settlement records still in the live data set. Archived positions are available via `GET /historical/positions`, which has different fields; this endpoint does not return archived settlement records. Resource-bound MCP OAuth tokens may read the owner\'s settlements with read::mcp_portfolio. * @summary Get Settlements * @param {number} [limit] Number of results per page. Defaults to 100. * @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} [ticker] Filter by market ticker * @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported. * @param {number} [minTs] Filter items after this Unix timestamp * @param {number} [maxTs] Filter items before this Unix timestamp * @param {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). If omitted, defaults to all subaccounts. * @param {*} [options] Override http request option. * @throws {RequiredError} */ getSettlements(limit?: number, cursor?: string, ticker?: string, eventTicker?: string, minTs?: number, maxTs?: number, subaccount?: number, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getSettlements(limit, cursor, ticker, eventTicker, minTs, maxTs, subaccount, options).then((request) => request(axios, basePath)); }, /** * Returns balances for all subaccounts, including the primary account. Only existing subaccount and exchange index pairs are returned, including pairs with a zero balance. A pair can exist before it is funded. For an API key restricted to a subaccount, returns only that subaccount\'s balances. * @summary Get All Subaccount Balances * @param {*} [options] Override http request option. * @throws {RequiredError} */ getSubaccountBalances(options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getSubaccountBalances(options).then((request) => request(axios, basePath)); }, /** * Gets the netting enabled settings for all subaccounts. * @summary Get Subaccount Netting * @param {*} [options] Override http request option. * @throws {RequiredError} */ getSubaccountNetting(options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getSubaccountNetting(options).then((request) => request(axios, basePath)); }, /** * Gets a paginated list of all transfers between subaccounts for the authenticated user. * @summary Get Subaccount Transfers * @param {number} [limit] Number of results per page. Defaults to 100. * @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} */ getSubaccountTransfers(limit?: number, cursor?: string, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getSubaccountTransfers(limit, cursor, options).then((request) => request(axios, basePath)); }, /** * Retrieves the caller\'s target balance allocation across exchange indexes. * @summary Get Target Balance Allocation * @param {*} [options] Override http request option. * @throws {RequiredError} */ getTargetBalanceAllocation(options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getTargetBalanceAllocation(options).then((request) => request(axios, basePath)); }, /** * Endpoint for getting the member\'s withdrawal history. * @summary Get Withdrawals * @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 500. * @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} */ getWithdrawals(limit?: number, cursor?: string, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getWithdrawals(limit, cursor, options).then((request) => request(axios, basePath)); }, /** * Transfers funds within the same account. Subaccount-restricted API keys can only transfer between `event_contract` exchange indices, with `source_subaccount` and `destination_subaccount` both set to the key\'s subaccount. When `source_exchange_shard` and `destination_exchange_shard` are the same, Kalshi treats the request as a subaccount transfer. The returned transfer ID appears in the subaccount transfer history. Cross-exchange-index subaccount transfers run in up to three non-atomic steps. If a later step fails, completed steps are not undone, so funds may remain in the primary account on the source or destination exchange index. * @summary Intra Account Transfer * @param {IntraExchangeInstanceTransferRequest} intraExchangeInstanceTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ intraExchangeInstanceTransfer(intraExchangeInstanceTransferRequest: IntraExchangeInstanceTransferRequest, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.intraExchangeInstanceTransfer(intraExchangeInstanceTransferRequest, options).then((request) => request(axios, basePath)); }, /** * Replaces the caller\'s target balance allocation across exchange indexes. Percentages must total 100. Passing an empty allocations array disables automatic rebalancing. * @summary Set Target Balance Allocation * @param {SetTargetBalanceAllocationRequest} setTargetBalanceAllocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ setTargetBalanceAllocation(setTargetBalanceAllocationRequest: SetTargetBalanceAllocationRequest, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.setTargetBalanceAllocation(setTargetBalanceAllocationRequest, options).then((request) => request(axios, basePath)); }, /** * Updates the netting enabled setting for a specific subaccount. Use 0 for the primary account, or 1-63 for numbered subaccounts. * @summary Update Subaccount Netting * @param {UpdateSubaccountNettingRequest} updateSubaccountNettingRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ updateSubaccountNetting(updateSubaccountNettingRequest: UpdateSubaccountNettingRequest, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.updateSubaccountNetting(updateSubaccountNettingRequest, options).then((request) => request(axios, basePath)); }, }; }; /** * PortfolioApi - object-oriented interface */ export class PortfolioApi extends BaseAPI { /** * Transfers funds between the authenticated user\'s subaccounts. Use 0 for the primary account, or 1-63 for numbered subaccounts. Set exchange_index to apply the transfer on a specific exchange shard (defaults to 0). * @summary Transfer Between Subaccounts * @param {ApplySubaccountTransferRequest} applySubaccountTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ public applySubaccountTransfer(applySubaccountTransferRequest: ApplySubaccountTransferRequest, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).applySubaccountTransfer(applySubaccountTransferRequest, options).then((request) => request(this.axios, this.basePath)); } /** * Creates a new subaccount for the authenticated user. This endpoint is available to all users on the Advanced API tier and above. Subaccounts are numbered sequentially starting from 1. Maximum 63 numbered subaccounts per user (64 including the primary account). * @summary Create Subaccount * @param {CreateSubaccountRequest} [createSubaccountRequest] * @param {*} [options] Override http request option. * @throws {RequiredError} */ public createSubaccount(createSubaccountRequest?: CreateSubaccountRequest, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).createSubaccount(createSubaccountRequest, options).then((request) => request(this.axios, this.basePath)); } /** * Returns the balance and portfolio value for a member. Both values include all exchange indexes unless `exchange_index` is provided. Pass `subaccount` to use a subaccount instead of the primary account. This endpoint also accepts API keys with the \'read::portfolio_balance\' scope. For per-subaccount balances, use `GET /portfolio/subaccounts/balances`. It returns existing subaccount and exchange index pairs, so its entry count can differ from `balance_breakdown`. The breakdown uses portfolio valuation snapshots; separate requests may reflect different stages of transfer processing. **Rate limit:** this endpoint has its own bucket, separate from the Read budget. Basic and Advanced tiers may call it **1 time per second**; all higher tiers may call it **5 times per second**. The bucket holds one second of budget, so there is no burst. Calls to this endpoint do not draw down the Read budget, and other reads do not draw down this bucket. Balance only changes on fills, settlements and transfers, so react to those (for example the user fills websocket channel) instead of polling this endpoint. * @summary Get Balance * @param {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). Defaults to 0. Subaccount-restricted API keys default to their locked subaccount and must omit this parameter or pass their locked subaccount. * @param {number} [exchangeIndex] Exchange index used to scope the balance and portfolio value. If omitted, both include all exchange indexes. * @param {*} [options] Override http request option. * @throws {RequiredError} */ public getBalance(subaccount?: number, exchangeIndex?: number, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getBalance(subaccount, exchangeIndex, options).then((request) => request(this.axios, this.basePath)); } /** * Returns the authenticated member\'s credit history, newest first. Filters apply to credit creation time: `min_ts` is inclusive and `max_ts` is exclusive. * @summary Get Credit History * @param {number} [limit] Number of results per page. Defaults to 100. * @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 {number} [minTs] Filter items after this Unix timestamp * @param {number} [maxTs] Filter items before this Unix timestamp * @param {*} [options] Override http request option. * @throws {RequiredError} */ public getCreditHistory(limit?: number, cursor?: string, minTs?: number, maxTs?: number, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getCreditHistory(limit, cursor, minTs, maxTs, options).then((request) => request(this.axios, this.basePath)); } /** * Endpoint for getting the member\'s deposit history. * @summary Get Deposits * @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 500. * @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 getDeposits(limit?: number, cursor?: string, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getDeposits(limit, cursor, options).then((request) => request(this.axios, this.basePath)); } /** * Endpoint for getting all fills for the member. A fill is when a trade you have is matched. Registered partners may also use a user OAuth access token with the explicitly granted read::compliance_partner scope. Fills that occurred before the historical cutoff are only available via `GET /historical/fills`. See [Historical Data](https://docs.kalshi.com/getting_started/historical_data) for details. * @summary Get Fills * @param {string} [ticker] Filter by market ticker. Accepts a comma-separated list of up to 100 market tickers. * @param {string} [orderId] Filter by order ID * @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. * @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 {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). If omitted, defaults to all subaccounts. * @param {number} [exchangeIndex] Filter results by exchange shard. Omit to return results from all exchange shards. * @param {*} [options] Override http request option. * @throws {RequiredError} */ public getFills(ticker?: string, orderId?: string, minTs?: number, maxTs?: number, limit?: number, cursor?: string, subaccount?: number, exchangeIndex?: number, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getFills(ticker, orderId, minTs, maxTs, limit, cursor, subaccount, exchangeIndex, options).then((request) => request(this.axios, this.basePath)); } /** * Endpoint for getting a single intra-account transfer by id. * @summary Get Intra Account Transfer * @param {string} transferId Transfer id returned by creation endpoint * @param {*} [options] Override http request option. * @throws {RequiredError} */ public getIntraExchangeInstanceTransfer(transferId: string, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getIntraExchangeInstanceTransfer(transferId, options).then((request) => request(this.axios, this.basePath)); } /** * Endpoint for fetching intra-exchange account transfer history. * @summary Get Intra Account Transfers * @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 500. * @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 getIntraExchangeInstanceTransfers(limit?: number, cursor?: string, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getIntraExchangeInstanceTransfers(limit, cursor, options).then((request) => request(this.axios, this.basePath)); } /** * Endpoint for getting the total value, in cents, of resting orders. This endpoint is only intended for use by FCM members (rare). Note: If you\'re uncertain about this endpoint, it likely does not apply to you. * @summary Get Total Resting Order Value * @param {*} [options] Override http request option. * @throws {RequiredError} */ public getPortfolioRestingOrderTotalValue(options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getPortfolioRestingOrderTotalValue(options).then((request) => request(this.axios, this.basePath)); } /** * Returns unsettled positions by default, including closed markets awaiting determination or settlement. These may retain non-zero quantities and cost basis. Check the market\'s `status` via `GET /markets/{ticker}` for trading status. Set `settlement_status=settled` for unarchived settled positions or `all` for both states. These results paginate by event ticker; cursors are specific to settlement status. Archived positions are available via `GET /historical/positions`. Use `count_filter=position` for non-zero net holdings, including closed, unsettled markets. Without a count filter, results may include fully exited positions with trading history, realized P&L or fees. Registered partners may also use a user OAuth access token with the explicitly granted read::compliance_partner scope. * @summary Get Positions * @param {string} [cursor] The Cursor represents a pointer to the next page of records in the pagination. Use the value returned from the previous response to get the next page. * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100. * @param {string} [countFilter] Comma-separated filters combined with OR: `position` (non-zero net contracts), `total_traded` (any contracts traded, including fully exited positions). Omit for no count filter. * @param {GetPositionsSettlementStatusEnum} [settlementStatus] Filters settlement state, not trading status: `unsettled` (default), `settled` (not yet archived), or `all` (both live states). * @param {string} [ticker] Filter by market ticker * @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported. * @param {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). Defaults to 0. Subaccount-restricted API keys default to their locked subaccount and must omit this parameter or pass their locked subaccount. * @param {number} [exchangeIndex] Filter results by exchange shard. Omit to return results from all exchange shards. * @param {*} [options] Override http request option. * @throws {RequiredError} */ public getPositions(cursor?: string, limit?: number, countFilter?: string, settlementStatus?: GetPositionsSettlementStatusEnum, ticker?: string, eventTicker?: string, subaccount?: number, exchangeIndex?: number, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getPositions(cursor, limit, countFilter, settlementStatus, ticker, eventTicker, subaccount, exchangeIndex, options).then((request) => request(this.axios, this.basePath)); } /** * Returns settlement records still in the live data set. Archived positions are available via `GET /historical/positions`, which has different fields; this endpoint does not return archived settlement records. Resource-bound MCP OAuth tokens may read the owner\'s settlements with read::mcp_portfolio. * @summary Get Settlements * @param {number} [limit] Number of results per page. Defaults to 100. * @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} [ticker] Filter by market ticker * @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported. * @param {number} [minTs] Filter items after this Unix timestamp * @param {number} [maxTs] Filter items before this Unix timestamp * @param {number} [subaccount] Subaccount number (0 for primary, 1-63 for subaccounts). If omitted, defaults to all subaccounts. * @param {*} [options] Override http request option. * @throws {RequiredError} */ public getSettlements(limit?: number, cursor?: string, ticker?: string, eventTicker?: string, minTs?: number, maxTs?: number, subaccount?: number, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getSettlements(limit, cursor, ticker, eventTicker, minTs, maxTs, subaccount, options).then((request) => request(this.axios, this.basePath)); } /** * Returns balances for all subaccounts, including the primary account. Only existing subaccount and exchange index pairs are returned, including pairs with a zero balance. A pair can exist before it is funded. For an API key restricted to a subaccount, returns only that subaccount\'s balances. * @summary Get All Subaccount Balances * @param {*} [options] Override http request option. * @throws {RequiredError} */ public getSubaccountBalances(options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getSubaccountBalances(options).then((request) => request(this.axios, this.basePath)); } /** * Gets the netting enabled settings for all subaccounts. * @summary Get Subaccount Netting * @param {*} [options] Override http request option. * @throws {RequiredError} */ public getSubaccountNetting(options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getSubaccountNetting(options).then((request) => request(this.axios, this.basePath)); } /** * Gets a paginated list of all transfers between subaccounts for the authenticated user. * @summary Get Subaccount Transfers * @param {number} [limit] Number of results per page. Defaults to 100. * @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 getSubaccountTransfers(limit?: number, cursor?: string, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getSubaccountTransfers(limit, cursor, options).then((request) => request(this.axios, this.basePath)); } /** * Retrieves the caller\'s target balance allocation across exchange indexes. * @summary Get Target Balance Allocation * @param {*} [options] Override http request option. * @throws {RequiredError} */ public getTargetBalanceAllocation(options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getTargetBalanceAllocation(options).then((request) => request(this.axios, this.basePath)); } /** * Endpoint for getting the member\'s withdrawal history. * @summary Get Withdrawals * @param {number} [limit] Number of results per page. Defaults to 100. Maximum value is 500. * @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 getWithdrawals(limit?: number, cursor?: string, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).getWithdrawals(limit, cursor, options).then((request) => request(this.axios, this.basePath)); } /** * Transfers funds within the same account. Subaccount-restricted API keys can only transfer between `event_contract` exchange indices, with `source_subaccount` and `destination_subaccount` both set to the key\'s subaccount. When `source_exchange_shard` and `destination_exchange_shard` are the same, Kalshi treats the request as a subaccount transfer. The returned transfer ID appears in the subaccount transfer history. Cross-exchange-index subaccount transfers run in up to three non-atomic steps. If a later step fails, completed steps are not undone, so funds may remain in the primary account on the source or destination exchange index. * @summary Intra Account Transfer * @param {IntraExchangeInstanceTransferRequest} intraExchangeInstanceTransferRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ public intraExchangeInstanceTransfer(intraExchangeInstanceTransferRequest: IntraExchangeInstanceTransferRequest, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).intraExchangeInstanceTransfer(intraExchangeInstanceTransferRequest, options).then((request) => request(this.axios, this.basePath)); } /** * Replaces the caller\'s target balance allocation across exchange indexes. Percentages must total 100. Passing an empty allocations array disables automatic rebalancing. * @summary Set Target Balance Allocation * @param {SetTargetBalanceAllocationRequest} setTargetBalanceAllocationRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ public setTargetBalanceAllocation(setTargetBalanceAllocationRequest: SetTargetBalanceAllocationRequest, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).setTargetBalanceAllocation(setTargetBalanceAllocationRequest, options).then((request) => request(this.axios, this.basePath)); } /** * Updates the netting enabled setting for a specific subaccount. Use 0 for the primary account, or 1-63 for numbered subaccounts. * @summary Update Subaccount Netting * @param {UpdateSubaccountNettingRequest} updateSubaccountNettingRequest * @param {*} [options] Override http request option. * @throws {RequiredError} */ public updateSubaccountNetting(updateSubaccountNettingRequest: UpdateSubaccountNettingRequest, options?: RawAxiosRequestConfig) { return PortfolioApiFp(this.configuration).updateSubaccountNetting(updateSubaccountNettingRequest, options).then((request) => request(this.axios, this.basePath)); } } export const GetPositionsSettlementStatusEnum = { Unsettled: 'unsettled', Settled: 'settled', All: 'all' } as const; export type GetPositionsSettlementStatusEnum = typeof GetPositionsSettlementStatusEnum[keyof typeof GetPositionsSettlementStatusEnum];