UNPKG

@binance/derivatives-trading-portfolio-margin-pro

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,256 lines (1,250 loc) 71.4 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_common5.BadRequestError, ConnectorClientError: () => import_common5.ConnectorClientError, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL: () => import_common5.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL, DerivativesTradingPortfolioMarginPro: () => DerivativesTradingPortfolioMarginPro, DerivativesTradingPortfolioMarginProRestAPI: () => rest_api_exports, ForbiddenError: () => import_common5.ForbiddenError, NetworkError: () => import_common5.NetworkError, NotFoundError: () => import_common5.NotFoundError, RateLimitBanError: () => import_common5.RateLimitBanError, RequiredError: () => import_common5.RequiredError, ServerError: () => import_common5.ServerError, TooManyRequestsError: () => import_common5.TooManyRequestsError, UnauthorizedError: () => import_common5.UnauthorizedError }); module.exports = __toCommonJS(index_exports); // src/derivatives-trading-portfolio-margin-pro.ts var import_os = require("os"); var import_common4 = require("@binance/common"); // package.json var name = "@binance/derivatives-trading-portfolio-margin-pro"; var version = "6.0.3"; // src/rest-api/index.ts var rest_api_exports = {}; __export(rest_api_exports, { AccountApi: () => AccountApi, MarketDataApi: () => MarketDataApi, RestAPI: () => RestAPI }); // src/rest-api/modules/account-api.ts var import_common = require("@binance/common"); var AccountApiAxiosParamCreator = function(configuration) { return { /** * BNB transfer can be between Margin Account and USDM Account * * * You can only use this function 2 times per 10 minutes in a rolling manner * * Weight: 1500 * * @summary BNB transfer(USER_DATA) * @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: "/sapi/v1/portfolio/bnb-transfer", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Change Auto-repay-futures Status * * Weight: 1500 * * @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: "/sapi/v1/portfolio/repay-futures-switch", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Transfers all assets from Futures Account to Margin account * * 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: 1500 * * @summary Fund Auto-collection(USER_DATA) * @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: "/sapi/v1/portfolio/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: 60 * * @summary Fund Collection by Asset(USER_DATA) * @param {string} asset `LDUSDT` only * @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: "/sapi/v1/portfolio/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: "/sapi/v1/portfolio/repay-futures-switch", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query Portfolio Margin Pro account balance * * Weight: 20 * * @summary Get Portfolio Margin Pro Account Balance(USER_DATA) * @param {string} [asset] * @param {number} [recvWindow] * * @throws {RequiredError} */ getPortfolioMarginProAccountBalance: 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: "/sapi/v1/portfolio/balance", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get Portfolio Margin Pro Account Info * * Weight: 5 * * @summary Get Portfolio Margin Pro Account Info(USER_DATA) * @param {number} [recvWindow] * * @throws {RequiredError} */ getPortfolioMarginProAccountInfo: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/portfolio/account", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get Portfolio Margin Pro SPAN Account Info (For Portfolio Margin Pro SPAN users only) * * Weight: 5 * * @summary Get Portfolio Margin Pro SPAN Account Info(USER_DATA) * @param {number} [recvWindow] * * @throws {RequiredError} */ getPortfolioMarginProSpanAccountInfo: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v2/portfolio/account", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get transferable earn asset balance for all types of Portfolio Margin account * * Weight: 1500 * * @summary Get Transferable Earn Asset Balance for Portfolio Margin (USER_DATA) * @param {string} asset `LDUSDT` only * @param {string} transferType `EARN_TO_FUTURE` /`FUTURE_TO_EARN` * @param {number} [recvWindow] * * @throws {RequiredError} */ getTransferableEarnAssetBalanceForPortfolioMargin: async (asset, transferType, recvWindow) => { (0, import_common.assertParamExists)("getTransferableEarnAssetBalanceForPortfolioMargin", "asset", asset); (0, import_common.assertParamExists)( "getTransferableEarnAssetBalanceForPortfolioMargin", "transferType", transferType ); const localVarQueryParameter = {}; if (asset !== void 0 && asset !== null) { localVarQueryParameter["asset"] = asset; } if (transferType !== void 0 && transferType !== null) { localVarQueryParameter["transferType"] = transferType; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/portfolio/earn-asset-balance", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Mint BFUSD for all types of Portfolio Margin account * * Weight: 1500 * * @summary Mint BFUSD for Portfolio Margin(TRADE) * @param {string} fromAsset `BFUSD` only * @param {string} targetAsset `USDT` only * @param {number} amount * @param {number} [recvWindow] * * @throws {RequiredError} */ mintBfusdForPortfolioMargin: async (fromAsset, targetAsset, amount, recvWindow) => { (0, import_common.assertParamExists)("mintBfusdForPortfolioMargin", "fromAsset", fromAsset); (0, import_common.assertParamExists)("mintBfusdForPortfolioMargin", "targetAsset", targetAsset); (0, import_common.assertParamExists)("mintBfusdForPortfolioMargin", "amount", amount); const localVarQueryParameter = {}; if (fromAsset !== void 0 && fromAsset !== null) { localVarQueryParameter["fromAsset"] = fromAsset; } if (targetAsset !== void 0 && targetAsset !== null) { localVarQueryParameter["targetAsset"] = targetAsset; } if (amount !== void 0 && amount !== null) { localVarQueryParameter["amount"] = amount; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/portfolio/mint", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Repay Portfolio Margin Pro Bankruptcy Loan * * Weight: 3000 * * @summary Portfolio Margin Pro Bankruptcy Loan Repay * @param {string} [from] SPOT or MARGIN,default SPOT * @param {number} [recvWindow] * * @throws {RequiredError} */ portfolioMarginProBankruptcyLoanRepay: async (from, recvWindow) => { const localVarQueryParameter = {}; if (from !== void 0 && from !== null) { localVarQueryParameter["from"] = from; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/portfolio/repay", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query Portfolio Margin Pro Bankruptcy Loan Amount * * If there’s no classic portfolio margin bankruptcy loan, the amount would be 0 * * Weight: 500 * * @summary Query Portfolio Margin Pro Bankruptcy Loan Amount(USER_DATA) * @param {number} [recvWindow] * * @throws {RequiredError} */ queryPortfolioMarginProBankruptcyLoanAmount: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/portfolio/pmLoan", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query repay history of pmloan for portfolio margin pro. * * `startTime` and `endTime` cannot be longer than 360 days * If `startTime` and `endTime` not sent, return records of the last 30 days by default. * If `startTime`is sent and `endTime` is not sent, return records of [startTime, startTime+30d]. * If `startTime` is not sent and `endTime` is sent, return records of [endTime-30d, endTime]. * * Weight: 500 * * @summary Query Portfolio Margin Pro Bankruptcy Loan Repay History(USER_DATA) * @param {number} [startTime] * @param {number} [endTime] * @param {number} [current] Currently querying page. Start from 1. Default:1 * @param {number} [size] Default:10 Max:100 * @param {number} [recvWindow] * * @throws {RequiredError} */ queryPortfolioMarginProBankruptcyLoanRepayHistory: async (startTime, endTime, current, size, recvWindow) => { const localVarQueryParameter = {}; 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 (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/portfolio/pmloan-history", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query interest history of negative balance for portfolio margin. * * Weight: 50 * * @summary Query Portfolio Margin Pro Negative Balance Interest History(USER_DATA) * @param {string} [asset] * @param {number} [startTime] * @param {number} [endTime] * @param {number} [size] Default:10 Max:100 * @param {number} [recvWindow] * * @throws {RequiredError} */ queryPortfolioMarginProNegativeBalanceInterestHistory: 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: "/sapi/v1/portfolio/interest-history", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Redeem BFUSD for all types of Portfolio Margin account * * Weight: 1500 * * @summary Redeem BFUSD for Portfolio Margin(TRADE) * @param {string} fromAsset `BFUSD` only * @param {string} targetAsset `USDT` only * @param {number} amount * @param {number} [recvWindow] * * @throws {RequiredError} */ redeemBfusdForPortfolioMargin: async (fromAsset, targetAsset, amount, recvWindow) => { (0, import_common.assertParamExists)("redeemBfusdForPortfolioMargin", "fromAsset", fromAsset); (0, import_common.assertParamExists)("redeemBfusdForPortfolioMargin", "targetAsset", targetAsset); (0, import_common.assertParamExists)("redeemBfusdForPortfolioMargin", "amount", amount); const localVarQueryParameter = {}; if (fromAsset !== void 0 && fromAsset !== null) { localVarQueryParameter["fromAsset"] = fromAsset; } if (targetAsset !== void 0 && targetAsset !== null) { localVarQueryParameter["targetAsset"] = targetAsset; } if (amount !== void 0 && amount !== null) { localVarQueryParameter["amount"] = amount; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/portfolio/redeem", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Repay futures Negative Balance * * Weight: 1500 * * @summary Repay futures Negative Balance(USER_DATA) * @param {string} [from] SPOT or MARGIN,default SPOT * @param {number} [recvWindow] * * @throws {RequiredError} */ repayFuturesNegativeBalance: async (from, recvWindow) => { const localVarQueryParameter = {}; if (from !== void 0 && from !== null) { localVarQueryParameter["from"] = from; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/portfolio/repay-futures-negative-balance", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Transfer LDUSDT as collateral for all types of Portfolio Margin account * * Weight: 1500 * * @summary Transfer LDUSDT for Portfolio Margin(TRADE) * @param {string} asset `LDUSDT` only * @param {string} transferType `EARN_TO_FUTURE` /`FUTURE_TO_EARN` * @param {number} amount * @param {number} [recvWindow] * * @throws {RequiredError} */ transferLdusdtForPortfolioMargin: async (asset, transferType, amount, recvWindow) => { (0, import_common.assertParamExists)("transferLdusdtForPortfolioMargin", "asset", asset); (0, import_common.assertParamExists)("transferLdusdtForPortfolioMargin", "transferType", transferType); (0, import_common.assertParamExists)("transferLdusdtForPortfolioMargin", "amount", amount); const localVarQueryParameter = {}; if (asset !== void 0 && asset !== null) { localVarQueryParameter["asset"] = asset; } if (transferType !== void 0 && transferType !== null) { localVarQueryParameter["transferType"] = transferType; } if (amount !== void 0 && amount !== null) { localVarQueryParameter["amount"] = amount; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/portfolio/earn-asset-transfer", method: "POST", params: localVarQueryParameter, timeUnit: _timeUnit }; } }; }; var AccountApi = class { constructor(configuration) { this.configuration = configuration; this.localVarAxiosParamCreator = AccountApiAxiosParamCreator(configuration); } /** * BNB transfer can be between Margin Account and USDM Account * * * You can only use this function 2 times per 10 minutes in a rolling manner * * Weight: 1500 * * @summary BNB transfer(USER_DATA) * @param {BnbTransferRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<BnbTransferResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/BNB-transfer Binance API Documentation} */ async bnbTransfer(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.bnbTransfer( requestParameters?.amount, requestParameters?.transferSide, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Change Auto-repay-futures Status * * Weight: 1500 * * @summary Change Auto-repay-futures Status(TRADE) * @param {ChangeAutoRepayFuturesStatusRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<ChangeAutoRepayFuturesStatusResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Change-Auto-repay-futures-Status Binance API Documentation} */ async changeAutoRepayFuturesStatus(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.changeAutoRepayFuturesStatus( requestParameters?.autoRepay, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Transfers all assets from Futures Account to Margin account * * 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: 1500 * * @summary Fund Auto-collection(USER_DATA) * @param {FundAutoCollectionRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<FundAutoCollectionResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Fund-Auto-collection Binance API Documentation} */ async fundAutoCollection(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.fundAutoCollection( requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Transfers specific asset from Futures Account to Margin account * * The BNB transfer is not be supported * * Weight: 60 * * @summary Fund Collection by Asset(USER_DATA) * @param {FundCollectionByAssetRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<FundCollectionByAssetResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Fund-Collection-by-Asset Binance API Documentation} */ async fundCollectionByAsset(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.fundCollectionByAsset( requestParameters?.asset, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Query Auto-repay-futures Status * * Weight: 30 * * @summary Get Auto-repay-futures Status(USER_DATA) * @param {GetAutoRepayFuturesStatusRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetAutoRepayFuturesStatusResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Auto-repay-futures-Status Binance API Documentation} */ async getAutoRepayFuturesStatus(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getAutoRepayFuturesStatus( requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Query Portfolio Margin Pro account balance * * Weight: 20 * * @summary Get Portfolio Margin Pro Account Balance(USER_DATA) * @param {GetPortfolioMarginProAccountBalanceRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetPortfolioMarginProAccountBalanceResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Classic-Portfolio-Margin-Balance-Info Binance API Documentation} */ async getPortfolioMarginProAccountBalance(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getPortfolioMarginProAccountBalance( requestParameters?.asset, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Get Portfolio Margin Pro Account Info * * Weight: 5 * * @summary Get Portfolio Margin Pro Account Info(USER_DATA) * @param {GetPortfolioMarginProAccountInfoRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetPortfolioMarginProAccountInfoResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Classic-Portfolio-Margin-Account-Info Binance API Documentation} */ async getPortfolioMarginProAccountInfo(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getPortfolioMarginProAccountInfo( requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Get Portfolio Margin Pro SPAN Account Info (For Portfolio Margin Pro SPAN users only) * * Weight: 5 * * @summary Get Portfolio Margin Pro SPAN Account Info(USER_DATA) * @param {GetPortfolioMarginProSpanAccountInfoRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetPortfolioMarginProSpanAccountInfoResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Classic-Portfolio-Margin-Account-Info-V2 Binance API Documentation} */ async getPortfolioMarginProSpanAccountInfo(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getPortfolioMarginProSpanAccountInfo( requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Get transferable earn asset balance for all types of Portfolio Margin account * * Weight: 1500 * * @summary Get Transferable Earn Asset Balance for Portfolio Margin (USER_DATA) * @param {GetTransferableEarnAssetBalanceForPortfolioMarginRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetTransferableEarnAssetBalanceForPortfolioMarginResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Transferable-Earn-Asset-Balance-for-Portfolio-Margin Binance API Documentation} */ async getTransferableEarnAssetBalanceForPortfolioMargin(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getTransferableEarnAssetBalanceForPortfolioMargin( requestParameters?.asset, requestParameters?.transferType, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Mint BFUSD for all types of Portfolio Margin account * * Weight: 1500 * * @summary Mint BFUSD for Portfolio Margin(TRADE) * @param {MintBfusdForPortfolioMarginRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<MintBfusdForPortfolioMarginResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Mint-BFUSD-Portfolio-Margin Binance API Documentation} */ async mintBfusdForPortfolioMargin(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.mintBfusdForPortfolioMargin( requestParameters?.fromAsset, requestParameters?.targetAsset, requestParameters?.amount, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Repay Portfolio Margin Pro Bankruptcy Loan * * Weight: 3000 * * @summary Portfolio Margin Pro Bankruptcy Loan Repay * @param {PortfolioMarginProBankruptcyLoanRepayRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<PortfolioMarginProBankruptcyLoanRepayResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Classic-Portfolio-Margin-Bankruptcy-Loan-Repay Binance API Documentation} */ async portfolioMarginProBankruptcyLoanRepay(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.portfolioMarginProBankruptcyLoanRepay( requestParameters?.from, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Query Portfolio Margin Pro Bankruptcy Loan Amount * * If there’s no classic portfolio margin bankruptcy loan, the amount would be 0 * * Weight: 500 * * @summary Query Portfolio Margin Pro Bankruptcy Loan Amount(USER_DATA) * @param {QueryPortfolioMarginProBankruptcyLoanAmountRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<QueryPortfolioMarginProBankruptcyLoanAmountResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Query-Classic-Portfolio-Margin-Bankruptcy-Loan-Amount Binance API Documentation} */ async queryPortfolioMarginProBankruptcyLoanAmount(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.queryPortfolioMarginProBankruptcyLoanAmount( requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Query repay history of pmloan for portfolio margin pro. * * `startTime` and `endTime` cannot be longer than 360 days * If `startTime` and `endTime` not sent, return records of the last 30 days by default. * If `startTime`is sent and `endTime` is not sent, return records of [startTime, startTime+30d]. * If `startTime` is not sent and `endTime` is sent, return records of [endTime-30d, endTime]. * * Weight: 500 * * @summary Query Portfolio Margin Pro Bankruptcy Loan Repay History(USER_DATA) * @param {QueryPortfolioMarginProBankruptcyLoanRepayHistoryRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Query-Portfolio-Margin-Pro-Bankruptcy-Loan-Repay-History Binance API Documentation} */ async queryPortfolioMarginProBankruptcyLoanRepayHistory(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.queryPortfolioMarginProBankruptcyLoanRepayHistory( requestParameters?.startTime, requestParameters?.endTime, requestParameters?.current, requestParameters?.size, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Query interest history of negative balance for portfolio margin. * * Weight: 50 * * @summary Query Portfolio Margin Pro Negative Balance Interest History(USER_DATA) * @param {QueryPortfolioMarginProNegativeBalanceInterestHistoryRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<QueryPortfolioMarginProNegativeBalanceInterestHistoryResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Query-Classic-Portfolio-Margin-Negative-Balance-Interest-History Binance API Documentation} */ async queryPortfolioMarginProNegativeBalanceInterestHistory(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.queryPortfolioMarginProNegativeBalanceInterestHistory( requestParameters?.asset, requestParameters?.startTime, requestParameters?.endTime, requestParameters?.size, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Redeem BFUSD for all types of Portfolio Margin account * * Weight: 1500 * * @summary Redeem BFUSD for Portfolio Margin(TRADE) * @param {RedeemBfusdForPortfolioMarginRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<RedeemBfusdForPortfolioMarginResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Redeem-BFUSD-Portfolio-Margin Binance API Documentation} */ async redeemBfusdForPortfolioMargin(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.redeemBfusdForPortfolioMargin( requestParameters?.fromAsset, requestParameters?.targetAsset, requestParameters?.amount, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Repay futures Negative Balance * * Weight: 1500 * * @summary Repay futures Negative Balance(USER_DATA) * @param {RepayFuturesNegativeBalanceRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<RepayFuturesNegativeBalanceResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Repay-futures-Negative-Balance Binance API Documentation} */ async repayFuturesNegativeBalance(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.repayFuturesNegativeBalance( requestParameters?.from, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Transfer LDUSDT as collateral for all types of Portfolio Margin account * * Weight: 1500 * * @summary Transfer LDUSDT for Portfolio Margin(TRADE) * @param {TransferLdusdtForPortfolioMarginRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<TransferLdusdtForPortfolioMarginResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof AccountApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Transfer-LDUSDT-Portfolio-Margin Binance API Documentation} */ async transferLdusdtForPortfolioMargin(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.transferLdusdtForPortfolioMargin( requestParameters?.asset, requestParameters?.transferType, requestParameters?.amount, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } }; // src/rest-api/modules/market-data-api.ts var import_common2 = require("@binance/common"); var MarketDataApiAxiosParamCreator = function(configuration) { return { /** * Get Portfolio Margin Asset Leverage * * Weight: 50 * * @summary Get Portfolio Margin Asset Leverage(USER_DATA) * * @throws {RequiredError} */ getPortfolioMarginAssetLeverage: async () => { const localVarQueryParameter = {}; let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/portfolio/margin-asset-leverage", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Portfolio Margin Collateral Rate * * Weight: 50 * * @summary Portfolio Margin Collateral Rate(MARKET_DATA) * * @throws {RequiredError} */ portfolioMarginCollateralRate: async () => { const localVarQueryParameter = {}; let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/portfolio/collateralRate", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Portfolio Margin PRO Tiered Collateral Rate * * Weight: 50 * * @summary Portfolio Margin Pro Tiered Collateral Rate(USER_DATA) * @param {number} [recvWindow] * * @throws {RequiredError} */ portfolioMarginProTieredCollateralRate: async (recvWindow) => { const localVarQueryParameter = {}; if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v2/portfolio/collateralRate", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Query Portfolio Margin Asset Index Price * * Weight: 1 if send asset or 50 if not send asset * * @summary Query Portfolio Margin Asset Index Price (MARKET_DATA) * @param {string} [asset] * * @throws {RequiredError} */ queryPortfolioMarginAssetIndexPrice: async (asset) => { const localVarQueryParameter = {}; if (asset !== void 0 && asset !== null) { localVarQueryParameter["asset"] = asset; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/portfolio/asset-index-price", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; } }; }; var MarketDataApi = class { constructor(configuration) { this.configuration = configuration; this.localVarAxiosParamCreator = MarketDataApiAxiosParamCreator(configuration); } /** * Get Portfolio Margin Asset Leverage * * Weight: 50 * * @summary Get Portfolio Margin Asset Leverage(USER_DATA) * @returns {Promise<RestApiResponse<GetPortfolioMarginAssetLeverageResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof MarketDataApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/market-data/Get-Portfolio-Margin-Asset-Leverage Binance API Documentation} */ async getPortfolioMarginAssetLeverage() { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getPortfolioMarginAssetLeverage(); return (0, import_common2.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Portfolio Margin Collateral Rate * * Weight: 50 * * @summary Portfolio Margin Collateral Rate(MARKET_DATA) * @returns {Promise<RestApiResponse<PortfolioMarginCollateralRateResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof MarketDataApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/market-data/Classic-Portfolio-Margin-Collateral-Rate Binance API Documentation} */ async portfolioMarginCollateralRate() { const localVarAxiosArgs = await this.localVarAxiosParamCreator.portfolioMarginCollateralRate(); return (0, import_common2.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: false } ); } /** * Portfolio Margin PRO Tiered Collateral Rate * * Weight: 50 * * @summary Portfolio Margin Pro Tiered Collateral Rate(USER_DATA) * @param {PortfolioMarginProTieredCollateralRateRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<PortfolioMarginProTieredCollateralRateResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof MarketDataApi * @see {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/market-data/Portfolio-Margin-Pro-Tiered-Collateral-Rate Binance API Documentation} */ async portfolioMarginProTieredCollateralRate(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.portfolioMarginProTieredCollateralRate( requestParameters?.recvWindow ); return (0, import_common2.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Query Portfolio Margin Asset Index Price * * Weight: 1 if send asset or 50 if not send asset * * @summary Query Portfolio Margin Asset Index Price (MARKET_DATA) * @param {QueryPortfolioMarginAssetIndexPriceRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<QueryPortfolioMarginAssetIndexPriceResponse>>} * @throws {