@binance/derivatives-trading-portfolio-margin-pro 6.0.3 → 7.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 +83 -9
- package/dist/index.d.mts +277 -63
- package/dist/index.d.ts +277 -63
- package/dist/index.js +162 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +151 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
This is a client library for the Binance Derivatives Trading Portfolio Margin Pro API, enabling developers to interact programmatically with Binance's API to suit their derivative trading needs, through three distinct endpoints:
|
|
12
12
|
|
|
13
13
|
- [REST API](./src/rest-api/rest-api.ts)
|
|
14
|
+
- [Websocket Stream](./src/websocket-streams/websocket-streams-connection.ts)
|
|
14
15
|
|
|
15
16
|
## Table of Contents
|
|
16
17
|
|
|
@@ -18,6 +19,7 @@ This is a client library for the Binance Derivatives Trading Portfolio Margin Pr
|
|
|
18
19
|
- [Installation](#installation)
|
|
19
20
|
- [Documentation](#documentation)
|
|
20
21
|
- [REST APIs](#rest-apis)
|
|
22
|
+
- [Websocket Streams](#websocket-streams)
|
|
21
23
|
- [Testing](#testing)
|
|
22
24
|
- [Migration Guide](#migration-guide)
|
|
23
25
|
- [Contributing](#contributing)
|
|
@@ -139,22 +141,94 @@ The REST API provides detailed error types to help you handle issues effectively
|
|
|
139
141
|
|
|
140
142
|
See the [Error Handling example](./docs/rest-api/error-handling.md) for detailed usage.
|
|
141
143
|
|
|
142
|
-
|
|
144
|
+
If `basePath` is not provided, it defaults to `https://api.binance.com`.
|
|
145
|
+
|
|
146
|
+
### Websocket Streams
|
|
147
|
+
|
|
148
|
+
WebSocket Streams in `derivatives-trading-portfolio-margin-pro` is used for subscribing to user data streams. Use the [websocket-streams](./src/websocket-streams/websocket-streams.ts) module to interact with it.
|
|
149
|
+
|
|
150
|
+
#### Configuration Options
|
|
151
|
+
|
|
152
|
+
The WebSocket Streams API supports the following advanced configuration options:
|
|
143
153
|
|
|
144
|
-
|
|
154
|
+
- `reconnectDelay`: Specify the delay between reconnection attempts (default: 5000 ms).
|
|
155
|
+
- `compression`: Enable or disable compression for WebSocket messages (default: true).
|
|
156
|
+
- `agent`: Customize the WebSocket agent for advanced configurations.
|
|
157
|
+
- `mode`: Choose between `single` and `pool` connection modes.
|
|
158
|
+
- `single`: A single WebSocket connection.
|
|
159
|
+
- `pool`: A pool of WebSocket connections.
|
|
160
|
+
- `poolSize`: Define the number of WebSocket connections in pool mode.
|
|
161
|
+
|
|
162
|
+
#### Subscribe to User Data Streams
|
|
163
|
+
|
|
164
|
+
You can consume the user data stream, which sends account-level events such as account and order updates. First create a listen-key via REST API; then:
|
|
145
165
|
|
|
146
166
|
```typescript
|
|
147
|
-
import { DerivativesTradingPortfolioMarginPro,
|
|
167
|
+
import { DerivativesTradingPortfolioMarginPro, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL } from '@binance/derivatives-trading-portfolio-margin-pro';
|
|
148
168
|
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
apiSecret: 'your-api-secret',
|
|
152
|
-
basePath: DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL,
|
|
169
|
+
const configurationWebsocketStreams = {
|
|
170
|
+
wsURL: DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL,
|
|
153
171
|
};
|
|
154
|
-
const client = new DerivativesTradingPortfolioMarginPro({
|
|
172
|
+
const client = new DerivativesTradingPortfolioMarginPro({ configurationWebsocketStreams });
|
|
173
|
+
|
|
174
|
+
client.websocketStreams
|
|
175
|
+
.connect()
|
|
176
|
+
.then((connection) => {
|
|
177
|
+
const stream = connection.userData('listenKey');
|
|
178
|
+
stream.on('message', (data) => {
|
|
179
|
+
switch (data.e) {
|
|
180
|
+
case 'riskLevelChange':
|
|
181
|
+
console.log('risk level change stream', data);
|
|
182
|
+
break;
|
|
183
|
+
default:
|
|
184
|
+
console.log('unknown stream', data);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
})
|
|
189
|
+
.catch((err) => console.error(err));
|
|
155
190
|
```
|
|
156
191
|
|
|
157
|
-
|
|
192
|
+
#### Unsubscribing from Streams
|
|
193
|
+
|
|
194
|
+
You can unsubscribe from the user data streams using the `unsubscribe` method. This is useful for managing active subscriptions without closing the connection.
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
import { DerivativesTradingPortfolioMarginPro, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL } from '@binance/derivatives-trading-portfolio-margin-pro';
|
|
198
|
+
|
|
199
|
+
const configurationWebsocketStreams = {
|
|
200
|
+
wsURL: DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL,
|
|
201
|
+
};
|
|
202
|
+
const client = new DerivativesTradingPortfolioMarginPro({ configurationWebsocketStreams });
|
|
203
|
+
|
|
204
|
+
client.websocketStreams
|
|
205
|
+
.connect()
|
|
206
|
+
.then((connection) => {
|
|
207
|
+
const stream = connection.userData('listenKey');
|
|
208
|
+
stream.on('message', (data) => {
|
|
209
|
+
switch (data.e) {
|
|
210
|
+
case 'riskLevelChange':
|
|
211
|
+
console.log('risk level change stream', data);
|
|
212
|
+
break;
|
|
213
|
+
default:
|
|
214
|
+
console.log('unknown stream', data);
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
setTimeout(() => {
|
|
220
|
+
stream.unsubscribe();
|
|
221
|
+
console.log('Unsubscribed from user data streams');
|
|
222
|
+
}, 10000);
|
|
223
|
+
})
|
|
224
|
+
.catch((err) => console.error(err));
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
If `wsURL` is not provided, it defaults to `wss://fstream.binance.com/pm-classic`.
|
|
228
|
+
|
|
229
|
+
### Automatic Connection Renewal
|
|
230
|
+
|
|
231
|
+
The WebSocket connection is automatically renewed for both WebSocket API and WebSocket Streams connections, before the 24 hours expiration of the API key. This ensures continuous connectivity.
|
|
158
232
|
|
|
159
233
|
## Testing
|
|
160
234
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RestApiResponse, ConfigurationRestAPI } from '@binance/common';
|
|
2
|
-
export { BadRequestError, ConnectorClientError, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL, ForbiddenError, NetworkError, NotFoundError, RateLimitBanError, RequiredError, ServerError, TooManyRequestsError, UnauthorizedError } from '@binance/common';
|
|
1
|
+
import { RestApiResponse, ConfigurationRestAPI, WebsocketStreamsBase, WebsocketStream, ConfigurationWebsocketStreams } from '@binance/common';
|
|
2
|
+
export { BadRequestError, ConnectorClientError, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_REST_API_PROD_URL, DERIVATIVES_TRADING_PORTFOLIO_MARGIN_PRO_WS_STREAMS_PROD_URL, ForbiddenError, NetworkError, NotFoundError, RateLimitBanError, RequiredError, ServerError, TooManyRequestsError, UnauthorizedError } from '@binance/common';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Binance Derivatives Trading Portfolio Margin Pro REST API
|
|
@@ -1484,7 +1484,7 @@ interface MintBfusdForPortfolioMarginRequest {
|
|
|
1484
1484
|
*/
|
|
1485
1485
|
readonly fromAsset: string;
|
|
1486
1486
|
/**
|
|
1487
|
-
* `USDT`
|
|
1487
|
+
* `USDT` `USDC`
|
|
1488
1488
|
* @type {string}
|
|
1489
1489
|
* @memberof AccountApiMintBfusdForPortfolioMargin
|
|
1490
1490
|
*/
|
|
@@ -1616,7 +1616,7 @@ interface RedeemBfusdForPortfolioMarginRequest {
|
|
|
1616
1616
|
*/
|
|
1617
1617
|
readonly fromAsset: string;
|
|
1618
1618
|
/**
|
|
1619
|
-
* `USDT`
|
|
1619
|
+
* `USDT` `USDC`
|
|
1620
1620
|
* @type {string}
|
|
1621
1621
|
* @memberof AccountApiRedeemBfusdForPortfolioMargin
|
|
1622
1622
|
*/
|
|
@@ -2393,73 +2393,287 @@ declare class RestAPI {
|
|
|
2393
2393
|
* Do not edit the class manually.
|
|
2394
2394
|
*/
|
|
2395
2395
|
|
|
2396
|
-
type
|
|
2397
|
-
declare const
|
|
2398
|
-
type
|
|
2399
|
-
type
|
|
2400
|
-
type
|
|
2401
|
-
type
|
|
2402
|
-
type
|
|
2403
|
-
type
|
|
2404
|
-
type
|
|
2405
|
-
type
|
|
2406
|
-
type
|
|
2407
|
-
type
|
|
2408
|
-
type
|
|
2409
|
-
type
|
|
2410
|
-
type
|
|
2411
|
-
type
|
|
2412
|
-
type
|
|
2413
|
-
type
|
|
2414
|
-
type
|
|
2415
|
-
type
|
|
2416
|
-
type
|
|
2417
|
-
type
|
|
2418
|
-
type
|
|
2419
|
-
type
|
|
2420
|
-
type
|
|
2421
|
-
type
|
|
2422
|
-
declare const
|
|
2423
|
-
type
|
|
2424
|
-
type
|
|
2425
|
-
type
|
|
2426
|
-
type
|
|
2427
|
-
type
|
|
2428
|
-
type
|
|
2429
|
-
type
|
|
2430
|
-
type
|
|
2431
|
-
type
|
|
2432
|
-
type
|
|
2433
|
-
type
|
|
2434
|
-
type
|
|
2435
|
-
type
|
|
2436
|
-
type
|
|
2437
|
-
type
|
|
2438
|
-
type
|
|
2439
|
-
type
|
|
2440
|
-
type
|
|
2441
|
-
type
|
|
2442
|
-
type
|
|
2443
|
-
type
|
|
2444
|
-
type
|
|
2445
|
-
type
|
|
2446
|
-
type
|
|
2447
|
-
type
|
|
2448
|
-
type
|
|
2449
|
-
type
|
|
2450
|
-
declare const
|
|
2451
|
-
type
|
|
2452
|
-
type
|
|
2396
|
+
type index$1_AccountApi = AccountApi;
|
|
2397
|
+
declare const index$1_AccountApi: typeof AccountApi;
|
|
2398
|
+
type index$1_AccountApiInterface = AccountApiInterface;
|
|
2399
|
+
type index$1_BnbTransferRequest = BnbTransferRequest;
|
|
2400
|
+
type index$1_BnbTransferResponse = BnbTransferResponse;
|
|
2401
|
+
type index$1_ChangeAutoRepayFuturesStatusRequest = ChangeAutoRepayFuturesStatusRequest;
|
|
2402
|
+
type index$1_ChangeAutoRepayFuturesStatusResponse = ChangeAutoRepayFuturesStatusResponse;
|
|
2403
|
+
type index$1_FundAutoCollectionRequest = FundAutoCollectionRequest;
|
|
2404
|
+
type index$1_FundAutoCollectionResponse = FundAutoCollectionResponse;
|
|
2405
|
+
type index$1_FundCollectionByAssetRequest = FundCollectionByAssetRequest;
|
|
2406
|
+
type index$1_FundCollectionByAssetResponse = FundCollectionByAssetResponse;
|
|
2407
|
+
type index$1_GetAutoRepayFuturesStatusRequest = GetAutoRepayFuturesStatusRequest;
|
|
2408
|
+
type index$1_GetAutoRepayFuturesStatusResponse = GetAutoRepayFuturesStatusResponse;
|
|
2409
|
+
type index$1_GetPortfolioMarginAssetLeverageResponse = GetPortfolioMarginAssetLeverageResponse;
|
|
2410
|
+
type index$1_GetPortfolioMarginAssetLeverageResponseInner = GetPortfolioMarginAssetLeverageResponseInner;
|
|
2411
|
+
type index$1_GetPortfolioMarginProAccountBalanceRequest = GetPortfolioMarginProAccountBalanceRequest;
|
|
2412
|
+
type index$1_GetPortfolioMarginProAccountBalanceResponse = GetPortfolioMarginProAccountBalanceResponse;
|
|
2413
|
+
type index$1_GetPortfolioMarginProAccountBalanceResponseInner = GetPortfolioMarginProAccountBalanceResponseInner;
|
|
2414
|
+
type index$1_GetPortfolioMarginProAccountInfoRequest = GetPortfolioMarginProAccountInfoRequest;
|
|
2415
|
+
type index$1_GetPortfolioMarginProAccountInfoResponse = GetPortfolioMarginProAccountInfoResponse;
|
|
2416
|
+
type index$1_GetPortfolioMarginProSpanAccountInfoRequest = GetPortfolioMarginProSpanAccountInfoRequest;
|
|
2417
|
+
type index$1_GetPortfolioMarginProSpanAccountInfoResponse = GetPortfolioMarginProSpanAccountInfoResponse;
|
|
2418
|
+
type index$1_GetPortfolioMarginProSpanAccountInfoResponseRiskUnitMMListInner = GetPortfolioMarginProSpanAccountInfoResponseRiskUnitMMListInner;
|
|
2419
|
+
type index$1_GetTransferableEarnAssetBalanceForPortfolioMarginRequest = GetTransferableEarnAssetBalanceForPortfolioMarginRequest;
|
|
2420
|
+
type index$1_GetTransferableEarnAssetBalanceForPortfolioMarginResponse = GetTransferableEarnAssetBalanceForPortfolioMarginResponse;
|
|
2421
|
+
type index$1_MarketDataApi = MarketDataApi;
|
|
2422
|
+
declare const index$1_MarketDataApi: typeof MarketDataApi;
|
|
2423
|
+
type index$1_MarketDataApiInterface = MarketDataApiInterface;
|
|
2424
|
+
type index$1_MintBfusdForPortfolioMarginRequest = MintBfusdForPortfolioMarginRequest;
|
|
2425
|
+
type index$1_MintBfusdForPortfolioMarginResponse = MintBfusdForPortfolioMarginResponse;
|
|
2426
|
+
type index$1_PortfolioMarginCollateralRateResponse = PortfolioMarginCollateralRateResponse;
|
|
2427
|
+
type index$1_PortfolioMarginCollateralRateResponseInner = PortfolioMarginCollateralRateResponseInner;
|
|
2428
|
+
type index$1_PortfolioMarginProBankruptcyLoanRepayRequest = PortfolioMarginProBankruptcyLoanRepayRequest;
|
|
2429
|
+
type index$1_PortfolioMarginProBankruptcyLoanRepayResponse = PortfolioMarginProBankruptcyLoanRepayResponse;
|
|
2430
|
+
type index$1_PortfolioMarginProTieredCollateralRateRequest = PortfolioMarginProTieredCollateralRateRequest;
|
|
2431
|
+
type index$1_PortfolioMarginProTieredCollateralRateResponse = PortfolioMarginProTieredCollateralRateResponse;
|
|
2432
|
+
type index$1_PortfolioMarginProTieredCollateralRateResponseInner = PortfolioMarginProTieredCollateralRateResponseInner;
|
|
2433
|
+
type index$1_PortfolioMarginProTieredCollateralRateResponseInnerCollateralInfoInner = PortfolioMarginProTieredCollateralRateResponseInnerCollateralInfoInner;
|
|
2434
|
+
type index$1_QueryPortfolioMarginAssetIndexPriceRequest = QueryPortfolioMarginAssetIndexPriceRequest;
|
|
2435
|
+
type index$1_QueryPortfolioMarginAssetIndexPriceResponse = QueryPortfolioMarginAssetIndexPriceResponse;
|
|
2436
|
+
type index$1_QueryPortfolioMarginAssetIndexPriceResponseInner = QueryPortfolioMarginAssetIndexPriceResponseInner;
|
|
2437
|
+
type index$1_QueryPortfolioMarginProBankruptcyLoanAmountRequest = QueryPortfolioMarginProBankruptcyLoanAmountRequest;
|
|
2438
|
+
type index$1_QueryPortfolioMarginProBankruptcyLoanAmountResponse = QueryPortfolioMarginProBankruptcyLoanAmountResponse;
|
|
2439
|
+
type index$1_QueryPortfolioMarginProBankruptcyLoanRepayHistoryRequest = QueryPortfolioMarginProBankruptcyLoanRepayHistoryRequest;
|
|
2440
|
+
type index$1_QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponse = QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponse;
|
|
2441
|
+
type index$1_QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponseRowsInner = QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponseRowsInner;
|
|
2442
|
+
type index$1_QueryPortfolioMarginProNegativeBalanceInterestHistoryRequest = QueryPortfolioMarginProNegativeBalanceInterestHistoryRequest;
|
|
2443
|
+
type index$1_QueryPortfolioMarginProNegativeBalanceInterestHistoryResponse = QueryPortfolioMarginProNegativeBalanceInterestHistoryResponse;
|
|
2444
|
+
type index$1_QueryPortfolioMarginProNegativeBalanceInterestHistoryResponseInner = QueryPortfolioMarginProNegativeBalanceInterestHistoryResponseInner;
|
|
2445
|
+
type index$1_RedeemBfusdForPortfolioMarginRequest = RedeemBfusdForPortfolioMarginRequest;
|
|
2446
|
+
type index$1_RedeemBfusdForPortfolioMarginResponse = RedeemBfusdForPortfolioMarginResponse;
|
|
2447
|
+
type index$1_RepayFuturesNegativeBalanceRequest = RepayFuturesNegativeBalanceRequest;
|
|
2448
|
+
type index$1_RepayFuturesNegativeBalanceResponse = RepayFuturesNegativeBalanceResponse;
|
|
2449
|
+
type index$1_RestAPI = RestAPI;
|
|
2450
|
+
declare const index$1_RestAPI: typeof RestAPI;
|
|
2451
|
+
type index$1_TransferLdusdtForPortfolioMarginRequest = TransferLdusdtForPortfolioMarginRequest;
|
|
2452
|
+
type index$1_TransferLdusdtForPortfolioMarginResponse = TransferLdusdtForPortfolioMarginResponse;
|
|
2453
|
+
declare namespace index$1 {
|
|
2454
|
+
export { index$1_AccountApi as AccountApi, type index$1_AccountApiInterface as AccountApiInterface, type index$1_BnbTransferRequest as BnbTransferRequest, type index$1_BnbTransferResponse as BnbTransferResponse, type index$1_ChangeAutoRepayFuturesStatusRequest as ChangeAutoRepayFuturesStatusRequest, type index$1_ChangeAutoRepayFuturesStatusResponse as ChangeAutoRepayFuturesStatusResponse, type index$1_FundAutoCollectionRequest as FundAutoCollectionRequest, type index$1_FundAutoCollectionResponse as FundAutoCollectionResponse, type index$1_FundCollectionByAssetRequest as FundCollectionByAssetRequest, type index$1_FundCollectionByAssetResponse as FundCollectionByAssetResponse, type index$1_GetAutoRepayFuturesStatusRequest as GetAutoRepayFuturesStatusRequest, type index$1_GetAutoRepayFuturesStatusResponse as GetAutoRepayFuturesStatusResponse, type index$1_GetPortfolioMarginAssetLeverageResponse as GetPortfolioMarginAssetLeverageResponse, type index$1_GetPortfolioMarginAssetLeverageResponseInner as GetPortfolioMarginAssetLeverageResponseInner, type index$1_GetPortfolioMarginProAccountBalanceRequest as GetPortfolioMarginProAccountBalanceRequest, type index$1_GetPortfolioMarginProAccountBalanceResponse as GetPortfolioMarginProAccountBalanceResponse, type index$1_GetPortfolioMarginProAccountBalanceResponseInner as GetPortfolioMarginProAccountBalanceResponseInner, type index$1_GetPortfolioMarginProAccountInfoRequest as GetPortfolioMarginProAccountInfoRequest, type index$1_GetPortfolioMarginProAccountInfoResponse as GetPortfolioMarginProAccountInfoResponse, type index$1_GetPortfolioMarginProSpanAccountInfoRequest as GetPortfolioMarginProSpanAccountInfoRequest, type index$1_GetPortfolioMarginProSpanAccountInfoResponse as GetPortfolioMarginProSpanAccountInfoResponse, type index$1_GetPortfolioMarginProSpanAccountInfoResponseRiskUnitMMListInner as GetPortfolioMarginProSpanAccountInfoResponseRiskUnitMMListInner, type index$1_GetTransferableEarnAssetBalanceForPortfolioMarginRequest as GetTransferableEarnAssetBalanceForPortfolioMarginRequest, type index$1_GetTransferableEarnAssetBalanceForPortfolioMarginResponse as GetTransferableEarnAssetBalanceForPortfolioMarginResponse, index$1_MarketDataApi as MarketDataApi, type index$1_MarketDataApiInterface as MarketDataApiInterface, type index$1_MintBfusdForPortfolioMarginRequest as MintBfusdForPortfolioMarginRequest, type index$1_MintBfusdForPortfolioMarginResponse as MintBfusdForPortfolioMarginResponse, type index$1_PortfolioMarginCollateralRateResponse as PortfolioMarginCollateralRateResponse, type index$1_PortfolioMarginCollateralRateResponseInner as PortfolioMarginCollateralRateResponseInner, type index$1_PortfolioMarginProBankruptcyLoanRepayRequest as PortfolioMarginProBankruptcyLoanRepayRequest, type index$1_PortfolioMarginProBankruptcyLoanRepayResponse as PortfolioMarginProBankruptcyLoanRepayResponse, type index$1_PortfolioMarginProTieredCollateralRateRequest as PortfolioMarginProTieredCollateralRateRequest, type index$1_PortfolioMarginProTieredCollateralRateResponse as PortfolioMarginProTieredCollateralRateResponse, type index$1_PortfolioMarginProTieredCollateralRateResponseInner as PortfolioMarginProTieredCollateralRateResponseInner, type index$1_PortfolioMarginProTieredCollateralRateResponseInnerCollateralInfoInner as PortfolioMarginProTieredCollateralRateResponseInnerCollateralInfoInner, type index$1_QueryPortfolioMarginAssetIndexPriceRequest as QueryPortfolioMarginAssetIndexPriceRequest, type index$1_QueryPortfolioMarginAssetIndexPriceResponse as QueryPortfolioMarginAssetIndexPriceResponse, type index$1_QueryPortfolioMarginAssetIndexPriceResponseInner as QueryPortfolioMarginAssetIndexPriceResponseInner, type index$1_QueryPortfolioMarginProBankruptcyLoanAmountRequest as QueryPortfolioMarginProBankruptcyLoanAmountRequest, type index$1_QueryPortfolioMarginProBankruptcyLoanAmountResponse as QueryPortfolioMarginProBankruptcyLoanAmountResponse, type index$1_QueryPortfolioMarginProBankruptcyLoanRepayHistoryRequest as QueryPortfolioMarginProBankruptcyLoanRepayHistoryRequest, type index$1_QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponse as QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponse, type index$1_QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponseRowsInner as QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponseRowsInner, type index$1_QueryPortfolioMarginProNegativeBalanceInterestHistoryRequest as QueryPortfolioMarginProNegativeBalanceInterestHistoryRequest, type index$1_QueryPortfolioMarginProNegativeBalanceInterestHistoryResponse as QueryPortfolioMarginProNegativeBalanceInterestHistoryResponse, type index$1_QueryPortfolioMarginProNegativeBalanceInterestHistoryResponseInner as QueryPortfolioMarginProNegativeBalanceInterestHistoryResponseInner, type index$1_RedeemBfusdForPortfolioMarginRequest as RedeemBfusdForPortfolioMarginRequest, type index$1_RedeemBfusdForPortfolioMarginResponse as RedeemBfusdForPortfolioMarginResponse, type index$1_RepayFuturesNegativeBalanceRequest as RepayFuturesNegativeBalanceRequest, type index$1_RepayFuturesNegativeBalanceResponse as RepayFuturesNegativeBalanceResponse, index$1_RestAPI as RestAPI, type index$1_TransferLdusdtForPortfolioMarginRequest as TransferLdusdtForPortfolioMarginRequest, type index$1_TransferLdusdtForPortfolioMarginResponse as TransferLdusdtForPortfolioMarginResponse };
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
/**
|
|
2458
|
+
* Binance Derivatives Trading Portfolio Margin Pro WebSocket Market Streams
|
|
2459
|
+
*
|
|
2460
|
+
* OpenAPI Specification for the Binance Derivatives Trading Portfolio Margin Pro WebSocket Market Streams
|
|
2461
|
+
*
|
|
2462
|
+
* The version of the OpenAPI document: 1.0.0
|
|
2463
|
+
*
|
|
2464
|
+
*
|
|
2465
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
2466
|
+
* https://openapi-generator.tech
|
|
2467
|
+
* Do not edit the class manually.
|
|
2468
|
+
*/
|
|
2469
|
+
/**
|
|
2470
|
+
*
|
|
2471
|
+
* @export
|
|
2472
|
+
* @interface Risklevelchange
|
|
2473
|
+
*/
|
|
2474
|
+
interface Risklevelchange {
|
|
2475
|
+
/**
|
|
2476
|
+
*
|
|
2477
|
+
* @type {number}
|
|
2478
|
+
* @memberof Risklevelchange
|
|
2479
|
+
*/
|
|
2480
|
+
E?: number;
|
|
2481
|
+
/**
|
|
2482
|
+
*
|
|
2483
|
+
* @type {string}
|
|
2484
|
+
* @memberof Risklevelchange
|
|
2485
|
+
*/
|
|
2486
|
+
u?: string;
|
|
2487
|
+
/**
|
|
2488
|
+
*
|
|
2489
|
+
* @type {string}
|
|
2490
|
+
* @memberof Risklevelchange
|
|
2491
|
+
*/
|
|
2492
|
+
s?: string;
|
|
2493
|
+
/**
|
|
2494
|
+
*
|
|
2495
|
+
* @type {string}
|
|
2496
|
+
* @memberof Risklevelchange
|
|
2497
|
+
*/
|
|
2498
|
+
eq?: string;
|
|
2499
|
+
/**
|
|
2500
|
+
*
|
|
2501
|
+
* @type {string}
|
|
2502
|
+
* @memberof Risklevelchange
|
|
2503
|
+
*/
|
|
2504
|
+
ae?: string;
|
|
2505
|
+
/**
|
|
2506
|
+
*
|
|
2507
|
+
* @type {string}
|
|
2508
|
+
* @memberof Risklevelchange
|
|
2509
|
+
*/
|
|
2510
|
+
m?: string;
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
/**
|
|
2514
|
+
* Binance Derivatives Trading Portfolio Margin Pro WebSocket Market Streams
|
|
2515
|
+
*
|
|
2516
|
+
* OpenAPI Specification for the Binance Derivatives Trading Portfolio Margin Pro WebSocket Market Streams
|
|
2517
|
+
*
|
|
2518
|
+
* The version of the OpenAPI document: 1.0.0
|
|
2519
|
+
*
|
|
2520
|
+
*
|
|
2521
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
2522
|
+
* https://openapi-generator.tech
|
|
2523
|
+
* Do not edit the class manually.
|
|
2524
|
+
*/
|
|
2525
|
+
|
|
2526
|
+
/**
|
|
2527
|
+
* @type UserDataStreamEventsResponse
|
|
2528
|
+
* @export
|
|
2529
|
+
*/
|
|
2530
|
+
type UserDataStreamEventsResponse = {
|
|
2531
|
+
e: 'riskLevelChange';
|
|
2532
|
+
} & Risklevelchange;
|
|
2533
|
+
|
|
2534
|
+
/**
|
|
2535
|
+
* Binance Derivatives Trading Portfolio Margin Pro WebSocket Market Streams
|
|
2536
|
+
*
|
|
2537
|
+
* OpenAPI Specification for the Binance Derivatives Trading Portfolio Margin Pro WebSocket Market Streams
|
|
2538
|
+
*
|
|
2539
|
+
* The version of the OpenAPI document: 1.0.0
|
|
2540
|
+
*
|
|
2541
|
+
*
|
|
2542
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
2543
|
+
* https://openapi-generator.tech
|
|
2544
|
+
* Do not edit the class manually.
|
|
2545
|
+
*/
|
|
2546
|
+
|
|
2547
|
+
declare class WebsocketStreamsConnection {
|
|
2548
|
+
private websocketBase;
|
|
2549
|
+
constructor(websocketBase: WebsocketStreamsBase);
|
|
2550
|
+
/**
|
|
2551
|
+
* Adds an event listener for the specified WebSocket event.
|
|
2552
|
+
* @param event - The WebSocket event to listen for, such as 'open', 'message', 'error', 'close', 'ping', or 'pong'.
|
|
2553
|
+
* @param listener - The callback function to be executed when the event is triggered. The function can accept any number of arguments.
|
|
2554
|
+
*/
|
|
2555
|
+
on(event: 'open' | 'message' | 'error' | 'close' | 'ping' | 'pong', listener: (...args: any[]) => void): void;
|
|
2556
|
+
/**
|
|
2557
|
+
* Removes an event listener for the specified WebSocket event.
|
|
2558
|
+
* @param event - The WebSocket event to stop listening for, such as 'open', 'message', 'error', 'close', 'ping', or 'pong'.
|
|
2559
|
+
* @param listener - The callback function that was previously added as the event listener.
|
|
2560
|
+
*/
|
|
2561
|
+
off(event: 'open' | 'message' | 'error' | 'close' | 'ping' | 'pong', listener: (...args: any[]) => void): void;
|
|
2562
|
+
/**
|
|
2563
|
+
* Disconnects from the WebSocket server.
|
|
2564
|
+
* If there is no active connection, a warning is logged.
|
|
2565
|
+
* Otherwise, all connections in the connection pool are closed gracefully,
|
|
2566
|
+
* and a message is logged indicating that the connection has been disconnected.
|
|
2567
|
+
* @returns A Promise that resolves when all connections have been closed.
|
|
2568
|
+
* @throws Error if the WebSocket client is not set.
|
|
2569
|
+
*/
|
|
2570
|
+
disconnect(): Promise<void>;
|
|
2571
|
+
/**
|
|
2572
|
+
* Checks if the WebSocket connection is currently open.
|
|
2573
|
+
* @returns `true` if the connection is open, `false` otherwise.
|
|
2574
|
+
*/
|
|
2575
|
+
isConnected(): boolean;
|
|
2576
|
+
/**
|
|
2577
|
+
* Sends a ping message to all connected Websocket servers in the pool.
|
|
2578
|
+
* If no connections are ready, a warning is logged.
|
|
2579
|
+
* For each active connection, the ping message is sent, and debug logs provide details.
|
|
2580
|
+
* @throws Error if a Websocket client is not set for a connection.
|
|
2581
|
+
*/
|
|
2582
|
+
pingServer(): void;
|
|
2583
|
+
/**
|
|
2584
|
+
* Subscribes to one or multiple WebSocket streams
|
|
2585
|
+
* Handles both single and pool modes
|
|
2586
|
+
* @param stream Single stream name or array of stream names to subscribe to
|
|
2587
|
+
* @param id Optional subscription ID
|
|
2588
|
+
* @returns void
|
|
2589
|
+
*/
|
|
2590
|
+
subscribe(stream: string | string[], id?: string): void;
|
|
2591
|
+
/**
|
|
2592
|
+
* Unsubscribes from one or multiple WebSocket streams
|
|
2593
|
+
* Handles both single and pool modes
|
|
2594
|
+
* @param stream Single stream name or array of stream names to unsubscribe from
|
|
2595
|
+
* @param id Optional unsubscription ID
|
|
2596
|
+
* @returns void
|
|
2597
|
+
*/
|
|
2598
|
+
unsubscribe(stream: string | string[], id?: string): void;
|
|
2599
|
+
/**
|
|
2600
|
+
* Checks if the WebSocket connection is subscribed to the specified stream.
|
|
2601
|
+
* @param stream The name of the WebSocket stream to check.
|
|
2602
|
+
* @returns `true` if the connection is subscribed to the stream, `false` otherwise.
|
|
2603
|
+
*/
|
|
2604
|
+
isSubscribed(stream: string): boolean;
|
|
2605
|
+
/**
|
|
2606
|
+
* Subscribes to the user data WebSocket stream using the provided listen key.
|
|
2607
|
+
* @param listenKey - The listen key for the user data WebSocket stream.
|
|
2608
|
+
* @param id - Optional user data stream ID
|
|
2609
|
+
* @returns A WebSocket stream handler for the user data stream.
|
|
2610
|
+
*/
|
|
2611
|
+
userData(listenKey: string, id?: string): WebsocketStream<UserDataStreamEventsResponse>;
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
/**
|
|
2615
|
+
* Binance Derivatives Trading Portfolio Margin Pro WebSocket Market Streams
|
|
2616
|
+
*
|
|
2617
|
+
* OpenAPI Specification for the Binance Derivatives Trading Portfolio Margin Pro WebSocket Market Streams
|
|
2618
|
+
*
|
|
2619
|
+
* The version of the OpenAPI document: 1.0.0
|
|
2620
|
+
*
|
|
2621
|
+
*
|
|
2622
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
2623
|
+
* https://openapi-generator.tech
|
|
2624
|
+
* Do not edit the class manually.
|
|
2625
|
+
*/
|
|
2626
|
+
|
|
2627
|
+
declare class WebsocketStreams {
|
|
2628
|
+
private configuration;
|
|
2629
|
+
constructor(configuration: ConfigurationWebsocketStreams);
|
|
2630
|
+
/**
|
|
2631
|
+
* Connects to the Binance WebSocket streams and returns a `WebsocketStreamsConnection` instance.
|
|
2632
|
+
*
|
|
2633
|
+
* @param {object} [options] - Optional connection options.
|
|
2634
|
+
* @param {string|string[]} [options.stream] - The stream(s) to connect to.
|
|
2635
|
+
* @param {'single'|'pool'} [options.mode] - The connection mode, either 'single' or 'pool'. Overwrite the `mode` option in the configuration.
|
|
2636
|
+
* @param {number} [options.poolSize] - The number of connections to use in pool mode. Overwrite the `poolSize` option in the configuration.
|
|
2637
|
+
* @returns {Promise<WebsocketStreamsConnection>} - A promise that resolves to a `WebsocketStreamsConnection` instance.
|
|
2638
|
+
*/
|
|
2639
|
+
connect({ stream, mode, poolSize, }?: {
|
|
2640
|
+
stream?: string | string[];
|
|
2641
|
+
mode?: 'single' | 'pool';
|
|
2642
|
+
poolSize?: number;
|
|
2643
|
+
}): Promise<WebsocketStreamsConnection>;
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
/**
|
|
2647
|
+
* Binance Derivatives Trading Portfolio Margin Pro WebSocket Market Streams
|
|
2648
|
+
*
|
|
2649
|
+
* OpenAPI Specification for the Binance Derivatives Trading Portfolio Margin Pro WebSocket Market Streams
|
|
2650
|
+
*
|
|
2651
|
+
* The version of the OpenAPI document: 1.0.0
|
|
2652
|
+
*
|
|
2653
|
+
*
|
|
2654
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
2655
|
+
* https://openapi-generator.tech
|
|
2656
|
+
* Do not edit the class manually.
|
|
2657
|
+
*/
|
|
2658
|
+
|
|
2659
|
+
type index_Risklevelchange = Risklevelchange;
|
|
2660
|
+
type index_UserDataStreamEventsResponse = UserDataStreamEventsResponse;
|
|
2661
|
+
type index_WebsocketStreams = WebsocketStreams;
|
|
2662
|
+
declare const index_WebsocketStreams: typeof WebsocketStreams;
|
|
2663
|
+
type index_WebsocketStreamsConnection = WebsocketStreamsConnection;
|
|
2664
|
+
declare const index_WebsocketStreamsConnection: typeof WebsocketStreamsConnection;
|
|
2453
2665
|
declare namespace index {
|
|
2454
|
-
export {
|
|
2666
|
+
export { type index_Risklevelchange as Risklevelchange, type index_UserDataStreamEventsResponse as UserDataStreamEventsResponse, index_WebsocketStreams as WebsocketStreams, index_WebsocketStreamsConnection as WebsocketStreamsConnection };
|
|
2455
2667
|
}
|
|
2456
2668
|
|
|
2457
2669
|
interface ConfigurationDerivativesTradingPortfolioMarginPro {
|
|
2458
2670
|
configurationRestAPI?: ConfigurationRestAPI;
|
|
2671
|
+
configurationWebsocketStreams?: ConfigurationWebsocketStreams;
|
|
2459
2672
|
}
|
|
2460
2673
|
declare class DerivativesTradingPortfolioMarginPro {
|
|
2461
2674
|
restAPI: RestAPI;
|
|
2675
|
+
websocketStreams: WebsocketStreams;
|
|
2462
2676
|
constructor(config: ConfigurationDerivativesTradingPortfolioMarginPro);
|
|
2463
2677
|
}
|
|
2464
2678
|
|
|
2465
|
-
export { type ConfigurationDerivativesTradingPortfolioMarginPro, DerivativesTradingPortfolioMarginPro, index as DerivativesTradingPortfolioMarginProRestAPI };
|
|
2679
|
+
export { type ConfigurationDerivativesTradingPortfolioMarginPro, DerivativesTradingPortfolioMarginPro, index$1 as DerivativesTradingPortfolioMarginProRestAPI, index as DerivativesTradingPortfolioMarginProWebsocketStreams };
|