UNPKG

@binance/derivatives-trading-portfolio-margin

Version:

Official Binance Derivatives Trading (COIN-M Futures) Connector - A lightweight library that provides a convenient interface to Binance's COINN-M Futures REST API, WebSocket API and WebSocket Streams.

1,313 lines (1,308 loc) 421 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name2 in all) __defProp(target, name2, { get: all[name2], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var index_exports = {}; __export(index_exports, { BadRequestError: () => import_common7.BadRequestError, ConnectorClientError: () => import_common7.ConnectorClientError, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL: () => import_common7.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL: () => import_common7.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL, DerivativesTradingPortfolioMargin: () => DerivativesTradingPortfolioMargin, DerivativesTradingPortfolioMarginRestAPI: () => rest_api_exports, ForbiddenError: () => import_common7.ForbiddenError, NetworkError: () => import_common7.NetworkError, NotFoundError: () => import_common7.NotFoundError, RateLimitBanError: () => import_common7.RateLimitBanError, RequiredError: () => import_common7.RequiredError, ServerError: () => import_common7.ServerError, TooManyRequestsError: () => import_common7.TooManyRequestsError, UnauthorizedError: () => import_common7.UnauthorizedError }); module.exports = __toCommonJS(index_exports); // src/derivatives-trading-portfolio-margin.ts var import_common6 = require("@binance/common"); // package.json var name = "@binance/derivatives-trading-portfolio-margin"; var version = "4.0.2"; // src/rest-api/index.ts var rest_api_exports = {}; __export(rest_api_exports, { AccountApi: () => AccountApi, MarginAccountNewOcoNewOrderRespTypeEnum: () => MarginAccountNewOcoNewOrderRespTypeEnum, MarginAccountNewOcoSideEffectTypeEnum: () => MarginAccountNewOcoSideEffectTypeEnum, MarginAccountNewOcoSideEnum: () => MarginAccountNewOcoSideEnum, MarginAccountNewOcoStopLimitTimeInForceEnum: () => MarginAccountNewOcoStopLimitTimeInForceEnum, MarketDataApi: () => MarketDataApi, ModifyCmOrderPriceMatchEnum: () => ModifyCmOrderPriceMatchEnum, ModifyCmOrderSideEnum: () => ModifyCmOrderSideEnum, ModifyUmOrderPriceMatchEnum: () => ModifyUmOrderPriceMatchEnum, ModifyUmOrderSideEnum: () => ModifyUmOrderSideEnum, NewCmConditionalOrderPositionSideEnum: () => NewCmConditionalOrderPositionSideEnum, NewCmConditionalOrderSideEnum: () => NewCmConditionalOrderSideEnum, NewCmConditionalOrderStrategyTypeEnum: () => NewCmConditionalOrderStrategyTypeEnum, NewCmConditionalOrderTimeInForceEnum: () => NewCmConditionalOrderTimeInForceEnum, NewCmConditionalOrderWorkingTypeEnum: () => NewCmConditionalOrderWorkingTypeEnum, NewCmOrderNewOrderRespTypeEnum: () => NewCmOrderNewOrderRespTypeEnum, NewCmOrderPositionSideEnum: () => NewCmOrderPositionSideEnum, NewCmOrderPriceMatchEnum: () => NewCmOrderPriceMatchEnum, NewCmOrderSideEnum: () => NewCmOrderSideEnum, NewCmOrderTimeInForceEnum: () => NewCmOrderTimeInForceEnum, NewCmOrderTypeEnum: () => NewCmOrderTypeEnum, NewMarginOrderNewOrderRespTypeEnum: () => NewMarginOrderNewOrderRespTypeEnum, NewMarginOrderSelfTradePreventionModeEnum: () => NewMarginOrderSelfTradePreventionModeEnum, NewMarginOrderSideEffectTypeEnum: () => NewMarginOrderSideEffectTypeEnum, NewMarginOrderSideEnum: () => NewMarginOrderSideEnum, NewMarginOrderTimeInForceEnum: () => NewMarginOrderTimeInForceEnum, NewMarginOrderTypeEnum: () => NewMarginOrderTypeEnum, NewUmConditionalOrderPositionSideEnum: () => NewUmConditionalOrderPositionSideEnum, NewUmConditionalOrderPriceMatchEnum: () => NewUmConditionalOrderPriceMatchEnum, NewUmConditionalOrderSelfTradePreventionModeEnum: () => NewUmConditionalOrderSelfTradePreventionModeEnum, NewUmConditionalOrderSideEnum: () => NewUmConditionalOrderSideEnum, NewUmConditionalOrderStrategyTypeEnum: () => NewUmConditionalOrderStrategyTypeEnum, NewUmConditionalOrderTimeInForceEnum: () => NewUmConditionalOrderTimeInForceEnum, NewUmConditionalOrderWorkingTypeEnum: () => NewUmConditionalOrderWorkingTypeEnum, NewUmOrderNewOrderRespTypeEnum: () => NewUmOrderNewOrderRespTypeEnum, NewUmOrderPositionSideEnum: () => NewUmOrderPositionSideEnum, NewUmOrderPriceMatchEnum: () => NewUmOrderPriceMatchEnum, NewUmOrderSelfTradePreventionModeEnum: () => NewUmOrderSelfTradePreventionModeEnum, NewUmOrderSideEnum: () => NewUmOrderSideEnum, NewUmOrderTimeInForceEnum: () => NewUmOrderTimeInForceEnum, NewUmOrderTypeEnum: () => NewUmOrderTypeEnum, QueryUsersCmForceOrdersAutoCloseTypeEnum: () => QueryUsersCmForceOrdersAutoCloseTypeEnum, QueryUsersUmForceOrdersAutoCloseTypeEnum: () => QueryUsersUmForceOrdersAutoCloseTypeEnum, RestAPI: () => RestAPI, TradeApi: () => TradeApi, UserDataStreamsApi: () => UserDataStreamsApi }); // src/rest-api/modules/account-api.ts var import_common = require("@binance/common"); var AccountApiAxiosParamCreator = function(configuration) { return { /** * Query account balance * * Weight: 20 * * @summary Account Balance(USER_DATA) * @param {string} [asset] * @param {number} [recvWindow] * * @throws {RequiredError} */ accountBalance: async (asset, recvWindow) => { const localVarQueryParameter = {}; if (asset !== void 0 && asset !== null) { localVarQueryParameter["asset"] = asset; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/balance", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query account information * * Weight: 20 * * @summary Account Information(USER_DATA) * @param {number} [recvWindow] * * @throws {RequiredError} */ accountInformation: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/account", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Transfer BNB in and out of UM * * The endpoint can only be called 10 times per 10 minutes in a rolling manner * * Weight: 750 * * @summary BNB transfer (TRADE) * @param {number} amount * @param {string} transferSide "TO_UM","FROM_UM" * @param {number} [recvWindow] * * @throws {RequiredError} */ bnbTransfer: async (amount, transferSide, recvWindow) => { (0, import_common.assertParamExists)("bnbTransfer", "amount", amount); (0, import_common.assertParamExists)("bnbTransfer", "transferSide", transferSide); const localVarQueryParameter = {}; if (amount !== void 0 && amount !== null) { localVarQueryParameter["amount"] = amount; } if (transferSide !== void 0 && transferSide !== null) { localVarQueryParameter["transferSide"] = transferSide; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/bnb-transfer", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Change Auto-repay-futures Status * * Weight: 750 * * @summary Change Auto-repay-futures Status(TRADE) * @param {string} autoRepay Default: `true`; `false` for turn off the auto-repay futures negative balance function * @param {number} [recvWindow] * * @throws {RequiredError} */ changeAutoRepayFuturesStatus: async (autoRepay, recvWindow) => { (0, import_common.assertParamExists)("changeAutoRepayFuturesStatus", "autoRepay", autoRepay); const localVarQueryParameter = {}; if (autoRepay !== void 0 && autoRepay !== null) { localVarQueryParameter["autoRepay"] = autoRepay; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/repay-futures-switch", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Change user's initial leverage of specific symbol in CM. * * Weight: 1 * * @summary Change CM Initial Leverage (TRADE) * @param {string} symbol * @param {number} leverage target initial leverage: int from 1 to 125 * @param {number} [recvWindow] * * @throws {RequiredError} */ changeCmInitialLeverage: async (symbol, leverage, recvWindow) => { (0, import_common.assertParamExists)("changeCmInitialLeverage", "symbol", symbol); (0, import_common.assertParamExists)("changeCmInitialLeverage", "leverage", leverage); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (leverage !== void 0 && leverage !== null) { localVarQueryParameter["leverage"] = leverage; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/cm/leverage", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Change user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in CM * * Weight: 1 * * @summary Change CM Position Mode(TRADE) * @param {string} dualSidePosition "true": Hedge Mode; "false": One-way Mode * @param {number} [recvWindow] * * @throws {RequiredError} */ changeCmPositionMode: async (dualSidePosition, recvWindow) => { (0, import_common.assertParamExists)("changeCmPositionMode", "dualSidePosition", dualSidePosition); const localVarQueryParameter = {}; if (dualSidePosition !== void 0 && dualSidePosition !== null) { localVarQueryParameter["dualSidePosition"] = dualSidePosition; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/cm/positionSide/dual", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Change user's initial leverage of specific symbol in UM. * * Weight: 1 * * @summary Change UM Initial Leverage(TRADE) * @param {string} symbol * @param {number} leverage target initial leverage: int from 1 to 125 * @param {number} [recvWindow] * * @throws {RequiredError} */ changeUmInitialLeverage: async (symbol, leverage, recvWindow) => { (0, import_common.assertParamExists)("changeUmInitialLeverage", "symbol", symbol); (0, import_common.assertParamExists)("changeUmInitialLeverage", "leverage", leverage); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (leverage !== void 0 && leverage !== null) { localVarQueryParameter["leverage"] = leverage; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/leverage", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Change user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in UM * * Weight: 1 * * @summary Change UM Position Mode(TRADE) * @param {string} dualSidePosition "true": Hedge Mode; "false": One-way Mode * @param {number} [recvWindow] * * @throws {RequiredError} */ changeUmPositionMode: async (dualSidePosition, recvWindow) => { (0, import_common.assertParamExists)("changeUmPositionMode", "dualSidePosition", dualSidePosition); const localVarQueryParameter = {}; if (dualSidePosition !== void 0 && dualSidePosition !== null) { localVarQueryParameter["dualSidePosition"] = dualSidePosition; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/positionSide/dual", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query CM notional and leverage brackets * * Weight: 1 * * @summary CM Notional and Leverage Brackets(USER_DATA) * @param {string} [symbol] * @param {number} [recvWindow] * * @throws {RequiredError} */ cmNotionalAndLeverageBrackets: async (symbol, recvWindow) => { const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/cm/leverageBracket", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Fund collection for Portfolio Margin * * The BNB would not be collected from UM-PM account to the Portfolio Margin account. * You can only use this function 500 times per hour in a rolling manner. * * Weight: 750 * * @summary Fund Auto-collection(TRADE) * @param {number} [recvWindow] * * @throws {RequiredError} */ fundAutoCollection: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/auto-collection", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Transfers specific asset from Futures Account to Margin account * * The BNB transfer is not be supported * * Weight: 30 * * @summary Fund Collection by Asset(TRADE) * @param {string} asset * @param {number} [recvWindow] * * @throws {RequiredError} */ fundCollectionByAsset: async (asset, recvWindow) => { (0, import_common.assertParamExists)("fundCollectionByAsset", "asset", asset); const localVarQueryParameter = {}; if (asset !== void 0 && asset !== null) { localVarQueryParameter["asset"] = asset; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/asset-collection", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query Auto-repay-futures Status * * Weight: 30 * * @summary Get Auto-repay-futures Status(USER_DATA) * @param {number} [recvWindow] * * @throws {RequiredError} */ getAutoRepayFuturesStatus: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/repay-futures-switch", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get current CM account asset and position information. * * Weight: 5 * * @summary Get CM Account Detail(USER_DATA) * @param {number} [recvWindow] * * @throws {RequiredError} */ getCmAccountDetail: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/cm/account", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in CM * * Weight: 30 * * @summary Get CM Current Position Mode(USER_DATA) * @param {number} [recvWindow] * * @throws {RequiredError} */ getCmCurrentPositionMode: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/cm/positionSide/dual", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get CM Income History * * * If `incomeType` is not sent, all kinds of flow will be returned * "trandId" is unique in the same "incomeType" for a user * The interval between `startTime` and `endTime` can not exceed 200 days: * If `startTime` and `endTime` are not sent, the last 200 days will be returned * * Weight: 30 * * @summary Get CM Income History(USER_DATA) * @param {string} [symbol] * @param {string} [incomeType] TRANSFER, WELCOME_BONUS, REALIZED_PNL, FUNDING_FEE, COMMISSION, INSURANCE_CLEAR, REFERRAL_KICKBACK, COMMISSION_REBATE, API_REBATE, CONTEST_REWARD, CROSS_COLLATERAL_TRANSFER, OPTIONS_PREMIUM_FEE, OPTIONS_SETTLE_PROFIT, INTERNAL_TRANSFER, AUTO_EXCHANGE, DELIVERED_SETTELMENT, COIN_SWAP_DEPOSIT, COIN_SWAP_WITHDRAW, POSITION_LIMIT_INCREASE_FEE * @param {number} [startTime] Timestamp in ms to get funding from INCLUSIVE. * @param {number} [endTime] Timestamp in ms to get funding until INCLUSIVE. * @param {number} [page] * @param {number} [limit] Default 100; max 1000 * @param {number} [recvWindow] * * @throws {RequiredError} */ getCmIncomeHistory: async (symbol, incomeType, startTime, endTime, page, limit, recvWindow) => { const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (incomeType !== void 0 && incomeType !== null) { localVarQueryParameter["incomeType"] = incomeType; } if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (page !== void 0 && page !== null) { localVarQueryParameter["page"] = page; } if (limit !== void 0 && limit !== null) { localVarQueryParameter["limit"] = limit; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/cm/income", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get download id for UM futures order history * * Request Limitation is 10 times per month, shared by front end download page and rest api * The time between `startTime` and `endTime` can not be longer than 1 year * * Weight: 1500 * * @summary Get Download Id For UM Futures Order History (USER_DATA) * @param {number} startTime * @param {number} endTime * @param {number} [recvWindow] * * @throws {RequiredError} */ getDownloadIdForUmFuturesOrderHistory: async (startTime, endTime, recvWindow) => { (0, import_common.assertParamExists)("getDownloadIdForUmFuturesOrderHistory", "startTime", startTime); (0, import_common.assertParamExists)("getDownloadIdForUmFuturesOrderHistory", "endTime", endTime); const localVarQueryParameter = {}; if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/order/asyn", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get download id for UM futures trade history * * Request Limitation is 5 times per month, shared by front end download page and rest api * The time between `startTime` and `endTime` can not be longer than 1 year * * Weight: 1500 * * @summary Get Download Id For UM Futures Trade History (USER_DATA) * @param {number} startTime * @param {number} endTime * @param {number} [recvWindow] * * @throws {RequiredError} */ getDownloadIdForUmFuturesTradeHistory: async (startTime, endTime, recvWindow) => { (0, import_common.assertParamExists)("getDownloadIdForUmFuturesTradeHistory", "startTime", startTime); (0, import_common.assertParamExists)("getDownloadIdForUmFuturesTradeHistory", "endTime", endTime); const localVarQueryParameter = {}; if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/trade/asyn", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get download id for UM futures transaction history * * Request Limitation is 5 times per month, shared by front end download page and rest api * The time between `startTime` and `endTime` can not be longer than 1 year * * Weight: 1500 * * @summary Get Download Id For UM Futures Transaction History (USER_DATA) * @param {number} startTime * @param {number} endTime * @param {number} [recvWindow] * * @throws {RequiredError} */ getDownloadIdForUmFuturesTransactionHistory: async (startTime, endTime, recvWindow) => { (0, import_common.assertParamExists)( "getDownloadIdForUmFuturesTransactionHistory", "startTime", startTime ); (0, import_common.assertParamExists)("getDownloadIdForUmFuturesTransactionHistory", "endTime", endTime); const localVarQueryParameter = {}; if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/income/asyn", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get Margin Borrow/Loan Interest History * * * Response in descending order * The max interval between startTime and endTime is 30 days. It is a MUST to ensure data correctness. * If `startTime` and `endTime` not sent, return records of the last 7 days by default * If `startTime` is sent and `endTime` is not sent, the records from `startTime` to the present will be returned; if `startTime` is more than 30 days ago, the records of the past 30 days will be returned. * If `startTime` is not sent and `endTime` is sent, the records of the 7 days before `endTime` is returned. * Type in response has 5 enums: * `PERIODIC` interest charged per hour * `ON_BORROW` first interest charged on borrow * `PERIODIC_CONVERTED` interest charged per hour converted into BNB * `ON_BORROW_CONVERTED` first interest charged on borrow converted into BNB * `PORTFOLIO` Portfolio Margin negative balance daily interest * * Weight: 1 * * @summary Get Margin Borrow/Loan Interest History(USER_DATA) * @param {string} [asset] * @param {number} [startTime] Timestamp in ms to get funding from INCLUSIVE. * @param {number} [endTime] Timestamp in ms to get funding until INCLUSIVE. * @param {number} [current] Currently querying page. Start from 1. Default:1 * @param {number} [size] Default:10 Max:100 * @param {string} [archived] Default: `false`. Set to `true` for archived data from 6 months ago * @param {number} [recvWindow] * * @throws {RequiredError} */ getMarginBorrowLoanInterestHistory: async (asset, startTime, endTime, current, size, archived, recvWindow) => { const localVarQueryParameter = {}; if (asset !== void 0 && asset !== null) { localVarQueryParameter["asset"] = asset; } if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (current !== void 0 && current !== null) { localVarQueryParameter["current"] = current; } if (size !== void 0 && size !== null) { localVarQueryParameter["size"] = size; } if (archived !== void 0 && archived !== null) { localVarQueryParameter["archived"] = archived; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/margin/marginInterestHistory", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get current UM account asset and position information. * * Weight: 5 * * @summary Get UM Account Detail(USER_DATA) * @param {number} [recvWindow] * * @throws {RequiredError} */ getUmAccountDetail: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/account", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get current UM account asset and position information. * * Weight: 5 * * @summary Get UM Account Detail V2(USER_DATA) * @param {number} [recvWindow] * * @throws {RequiredError} */ getUmAccountDetailV2: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v2/um/account", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in UM * * Weight: 30 * * @summary Get UM Current Position Mode(USER_DATA) * @param {number} [recvWindow] * * @throws {RequiredError} */ getUmCurrentPositionMode: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/positionSide/dual", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get UM futures order download link by Id * * Download link expiration: 24h * * Weight: 10 * * @summary Get UM Futures Order Download Link by Id(USER_DATA) * @param {string} downloadId get by download id api * @param {number} [recvWindow] * * @throws {RequiredError} */ getUmFuturesOrderDownloadLinkById: async (downloadId, recvWindow) => { (0, import_common.assertParamExists)("getUmFuturesOrderDownloadLinkById", "downloadId", downloadId); const localVarQueryParameter = {}; if (downloadId !== void 0 && downloadId !== null) { localVarQueryParameter["downloadId"] = downloadId; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/order/asyn/id", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get UM futures trade download link by Id * * Download link expiration: 24h * * Weight: 10 * * @summary Get UM Futures Trade Download Link by Id(USER_DATA) * @param {string} downloadId get by download id api * @param {number} [recvWindow] * * @throws {RequiredError} */ getUmFuturesTradeDownloadLinkById: async (downloadId, recvWindow) => { (0, import_common.assertParamExists)("getUmFuturesTradeDownloadLinkById", "downloadId", downloadId); const localVarQueryParameter = {}; if (downloadId !== void 0 && downloadId !== null) { localVarQueryParameter["downloadId"] = downloadId; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/trade/asyn/id", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get UM futures Transaction download link by Id * * Download link expiration: 24h * * Weight: 10 * * @summary Get UM Futures Transaction Download Link by Id(USER_DATA) * @param {string} downloadId get by download id api * @param {number} [recvWindow] * * @throws {RequiredError} */ getUmFuturesTransactionDownloadLinkById: async (downloadId, recvWindow) => { (0, import_common.assertParamExists)("getUmFuturesTransactionDownloadLinkById", "downloadId", downloadId); const localVarQueryParameter = {}; if (downloadId !== void 0 && downloadId !== null) { localVarQueryParameter["downloadId"] = downloadId; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/income/asyn/id", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get UM Income History * * If neither `startTime` nor `endTime` is sent, the recent 7-day data will be returned. * If `incomeType` is not sent, all kinds of flow will be returned * "trandId" is unique in the same incomeType for a user * Income history only contains data for the last three months * * Weight: 30 * * @summary Get UM Income History(USER_DATA) * @param {string} [symbol] * @param {string} [incomeType] TRANSFER, WELCOME_BONUS, REALIZED_PNL, FUNDING_FEE, COMMISSION, INSURANCE_CLEAR, REFERRAL_KICKBACK, COMMISSION_REBATE, API_REBATE, CONTEST_REWARD, CROSS_COLLATERAL_TRANSFER, OPTIONS_PREMIUM_FEE, OPTIONS_SETTLE_PROFIT, INTERNAL_TRANSFER, AUTO_EXCHANGE, DELIVERED_SETTELMENT, COIN_SWAP_DEPOSIT, COIN_SWAP_WITHDRAW, POSITION_LIMIT_INCREASE_FEE * @param {number} [startTime] Timestamp in ms to get funding from INCLUSIVE. * @param {number} [endTime] Timestamp in ms to get funding until INCLUSIVE. * @param {number} [page] * @param {number} [limit] Default 100; max 1000 * @param {number} [recvWindow] * * @throws {RequiredError} */ getUmIncomeHistory: async (symbol, incomeType, startTime, endTime, page, limit, recvWindow) => { const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (incomeType !== void 0 && incomeType !== null) { localVarQueryParameter["incomeType"] = incomeType; } if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (page !== void 0 && page !== null) { localVarQueryParameter["page"] = page; } if (limit !== void 0 && limit !== null) { localVarQueryParameter["limit"] = limit; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/income", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get User Commission Rate for CM * * Weight: 20 * * @summary Get User Commission Rate for CM(USER_DATA) * @param {string} symbol * @param {number} [recvWindow] * * @throws {RequiredError} */ getUserCommissionRateForCm: async (symbol, recvWindow) => { (0, import_common.assertParamExists)("getUserCommissionRateForCm", "symbol", symbol); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/cm/commissionRate", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get User Commission Rate for UM * * Weight: 20 * * @summary Get User Commission Rate for UM(USER_DATA) * @param {string} symbol * @param {number} [recvWindow] * * @throws {RequiredError} */ getUserCommissionRateForUm: async (symbol, recvWindow) => { (0, import_common.assertParamExists)("getUserCommissionRateForUm", "symbol", symbol); const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/commissionRate", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query margin max borrow * * Weight: 5 * * @summary Margin Max Borrow(USER_DATA) * @param {string} asset * @param {number} [recvWindow] * * @throws {RequiredError} */ marginMaxBorrow: async (asset, recvWindow) => { (0, import_common.assertParamExists)("marginMaxBorrow", "asset", asset); const localVarQueryParameter = {}; if (asset !== void 0 && asset !== null) { localVarQueryParameter["asset"] = asset; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/margin/maxBorrowable", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Portfolio Margin UM Trading Quantitative Rules Indicators * * Weight: 1 for a single symbol * 10 when the symbol parameter is omitted * * @summary Portfolio Margin UM Trading Quantitative Rules Indicators(USER_DATA) * @param {string} [symbol] * @param {number} [recvWindow] * * @throws {RequiredError} */ portfolioMarginUmTradingQuantitativeRulesIndicators: async (symbol, recvWindow) => { const localVarQueryParameter = {}; if (symbol !== void 0 && symbol !== null) { localVarQueryParameter["symbol"] = symbol; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/um/apiTradingStatus", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get current CM position information. * * If neither `marginAsset` nor `pair` is sent, positions of all symbols with `TRADING` status will be returned. * for One-way Mode user, the response will only show the "BOTH" positions * for Hedge Mode user, the response will show "LONG", and "SHORT" positions. * Please use with user data stream `ACCOUNT_UPDATE` to meet your timeliness and accuracy needs. * * Weight: 1 * * @summary Query CM Position Information(USER_DATA) * @param {string} [marginAsset] * @param {string} [pair] * @param {number} [recvWindow] * * @throws {RequiredError} */ queryCmPositionInformation: async (marginAsset, pair, recvWindow) => { const localVarQueryParameter = {}; if (marginAsset !== void 0 && marginAsset !== null) { localVarQueryParameter["marginAsset"] = marginAsset; } if (pair !== void 0 && pair !== null) { localVarQueryParameter["pair"] = pair; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/cm/positionRisk", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query margin loan record * * txId or startTime must be sent. txId takes precedence. * Response in descending order * The max interval between `startTime` and `endTime` is 30 days. * If `startTime` and `endTime` not sent, return records of the last 7 days by default * Set `archived` to `true` to query data from 6 months ago * * Weight: 10 * * @summary Query Margin Loan Record(USER_DATA) * @param {string} asset * @param {number} [txId] the `tranId` in `POST/papi/v1/marginLoan` * @param {number} [startTime] Timestamp in ms to get funding from INCLUSIVE. * @param {number} [endTime] Timestamp in ms to get funding until INCLUSIVE. * @param {number} [current] Currently querying page. Start from 1. Default:1 * @param {number} [size] Default:10 Max:100 * @param {string} [archived] Default: `false`. Set to `true` for archived data from 6 months ago * @param {number} [recvWindow] * * @throws {RequiredError} */ queryMarginLoanRecord: async (asset, txId, startTime, endTime, current, size, archived, recvWindow) => { (0, import_common.assertParamExists)("queryMarginLoanRecord", "asset", asset); const localVarQueryParameter = {}; if (asset !== void 0 && asset !== null) { localVarQueryParameter["asset"] = asset; } if (txId !== void 0 && txId !== null) { localVarQueryParameter["txId"] = txId; } if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (current !== void 0 && current !== null) { localVarQueryParameter["current"] = current; } if (size !== void 0 && size !== null) { localVarQueryParameter["size"] = size; } if (archived !== void 0 && archived !== null) { localVarQueryParameter["archived"] = archived; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/margin/marginLoan", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query Margin Max Withdraw * * Weight: 5 * * @summary Query Margin Max Withdraw(USER_DATA) * @param {string} asset * @param {number} [recvWindow] * * @throws {RequiredError} */ queryMarginMaxWithdraw: async (asset, recvWindow) => { (0, import_common.assertParamExists)("queryMarginMaxWithdraw", "asset", asset); const localVarQueryParameter = {}; if (asset !== void 0 && asset !== null) { localVarQueryParameter["asset"] = asset; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/margin/maxWithdraw", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query margin repay record. * * txId or startTime must be sent. txId takes precedence. * Response in descending order * The max interval between `startTime` and `endTime` is 30 days. * If `startTime` and `endTime` not sent, return records of the last 7 days by default * Set `archived` to `true` to query data from 6 months ago * * Weight: 10 * * @summary Query Margin repay Record(USER_DATA) * @param {string} asset * @param {number} [txId] the `tranId` in `POST/papi/v1/marginLoan` * @param {number} [startTime] Timestamp in ms to get funding from INCLUSIVE. * @param {number} [endTime] Timestamp in ms to get funding until INCLUSIVE. * @param {number} [current] Currently querying page. Start from 1. Default:1 * @param {number} [size] Default:10 Max:100 * @param {string} [archived] Default: `false`. Set to `true` for archived data from 6 months ago * @param {number} [recvWindow] * * @throws {RequiredError} */ queryMarginRepayRecord: async (asset, txId, startTime, endTime, current, size, archived, recvWindow) => { (0, import_common.assertParamExists)("queryMarginRepayRecord", "asset", asset); const localVarQueryParameter = {}; if (asset !== void 0 && asset !== null) { localVarQueryParameter["asset"] = asset; } if (txId !== void 0 && txId !== null) { localVarQueryParameter["txId"] = txId; } if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (current !== void 0 && current !== null) { localVarQueryParameter["current"] = current; } if (size !== void 0 && size !== null) { localVarQueryParameter["size"] = size; } if (archived !== void 0 && archived !== null) { localVarQueryParameter["archived"] = archived; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/margin/repayLoan", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query interest history of negative balance for portfolio margin. * * Response in descending order * The max interval between startTime and endTime is 30 days. It is a MUST to ensure data correctness. * If `startTime` and `endTime` not sent, return records of the last 7 days by default * If `startTime` is sent and `endTime` is not sent, the records from `startTime` to the present will be returned; if `startTime` is more than 30 days ago, the records of the past 30 days will be returned. * If `startTime` is not sent and `endTime` is sent, the records of the 7 days before `endTime` is returned. * * Weight: 50 * * @summary Query Portfolio Margin Negative Balance Interest History(USER_DATA) * @param {string} [asset] * @param {number} [startTime] Timestamp in ms to get funding from INCLUSIVE. * @param {number} [endTime] Timestamp in ms to get funding until INCLUSIVE. * @param {number} [size] Default:10 Max:100 * @param {number} [recvWindow] * * @throws {RequiredError} */ queryPortfolioMarginNegativeBalanceInterestHistory: async (asset, startTime, endTime, size, recvWindow) => { const localVarQueryParameter = {}; if (asset !== void 0 && asset !== null) { localVarQueryParameter["asset"] = asset; } if (startTime !== void 0 && startTime !== null) { localVarQueryParameter["startTime"] = startTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (size !== void 0 && size !== null) { localVarQueryParameter["size"] = size; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/papi/v1/portfolio/interest-history", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get current UM position information. * * Please use with user data stream `ACCOUNT_UPDATE` to meet your timeliness and accuracy needs. * for One-way Mode user, the response will only show the "BOTH" positions * for Hedge Mode user, the response will show "LONG", and "SHORT" positions. * * Weight: 5 * * @summary Query UM Position Information(USER_DATA) * @param {string} [symbol] * @param {number} [recvWindow] * * @throws {RequiredError} */ queryUmPositionInformation: async (symbol, recvWindow) => { const localVarQueryParam