@binance/derivatives-trading-portfolio-margin 4.0.2 → 5.0.1
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 +111 -0
- package/dist/index.d.mts +1890 -365
- package/dist/index.d.ts +1890 -365
- package/dist/index.js +172 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +157 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -20,29 +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
|
|
44
|
+
var import_common8 = require("@binance/common");
|
|
42
45
|
|
|
43
46
|
// package.json
|
|
44
47
|
var name = "@binance/derivatives-trading-portfolio-margin";
|
|
45
|
-
var version = "
|
|
48
|
+
var version = "5.0.1";
|
|
46
49
|
|
|
47
50
|
// src/rest-api/index.ts
|
|
48
51
|
var rest_api_exports = {};
|
|
@@ -3151,6 +3154,8 @@ var TradeApiAxiosParamCreator = function(configuration) {
|
|
|
3151
3154
|
* `OrderId` can only be sent together with symbol
|
|
3152
3155
|
* If a `pair` is sent, tickers for all symbols of the `pair` will be returned
|
|
3153
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.
|
|
3154
3159
|
*
|
|
3155
3160
|
* Weight: 20 with symbol, 40 with pair
|
|
3156
3161
|
*
|
|
@@ -5257,8 +5262,8 @@ var TradeApiAxiosParamCreator = function(configuration) {
|
|
|
5257
5262
|
* Get trades for a specific account and UM symbol.
|
|
5258
5263
|
*
|
|
5259
5264
|
*
|
|
5260
|
-
* If `startTime` and `endTime` are both not sent, then the last '
|
|
5261
|
-
* 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.
|
|
5262
5267
|
* The parameter `fromId` cannot be sent with `startTime` or `endTime`.
|
|
5263
5268
|
*
|
|
5264
5269
|
* Weight: 5
|
|
@@ -5666,6 +5671,8 @@ var TradeApi = class {
|
|
|
5666
5671
|
* `OrderId` can only be sent together with symbol
|
|
5667
5672
|
* If a `pair` is sent, tickers for all symbols of the `pair` will be returned
|
|
5668
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.
|
|
5669
5676
|
*
|
|
5670
5677
|
* Weight: 20 with symbol, 40 with pair
|
|
5671
5678
|
*
|
|
@@ -7138,8 +7145,8 @@ var TradeApi = class {
|
|
|
7138
7145
|
* Get trades for a specific account and UM symbol.
|
|
7139
7146
|
*
|
|
7140
7147
|
*
|
|
7141
|
-
* If `startTime` and `endTime` are both not sent, then the last '
|
|
7142
|
-
* 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.
|
|
7143
7150
|
* The parameter `fromId` cannot be sent with `startTime` or `endTime`.
|
|
7144
7151
|
*
|
|
7145
7152
|
* Weight: 5
|
|
@@ -8501,6 +8508,8 @@ var RestAPI = class {
|
|
|
8501
8508
|
* `OrderId` can only be sent together with symbol
|
|
8502
8509
|
* If a `pair` is sent, tickers for all symbols of the `pair` will be returned
|
|
8503
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.
|
|
8504
8513
|
*
|
|
8505
8514
|
* Weight: 20 with symbol, 40 with pair
|
|
8506
8515
|
*
|
|
@@ -9291,8 +9300,8 @@ var RestAPI = class {
|
|
|
9291
9300
|
* Get trades for a specific account and UM symbol.
|
|
9292
9301
|
*
|
|
9293
9302
|
*
|
|
9294
|
-
* If `startTime` and `endTime` are both not sent, then the last '
|
|
9295
|
-
* 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.
|
|
9296
9305
|
* The parameter `fromId` cannot be sent with `startTime` or `endTime`.
|
|
9297
9306
|
*
|
|
9298
9307
|
* Weight: 5
|
|
@@ -9368,15 +9377,143 @@ var RestAPI = class {
|
|
|
9368
9377
|
}
|
|
9369
9378
|
};
|
|
9370
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
|
+
|
|
9371
9508
|
// src/derivatives-trading-portfolio-margin.ts
|
|
9372
9509
|
var DerivativesTradingPortfolioMargin = class {
|
|
9373
9510
|
constructor(config) {
|
|
9374
|
-
const userAgent = (0,
|
|
9511
|
+
const userAgent = (0, import_common8.buildUserAgent)(name, version);
|
|
9375
9512
|
if (config?.configurationRestAPI) {
|
|
9376
|
-
const configRestAPI = new
|
|
9513
|
+
const configRestAPI = new import_common8.ConfigurationRestAPI(
|
|
9377
9514
|
config.configurationRestAPI
|
|
9378
9515
|
);
|
|
9379
|
-
configRestAPI.basePath = configRestAPI.basePath ||
|
|
9516
|
+
configRestAPI.basePath = configRestAPI.basePath || import_common8.DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL;
|
|
9380
9517
|
configRestAPI.baseOptions = configRestAPI.baseOptions || {};
|
|
9381
9518
|
configRestAPI.baseOptions.headers = {
|
|
9382
9519
|
...configRestAPI.baseOptions.headers || {},
|
|
@@ -9384,19 +9521,30 @@ var DerivativesTradingPortfolioMargin = class {
|
|
|
9384
9521
|
};
|
|
9385
9522
|
this.restAPI = new RestAPI(configRestAPI);
|
|
9386
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
|
+
}
|
|
9387
9532
|
}
|
|
9388
9533
|
};
|
|
9389
9534
|
|
|
9390
9535
|
// src/index.ts
|
|
9391
|
-
var
|
|
9536
|
+
var import_common9 = require("@binance/common");
|
|
9392
9537
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9393
9538
|
0 && (module.exports = {
|
|
9394
9539
|
BadRequestError,
|
|
9395
9540
|
ConnectorClientError,
|
|
9396
9541
|
DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_PROD_URL,
|
|
9397
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,
|
|
9398
9545
|
DerivativesTradingPortfolioMargin,
|
|
9399
9546
|
DerivativesTradingPortfolioMarginRestAPI,
|
|
9547
|
+
DerivativesTradingPortfolioMarginWebsocketStreams,
|
|
9400
9548
|
ForbiddenError,
|
|
9401
9549
|
NetworkError,
|
|
9402
9550
|
NotFoundError,
|