@binance/derivatives-trading-options
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,385 lines (1,378 loc) • 184 kB
JavaScript
var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name2 in all)
__defProp(target, name2, { get: all[name2], enumerable: true });
};
// src/derivatives-trading-options.ts
import { platform, arch } from "os";
import {
ConfigurationRestAPI as ConfigurationRestAPI8,
ConfigurationWebsocketStreams as ConfigurationWebsocketStreams2,
DERIVATIVES_TRADING_OPTIONS_REST_API_PROD_URL,
DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL
} from "@binance/common";
// package.json
var name = "@binance/derivatives-trading-options";
var version = "1.0.0";
// src/rest-api/index.ts
var rest_api_exports = {};
__export(rest_api_exports, {
AccountApi: () => AccountApi,
MarketDataApi: () => MarketDataApi,
MarketMakerBlockTradeApi: () => MarketMakerBlockTradeApi,
MarketMakerEndpointsApi: () => MarketMakerEndpointsApi,
NewBlockTradeOrderSideEnum: () => NewBlockTradeOrderSideEnum,
NewOrderNewOrderRespTypeEnum: () => NewOrderNewOrderRespTypeEnum,
NewOrderSideEnum: () => NewOrderSideEnum,
NewOrderTimeInForceEnum: () => NewOrderTimeInForceEnum,
NewOrderTypeEnum: () => NewOrderTypeEnum,
PlaceMultipleOrdersOrdersParameterInnerNewOrderRespTypeEnum: () => PlaceMultipleOrdersOrdersParameterInnerNewOrderRespTypeEnum,
PlaceMultipleOrdersOrdersParameterInnerSideEnum: () => PlaceMultipleOrdersOrdersParameterInnerSideEnum,
PlaceMultipleOrdersOrdersParameterInnerTimeInForceEnum: () => PlaceMultipleOrdersOrdersParameterInnerTimeInForceEnum,
PlaceMultipleOrdersOrdersParameterInnerTypeEnum: () => PlaceMultipleOrdersOrdersParameterInnerTypeEnum,
RestAPI: () => RestAPI,
TradeApi: () => TradeApi,
UserDataStreamsApi: () => UserDataStreamsApi
});
// src/rest-api/types/place-multiple-orders-orders-parameter-inner.ts
var PlaceMultipleOrdersOrdersParameterInnerSideEnum = {
BUY: "BUY",
SELL: "SELL"
};
var PlaceMultipleOrdersOrdersParameterInnerTypeEnum = {
LIMIT: "LIMIT"
};
var PlaceMultipleOrdersOrdersParameterInnerTimeInForceEnum = {
GTC: "GTC",
IOC: "IOC",
FOK: "FOK"
};
var PlaceMultipleOrdersOrdersParameterInnerNewOrderRespTypeEnum = {
ACK: "ACK",
RESULT: "RESULT"
};
// src/rest-api/modules/account-api.ts
import {
assertParamExists,
sendRequest
} from "@binance/common";
var AccountApiAxiosParamCreator = function(configuration) {
return {
/**
* Query account funding flows.
*
* Weight: 1
*
* @summary Account Funding Flow (USER_DATA)
* @param {string} currency Asset type, only support USDT as of now
* @param {number} [recordId] Return the recordId and subsequent data, the latest data is returned by default, e.g 100000
* @param {number} [startTime] Start Time, e.g 1593511200000
* @param {number} [endTime] End Time, e.g 1593512200000
* @param {number} [limit] Number of result sets returned Default:100 Max:1000
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
accountFundingFlow: async (currency, recordId, startTime, endTime, limit, recvWindow) => {
assertParamExists("accountFundingFlow", "currency", currency);
const localVarQueryParameter = {};
if (currency !== void 0 && currency !== null) {
localVarQueryParameter["currency"] = currency;
}
if (recordId !== void 0 && recordId !== null) {
localVarQueryParameter["recordId"] = recordId;
}
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;
}
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/bill",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get download id for option 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 Option Transaction History (USER_DATA)
* @param {number} startTime Timestamp in ms
* @param {number} endTime Timestamp in ms
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getDownloadIdForOptionTransactionHistory: async (startTime, endTime, recvWindow) => {
assertParamExists("getDownloadIdForOptionTransactionHistory", "startTime", startTime);
assertParamExists("getDownloadIdForOptionTransactionHistory", "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: "/eapi/v1/income/asyn",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get option transaction history download Link by Id
*
* Download link expiration: 24h
*
* Weight: 5
*
* @summary Get Option Transaction History Download Link by Id (USER_DATA)
* @param {string} downloadId get by download id api
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
getOptionTransactionHistoryDownloadLinkById: async (downloadId, recvWindow) => {
assertParamExists(
"getOptionTransactionHistoryDownloadLinkById",
"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: "/eapi/v1/income/asyn/id",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get current account information.
*
* Weight: 3
*
* @summary Option Account Information(TRADE)
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
optionAccountInformation: async (recvWindow) => {
const localVarQueryParameter = {};
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/account",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
}
};
};
var AccountApi = class {
constructor(configuration) {
this.configuration = configuration;
this.localVarAxiosParamCreator = AccountApiAxiosParamCreator(configuration);
}
/**
* Query account funding flows.
*
* Weight: 1
*
* @summary Account Funding Flow (USER_DATA)
* @param {AccountFundingFlowRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<AccountFundingFlowResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow Binance API Documentation}
*/
async accountFundingFlow(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.accountFundingFlow(
requestParameters?.currency,
requestParameters?.recordId,
requestParameters?.startTime,
requestParameters?.endTime,
requestParameters?.limit,
requestParameters?.recvWindow
);
return sendRequest(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get download id for option 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 Option Transaction History (USER_DATA)
* @param {GetDownloadIdForOptionTransactionHistoryRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetDownloadIdForOptionTransactionHistoryResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/option/account/Get-Download-Id-For-Option-Transaction-History Binance API Documentation}
*/
async getDownloadIdForOptionTransactionHistory(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getDownloadIdForOptionTransactionHistory(
requestParameters?.startTime,
requestParameters?.endTime,
requestParameters?.recvWindow
);
return sendRequest(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get option transaction history download Link by Id
*
* Download link expiration: 24h
*
* Weight: 5
*
* @summary Get Option Transaction History Download Link by Id (USER_DATA)
* @param {GetOptionTransactionHistoryDownloadLinkByIdRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<GetOptionTransactionHistoryDownloadLinkByIdResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/option/account/Get-Option-Transaction-History-Download-Link-by-Id Binance API Documentation}
*/
async getOptionTransactionHistoryDownloadLinkById(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.getOptionTransactionHistoryDownloadLinkById(
requestParameters?.downloadId,
requestParameters?.recvWindow
);
return sendRequest(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Get current account information.
*
* Weight: 3
*
* @summary Option Account Information(TRADE)
* @param {OptionAccountInformationRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<OptionAccountInformationResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof AccountApi
* @see {@link https://developers.binance.com/docs/derivatives/option/account/Option-Account-Information Binance API Documentation}
*/
async optionAccountInformation(requestParameters = {}) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.optionAccountInformation(
requestParameters?.recvWindow
);
return sendRequest(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
};
// src/rest-api/modules/market-data-api.ts
import {
assertParamExists as assertParamExists2,
sendRequest as sendRequest2
} from "@binance/common";
var MarketDataApiAxiosParamCreator = function(configuration) {
return {
/**
* 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: "/eapi/v1/time",
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: "/eapi/v1/exchangeInfo",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get historical exercise records.
* REALISTIC_VALUE_STRICKEN -> Exercised
* EXTRINSIC_VALUE_EXPIRED -> Expired OTM
*
* Weight: 3
*
* @summary Historical Exercise Records
* @param {string} [underlying] underlying, e.g BTCUSDT
* @param {number} [startTime] Start Time, e.g 1593511200000
* @param {number} [endTime] End Time, e.g 1593512200000
* @param {number} [limit] Number of result sets returned Default:100 Max:1000
*
* @throws {RequiredError}
*/
historicalExerciseRecords: async (underlying, startTime, endTime, limit) => {
const localVarQueryParameter = {};
if (underlying !== void 0 && underlying !== null) {
localVarQueryParameter["underlying"] = underlying;
}
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: "/eapi/v1/exerciseHistory",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Kline/candlestick bars for an option symbol.
* Klines are uniquely identified by their open time.
*
* If startTime and endTime are not sent, the most recent klines are returned.
*
* Weight: 1
*
* @summary Kline/Candlestick Data
* @param {string} symbol Option trading pair, e.g BTC-200730-9000-C
* @param {string} interval Time interval
* @param {number} [startTime] Start Time, e.g 1593511200000
* @param {number} [endTime] End Time, e.g 1593512200000
* @param {number} [limit] Number of result sets returned Default:100 Max:1000
*
* @throws {RequiredError}
*/
klineCandlestickData: async (symbol, interval, startTime, endTime, limit) => {
assertParamExists2("klineCandlestickData", "symbol", symbol);
assertParamExists2("klineCandlestickData", "interval", interval);
const localVarQueryParameter = {};
if (symbol !== void 0 && symbol !== null) {
localVarQueryParameter["symbol"] = symbol;
}
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: "/eapi/v1/klines",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get older market historical trades.
*
* Weight: 20
*
* @summary Old Trades Lookup (MARKET_DATA)
* @param {string} symbol Option trading pair, e.g BTC-200730-9000-C
* @param {number} [fromId] The UniqueId ID from which to return. The latest deal record is returned by default
* @param {number} [limit] Number of result sets returned Default:100 Max:1000
*
* @throws {RequiredError}
*/
oldTradesLookup: async (symbol, fromId, limit) => {
assertParamExists2("oldTradesLookup", "symbol", symbol);
const localVarQueryParameter = {};
if (symbol !== void 0 && symbol !== null) {
localVarQueryParameter["symbol"] = symbol;
}
if (fromId !== void 0 && fromId !== null) {
localVarQueryParameter["fromId"] = fromId;
}
if (limit !== void 0 && limit !== null) {
localVarQueryParameter["limit"] = limit;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/historicalTrades",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get open interest for specific underlying asset on specific expiration date.
*
* Weight: 0
*
* @summary Open Interest
* @param {string} underlyingAsset underlying asset, e.g ETH/BTC
* @param {string} expiration expiration date, e.g 221225
*
* @throws {RequiredError}
*/
openInterest: async (underlyingAsset, expiration) => {
assertParamExists2("openInterest", "underlyingAsset", underlyingAsset);
assertParamExists2("openInterest", "expiration", expiration);
const localVarQueryParameter = {};
if (underlyingAsset !== void 0 && underlyingAsset !== null) {
localVarQueryParameter["underlyingAsset"] = underlyingAsset;
}
if (expiration !== void 0 && expiration !== null) {
localVarQueryParameter["expiration"] = expiration;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/openInterest",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Option mark price and greek info.
*
* Weight: 5
*
* @summary Option Mark Price
* @param {string} [symbol] Option trading pair, e.g BTC-200730-9000-C
*
* @throws {RequiredError}
*/
optionMarkPrice: async (symbol) => {
const localVarQueryParameter = {};
if (symbol !== void 0 && symbol !== null) {
localVarQueryParameter["symbol"] = symbol;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/mark",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Check orderbook depth on specific symbol
*
* Weight: limit | weight
* ------------ | ------------
* 5, 10, 20, 50 | 2
* 100 | 5
* 500 | 10
* 1000 | 20
*
* @summary Order Book
* @param {string} symbol Option trading pair, e.g BTC-200730-9000-C
* @param {number} [limit] Number of result sets returned Default:100 Max:1000
*
* @throws {RequiredError}
*/
orderBook: async (symbol, limit) => {
assertParamExists2("orderBook", "symbol", symbol);
const localVarQueryParameter = {};
if (symbol !== void 0 && symbol !== null) {
localVarQueryParameter["symbol"] = symbol;
}
if (limit !== void 0 && limit !== null) {
localVarQueryParameter["limit"] = limit;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/depth",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get recent block trades
*
* Weight: 5
*
* @summary Recent Block Trades List
* @param {string} [symbol] Option trading pair, e.g BTC-200730-9000-C
* @param {number} [limit] Number of result sets returned Default:100 Max:1000
*
* @throws {RequiredError}
*/
recentBlockTradesList: async (symbol, limit) => {
const localVarQueryParameter = {};
if (symbol !== void 0 && symbol !== null) {
localVarQueryParameter["symbol"] = symbol;
}
if (limit !== void 0 && limit !== null) {
localVarQueryParameter["limit"] = limit;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/blockTrades",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get recent market trades
*
* Weight: 5
*
* @summary Recent Trades List
* @param {string} symbol Option trading pair, e.g BTC-200730-9000-C
* @param {number} [limit] Number of result sets returned Default:100 Max:1000
*
* @throws {RequiredError}
*/
recentTradesList: async (symbol, limit) => {
assertParamExists2("recentTradesList", "symbol", symbol);
const localVarQueryParameter = {};
if (symbol !== void 0 && symbol !== null) {
localVarQueryParameter["symbol"] = symbol;
}
if (limit !== void 0 && limit !== null) {
localVarQueryParameter["limit"] = limit;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/trades",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Get spot index price for option underlying.
*
* Weight: 1
*
* @summary Symbol Price Ticker
* @param {string} underlying Option underlying, e.g BTCUSDT
*
* @throws {RequiredError}
*/
symbolPriceTicker: async (underlying) => {
assertParamExists2("symbolPriceTicker", "underlying", underlying);
const localVarQueryParameter = {};
if (underlying !== void 0 && underlying !== null) {
localVarQueryParameter["underlying"] = underlying;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/index",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Test connectivity to the Rest API.
*
* Weight: 1
*
* @summary Test Connectivity
*
* @throws {RequiredError}
*/
testConnectivity: async () => {
const localVarQueryParameter = {};
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/ping",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* 24 hour rolling window price change statistics.
*
* Weight: 5
*
* @summary 24hr Ticker Price Change Statistics
* @param {string} [symbol] Option trading pair, e.g BTC-200730-9000-C
*
* @throws {RequiredError}
*/
ticker24hrPriceChangeStatistics: async (symbol) => {
const localVarQueryParameter = {};
if (symbol !== void 0 && symbol !== null) {
localVarQueryParameter["symbol"] = symbol;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/ticker",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
}
};
};
var MarketDataApi = class {
constructor(configuration) {
this.configuration = configuration;
this.localVarAxiosParamCreator = MarketDataApiAxiosParamCreator(configuration);
}
/**
* Test connectivity to the Rest API and get the current server time.
*
* Weight: 1
*
* @summary Check Server Time
* @returns {Promise<RestApiResponse<CheckServerTimeResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/Check-Server-Time Binance API Documentation}
*/
async checkServerTime() {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.checkServerTime();
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
/**
* Current exchange trading rules and symbol information
*
* Weight: 1
*
* @summary Exchange Information
* @returns {Promise<RestApiResponse<ExchangeInformationResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/Exchange-Information Binance API Documentation}
*/
async exchangeInformation() {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.exchangeInformation();
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
/**
* Get historical exercise records.
* REALISTIC_VALUE_STRICKEN -> Exercised
* EXTRINSIC_VALUE_EXPIRED -> Expired OTM
*
* Weight: 3
*
* @summary Historical Exercise Records
* @param {HistoricalExerciseRecordsRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<HistoricalExerciseRecordsResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/Historical-Exercise-Records Binance API Documentation}
*/
async historicalExerciseRecords(requestParameters = {}) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.historicalExerciseRecords(
requestParameters?.underlying,
requestParameters?.startTime,
requestParameters?.endTime,
requestParameters?.limit
);
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
/**
* Kline/candlestick bars for an option symbol.
* Klines are uniquely identified by their open time.
*
* If startTime and endTime are not sent, the most recent klines are returned.
*
* Weight: 1
*
* @summary Kline/Candlestick Data
* @param {KlineCandlestickDataRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<KlineCandlestickDataResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/Kline-Candlestick-Data Binance API Documentation}
*/
async klineCandlestickData(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.klineCandlestickData(
requestParameters?.symbol,
requestParameters?.interval,
requestParameters?.startTime,
requestParameters?.endTime,
requestParameters?.limit
);
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
/**
* Get older market historical trades.
*
* Weight: 20
*
* @summary Old Trades Lookup (MARKET_DATA)
* @param {OldTradesLookupRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<OldTradesLookupResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/Old-Trades-Lookup Binance API Documentation}
*/
async oldTradesLookup(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.oldTradesLookup(
requestParameters?.symbol,
requestParameters?.fromId,
requestParameters?.limit
);
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
/**
* Get open interest for specific underlying asset on specific expiration date.
*
* Weight: 0
*
* @summary Open Interest
* @param {OpenInterestRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<OpenInterestResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/Open-Interest Binance API Documentation}
*/
async openInterest(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.openInterest(
requestParameters?.underlyingAsset,
requestParameters?.expiration
);
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
/**
* Option mark price and greek info.
*
* Weight: 5
*
* @summary Option Mark Price
* @param {OptionMarkPriceRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<OptionMarkPriceResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/Option-Mark-Price Binance API Documentation}
*/
async optionMarkPrice(requestParameters = {}) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.optionMarkPrice(
requestParameters?.symbol
);
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
/**
* Check orderbook depth on specific symbol
*
* Weight: limit | weight
* ------------ | ------------
* 5, 10, 20, 50 | 2
* 100 | 5
* 500 | 10
* 1000 | 20
*
* @summary Order Book
* @param {OrderBookRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<OrderBookResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/Order-Book Binance API Documentation}
*/
async orderBook(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.orderBook(
requestParameters?.symbol,
requestParameters?.limit
);
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
/**
* Get recent block trades
*
* Weight: 5
*
* @summary Recent Block Trades List
* @param {RecentBlockTradesListRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<RecentBlockTradesListResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/Recent-Block-Trade-List Binance API Documentation}
*/
async recentBlockTradesList(requestParameters = {}) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.recentBlockTradesList(
requestParameters?.symbol,
requestParameters?.limit
);
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
/**
* Get recent market trades
*
* Weight: 5
*
* @summary Recent Trades List
* @param {RecentTradesListRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<RecentTradesListResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/Recent-Trades-List Binance API Documentation}
*/
async recentTradesList(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.recentTradesList(
requestParameters?.symbol,
requestParameters?.limit
);
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
/**
* Get spot index price for option underlying.
*
* Weight: 1
*
* @summary Symbol Price Ticker
* @param {SymbolPriceTickerRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<SymbolPriceTickerResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/Symbol-Price-Ticker Binance API Documentation}
*/
async symbolPriceTicker(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.symbolPriceTicker(
requestParameters?.underlying
);
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
/**
* Test connectivity to the Rest API.
*
* Weight: 1
*
* @summary Test Connectivity
* @returns {Promise<RestApiResponse<void>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/Test-Connectivity Binance API Documentation}
*/
async testConnectivity() {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.testConnectivity();
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
/**
* 24 hour rolling window price change statistics.
*
* Weight: 5
*
* @summary 24hr Ticker Price Change Statistics
* @param {Ticker24hrPriceChangeStatisticsRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<Ticker24hrPriceChangeStatisticsResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketDataApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-data/24hr-Ticker-Price-Change-Statistics Binance API Documentation}
*/
async ticker24hrPriceChangeStatistics(requestParameters = {}) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.ticker24hrPriceChangeStatistics(
requestParameters?.symbol
);
return sendRequest2(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: false }
);
}
};
// src/rest-api/modules/market-maker-block-trade-api.ts
import {
assertParamExists as assertParamExists3,
sendRequest as sendRequest3
} from "@binance/common";
var MarketMakerBlockTradeApiAxiosParamCreator = function(configuration) {
return {
/**
* Accept a block trade order
*
* Weight: 5
*
* @summary Accept Block Trade Order (TRADE)
* @param {string} blockOrderMatchingKey
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
acceptBlockTradeOrder: async (blockOrderMatchingKey, recvWindow) => {
assertParamExists3(
"acceptBlockTradeOrder",
"blockOrderMatchingKey",
blockOrderMatchingKey
);
const localVarQueryParameter = {};
if (blockOrderMatchingKey !== void 0 && blockOrderMatchingKey !== null) {
localVarQueryParameter["blockOrderMatchingKey"] = blockOrderMatchingKey;
}
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/block/order/execute",
method: "POST",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Gets block trades for a specific account.
*
* Weight: 5
*
* @summary Account Block Trade List (USER_DATA)
* @param {number} [endTime] End Time, e.g 1593512200000
* @param {number} [startTime] Start Time, e.g 1593511200000
* @param {string} [underlying] underlying, e.g BTCUSDT
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
accountBlockTradeList: async (endTime, startTime, underlying, recvWindow) => {
const localVarQueryParameter = {};
if (endTime !== void 0 && endTime !== null) {
localVarQueryParameter["endTime"] = endTime;
}
if (startTime !== void 0 && startTime !== null) {
localVarQueryParameter["startTime"] = startTime;
}
if (underlying !== void 0 && underlying !== null) {
localVarQueryParameter["underlying"] = underlying;
}
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/block/user-trades",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Cancel a block trade order.
*
* Weight: 5
*
* @summary Cancel Block Trade Order (TRADE)
* @param {string} blockOrderMatchingKey
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
cancelBlockTradeOrder: async (blockOrderMatchingKey, recvWindow) => {
assertParamExists3(
"cancelBlockTradeOrder",
"blockOrderMatchingKey",
blockOrderMatchingKey
);
const localVarQueryParameter = {};
if (blockOrderMatchingKey !== void 0 && blockOrderMatchingKey !== null) {
localVarQueryParameter["blockOrderMatchingKey"] = blockOrderMatchingKey;
}
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/block/order/create",
method: "DELETE",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Extends a block trade expire time by 30 mins from the current time.
*
* Weight: 5
*
* @summary Extend Block Trade Order (TRADE)
* @param {string} blockOrderMatchingKey
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
extendBlockTradeOrder: async (blockOrderMatchingKey, recvWindow) => {
assertParamExists3(
"extendBlockTradeOrder",
"blockOrderMatchingKey",
blockOrderMatchingKey
);
const localVarQueryParameter = {};
if (blockOrderMatchingKey !== void 0 && blockOrderMatchingKey !== null) {
localVarQueryParameter["blockOrderMatchingKey"] = blockOrderMatchingKey;
}
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/block/order/create",
method: "PUT",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Send in a new block trade order.
*
* Weight: 5
*
* @summary New Block Trade Order (TRADE)
* @param {string} liquidity Taker or Maker
* @param {Array<object>} legs Max 1 (only single leg supported), list of legs parameters in JSON; example: eapi/v1/block/order/create?orders=[{"symbol":"BTC-210115-35000-C", "price":"100","quantity":"0.0002","side":"BUY","type":"LIMIT"}]
* @param {string} symbol Option trading pair, e.g BTC-200730-9000-C
* @param {NewBlockTradeOrderSideEnum} side BUY or SELL
* @param {number} price Order Price
* @param {number} quantity Order Quantity
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
newBlockTradeOrder: async (liquidity, legs, symbol, side, price, quantity, recvWindow) => {
assertParamExists3("newBlockTradeOrder", "liquidity", liquidity);
assertParamExists3("newBlockTradeOrder", "legs", legs);
assertParamExists3("newBlockTradeOrder", "symbol", symbol);
assertParamExists3("newBlockTradeOrder", "side", side);
assertParamExists3("newBlockTradeOrder", "price", price);
assertParamExists3("newBlockTradeOrder", "quantity", quantity);
const localVarQueryParameter = {};
if (liquidity !== void 0 && liquidity !== null) {
localVarQueryParameter["liquidity"] = liquidity;
}
if (legs) {
localVarQueryParameter["legs"] = legs;
}
if (symbol !== void 0 && symbol !== null) {
localVarQueryParameter["symbol"] = symbol;
}
if (side !== void 0 && side !== null) {
localVarQueryParameter["side"] = side;
}
if (price !== void 0 && price !== null) {
localVarQueryParameter["price"] = price;
}
if (quantity !== void 0 && quantity !== null) {
localVarQueryParameter["quantity"] = quantity;
}
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/block/order/create",
method: "POST",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Query block trade details; returns block trade details from counterparty's perspective.
*
* Weight: 5
*
* @summary Query Block Trade Details (USER_DATA)
* @param {string} blockOrderMatchingKey
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
queryBlockTradeDetails: async (blockOrderMatchingKey, recvWindow) => {
assertParamExists3(
"queryBlockTradeDetails",
"blockOrderMatchingKey",
blockOrderMatchingKey
);
const localVarQueryParameter = {};
if (blockOrderMatchingKey !== void 0 && blockOrderMatchingKey !== null) {
localVarQueryParameter["blockOrderMatchingKey"] = blockOrderMatchingKey;
}
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/block/order/execute",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
},
/**
* Check block trade order status.
*
* Weight: 5
*
* @summary Query Block Trade Order (TRADE)
* @param {string} [blockOrderMatchingKey] If specified, returns the specific block trade associated with the blockOrderMatchingKey
* @param {number} [endTime] End Time, e.g 1593512200000
* @param {number} [startTime] Start Time, e.g 1593511200000
* @param {string} [underlying] underlying, e.g BTCUSDT
* @param {number} [recvWindow]
*
* @throws {RequiredError}
*/
queryBlockTradeOrder: async (blockOrderMatchingKey, endTime, startTime, underlying, recvWindow) => {
const localVarQueryParameter = {};
if (blockOrderMatchingKey !== void 0 && blockOrderMatchingKey !== null) {
localVarQueryParameter["blockOrderMatchingKey"] = blockOrderMatchingKey;
}
if (endTime !== void 0 && endTime !== null) {
localVarQueryParameter["endTime"] = endTime;
}
if (startTime !== void 0 && startTime !== null) {
localVarQueryParameter["startTime"] = startTime;
}
if (underlying !== void 0 && underlying !== null) {
localVarQueryParameter["underlying"] = underlying;
}
if (recvWindow !== void 0 && recvWindow !== null) {
localVarQueryParameter["recvWindow"] = recvWindow;
}
let _timeUnit;
if ("timeUnit" in configuration)
_timeUnit = configuration.timeUnit;
return {
endpoint: "/eapi/v1/block/order/orders",
method: "GET",
params: localVarQueryParameter,
timeUnit: _timeUnit
};
}
};
};
var MarketMakerBlockTradeApi = class {
constructor(configuration) {
this.configuration = configuration;
this.localVarAxiosParamCreator = MarketMakerBlockTradeApiAxiosParamCreator(configuration);
}
/**
* Accept a block trade order
*
* Weight: 5
*
* @summary Accept Block Trade Order (TRADE)
* @param {AcceptBlockTradeOrderRequest} requestParameters Request parameters.
* @returns {Promise<RestApiResponse<AcceptBlockTradeOrderResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @memberof MarketMakerBlockTradeApi
* @see {@link https://developers.binance.com/docs/derivatives/option/market-maker-block-trade/Accept-Block-Trade-Order Binance API Documentation}
*/
async acceptBlockTradeOrder(requestParameters) {
const localVarAxiosArgs = await this.localVarAxiosParamCreator.acceptBlockTradeOrder(
requestParameters?.blockOrderMatchingKey,
requestParameters?.recvWindow
);
return sendRequest3(
this.configuration,
localVarAxiosArgs.endpoint,
localVarAxiosArgs.method,
localVarAxiosArgs.params,
localVarAxiosArgs?.timeUnit,
{ isSigned: true }
);
}
/**
* Gets block trades for a specific account.
*
* Weight: 5
*
* @summary Account Block Trade List (USER_D