@binance/derivatives-trading-coin-futures
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,235 lines (1,227 loc) • 362 kB
JavaScript
"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_common12.BadRequestError,
ConnectorClientError: () => import_common12.ConnectorClientError,
DERIVATIVES_TRADING_COIN_FUTURES_REST_API_PROD_URL: () => import_common12.DERIVATIVES_TRADING_COIN_FUTURES_REST_API_PROD_URL,
DERIVATIVES_TRADING_COIN_FUTURES_REST_API_TESTNET_URL: () => import_common12.DERIVATIVES_TRADING_COIN_FUTURES_REST_API_TESTNET_URL,
DERIVATIVES_TRADING_COIN_FUTURES_WS_API_PROD_URL: () => import_common12.DERIVATIVES_TRADING_COIN_FUTURES_WS_API_PROD_URL,
DERIVATIVES_TRADING_COIN_FUTURES_WS_API_TESTNET_URL: () => import_common12.DERIVATIVES_TRADING_COIN_FUTURES_WS_API_TESTNET_URL,
DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_PROD_URL: () => import_common12.DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_PROD_URL,
DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_TESTNET_URL: () => import_common12.DERIVATIVES_TRADING_COIN_FUTURES_WS_STREAMS_TESTNET_URL,
DerivativesTradingCoinFutures: () => DerivativesTradingCoinFutures,
DerivativesTradingCoinFuturesRestAPI: () => rest_api_exports,
DerivativesTradingCoinFuturesWebsocketAPI: () => websocket_api_exports,
DerivativesTradingCoinFuturesWebsocketStreams: () => websocket_streams_exports,
ForbiddenError: () => import_common12.ForbiddenError,
NetworkError: () => import_common12.NetworkError,
NotFoundError: () => import_common12.NotFoundError,
RateLimitBanError: () => import_common12.RateLimitBanError,
RequiredError: () => import_common12.RequiredError,
ServerError: () => import_common12.ServerError,
TooManyRequestsError: () => import_common12.TooManyRequestsError,
UnauthorizedError: () => import_common12.UnauthorizedError
});
module.exports = __toCommonJS(index_exports);
// src/derivatives-trading-coin-futures.ts
var import_common11 = require("@binance/common");
// package.json
var name = "@binance/derivatives-trading-coin-futures";
var version = "6.0.3";
// src/rest-api/index.ts
var rest_api_exports = {};
__export(rest_api_exports, {
AccountApi: () => AccountApi,
BasisContractTypeEnum: () => BasisContractTypeEnum,
BasisPeriodEnum: () => BasisPeriodEnum,
ChangeMarginTypeMarginTypeEnum: () => ChangeMarginTypeMarginTypeEnum,
ContinuousContractKlineCandlestickDataContractTypeEnum: () => ContinuousContractKlineCandlestickDataContractTypeEnum,
ContinuousContractKlineCandlestickDataIntervalEnum: () => ContinuousContractKlineCandlestickDataIntervalEnum,
IndexPriceKlineCandlestickDataIntervalEnum: () => IndexPriceKlineCandlestickDataIntervalEnum,
KlineCandlestickDataIntervalEnum: () => KlineCandlestickDataIntervalEnum,
LongShortRatioPeriodEnum: () => LongShortRatioPeriodEnum,
MarkPriceKlineCandlestickDataIntervalEnum: () => MarkPriceKlineCandlestickDataIntervalEnum,
MarketDataApi: () => MarketDataApi,
ModifyIsolatedPositionMarginPositionSideEnum: () => ModifyIsolatedPositionMarginPositionSideEnum,
ModifyIsolatedPositionMarginTypeEnum: () => ModifyIsolatedPositionMarginTypeEnum,
ModifyMultipleOrdersBatchOrdersParameterInnerSideEnum: () => ModifyMultipleOrdersBatchOrdersParameterInnerSideEnum,
ModifyOrderPriceMatchEnum: () => ModifyOrderPriceMatchEnum,
ModifyOrderSideEnum: () => ModifyOrderSideEnum,
NewOrderNewOrderRespTypeEnum: () => NewOrderNewOrderRespTypeEnum,
NewOrderPositionSideEnum: () => NewOrderPositionSideEnum,
NewOrderPriceMatchEnum: () => NewOrderPriceMatchEnum,
NewOrderSelfTradePreventionModeEnum: () => NewOrderSelfTradePreventionModeEnum,
NewOrderSideEnum: () => NewOrderSideEnum,
NewOrderTimeInForceEnum: () => NewOrderTimeInForceEnum,
NewOrderTypeEnum: () => NewOrderTypeEnum,
NewOrderWorkingTypeEnum: () => NewOrderWorkingTypeEnum,
OpenInterestStatisticsContractTypeEnum: () => OpenInterestStatisticsContractTypeEnum,
OpenInterestStatisticsPeriodEnum: () => OpenInterestStatisticsPeriodEnum,
PortfolioMarginEndpointsApi: () => PortfolioMarginEndpointsApi,
PremiumIndexKlineDataIntervalEnum: () => PremiumIndexKlineDataIntervalEnum,
RestAPI: () => RestAPI,
TakerBuySellVolumeContractTypeEnum: () => TakerBuySellVolumeContractTypeEnum,
TakerBuySellVolumePeriodEnum: () => TakerBuySellVolumePeriodEnum,
TopTraderLongShortRatioAccountsPeriodEnum: () => TopTraderLongShortRatioAccountsPeriodEnum,
TopTraderLongShortRatioPositionsPeriodEnum: () => TopTraderLongShortRatioPositionsPeriodEnum,
TradeApi: () => TradeApi,
UserDataStreamsApi: () => UserDataStreamsApi,
UsersForceOrdersAutoCloseTypeEnum: () => UsersForceOrdersAutoCloseTypeEnum
});
// src/rest-api/types/modify-multiple-orders-batch-orders-parameter-inner.ts
var ModifyMultipleOrdersBatchOrdersParameterInnerSideEnum = {
BUY: "BUY",
SELL: "SELL"
};
// src/rest-api/modules/account-api.ts
var import_common = require("@binance/common");
var AccountApiAxiosParamCreator = function(configuration) {
return {
/**
* Get current account information.
*
* for One-way Mode user, the "positions" will only show the "BOTH" positions
* for Hedge Mode user, the "positions" will show "BOTH", "LONG", and "SHORT" positions.
*
* Weight: 5
*
* @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: "/dapi/v1/account",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Check futures account balance
*
* Weight: 1
*
* @summary Futures Account Balance (USER_DATA)
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
futuresAccountBalance: async (recvWindow) => {
const localVarQueryParameter = {};
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/dapi/v1/balance",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get user's position mode (Hedge Mode or One-way Mode ) on ***EVERY symbol***
*
* Weight: 30
*
* @summary Get Current Position Mode(USER_DATA)
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getCurrentPositionMode: async (recvWindow) => {
const localVarQueryParameter = {};
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/dapi/v1/positionSide/dual",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get Download Id For 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: 5
*
* @summary Get Download Id For Futures Order History (USER_DATA)
* @param {number} startTime Timestamp in ms
* @param {number} endTime Timestamp in ms
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getDownloadIdForFuturesOrderHistory: async (startTime, endTime, recvWindow) => {
(0, import_common.assertParamExists)("getDownloadIdForFuturesOrderHistory", "startTime", startTime);
(0, import_common.assertParamExists)("getDownloadIdForFuturesOrderHistory", "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: "/dapi/v1/order/asyn",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get download id for 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: 5
*
* @summary Get Download Id For Futures Trade History (USER_DATA)
* @param {number} startTime Timestamp in ms
* @param {number} endTime Timestamp in ms
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getDownloadIdForFuturesTradeHistory: async (startTime, endTime, recvWindow) => {
(0, import_common.assertParamExists)("getDownloadIdForFuturesTradeHistory", "startTime", startTime);
(0, import_common.assertParamExists)("getDownloadIdForFuturesTradeHistory", "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: "/dapi/v1/trade/asyn",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get download id for 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: 5
*
* @summary Get Download Id For Futures Transaction History(USER_DATA)
* @param {number} startTime Timestamp in ms
* @param {number} endTime Timestamp in ms
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getDownloadIdForFuturesTransactionHistory: async (startTime, endTime, recvWindow) => {
(0, import_common.assertParamExists)("getDownloadIdForFuturesTransactionHistory", "startTime", startTime);
(0, import_common.assertParamExists)("getDownloadIdForFuturesTransactionHistory", "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: "/dapi/v1/income/asyn",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get futures order history download link by Id
*
* Download link expiration: 24h
*
* Weight: 5
*
* @summary Get Futures Order History Download Link by Id (USER_DATA)
* @param {string} downloadId get by download id api
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getFuturesOrderHistoryDownloadLinkById: async (downloadId, recvWindow) => {
(0, import_common.assertParamExists)("getFuturesOrderHistoryDownloadLinkById", "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: "/dapi/v1/order/asyn/id",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get futures trade download link by Id
*
* Download link expiration: 24h
*
* Weight: 5
*
* @summary Get Futures Trade Download Link by Id(USER_DATA)
* @param {string} downloadId get by download id api
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getFuturesTradeDownloadLinkById: async (downloadId, recvWindow) => {
(0, import_common.assertParamExists)("getFuturesTradeDownloadLinkById", "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: "/dapi/v1/trade/asyn/id",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get futures transaction history download link by Id
*
* Download link expiration: 24h
*
* Weight: 5
*
* @summary Get Futures Transaction History Download Link by Id (USER_DATA)
* @param {string} downloadId get by download id api
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getFuturesTransactionHistoryDownloadLinkById: async (downloadId, recvWindow) => {
(0, import_common.assertParamExists)(
"getFuturesTransactionHistoryDownloadLinkById",
"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: "/dapi/v1/income/asyn/id",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get 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 time between `startTime` and `endTime` can not be longer than 1 year
*
* Weight: 20
*
* @summary Get Income History(USER_DATA)
* @param {string} [symbol]
* @param {string} [incomeType] "TRANSFER","WELCOME_BONUS", "FUNDING_FEE", "REALIZED_PNL", "COMMISSION", "INSURANCE_CLEAR", and "DELIVERED_SETTELMENT"
* @param {number} [startTime]
* @param {number} [endTime]
* @param {number} [page]
* @param {number} [limit] Default 100; max 1000
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getIncomeHistory: 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: "/dapi/v1/income",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* **Not recommended to continue using this v1 endpoint**
*
* Get the pair's default notional bracket list, may return ambiguous values when there have been multiple different `symbol` brackets under the `pair`, suggest using the following `GET /dapi/v2/leverageBracket` query instead to get the specific `symbol` notional bracket list.
*
* Weight: 1
*
* @summary Notional Bracket for Pair(USER_DATA)
* @param {string} [pair]
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
notionalBracketForPair: async (pair, recvWindow) => {
const localVarQueryParameter = {};
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: "/dapi/v1/leverageBracket",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get the symbol's notional bracket list.
*
* Weight: 1
*
* @summary Notional Bracket for Symbol(USER_DATA)
* @param {string} [symbol]
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
notionalBracketForSymbol: 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: "/dapi/v2/leverageBracket",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Query user commission rate
*
* Weight: 20
*
* @summary User Commission Rate (USER_DATA)
* @param {string} symbol
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
userCommissionRate: async (symbol, recvWindow) => {
(0, import_common.assertParamExists)("userCommissionRate", "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: "/dapi/v1/commissionRate",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
}
};
};
var AccountApi = class {
constructor(configuration) {
this.configuration = configuration;
this.localVarAxiosParamCreator = AccountApiAxiosParamCreator(configuration);
}
/**
* Get current account information.
*
* for One-way Mode user, the "positions" will only show the "BOTH" positions
* for Hedge Mode user, the "positions" will show "BOTH", "LONG", and "SHORT" positions.
*
* Weight: 5
*
* @summary Account Information (USER_DATA)
* @param {AccountInformationRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<AccountInformationResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information Binance API Documentation}
*/
async accountInformation(requestParameters = {}) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.accountInformation(
requestParameters?.recvWindow
);
return (0, import_common.sendRequest)(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Check futures account balance
*
* Weight: 1
*
* @summary Futures Account Balance (USER_DATA)
* @param {FuturesAccountBalanceRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<FuturesAccountBalanceResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Futures-Account-Balance Binance API Documentation}
*/
async futuresAccountBalance(requestParameters = {}) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.futuresAccountBalance(
requestParameters?.recvWindow
);
return (0, import_common.sendRequest)(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get user's position mode (Hedge Mode or One-way Mode ) on ***EVERY symbol***
*
* Weight: 30
*
* @summary Get Current Position Mode(USER_DATA)
* @param {GetCurrentPositionModeRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetCurrentPositionModeResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Current-Position-Mode Binance API Documentation}
*/
async getCurrentPositionMode(requestParameters = {}) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getCurrentPositionMode(
requestParameters?.recvWindow
);
return (0, import_common.sendRequest)(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get Download Id For 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: 5
*
* @summary Get Download Id For Futures Order History (USER_DATA)
* @param {GetDownloadIdForFuturesOrderHistoryRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetDownloadIdForFuturesOrderHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Download-Id-For-Futures-Order-History Binance API Documentation}
*/
async getDownloadIdForFuturesOrderHistory(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getDownloadIdForFuturesOrderHistory(
requestParameters?.startTime,
requestParameters?.endTime,
requestParameters?.recvWindow
);
return (0, import_common.sendRequest)(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get download id for 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: 5
*
* @summary Get Download Id For Futures Trade History (USER_DATA)
* @param {GetDownloadIdForFuturesTradeHistoryRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetDownloadIdForFuturesTradeHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Download-Id-For-Futures-Trade-History Binance API Documentation}
*/
async getDownloadIdForFuturesTradeHistory(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getDownloadIdForFuturesTradeHistory(
requestParameters?.startTime,
requestParameters?.endTime,
requestParameters?.recvWindow
);
return (0, import_common.sendRequest)(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get download id for 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: 5
*
* @summary Get Download Id For Futures Transaction History(USER_DATA)
* @param {GetDownloadIdForFuturesTransactionHistoryRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetDownloadIdForFuturesTransactionHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Download-Id-For-Futures-Transaction-History Binance API Documentation}
*/
async getDownloadIdForFuturesTransactionHistory(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getDownloadIdForFuturesTransactionHistory(
requestParameters?.startTime,
requestParameters?.endTime,
requestParameters?.recvWindow
);
return (0, import_common.sendRequest)(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get futures order history download link by Id
*
* Download link expiration: 24h
*
* Weight: 5
*
* @summary Get Futures Order History Download Link by Id (USER_DATA)
* @param {GetFuturesOrderHistoryDownloadLinkByIdRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetFuturesOrderHistoryDownloadLinkByIdResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Futures-Order-History-Download-Link-by-Id Binance API Documentation}
*/
async getFuturesOrderHistoryDownloadLinkById(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getFuturesOrderHistoryDownloadLinkById(
requestParameters?.downloadId,
requestParameters?.recvWindow
);
return (0, import_common.sendRequest)(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get futures trade download link by Id
*
* Download link expiration: 24h
*
* Weight: 5
*
* @summary Get Futures Trade Download Link by Id(USER_DATA)
* @param {GetFuturesTradeDownloadLinkByIdRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetFuturesTradeDownloadLinkByIdResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Futures-Trade-Download-Link-by-Id Binance API Documentation}
*/
async getFuturesTradeDownloadLinkById(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getFuturesTradeDownloadLinkById(
requestParameters?.downloadId,
requestParameters?.recvWindow
);
return (0, import_common.sendRequest)(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get futures transaction history download link by Id
*
* Download link expiration: 24h
*
* Weight: 5
*
* @summary Get Futures Transaction History Download Link by Id (USER_DATA)
* @param {GetFuturesTransactionHistoryDownloadLinkByIdRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetFuturesTransactionHistoryDownloadLinkByIdResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Futures-Transaction-History-Download-Link-by-Id Binance API Documentation}
*/
async getFuturesTransactionHistoryDownloadLinkById(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getFuturesTransactionHistoryDownloadLinkById(
requestParameters?.downloadId,
requestParameters?.recvWindow
);
return (0, import_common.sendRequest)(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get 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 time between `startTime` and `endTime` can not be longer than 1 year
*
* Weight: 20
*
* @summary Get Income History(USER_DATA)
* @param {GetIncomeHistoryRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetIncomeHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Income-History Binance API Documentation}
*/
async getIncomeHistory(requestParameters = {}) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getIncomeHistory(
requestParameters?.symbol,
requestParameters?.incomeType,
requestParameters?.startTime,
requestParameters?.endTime,
requestParameters?.page,
requestParameters?.limit,
requestParameters?.recvWindow
);
return (0, import_common.sendRequest)(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* **Not recommended to continue using this v1 endpoint**
*
* Get the pair's default notional bracket list, may return ambiguous values when there have been multiple different `symbol` brackets under the `pair`, suggest using the following `GET /dapi/v2/leverageBracket` query instead to get the specific `symbol` notional bracket list.
*
* Weight: 1
*
* @summary Notional Bracket for Pair(USER_DATA)
* @param {NotionalBracketForPairRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<NotionalBracketForPairResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Notional-Bracket-for-Pair Binance API Documentation}
*/
async notionalBracketForPair(requestParameters = {}) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.notionalBracketForPair(
requestParameters?.pair,
requestParameters?.recvWindow
);
return (0, import_common.sendRequest)(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get the symbol's notional bracket list.
*
* Weight: 1
*
* @summary Notional Bracket for Symbol(USER_DATA)
* @param {NotionalBracketForSymbolRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<NotionalBracketForSymbolResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Notional-Bracket-for-Symbol Binance API Documentation}
*/
async notionalBracketForSymbol(requestParameters = {}) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.notionalBracketForSymbol(
requestParameters?.symbol,
requestParameters?.recvWindow
);
return (0, import_common.sendRequest)(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Query user commission rate
*
* Weight: 20
*
* @summary User Commission Rate (USER_DATA)
* @param {UserCommissionRateRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<UserCommissionRateResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/User-Commission-Rate Binance API Documentation}
*/
async userCommissionRate(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.userCommissionRate(
requestParameters?.symbol,
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 {
/**
* Query basis
*
* If startTime and endTime are not sent, the most recent data is returned.
* Only the data of the latest 30 days is available.
*
* Weight: 1
*
* @summary Basis
* @param {string} pair BTCUSD
* @param {BasisContractTypeEnum} contractType ALL, CURRENT_QUARTER, NEXT_QUARTER, PERPETUAL
* @param {BasisPeriodEnum} period "5m","15m","30m","1h","2h","4h","6h","12h","1d"
* @param {number} [limit] Default 100; max 1000
* @param {number} [startTime]
* @param {number} [endTime]
*
* @throws {RequiredError}
*/
basis: async (pair, contractType, period, limit, startTime, endTime) => {
(0, import_common2.assertParamExists)("basis", "pair", pair);
(0, import_common2.assertParamExists)("basis", "contractType", contractType);
(0, import_common2.assertParamExists)("basis", "period", period);
const localVarQueryParameter = {};
if (pair !== void 0 && pair !== null) {
localVarQueryParameter["pair"] = pair;
}
if (contractType !== void 0 && contractType !== null) {
localVarQueryParameter["contractType"] = contractType;
}
if (period !== void 0 && period !== null) {
localVarQueryParameter["period"] = period;
}
if (limit !== void 0 && limit !== null) {
localVarQueryParameter["limit"] = limit;
}
if (startTime !== void 0 && startTime !== null) {
localVarQueryParameter["startTime"] = startTime;
}
if (endTime !== void 0 && endTime !== null) {
localVarQueryParameter["endTime"] = endTime;
}
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/futures/data/basis",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Test connectivity to the Rest API and get the current server time.
*
* Weight: 1
*
* @summary Check Server time
*
* @throws {RequiredError}
*/
checkServerTime: async () => {
const localVarQueryParameter = {};
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/dapi/v1/time",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get compressed, aggregate trades. Market trades that fill in 100ms with the same price and the same taking side will have the quantity aggregated.
*
* support querying futures trade histories that are not older than one year
* If both `startTime` and `endTime` are sent, time between `startTime` and `endTime` must be less than 1 hour.
* If `fromId`, `startTime`, and `endTime` are not sent, the most recent aggregate trades will be returned.
* Only market trades will be aggregated and returned, which means the insurance fund trades and ADL trades won't be aggregated.
* Sending both `startTime`/`endTime` and `fromId` might cause response timeout, please send either `fromId` or `startTime`/`endTime`
*
* Weight: 20
*
* @summary Compressed/Aggregate Trades List
* @param {string} symbol
* @param {number} [fromId] ID to get aggregate trades from INCLUSIVE.
* @param {number} [startTime]
* @param {number} [endTime]
* @param {number} [limit] Default 100; max 1000
*
* @throws {RequiredError}
*/
compressedAggregateTradesList: async (symbol, fromId, startTime, endTime, limit) => {
(0, import_common2.assertParamExists)("compressedAggregateTradesList", "symbol", symbol);
const localVarQueryParameter = {};
if (symbol !== void 0 && symbol !== null) {
localVarQueryParameter["symbol"] = symbol;
}
if (fromId !== void 0 && fromId !== null) {
localVarQueryParameter["fromId"] = fromId;
}
if (startTime !== void 0 && startTime !== null) {
localVarQueryParameter["startTime"] = startTime;
}
if (endTime !== void 0 && endTime !== null) {
localVarQueryParameter["endTime"] = endTime;
}
if (limit !== void 0 && limit !== null) {
localVarQueryParameter["limit"] = limit;
}
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/dapi/v1/aggTrades",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Kline/candlestick bars for a specific contract type.
* Klines are uniquely identified by their open time.
*
* Contract type:
* PERPETUAL
* CURRENT_QUARTER
* NEXT_QUARTER
*
*
* 1000 | 10
* The difference between `startTime` and `endTime` can only be up to 200 days
* Between `startTime` and `endTime`, the most recent `limit` data from `endTime` will be returned:
* If `startTime` and `endTime` are not sent, current timestamp will be set as `endTime`, and the most recent data will be returned.
* If `startTime` is sent only, the timestamp of 200 days after `startTime` will be set as `endTime`(up to the current time)
* If `endTime` is sent only, the timestamp of 200 days before `endTime` will be set as `startTime`
*
* Weight: based on parameter LIMIT
* LIMIT | weight
* ---|---
* [1,100) | 1
* [100, 500) | 2
* [500, 1000] | 5
* > 1000 | 10
*
* @summary Continuous Contract Kline/Candlestick Data
* @param {string} pair BTCUSD
* @param {ContinuousContractKlineCandlestickDataContractTypeEnum} contractType ALL, CURRENT_QUARTER, NEXT_QUARTER, PERPETUAL
* @param {ContinuousContractKlineCandlestickDataIntervalEnum} interval
* @param {number} [startTime]
* @param {number} [endTime]
* @param {number} [limit] Default 100; max 1000
*
* @throws {RequiredError}
*/
continuousContractKlineCandlestickData: async (pair, contractType, interval, startTime, endTime, limit) => {
(0, import_common2.assertParamExists)("continuousContractKlineCandlestickData", "pair", pair);
(0, import_common2.assertParamExists)(
"continuousContractKlineCandlestickData",
"contractType",
contractType
);
(0, import_common2.assertParamExists)("continuousContractKlineCandlestickData", "interval", interval);
const localVarQueryParameter = {};
if (pair !== void 0 && pair !== null) {
localVarQueryParameter["pair"] = pair;
}
if (contractType !== void 0 && contractType !== null) {
localVarQueryParameter["contractType"] = contractType;
}
if (interval !== void 0 && interval !== null) {
localVarQueryParameter["interval"] = interval;
}
if (startTime !== void 0 && startTime !== null) {
localVarQueryParameter["startTime"] = startTime;
}
if (endTime !== void 0 && endTime !== null) {
localVarQueryParameter["endTime"] = endTime;
}
if (limit !== void 0 && limit !== null) {
localVarQueryParameter["limit"] = limit;
}
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/dapi/v1/continuousKlines",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Current exchange trading rules and symbol information
*
* Weight: 1
*
* @summary Exchange Information
*
* @throws {RequiredError}
*/
exchangeInformation: async () => {
const localVarQueryParameter = {};
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/dapi/v1/exchangeInfo",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get Funding Rate History of Perpetual Futures
*
* empty array will be returned for delivery symbols.
*
* Weight: 1
*
* @summary Get Funding Rate History of Perpetual Futures
* @param {string} symbol
* @param {number} [startTime]
* @param {number} [endTime]
* @param {number} [limit] Default 100; max 1000
*
* @throws {RequiredError}
*/
getFundingRateHistoryOfPerpetualFutures: async (symbol, startTime, endTime, limit) => {
(0, import_common2.assertParamExists)("getFundingRateHistoryOfPerpetualFutures", "symbol", symbol);
const localVarQueryParameter = {};
if (symbol !== void 0 && symbol !== null) {
localVarQueryParameter["symbol"] = symbol;
}
if (startTime !== void 0 && startTime !== null) {
localVarQueryParameter["startTime"] = startTime;
}
if (endTime !== void 0 && endTime !== null) {
localVarQueryParameter["endTime"] = endTime;
}
if (limit !== void 0 && limit !== null) {
localVarQueryParameter["limit"] = limit;
}
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/dapi/v1/fundingRate",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Query funding rate info for symbols that had FundingRateCap/ FundingRateFloor / fundingIntervalHours adjustment
*
* Weight: 0
*
* @summary Get Funding Rate Info
*
* @throws {RequiredError}
*/
getFundingRateInfo: async () => {
const localVarQueryParameter = {};
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/dapi/v1/fundingInfo",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Query index price and mark price
*
* Weight: 10
*
* @summary Index Price and Mark Price
* @param {string} [symbol]
* @param {string} [pair]
*
* @throws {RequiredError}
*/
indexPriceAndMarkPrice: async (symbol, pair) => {
const localVarQueryParameter = {};
if (symbol !== void 0 && symbol !== null) {
localVarQueryParameter["symbol"] = symbol;
}
if (pair !== void 0 && pair !== null) {
localVarQueryParameter["pair"] = pair;
}
let _timeUnit;
if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit;
return {
endpoint: "/dapi/v1/premiumIndex",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Kline/candlestick bars for the index price of a pair. Klines are uniquely identified by their open time.
*
*
* 1000 | 10
* The difference between `startTime` and `endTime` can only be up to 200 days
* Between `startTime` and `endTime`, the most recent `limit` data from `endTime` will be returned:
* If `startTime` and `endTime` are not sent, current timestamp will be set as `endTime`, and the most recent data will be returned.
* If `startTime` is sent only, the timestamp of 200 days after `startTime` will be set as `endTime`(up to the current time)
* If `endTime` is sent only, the timestamp of 200 days before `endTime` will be set as `startTime`
*
* Weight: based on parameter LIMIT
* LIMIT | weight
* ---|---
* [1,100) | 1
* [100, 500) | 2
* [500, 1000] | 5
* > 1000 | 10
*
* @summary Index Price Kline/Candlestick Data
* @param {string} pair BTCUSD
* @param {IndexPriceKlineCandlestickDataIntervalEnum} interval
* @param {number} [startTime]
* @param {number} [endTime]
* @param {number} [limit] Default 100; max 1000
*
* @throws {RequiredError}
*/
indexPriceKlineCandlestickData: async (pair, interval, startTime, endTime, limit) => {
(0, import_common2.assertParamExists)("indexPriceKlineCandlestickData", "pair", pair);
(0, import_common2.assertParamExists)("indexPriceKlineCandlestickData", "interval", interval);
const localVarQueryParameter = {};
if (pair !== void 0 && pair !== null) {
localVarQueryParameter["pair"] = pair;