@binance/derivatives-trading-portfolio-margin 4.0.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -0
- package/dist/index.d.mts +1890 -365
- package/dist/index.d.ts +1890 -365
- package/dist/index.js +175 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +163 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -20,30 +20,32 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
BadRequestError: () =>
|
|
24
|
-
ConnectorClientError: () =>
|
|
25
|
-
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL: () =>
|
|
26
|
-
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL: () =>
|
|
23
|
+
BadRequestError: () => import_common9.BadRequestError,
|
|
24
|
+
ConnectorClientError: () => import_common9.ConnectorClientError,
|
|
25
|
+
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL: () => import_common9.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL,
|
|
26
|
+
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL: () => import_common9.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL,
|
|
27
|
+
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_PROD_URL: () => import_common9.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_PROD_URL,
|
|
28
|
+
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_TESTNET_URL: () => import_common9.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_TESTNET_URL,
|
|
27
29
|
DerivativesTradingPortfolioMargin: () => DerivativesTradingPortfolioMargin,
|
|
28
30
|
DerivativesTradingPortfolioMarginRestAPI: () => rest_api_exports,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
DerivativesTradingPortfolioMarginWebsocketStreams: () => websocket_streams_exports,
|
|
32
|
+
ForbiddenError: () => import_common9.ForbiddenError,
|
|
33
|
+
NetworkError: () => import_common9.NetworkError,
|
|
34
|
+
NotFoundError: () => import_common9.NotFoundError,
|
|
35
|
+
RateLimitBanError: () => import_common9.RateLimitBanError,
|
|
36
|
+
RequiredError: () => import_common9.RequiredError,
|
|
37
|
+
ServerError: () => import_common9.ServerError,
|
|
38
|
+
TooManyRequestsError: () => import_common9.TooManyRequestsError,
|
|
39
|
+
UnauthorizedError: () => import_common9.UnauthorizedError
|
|
37
40
|
});
|
|
38
41
|
module.exports = __toCommonJS(index_exports);
|
|
39
42
|
|
|
40
43
|
// src/derivatives-trading-portfolio-margin.ts
|
|
41
|
-
var
|
|
42
|
-
var import_common6 = require("@binance/common");
|
|
44
|
+
var import_common8 = require("@binance/common");
|
|
43
45
|
|
|
44
46
|
// package.json
|
|
45
47
|
var name = "@binance/derivatives-trading-portfolio-margin";
|
|
46
|
-
var version = "
|
|
48
|
+
var version = "5.0.0";
|
|
47
49
|
|
|
48
50
|
// src/rest-api/index.ts
|
|
49
51
|
var rest_api_exports = {};
|
|
@@ -3152,6 +3154,8 @@ var TradeApiAxiosParamCreator = function(configuration) {
|
|
|
3152
3154
|
* `OrderId` can only be sent together with symbol
|
|
3153
3155
|
* If a `pair` is sent, tickers for all symbols of the `pair` will be returned
|
|
3154
3156
|
* The parameter `fromId` cannot be sent with `startTime` or `endTime`
|
|
3157
|
+
* If `startTime` and `endTime` are both not sent, then the last '24 hours' data will be returned.
|
|
3158
|
+
* The time between `startTime` and `endTime` cannot be longer than 24 hours.
|
|
3155
3159
|
*
|
|
3156
3160
|
* Weight: 20 with symbol, 40 with pair
|
|
3157
3161
|
*
|
|
@@ -5258,8 +5262,8 @@ var TradeApiAxiosParamCreator = function(configuration) {
|
|
|
5258
5262
|
* Get trades for a specific account and UM symbol.
|
|
5259
5263
|
*
|
|
5260
5264
|
*
|
|
5261
|
-
* If `startTime` and `endTime` are both not sent, then the last '
|
|
5262
|
-
* The time between `startTime` and `endTime` cannot be longer than
|
|
5265
|
+
* If `startTime` and `endTime` are both not sent, then the last '7 days' data will be returned.
|
|
5266
|
+
* The time between `startTime` and `endTime` cannot be longer than 7 days.
|
|
5263
5267
|
* The parameter `fromId` cannot be sent with `startTime` or `endTime`.
|
|
5264
5268
|
*
|
|
5265
5269
|
* Weight: 5
|
|
@@ -5667,6 +5671,8 @@ var TradeApi = class {
|
|
|
5667
5671
|
* `OrderId` can only be sent together with symbol
|
|
5668
5672
|
* If a `pair` is sent, tickers for all symbols of the `pair` will be returned
|
|
5669
5673
|
* The parameter `fromId` cannot be sent with `startTime` or `endTime`
|
|
5674
|
+
* If `startTime` and `endTime` are both not sent, then the last '24 hours' data will be returned.
|
|
5675
|
+
* The time between `startTime` and `endTime` cannot be longer than 24 hours.
|
|
5670
5676
|
*
|
|
5671
5677
|
* Weight: 20 with symbol, 40 with pair
|
|
5672
5678
|
*
|
|
@@ -7139,8 +7145,8 @@ var TradeApi = class {
|
|
|
7139
7145
|
* Get trades for a specific account and UM symbol.
|
|
7140
7146
|
*
|
|
7141
7147
|
*
|
|
7142
|
-
* If `startTime` and `endTime` are both not sent, then the last '
|
|
7143
|
-
* The time between `startTime` and `endTime` cannot be longer than
|
|
7148
|
+
* If `startTime` and `endTime` are both not sent, then the last '7 days' data will be returned.
|
|
7149
|
+
* The time between `startTime` and `endTime` cannot be longer than 7 days.
|
|
7144
7150
|
* The parameter `fromId` cannot be sent with `startTime` or `endTime`.
|
|
7145
7151
|
*
|
|
7146
7152
|
* Weight: 5
|
|
@@ -8502,6 +8508,8 @@ var RestAPI = class {
|
|
|
8502
8508
|
* `OrderId` can only be sent together with symbol
|
|
8503
8509
|
* If a `pair` is sent, tickers for all symbols of the `pair` will be returned
|
|
8504
8510
|
* The parameter `fromId` cannot be sent with `startTime` or `endTime`
|
|
8511
|
+
* If `startTime` and `endTime` are both not sent, then the last '24 hours' data will be returned.
|
|
8512
|
+
* The time between `startTime` and `endTime` cannot be longer than 24 hours.
|
|
8505
8513
|
*
|
|
8506
8514
|
* Weight: 20 with symbol, 40 with pair
|
|
8507
8515
|
*
|
|
@@ -9292,8 +9300,8 @@ var RestAPI = class {
|
|
|
9292
9300
|
* Get trades for a specific account and UM symbol.
|
|
9293
9301
|
*
|
|
9294
9302
|
*
|
|
9295
|
-
* If `startTime` and `endTime` are both not sent, then the last '
|
|
9296
|
-
* The time between `startTime` and `endTime` cannot be longer than
|
|
9303
|
+
* If `startTime` and `endTime` are both not sent, then the last '7 days' data will be returned.
|
|
9304
|
+
* The time between `startTime` and `endTime` cannot be longer than 7 days.
|
|
9297
9305
|
* The parameter `fromId` cannot be sent with `startTime` or `endTime`.
|
|
9298
9306
|
*
|
|
9299
9307
|
* Weight: 5
|
|
@@ -9369,32 +9377,174 @@ var RestAPI = class {
|
|
|
9369
9377
|
}
|
|
9370
9378
|
};
|
|
9371
9379
|
|
|
9380
|
+
// src/websocket-streams/index.ts
|
|
9381
|
+
var websocket_streams_exports = {};
|
|
9382
|
+
__export(websocket_streams_exports, {
|
|
9383
|
+
WebsocketStreams: () => WebsocketStreams,
|
|
9384
|
+
WebsocketStreamsConnection: () => WebsocketStreamsConnection
|
|
9385
|
+
});
|
|
9386
|
+
|
|
9387
|
+
// src/websocket-streams/websocket-streams.ts
|
|
9388
|
+
var import_common7 = require("@binance/common");
|
|
9389
|
+
|
|
9390
|
+
// src/websocket-streams/websocket-streams-connection.ts
|
|
9391
|
+
var import_common6 = require("@binance/common");
|
|
9392
|
+
var WebsocketStreamsConnection = class {
|
|
9393
|
+
constructor(websocketBase) {
|
|
9394
|
+
this.websocketBase = websocketBase;
|
|
9395
|
+
}
|
|
9396
|
+
/**
|
|
9397
|
+
* Adds an event listener for the specified WebSocket event.
|
|
9398
|
+
* @param event - The WebSocket event to listen for, such as 'open', 'message', 'error', 'close', 'ping', or 'pong'.
|
|
9399
|
+
* @param listener - The callback function to be executed when the event is triggered. The function can accept any number of arguments.
|
|
9400
|
+
*/
|
|
9401
|
+
on(event, listener) {
|
|
9402
|
+
this.websocketBase.on(event, listener);
|
|
9403
|
+
}
|
|
9404
|
+
/**
|
|
9405
|
+
* Removes an event listener for the specified WebSocket event.
|
|
9406
|
+
* @param event - The WebSocket event to stop listening for, such as 'open', 'message', 'error', 'close', 'ping', or 'pong'.
|
|
9407
|
+
* @param listener - The callback function that was previously added as the event listener.
|
|
9408
|
+
*/
|
|
9409
|
+
off(event, listener) {
|
|
9410
|
+
this.websocketBase.off(event, listener);
|
|
9411
|
+
}
|
|
9412
|
+
/**
|
|
9413
|
+
* Disconnects from the WebSocket server.
|
|
9414
|
+
* If there is no active connection, a warning is logged.
|
|
9415
|
+
* Otherwise, all connections in the connection pool are closed gracefully,
|
|
9416
|
+
* and a message is logged indicating that the connection has been disconnected.
|
|
9417
|
+
* @returns A Promise that resolves when all connections have been closed.
|
|
9418
|
+
* @throws Error if the WebSocket client is not set.
|
|
9419
|
+
*/
|
|
9420
|
+
disconnect() {
|
|
9421
|
+
return this.websocketBase.disconnect();
|
|
9422
|
+
}
|
|
9423
|
+
/**
|
|
9424
|
+
* Checks if the WebSocket connection is currently open.
|
|
9425
|
+
* @returns `true` if the connection is open, `false` otherwise.
|
|
9426
|
+
*/
|
|
9427
|
+
isConnected() {
|
|
9428
|
+
return this.websocketBase.isConnected();
|
|
9429
|
+
}
|
|
9430
|
+
/**
|
|
9431
|
+
* Sends a ping message to all connected Websocket servers in the pool.
|
|
9432
|
+
* If no connections are ready, a warning is logged.
|
|
9433
|
+
* For each active connection, the ping message is sent, and debug logs provide details.
|
|
9434
|
+
* @throws Error if a Websocket client is not set for a connection.
|
|
9435
|
+
*/
|
|
9436
|
+
pingServer() {
|
|
9437
|
+
this.websocketBase.pingServer();
|
|
9438
|
+
}
|
|
9439
|
+
/**
|
|
9440
|
+
* Subscribes to one or multiple WebSocket streams
|
|
9441
|
+
* Handles both single and pool modes
|
|
9442
|
+
* @param stream Single stream name or array of stream names to subscribe to
|
|
9443
|
+
* @param id Optional subscription ID
|
|
9444
|
+
* @returns void
|
|
9445
|
+
*/
|
|
9446
|
+
subscribe(stream, id) {
|
|
9447
|
+
this.websocketBase.subscribe(stream, id);
|
|
9448
|
+
}
|
|
9449
|
+
/**
|
|
9450
|
+
* Unsubscribes from one or multiple WebSocket streams
|
|
9451
|
+
* Handles both single and pool modes
|
|
9452
|
+
* @param stream Single stream name or array of stream names to unsubscribe from
|
|
9453
|
+
* @param id Optional unsubscription ID
|
|
9454
|
+
* @returns void
|
|
9455
|
+
*/
|
|
9456
|
+
unsubscribe(stream, id) {
|
|
9457
|
+
this.websocketBase.unsubscribe(stream, id);
|
|
9458
|
+
}
|
|
9459
|
+
/**
|
|
9460
|
+
* Checks if the WebSocket connection is subscribed to the specified stream.
|
|
9461
|
+
* @param stream The name of the WebSocket stream to check.
|
|
9462
|
+
* @returns `true` if the connection is subscribed to the stream, `false` otherwise.
|
|
9463
|
+
*/
|
|
9464
|
+
isSubscribed(stream) {
|
|
9465
|
+
return this.websocketBase.isSubscribed(stream);
|
|
9466
|
+
}
|
|
9467
|
+
/**
|
|
9468
|
+
* Subscribes to the user data WebSocket stream using the provided listen key.
|
|
9469
|
+
* @param listenKey - The listen key for the user data WebSocket stream.
|
|
9470
|
+
* @param id - Optional user data stream ID
|
|
9471
|
+
* @returns A WebSocket stream handler for the user data stream.
|
|
9472
|
+
*/
|
|
9473
|
+
userData(listenKey, id) {
|
|
9474
|
+
return (0, import_common6.createStreamHandler)(this.websocketBase, listenKey, id);
|
|
9475
|
+
}
|
|
9476
|
+
};
|
|
9477
|
+
|
|
9478
|
+
// src/websocket-streams/websocket-streams.ts
|
|
9479
|
+
var WebsocketStreams = class {
|
|
9480
|
+
constructor(configuration) {
|
|
9481
|
+
this.configuration = configuration;
|
|
9482
|
+
}
|
|
9483
|
+
/**
|
|
9484
|
+
* Connects to the Binance WebSocket streams and returns a `WebsocketStreamsConnection` instance.
|
|
9485
|
+
*
|
|
9486
|
+
* @param {object} [options] - Optional connection options.
|
|
9487
|
+
* @param {string|string[]} [options.stream] - The stream(s) to connect to.
|
|
9488
|
+
* @param {'single'|'pool'} [options.mode] - The connection mode, either 'single' or 'pool'. Overwrite the `mode` option in the configuration.
|
|
9489
|
+
* @param {number} [options.poolSize] - The number of connections to use in pool mode. Overwrite the `poolSize` option in the configuration.
|
|
9490
|
+
* @returns {Promise<WebsocketStreamsConnection>} - A promise that resolves to a `WebsocketStreamsConnection` instance.
|
|
9491
|
+
*/
|
|
9492
|
+
async connect({
|
|
9493
|
+
stream,
|
|
9494
|
+
mode,
|
|
9495
|
+
poolSize
|
|
9496
|
+
} = {}) {
|
|
9497
|
+
const websocketBase = new import_common7.WebsocketStreamsBase({
|
|
9498
|
+
...this.configuration,
|
|
9499
|
+
...mode && { mode },
|
|
9500
|
+
...poolSize && { poolSize }
|
|
9501
|
+
});
|
|
9502
|
+
const websocketStreamsConnection = new WebsocketStreamsConnection(websocketBase);
|
|
9503
|
+
await websocketBase.connect(stream);
|
|
9504
|
+
return websocketStreamsConnection;
|
|
9505
|
+
}
|
|
9506
|
+
};
|
|
9507
|
+
|
|
9372
9508
|
// src/derivatives-trading-portfolio-margin.ts
|
|
9373
9509
|
var DerivativesTradingPortfolioMargin = class {
|
|
9374
9510
|
constructor(config) {
|
|
9511
|
+
const userAgent = (0, import_common8.buildUserAgent)(name, version);
|
|
9375
9512
|
if (config?.configurationRestAPI) {
|
|
9376
|
-
const configRestAPI = new
|
|
9377
|
-
|
|
9513
|
+
const configRestAPI = new import_common8.ConfigurationRestAPI(
|
|
9514
|
+
config.configurationRestAPI
|
|
9515
|
+
);
|
|
9516
|
+
configRestAPI.basePath = configRestAPI.basePath || import_common8.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL;
|
|
9378
9517
|
configRestAPI.baseOptions = configRestAPI.baseOptions || {};
|
|
9379
9518
|
configRestAPI.baseOptions.headers = {
|
|
9380
9519
|
...configRestAPI.baseOptions.headers || {},
|
|
9381
|
-
"User-Agent":
|
|
9520
|
+
"User-Agent": userAgent
|
|
9382
9521
|
};
|
|
9383
9522
|
this.restAPI = new RestAPI(configRestAPI);
|
|
9384
9523
|
}
|
|
9524
|
+
if (config?.configurationWebsocketStreams) {
|
|
9525
|
+
const configWebsocketStreams = new import_common8.ConfigurationWebsocketStreams(
|
|
9526
|
+
config.configurationWebsocketStreams
|
|
9527
|
+
);
|
|
9528
|
+
configWebsocketStreams.wsURL = configWebsocketStreams.wsURL || import_common8.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_PROD_URL;
|
|
9529
|
+
configWebsocketStreams.userAgent = userAgent;
|
|
9530
|
+
this.websocketStreams = new WebsocketStreams(configWebsocketStreams);
|
|
9531
|
+
}
|
|
9385
9532
|
}
|
|
9386
9533
|
};
|
|
9387
9534
|
|
|
9388
9535
|
// src/index.ts
|
|
9389
|
-
var
|
|
9536
|
+
var import_common9 = require("@binance/common");
|
|
9390
9537
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9391
9538
|
0 && (module.exports = {
|
|
9392
9539
|
BadRequestError,
|
|
9393
9540
|
ConnectorClientError,
|
|
9394
9541
|
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL,
|
|
9395
9542
|
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL,
|
|
9543
|
+
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_PROD_URL,
|
|
9544
|
+
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_WS_STREAMS_TESTNET_URL,
|
|
9396
9545
|
DerivativesTradingPortfolioMargin,
|
|
9397
9546
|
DerivativesTradingPortfolioMarginRestAPI,
|
|
9547
|
+
DerivativesTradingPortfolioMarginWebsocketStreams,
|
|
9398
9548
|
ForbiddenError,
|
|
9399
9549
|
NetworkError,
|
|
9400
9550
|
NotFoundError,
|