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 lines 153 kB
{"version":3,"sources":["../src/derivatives-trading-portfolio-margin-pro.ts","../package.json","../src/rest-api/index.ts","../src/rest-api/modules/account-api.ts","../src/rest-api/modules/market-data-api.ts","../src/rest-api/rest-api.ts","../src/websocket-streams/index.ts","../src/websocket-streams/websocket-streams.ts","../src/websocket-streams/websocket-streams-connection.ts","../src/index.ts"],"sourcesContent":["import {\n buildUserAgent,\n ConfigurationRestAPI,\n ConfigurationWebsocketStreams,\n DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL,\n DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL,\n} from '@binance/common';\nimport { name, version } from '../package.json';\nimport { RestAPI } from './rest-api';\n\nimport { WebsocketStreams } from './websocket-streams';\n\nexport interface ConfigurationDerivativesTradingPortfolioMarginPro {\n configurationRestAPI?: ConfigurationRestAPI;\n\n configurationWebsocketStreams?: ConfigurationWebsocketStreams;\n}\n\nexport class DerivativesTradingPortfolioMarginPro {\n public restAPI!: RestAPI;\n\n public websocketStreams!: WebsocketStreams;\n\n constructor(config: ConfigurationDerivativesTradingPortfolioMarginPro) {\n const userAgent = buildUserAgent(name, version);\n\n if (config?.configurationRestAPI) {\n const configRestAPI = new ConfigurationRestAPI(\n config.configurationRestAPI\n ) as ConfigurationRestAPI & {\n baseOptions: Record<string, unknown>;\n };\n configRestAPI.basePath =\n configRestAPI.basePath ||\n DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL;\n configRestAPI.baseOptions = configRestAPI.baseOptions || {};\n configRestAPI.baseOptions.headers = {\n ...(configRestAPI.baseOptions.headers || {}),\n 'User-Agent': userAgent,\n };\n this.restAPI = new RestAPI(configRestAPI);\n }\n if (config?.configurationWebsocketStreams) {\n const configWebsocketStreams = new ConfigurationWebsocketStreams(\n config.configurationWebsocketStreams\n ) as ConfigurationWebsocketStreams & {\n userAgent: string;\n };\n configWebsocketStreams.wsURL =\n configWebsocketStreams.wsURL ||\n DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL;\n configWebsocketStreams.userAgent = userAgent;\n this.websocketStreams = new WebsocketStreams(configWebsocketStreams);\n }\n }\n}\n","{\n \"name\": \"@binance/derivatives-trading-portfolio-margin-pro\",\n \"description\": \"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.\",\n \"version\": \"7.0.3\",\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"require\": \"./dist/index.js\",\n \"import\": \"./dist/index.mjs\"\n }\n },\n \"scripts\": {\n \"prepublishOnly\": \"npm run build\",\n \"build\": \"npm run clean && tsup\",\n \"typecheck\": \"tsc --noEmit\",\n \"clean\": \"rm -rf dist\",\n \"test\": \"npx jest --maxWorkers=4 --bail\",\n \"test:watch\": \"npx jest --watch\",\n \"format\": \"npx prettier --ignore-path .prettierignore --write .\",\n \"lint\": \"npx eslint '**/*.ts' --fix\"\n },\n \"keywords\": [\n \"Binance\",\n \"API\",\n \"Derivatives\",\n \"Futures\",\n \"Coin-M\",\n \"Connector\",\n \"REST\",\n \"WebSocket\",\n \"Trading\"\n ],\n \"author\": \"Binance\",\n \"license\": \"MIT\",\n \"files\": [\n \"dist\"\n ],\n \"devDependencies\": {\n \"@types/jest\": \"^29.5.4\",\n \"@types/node\": \"^20.17.24\",\n \"eslint\": \"8.57.0\",\n \"jest\": \"^29.6.4\",\n \"prettier\": \"^3.3.3\",\n \"ts-jest\": \"^29.1.1\",\n \"ts-node\": \"^10.9.1\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.7.2\",\n \"typescript-eslint\": \"^8.24.0\"\n },\n \"dependencies\": {\n \"@binance/common\": \"1.2.3\",\n \"@types/ws\": \"^8.5.5\",\n \"axios\": \"^1.7.4\",\n \"ws\": \"^8.17.1\"\n }\n}\n","/**\n * Binance Derivatives Trading Portfolio Margin Pro REST API\n *\n * OpenAPI Specification for the Binance Derivatives Trading Portfolio Margin Pro REST API\n *\n * The version of the OpenAPI document: 1.0.0\n *\n *\n * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).\n * https://openapi-generator.tech\n * Do not edit the class manually.\n */\n\nexport * from './types';\nexport * from './modules';\nexport * from './rest-api';\n","/**\n * Binance Derivatives Trading Portfolio Margin Pro REST API\n *\n * OpenAPI Specification for the Binance Derivatives Trading Portfolio Margin Pro REST API\n *\n * The version of the OpenAPI document: 1.0.0\n *\n *\n * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).\n * https://openapi-generator.tech\n * Do not edit the class manually.\n */\n\nimport {\n ConfigurationRestAPI,\n TimeUnit,\n RestApiResponse,\n assertParamExists,\n sendRequest,\n type RequestArgs,\n} from '@binance/common';\nimport type {\n BnbTransferResponse,\n ChangeAutoRepayFuturesStatusResponse,\n FundAutoCollectionResponse,\n FundCollectionByAssetResponse,\n GetAutoRepayFuturesStatusResponse,\n GetPortfolioMarginProAccountBalanceResponse,\n GetPortfolioMarginProAccountInfoResponse,\n GetPortfolioMarginProSpanAccountInfoResponse,\n GetTransferableEarnAssetBalanceForPortfolioMarginResponse,\n MintBfusdForPortfolioMarginResponse,\n PortfolioMarginProBankruptcyLoanRepayResponse,\n QueryPortfolioMarginProBankruptcyLoanAmountResponse,\n QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponse,\n QueryPortfolioMarginProNegativeBalanceInterestHistoryResponse,\n RedeemBfusdForPortfolioMarginResponse,\n RepayFuturesNegativeBalanceResponse,\n TransferLdusdtForPortfolioMarginResponse,\n} from '../types';\n\n/**\n * AccountApi - axios parameter creator\n */\nconst AccountApiAxiosParamCreator = function (configuration: ConfigurationRestAPI) {\n return {\n /**\n * BNB transfer can be between Margin Account and USDM Account\n *\n *\n * You can only use this function 2 times per 10 minutes in a rolling manner\n *\n * Weight: 1500\n *\n * @summary BNB transfer(USER_DATA)\n * @param {number} amount\n * @param {string} transferSide \"TO_UM\",\"FROM_UM\"\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n bnbTransfer: async (\n amount: number,\n transferSide: string,\n recvWindow?: number\n ): Promise<RequestArgs> => {\n // verify required parameter 'amount' is not null or undefined\n assertParamExists('bnbTransfer', 'amount', amount);\n // verify required parameter 'transferSide' is not null or undefined\n assertParamExists('bnbTransfer', 'transferSide', transferSide);\n\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (amount !== undefined && amount !== null) {\n localVarQueryParameter['amount'] = amount;\n }\n\n if (transferSide !== undefined && transferSide !== null) {\n localVarQueryParameter['transferSide'] = transferSide;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/bnb-transfer',\n method: 'POST',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Change Auto-repay-futures Status\n *\n * Weight: 1500\n *\n * @summary Change Auto-repay-futures Status(TRADE)\n * @param {string} autoRepay Default: `true`; `false` for turn off the auto-repay futures negative balance function\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n changeAutoRepayFuturesStatus: async (\n autoRepay: string,\n recvWindow?: number\n ): Promise<RequestArgs> => {\n // verify required parameter 'autoRepay' is not null or undefined\n assertParamExists('changeAutoRepayFuturesStatus', 'autoRepay', autoRepay);\n\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (autoRepay !== undefined && autoRepay !== null) {\n localVarQueryParameter['autoRepay'] = autoRepay;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/repay-futures-switch',\n method: 'POST',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Transfers all assets from Futures Account to Margin account\n *\n * The BNB would not be collected from UM-PM account to the Portfolio Margin account.\n * You can only use this function 500 times per hour in a rolling manner.\n *\n * Weight: 1500\n *\n * @summary Fund Auto-collection(USER_DATA)\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n fundAutoCollection: async (recvWindow?: number): Promise<RequestArgs> => {\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/auto-collection',\n method: 'POST',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Transfers specific asset from Futures Account to Margin account\n *\n * The BNB transfer is not be supported\n *\n * Weight: 60\n *\n * @summary Fund Collection by Asset(USER_DATA)\n * @param {string} asset `LDUSDT` only\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n fundCollectionByAsset: async (asset: string, recvWindow?: number): Promise<RequestArgs> => {\n // verify required parameter 'asset' is not null or undefined\n assertParamExists('fundCollectionByAsset', 'asset', asset);\n\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (asset !== undefined && asset !== null) {\n localVarQueryParameter['asset'] = asset;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/asset-collection',\n method: 'POST',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Query Auto-repay-futures Status\n *\n * Weight: 30\n *\n * @summary Get Auto-repay-futures Status(USER_DATA)\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n getAutoRepayFuturesStatus: async (recvWindow?: number): Promise<RequestArgs> => {\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/repay-futures-switch',\n method: 'GET',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Query Portfolio Margin Pro account balance\n *\n * Weight: 20\n *\n * @summary Get Portfolio Margin Pro Account Balance(USER_DATA)\n * @param {string} [asset]\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n getPortfolioMarginProAccountBalance: async (\n asset?: string,\n recvWindow?: number\n ): Promise<RequestArgs> => {\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (asset !== undefined && asset !== null) {\n localVarQueryParameter['asset'] = asset;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/balance',\n method: 'GET',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Get Portfolio Margin Pro Account Info\n *\n * Weight: 5\n *\n * @summary Get Portfolio Margin Pro Account Info(USER_DATA)\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n getPortfolioMarginProAccountInfo: async (recvWindow?: number): Promise<RequestArgs> => {\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/account',\n method: 'GET',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Get Portfolio Margin Pro SPAN Account Info (For Portfolio Margin Pro SPAN users only)\n *\n * Weight: 5\n *\n * @summary Get Portfolio Margin Pro SPAN Account Info(USER_DATA)\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n getPortfolioMarginProSpanAccountInfo: async (recvWindow?: number): Promise<RequestArgs> => {\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v2/portfolio/account',\n method: 'GET',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Get transferable earn asset balance for all types of Portfolio Margin account\n *\n * Weight: 1500\n *\n * @summary Get Transferable Earn Asset Balance for Portfolio Margin (USER_DATA)\n * @param {string} asset `LDUSDT` only\n * @param {string} transferType `EARN_TO_FUTURE` /`FUTURE_TO_EARN`\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n getTransferableEarnAssetBalanceForPortfolioMargin: async (\n asset: string,\n transferType: string,\n recvWindow?: number\n ): Promise<RequestArgs> => {\n // verify required parameter 'asset' is not null or undefined\n assertParamExists('getTransferableEarnAssetBalanceForPortfolioMargin', 'asset', asset);\n // verify required parameter 'transferType' is not null or undefined\n assertParamExists(\n 'getTransferableEarnAssetBalanceForPortfolioMargin',\n 'transferType',\n transferType\n );\n\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (asset !== undefined && asset !== null) {\n localVarQueryParameter['asset'] = asset;\n }\n\n if (transferType !== undefined && transferType !== null) {\n localVarQueryParameter['transferType'] = transferType;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/earn-asset-balance',\n method: 'GET',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Mint BFUSD for all types of Portfolio Margin account\n *\n * Weight: 1500\n *\n * @summary Mint BFUSD for Portfolio Margin(TRADE)\n * @param {string} fromAsset `BFUSD` only\n * @param {string} targetAsset `USDT` `USDC`\n * @param {number} amount\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n mintBfusdForPortfolioMargin: async (\n fromAsset: string,\n targetAsset: string,\n amount: number,\n recvWindow?: number\n ): Promise<RequestArgs> => {\n // verify required parameter 'fromAsset' is not null or undefined\n assertParamExists('mintBfusdForPortfolioMargin', 'fromAsset', fromAsset);\n // verify required parameter 'targetAsset' is not null or undefined\n assertParamExists('mintBfusdForPortfolioMargin', 'targetAsset', targetAsset);\n // verify required parameter 'amount' is not null or undefined\n assertParamExists('mintBfusdForPortfolioMargin', 'amount', amount);\n\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (fromAsset !== undefined && fromAsset !== null) {\n localVarQueryParameter['fromAsset'] = fromAsset;\n }\n\n if (targetAsset !== undefined && targetAsset !== null) {\n localVarQueryParameter['targetAsset'] = targetAsset;\n }\n\n if (amount !== undefined && amount !== null) {\n localVarQueryParameter['amount'] = amount;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/mint',\n method: 'POST',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Repay Portfolio Margin Pro Bankruptcy Loan\n *\n * Weight: 3000\n *\n * @summary Portfolio Margin Pro Bankruptcy Loan Repay\n * @param {string} [from] SPOT or MARGIN,default SPOT\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n portfolioMarginProBankruptcyLoanRepay: async (\n from?: string,\n recvWindow?: number\n ): Promise<RequestArgs> => {\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (from !== undefined && from !== null) {\n localVarQueryParameter['from'] = from;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/repay',\n method: 'POST',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Query Portfolio Margin Pro Bankruptcy Loan Amount\n *\n * If there’s no classic portfolio margin bankruptcy loan, the amount would be 0\n *\n * Weight: 500\n *\n * @summary Query Portfolio Margin Pro Bankruptcy Loan Amount(USER_DATA)\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n queryPortfolioMarginProBankruptcyLoanAmount: async (\n recvWindow?: number\n ): Promise<RequestArgs> => {\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/pmLoan',\n method: 'GET',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Query repay history of pmloan for portfolio margin pro.\n *\n * `startTime` and `endTime` cannot be longer than 360 days\n * If `startTime` and `endTime` not sent, return records of the last 30 days by default.\n * If `startTime`is sent and `endTime` is not sent, return records of [startTime, startTime+30d].\n * If `startTime` is not sent and `endTime` is sent, return records of [endTime-30d, endTime].\n *\n * Weight: 500\n *\n * @summary Query Portfolio Margin Pro Bankruptcy Loan Repay History(USER_DATA)\n * @param {number} [startTime]\n * @param {number} [endTime]\n * @param {number} [current] Currently querying page. Start from 1. Default:1\n * @param {number} [size] Default:10 Max:100\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n queryPortfolioMarginProBankruptcyLoanRepayHistory: async (\n startTime?: number,\n endTime?: number,\n current?: number,\n size?: number,\n recvWindow?: number\n ): Promise<RequestArgs> => {\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (startTime !== undefined && startTime !== null) {\n localVarQueryParameter['startTime'] = startTime;\n }\n\n if (endTime !== undefined && endTime !== null) {\n localVarQueryParameter['endTime'] = endTime;\n }\n\n if (current !== undefined && current !== null) {\n localVarQueryParameter['current'] = current;\n }\n\n if (size !== undefined && size !== null) {\n localVarQueryParameter['size'] = size;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/pmloan-history',\n method: 'GET',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Query interest history of negative balance for portfolio margin.\n *\n * Weight: 50\n *\n * @summary Query Portfolio Margin Pro Negative Balance Interest History(USER_DATA)\n * @param {string} [asset]\n * @param {number} [startTime]\n * @param {number} [endTime]\n * @param {number} [size] Default:10 Max:100\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n queryPortfolioMarginProNegativeBalanceInterestHistory: async (\n asset?: string,\n startTime?: number,\n endTime?: number,\n size?: number,\n recvWindow?: number\n ): Promise<RequestArgs> => {\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (asset !== undefined && asset !== null) {\n localVarQueryParameter['asset'] = asset;\n }\n\n if (startTime !== undefined && startTime !== null) {\n localVarQueryParameter['startTime'] = startTime;\n }\n\n if (endTime !== undefined && endTime !== null) {\n localVarQueryParameter['endTime'] = endTime;\n }\n\n if (size !== undefined && size !== null) {\n localVarQueryParameter['size'] = size;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/interest-history',\n method: 'GET',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Redeem BFUSD for all types of Portfolio Margin account\n *\n * Weight: 1500\n *\n * @summary Redeem BFUSD for Portfolio Margin(TRADE)\n * @param {string} fromAsset `BFUSD` only\n * @param {string} targetAsset `USDT` `USDC`\n * @param {number} amount\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n redeemBfusdForPortfolioMargin: async (\n fromAsset: string,\n targetAsset: string,\n amount: number,\n recvWindow?: number\n ): Promise<RequestArgs> => {\n // verify required parameter 'fromAsset' is not null or undefined\n assertParamExists('redeemBfusdForPortfolioMargin', 'fromAsset', fromAsset);\n // verify required parameter 'targetAsset' is not null or undefined\n assertParamExists('redeemBfusdForPortfolioMargin', 'targetAsset', targetAsset);\n // verify required parameter 'amount' is not null or undefined\n assertParamExists('redeemBfusdForPortfolioMargin', 'amount', amount);\n\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (fromAsset !== undefined && fromAsset !== null) {\n localVarQueryParameter['fromAsset'] = fromAsset;\n }\n\n if (targetAsset !== undefined && targetAsset !== null) {\n localVarQueryParameter['targetAsset'] = targetAsset;\n }\n\n if (amount !== undefined && amount !== null) {\n localVarQueryParameter['amount'] = amount;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/redeem',\n method: 'POST',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Repay futures Negative Balance\n *\n * Weight: 1500\n *\n * @summary Repay futures Negative Balance(USER_DATA)\n * @param {string} [from] SPOT or MARGIN,default SPOT\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n repayFuturesNegativeBalance: async (\n from?: string,\n recvWindow?: number\n ): Promise<RequestArgs> => {\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (from !== undefined && from !== null) {\n localVarQueryParameter['from'] = from;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/repay-futures-negative-balance',\n method: 'POST',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n /**\n * Transfer LDUSDT as collateral for all types of Portfolio Margin account\n *\n * Weight: 1500\n *\n * @summary Transfer LDUSDT for Portfolio Margin(TRADE)\n * @param {string} asset `LDUSDT` only\n * @param {string} transferType `EARN_TO_FUTURE` /`FUTURE_TO_EARN`\n * @param {number} amount\n * @param {number} [recvWindow]\n *\n * @throws {RequiredError}\n */\n transferLdusdtForPortfolioMargin: async (\n asset: string,\n transferType: string,\n amount: number,\n recvWindow?: number\n ): Promise<RequestArgs> => {\n // verify required parameter 'asset' is not null or undefined\n assertParamExists('transferLdusdtForPortfolioMargin', 'asset', asset);\n // verify required parameter 'transferType' is not null or undefined\n assertParamExists('transferLdusdtForPortfolioMargin', 'transferType', transferType);\n // verify required parameter 'amount' is not null or undefined\n assertParamExists('transferLdusdtForPortfolioMargin', 'amount', amount);\n\n const localVarQueryParameter: Record<string, unknown> = {};\n\n if (asset !== undefined && asset !== null) {\n localVarQueryParameter['asset'] = asset;\n }\n\n if (transferType !== undefined && transferType !== null) {\n localVarQueryParameter['transferType'] = transferType;\n }\n\n if (amount !== undefined && amount !== null) {\n localVarQueryParameter['amount'] = amount;\n }\n\n if (recvWindow !== undefined && recvWindow !== null) {\n localVarQueryParameter['recvWindow'] = recvWindow;\n }\n\n let _timeUnit: TimeUnit | undefined;\n if ('timeUnit' in configuration) _timeUnit = configuration.timeUnit as TimeUnit;\n\n return {\n endpoint: '/sapi/v1/portfolio/earn-asset-transfer',\n method: 'POST',\n params: localVarQueryParameter,\n timeUnit: _timeUnit,\n };\n },\n };\n};\n\n/**\n * AccountApi - interface\n * @interface AccountApi\n */\nexport interface AccountApiInterface {\n /**\n * BNB transfer can be between Margin Account and USDM Account\n *\n *\n * You can only use this function 2 times per 10 minutes in a rolling manner\n *\n * Weight: 1500\n *\n * @summary BNB transfer(USER_DATA)\n * @param {BnbTransferRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n bnbTransfer(\n requestParameters: BnbTransferRequest\n ): Promise<RestApiResponse<BnbTransferResponse>>;\n /**\n * Change Auto-repay-futures Status\n *\n * Weight: 1500\n *\n * @summary Change Auto-repay-futures Status(TRADE)\n * @param {ChangeAutoRepayFuturesStatusRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n changeAutoRepayFuturesStatus(\n requestParameters: ChangeAutoRepayFuturesStatusRequest\n ): Promise<RestApiResponse<ChangeAutoRepayFuturesStatusResponse>>;\n /**\n * Transfers all assets from Futures Account to Margin account\n *\n * The BNB would not be collected from UM-PM account to the Portfolio Margin account.\n * You can only use this function 500 times per hour in a rolling manner.\n *\n * Weight: 1500\n *\n * @summary Fund Auto-collection(USER_DATA)\n * @param {FundAutoCollectionRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n fundAutoCollection(\n requestParameters?: FundAutoCollectionRequest\n ): Promise<RestApiResponse<FundAutoCollectionResponse>>;\n /**\n * Transfers specific asset from Futures Account to Margin account\n *\n * The BNB transfer is not be supported\n *\n * Weight: 60\n *\n * @summary Fund Collection by Asset(USER_DATA)\n * @param {FundCollectionByAssetRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n fundCollectionByAsset(\n requestParameters: FundCollectionByAssetRequest\n ): Promise<RestApiResponse<FundCollectionByAssetResponse>>;\n /**\n * Query Auto-repay-futures Status\n *\n * Weight: 30\n *\n * @summary Get Auto-repay-futures Status(USER_DATA)\n * @param {GetAutoRepayFuturesStatusRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n getAutoRepayFuturesStatus(\n requestParameters?: GetAutoRepayFuturesStatusRequest\n ): Promise<RestApiResponse<GetAutoRepayFuturesStatusResponse>>;\n /**\n * Query Portfolio Margin Pro account balance\n *\n * Weight: 20\n *\n * @summary Get Portfolio Margin Pro Account Balance(USER_DATA)\n * @param {GetPortfolioMarginProAccountBalanceRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n getPortfolioMarginProAccountBalance(\n requestParameters?: GetPortfolioMarginProAccountBalanceRequest\n ): Promise<RestApiResponse<GetPortfolioMarginProAccountBalanceResponse>>;\n /**\n * Get Portfolio Margin Pro Account Info\n *\n * Weight: 5\n *\n * @summary Get Portfolio Margin Pro Account Info(USER_DATA)\n * @param {GetPortfolioMarginProAccountInfoRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n getPortfolioMarginProAccountInfo(\n requestParameters?: GetPortfolioMarginProAccountInfoRequest\n ): Promise<RestApiResponse<GetPortfolioMarginProAccountInfoResponse>>;\n /**\n * Get Portfolio Margin Pro SPAN Account Info (For Portfolio Margin Pro SPAN users only)\n *\n * Weight: 5\n *\n * @summary Get Portfolio Margin Pro SPAN Account Info(USER_DATA)\n * @param {GetPortfolioMarginProSpanAccountInfoRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n getPortfolioMarginProSpanAccountInfo(\n requestParameters?: GetPortfolioMarginProSpanAccountInfoRequest\n ): Promise<RestApiResponse<GetPortfolioMarginProSpanAccountInfoResponse>>;\n /**\n * Get transferable earn asset balance for all types of Portfolio Margin account\n *\n * Weight: 1500\n *\n * @summary Get Transferable Earn Asset Balance for Portfolio Margin (USER_DATA)\n * @param {GetTransferableEarnAssetBalanceForPortfolioMarginRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n getTransferableEarnAssetBalanceForPortfolioMargin(\n requestParameters: GetTransferableEarnAssetBalanceForPortfolioMarginRequest\n ): Promise<RestApiResponse<GetTransferableEarnAssetBalanceForPortfolioMarginResponse>>;\n /**\n * Mint BFUSD for all types of Portfolio Margin account\n *\n * Weight: 1500\n *\n * @summary Mint BFUSD for Portfolio Margin(TRADE)\n * @param {MintBfusdForPortfolioMarginRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n mintBfusdForPortfolioMargin(\n requestParameters: MintBfusdForPortfolioMarginRequest\n ): Promise<RestApiResponse<MintBfusdForPortfolioMarginResponse>>;\n /**\n * Repay Portfolio Margin Pro Bankruptcy Loan\n *\n * Weight: 3000\n *\n * @summary Portfolio Margin Pro Bankruptcy Loan Repay\n * @param {PortfolioMarginProBankruptcyLoanRepayRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n portfolioMarginProBankruptcyLoanRepay(\n requestParameters?: PortfolioMarginProBankruptcyLoanRepayRequest\n ): Promise<RestApiResponse<PortfolioMarginProBankruptcyLoanRepayResponse>>;\n /**\n * Query Portfolio Margin Pro Bankruptcy Loan Amount\n *\n * If there’s no classic portfolio margin bankruptcy loan, the amount would be 0\n *\n * Weight: 500\n *\n * @summary Query Portfolio Margin Pro Bankruptcy Loan Amount(USER_DATA)\n * @param {QueryPortfolioMarginProBankruptcyLoanAmountRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n queryPortfolioMarginProBankruptcyLoanAmount(\n requestParameters?: QueryPortfolioMarginProBankruptcyLoanAmountRequest\n ): Promise<RestApiResponse<QueryPortfolioMarginProBankruptcyLoanAmountResponse>>;\n /**\n * Query repay history of pmloan for portfolio margin pro.\n *\n * `startTime` and `endTime` cannot be longer than 360 days\n * If `startTime` and `endTime` not sent, return records of the last 30 days by default.\n * If `startTime`is sent and `endTime` is not sent, return records of [startTime, startTime+30d].\n * If `startTime` is not sent and `endTime` is sent, return records of [endTime-30d, endTime].\n *\n * Weight: 500\n *\n * @summary Query Portfolio Margin Pro Bankruptcy Loan Repay History(USER_DATA)\n * @param {QueryPortfolioMarginProBankruptcyLoanRepayHistoryRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n queryPortfolioMarginProBankruptcyLoanRepayHistory(\n requestParameters?: QueryPortfolioMarginProBankruptcyLoanRepayHistoryRequest\n ): Promise<RestApiResponse<QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponse>>;\n /**\n * Query interest history of negative balance for portfolio margin.\n *\n * Weight: 50\n *\n * @summary Query Portfolio Margin Pro Negative Balance Interest History(USER_DATA)\n * @param {QueryPortfolioMarginProNegativeBalanceInterestHistoryRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n queryPortfolioMarginProNegativeBalanceInterestHistory(\n requestParameters?: QueryPortfolioMarginProNegativeBalanceInterestHistoryRequest\n ): Promise<RestApiResponse<QueryPortfolioMarginProNegativeBalanceInterestHistoryResponse>>;\n /**\n * Redeem BFUSD for all types of Portfolio Margin account\n *\n * Weight: 1500\n *\n * @summary Redeem BFUSD for Portfolio Margin(TRADE)\n * @param {RedeemBfusdForPortfolioMarginRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n redeemBfusdForPortfolioMargin(\n requestParameters: RedeemBfusdForPortfolioMarginRequest\n ): Promise<RestApiResponse<RedeemBfusdForPortfolioMarginResponse>>;\n /**\n * Repay futures Negative Balance\n *\n * Weight: 1500\n *\n * @summary Repay futures Negative Balance(USER_DATA)\n * @param {RepayFuturesNegativeBalanceRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n repayFuturesNegativeBalance(\n requestParameters?: RepayFuturesNegativeBalanceRequest\n ): Promise<RestApiResponse<RepayFuturesNegativeBalanceResponse>>;\n /**\n * Transfer LDUSDT as collateral for all types of Portfolio Margin account\n *\n * Weight: 1500\n *\n * @summary Transfer LDUSDT for Portfolio Margin(TRADE)\n * @param {TransferLdusdtForPortfolioMarginRequest} requestParameters Request parameters.\n *\n * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}\n * @memberof AccountApiInterface\n */\n transferLdusdtForPortfolioMargin(\n requestParameters: TransferLdusdtForPortfolioMarginRequest\n ): Promise<RestApiResponse<TransferLdusdtForPortfolioMarginResponse>>;\n}\n\n/**\n * Request parameters for bnbTransfer operation in AccountApi.\n * @interface BnbTransferRequest\n */\nexport interface BnbTransferRequest {\n /**\n *\n * @type {number}\n * @memberof AccountApiBnbTransfer\n */\n readonly amount: number;\n\n /**\n * \"TO_UM\",\"FROM_UM\"\n * @type {string}\n * @memberof AccountApiBnbTransfer\n */\n readonly transferSide: string;\n\n /**\n *\n * @type {number}\n * @memberof AccountApiBnbTransfer\n */\n readonly recvWindow?: number;\n}\n\n/**\n * Request parameters for changeAutoRepayFuturesStatus operation in AccountApi.\n * @interface ChangeAutoRepayFuturesStatusRequest\n */\nexport interface ChangeAutoRepayFuturesStatusRequest {\n /**\n * Default: `true`; `false` for turn off the auto-repay futures negative balance function\n * @type {string}\n * @memberof AccountApiChangeAutoRepayFuturesStatus\n */\n readonly autoRepay: string;\n\n /**\n *\n * @type {number}\n * @memberof AccountApiChangeAutoRepayFuturesStatus\n */\n readonly recvWindow?: number;\n}\n\n/**\n * Request parameters for fundAutoCollection operation in AccountApi.\n * @interface FundAutoCollectionRequest\n */\nexport interface FundAutoCollectionRequest {\n /**\n *\n * @type {number}\n * @memberof AccountApiFundAutoCollection\n */\n readonly recvWindow?: number;\n}\n\n/**\n * Request parameters for fundCollectionByAsset operation in AccountApi.\n * @interface FundCollectionByAssetRequest\n */\nexport interface FundCollectionByAssetRequest {\n /**\n * `LDUSDT` only\n * @type {string}\n * @memberof AccountApiFundCollectionByAsset\n */\n readonly asset: string;\n\n /**\n *\n * @type {number}\n * @memberof AccountApiFundCollectionByAsset\n */\n readonly recvWindow?: number;\n}\n\n/**\n * Request parameters for getAutoRepayFuturesStatus operation in AccountApi.\n * @interface GetAutoRepayFuturesStatusRequest\n */\nexport interface GetAutoRepayFuturesStatusRequest {\n /**\n *\n * @type {number}\n * @memberof AccountApiGetAutoRepayFuturesStatus\n */\n readonly recvWindow?: number;\n}\n\n/**\n * Request parameters for getPortfolioMarginProAccountBalance operation in AccountApi.\n * @interface GetPortfolioMarginProAccountBalanceRequest\n */\nexport interface GetPortfolioMarginProAccountBalanceRequest {\n /**\n *\n * @type {string}\n * @memberof AccountApiGetPortfolioMarginProAccountBalance\n */\n readonly asset?: string;\n\n /**\n *\n * @type {number}\n * @memberof AccountApiGetPortfolioMarginProAccountBalance\n */\n readonly recvWindow?: number;\n}\n\n/**\n * Request parameters for getPortfolioMarginProAccountInfo operation in AccountApi.\n * @interface GetPortfolioMarginProAccountInfoRequest\n */\nexport interface GetPortfolioMarginProAccountInfoRequest {\n /**\n *\n * @type {number}\n * @memberof AccountApiGetPortfolioMarginProAccountInfo\n */\n readonly recvWindow?: number;\n}\n\n/**\n * Request parameters for getPortfolioMarginProSpanAccountInfo operation in AccountApi.\n * @interface GetPortfolioMarginProSpanAccountInfoRequest\n */\nexport interface GetPortfolioMarginProSpanAccountInfoRequest {\n /**\n *\n * @type {number}\n * @memberof AccountApiGetPortfolioMarginProSpanAccountInfo\n */\n readonly recvWindow?: number;\n}\n\n/**\n * Request parameters for getTransferableEarnAssetBalanceForPortfolioMargin operation in AccountApi.\n * @interface GetTransferableEarnAssetBalanceForPortfolioMarginRequest\n */\nexport interface GetTransferableEarnAssetBalanceForPortfolioMarginRequest {\n /**\n * `LDUSDT` only\n * @type {string}\n * @memberof AccountApiGetTransferableEarnAssetBalanceForPortfolioMargin\n *