bybit-api 3.7.1-beta.0 → 3.7.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.
Files changed (69) hide show
  1. package/README.md +34 -6
  2. package/lib/rest-client-v5.d.ts +3 -3
  3. package/lib/rest-client-v5.js.map +1 -1
  4. package/lib/types/request/v5-trade.d.ts +2 -2
  5. package/package.json +1 -13
  6. package/src/account-asset-client-v3.ts +0 -310
  7. package/src/account-asset-client.ts +0 -149
  8. package/src/constants/enum.ts +0 -105
  9. package/src/contract-client.ts +0 -360
  10. package/src/copy-trading-client.ts +0 -159
  11. package/src/index.ts +0 -18
  12. package/src/inverse-client.ts +0 -337
  13. package/src/inverse-futures-client.ts +0 -403
  14. package/src/linear-client.ts +0 -387
  15. package/src/rest-client-v5.ts +0 -1638
  16. package/src/spot-client-v3.ts +0 -303
  17. package/src/spot-client.ts +0 -180
  18. package/src/types/index.ts +0 -5
  19. package/src/types/request/account-asset.ts +0 -258
  20. package/src/types/request/contract.ts +0 -139
  21. package/src/types/request/copy-trading.ts +0 -53
  22. package/src/types/request/index.ts +0 -18
  23. package/src/types/request/inverse.ts +0 -135
  24. package/src/types/request/linear.ts +0 -201
  25. package/src/types/request/spot.ts +0 -89
  26. package/src/types/request/unified-margin.ts +0 -247
  27. package/src/types/request/usdc-options.ts +0 -134
  28. package/src/types/request/usdc-perp.ts +0 -100
  29. package/src/types/request/usdc-shared.ts +0 -39
  30. package/src/types/request/v5-account.ts +0 -40
  31. package/src/types/request/v5-asset.ts +0 -133
  32. package/src/types/request/v5-market.ts +0 -127
  33. package/src/types/request/v5-position.ts +0 -107
  34. package/src/types/request/v5-pre-upgrade.ts +0 -37
  35. package/src/types/request/v5-spot-leverage-token.ts +0 -23
  36. package/src/types/request/v5-trade.ts +0 -133
  37. package/src/types/request/v5-user.ts +0 -21
  38. package/src/types/response/account-asset.ts +0 -236
  39. package/src/types/response/contract.ts +0 -74
  40. package/src/types/response/index.ts +0 -13
  41. package/src/types/response/shared.ts +0 -19
  42. package/src/types/response/spot.ts +0 -17
  43. package/src/types/response/unified-margin.ts +0 -71
  44. package/src/types/response/usdt-perp.ts +0 -58
  45. package/src/types/response/v5-account.ts +0 -122
  46. package/src/types/response/v5-asset.ts +0 -170
  47. package/src/types/response/v5-market.ts +0 -271
  48. package/src/types/response/v5-position.ts +0 -118
  49. package/src/types/response/v5-spot-leverage-token.ts +0 -70
  50. package/src/types/response/v5-trade.ts +0 -103
  51. package/src/types/response/v5-user.ts +0 -58
  52. package/src/types/shared.ts +0 -175
  53. package/src/types/v5-shared.ts +0 -213
  54. package/src/types/websockets.ts +0 -115
  55. package/src/types/ws-events/failed-topic-subscription-confirmation.ts +0 -6
  56. package/src/types/ws-events/succeeded-topic-subscription-confirmation.ts +0 -6
  57. package/src/types/ws-events/topic-subscription-confirmation.ts +0 -7
  58. package/src/unified-margin-client.ts +0 -400
  59. package/src/usdc-option-client.ts +0 -333
  60. package/src/usdc-perpetual-client.ts +0 -312
  61. package/src/util/BaseRestClient.ts +0 -502
  62. package/src/util/WsStore.ts +0 -160
  63. package/src/util/browser-support.ts +0 -29
  64. package/src/util/index.ts +0 -5
  65. package/src/util/logger.ts +0 -26
  66. package/src/util/node-support.ts +0 -9
  67. package/src/util/requestUtils.ts +0 -171
  68. package/src/util/websocket-util.ts +0 -550
  69. package/src/websocket-client.ts +0 -1262
@@ -1,70 +0,0 @@
1
- import {
2
- LTOrderStatusV5,
3
- LTOrderTypeV5,
4
- LeverageTokenStatusV5,
5
- } from '../v5-shared';
6
-
7
- export interface LeverageTokenInfoV5 {
8
- ltCoin: string;
9
- ltName: string;
10
- maxPurchase: string;
11
- minPurchase: string;
12
- maxPurchaseDaily: string;
13
- maxRedeem: string;
14
- minRedeem: string;
15
- maxRedeemDaily: string;
16
- purchaseFeeRate: string;
17
- redeemFeeRate: string;
18
- ltStatus: LeverageTokenStatusV5;
19
- fundFee: string;
20
- fundFeeTime: string;
21
- manageFeeRate: string;
22
- manageFeeTime: string;
23
- value: string;
24
- netValue: string;
25
- total: string;
26
- }
27
-
28
- export interface LeveragedTokenMarketResultV5 {
29
- ltCoin: string;
30
- nav: string;
31
- navTime: string;
32
- circulation: string;
33
- basket: string;
34
- leverage: string;
35
- }
36
-
37
- export interface PurchaseSpotLeveragedTokenResultV5 {
38
- ltCoin: string;
39
- ltOrderStatus: LTOrderStatusV5;
40
- execQty: string;
41
- execAmt: string;
42
- amount: string;
43
- purchaseId: string;
44
- serialNo: string;
45
- valueCoin: string;
46
- }
47
- export interface RedeemSpotLeveragedTokenResultV5 {
48
- ltCoin: string;
49
- ltOrderStatus: LTOrderStatusV5;
50
- quantity: string;
51
- execQty: string;
52
- execAmt: string;
53
- redeemId: string;
54
- serialNo: string;
55
- valueCoin: string;
56
- }
57
-
58
- export interface SpotLeveragedTokenOrderHistoryV5 {
59
- ltCoin: string;
60
- orderId: string;
61
- ltOrderType: LTOrderTypeV5;
62
- orderTime: number;
63
- updateTime: number;
64
- ltOrderStatus: LTOrderStatusV5;
65
- fee: string;
66
- amount: string;
67
- value: string;
68
- valueCoin: string;
69
- serialNo: string;
70
- }
@@ -1,103 +0,0 @@
1
- import {
2
- CategoryV5,
3
- OrderCancelTypeV5,
4
- OrderRejectReasonV5,
5
- OrderSideV5,
6
- OrderStatusV5,
7
- OrderTimeInForceV5,
8
- OrderTriggerByV5,
9
- OrderTypeV5,
10
- PositionIdx,
11
- StopOrderTypeV5,
12
- } from '../v5-shared';
13
-
14
- export interface OrderResultV5 {
15
- orderId: string;
16
- orderLinkId: string;
17
- }
18
-
19
- export interface AccountOrderV5 {
20
- orderId: string;
21
- orderLinkId?: string;
22
- blockTradeId?: string;
23
- symbol: string;
24
- price: string;
25
- qty: string;
26
- side: OrderSideV5;
27
- isLeverage?: string;
28
- positionIdx?: PositionIdx;
29
- orderStatus: OrderStatusV5;
30
- cancelType?: OrderCancelTypeV5;
31
- rejectReason?: OrderRejectReasonV5;
32
- avgPrice: string;
33
- leavesQty: string;
34
- leavesValue: string;
35
- cumExecQty: string;
36
- cumExecValue: string;
37
- cumExecFee: string;
38
- timeInForce?: OrderTimeInForceV5;
39
- orderType?: OrderTypeV5;
40
- stopOrderType?: StopOrderTypeV5;
41
- orderIv?: string;
42
- triggerPrice?: string;
43
- takeProfit?: string;
44
- stopLoss?: string;
45
- tpslMode: 'Full' | 'Partial' | '';
46
- tpLimitPrice: string;
47
- slLimitPrice: string;
48
- tpTriggerBy?: OrderTriggerByV5;
49
- slTriggerBy?: OrderTriggerByV5;
50
- triggerDirection?: number;
51
- triggerBy?: OrderTriggerByV5;
52
- lastPriceOnCreated?: string;
53
- reduceOnly?: boolean;
54
- closeOnTrigger?: boolean;
55
- placeType: 'iv' | 'price' | '';
56
- smpType: string;
57
- smpGroup: string;
58
- smpOrderId: string;
59
- createdTime: string;
60
- updatedTime: string;
61
- }
62
-
63
- export interface BatchCreateOrderResultV5 {
64
- category: CategoryV5;
65
- symbol: string;
66
- orderId: string;
67
- orderLinkId: string;
68
- createAt: string;
69
- }
70
-
71
- export interface BatchOrdersResponseV5<T extends unknown[]> {
72
- result: {
73
- list: T;
74
- };
75
- retExtInfo: {
76
- list: {
77
- code: number;
78
- msg: string;
79
- }[];
80
- };
81
- }
82
-
83
- export interface BatchAmendOrderResultV5 {
84
- category: CategoryV5;
85
- symbol: string;
86
- orderId: string;
87
- orderLinkId: string;
88
- }
89
-
90
- export interface BatchCancelOrderResultV5 {
91
- category: CategoryV5;
92
- symbol: string;
93
- orderId: string;
94
- orderLinkId: string;
95
- }
96
-
97
- export interface SpotBorrowCheckResultV5 {
98
- symbol: string;
99
- side: OrderSideV5;
100
- maxTradeQty: string;
101
- maxTradeAmount: string;
102
- borrowCoin: string;
103
- }
@@ -1,58 +0,0 @@
1
- import { PermissionsV5 } from '../v5-shared';
2
-
3
- export interface CreateSubMemberResultV5 {
4
- uid: string;
5
- username: string;
6
- memberType: number;
7
- status: number;
8
- remark: string;
9
- }
10
-
11
- export interface CreateSubApiKeyResultV5 {
12
- id: string;
13
- note: string;
14
- apiKey: string;
15
- readOnly: number;
16
- secret: string;
17
- permissions: PermissionsV5;
18
- }
19
-
20
- export interface SubMemberV5 {
21
- uid: string;
22
- username: string;
23
- memberType: number;
24
- status: number;
25
- remark: string;
26
- }
27
- export type ApiKeyType = 1 | 2;
28
-
29
- export interface ApiKeyInfoV5 {
30
- id: string;
31
- note: string;
32
- apiKey: string;
33
- readOnly: 0 | 1;
34
- secret: string;
35
- permissions: PermissionsV5;
36
- ips?: string[];
37
- type: 1 | 2;
38
- deadlineDay?: number;
39
- expiredAt?: string;
40
- createdAt: string;
41
- unified: 0 | 1;
42
- uta: 0 | 1;
43
- userID: number;
44
- inviterID: number;
45
- vipLevel?: string;
46
- mktMakerLevel?: string;
47
- affiliateID?: number;
48
- }
49
-
50
- export interface UpdateApiKeyResultV5 {
51
- id: string;
52
- note: string;
53
- apiKey: string;
54
- readOnly: 0 | 1;
55
- secret: string;
56
- permissions: PermissionsV5;
57
- ips: string[];
58
- }
@@ -1,175 +0,0 @@
1
- import { ContractClient } from '../contract-client';
2
- import { InverseClient } from '../inverse-client';
3
- import { LinearClient } from '../linear-client';
4
- import { RestClientV5 } from '../rest-client-v5';
5
- import { SpotClient } from '../spot-client';
6
- import { SpotClientV3 } from '../spot-client-v3';
7
- import { UnifiedMarginClient } from '../unified-margin-client';
8
- import { USDCOptionClient } from '../usdc-option-client';
9
- import { USDCPerpetualClient } from '../usdc-perpetual-client';
10
-
11
- export type RESTClient =
12
- | InverseClient
13
- | LinearClient
14
- | SpotClient
15
- | SpotClientV3
16
- | USDCOptionClient
17
- | USDCPerpetualClient
18
- | UnifiedMarginClient
19
- | ContractClient
20
- | RestClientV5;
21
-
22
- export type numberInString = string;
23
-
24
- export type OrderSide = 'Buy' | 'Sell';
25
-
26
- export type KlineInterval =
27
- | '1m'
28
- | '3m'
29
- | '5m'
30
- | '15m'
31
- | '30m'
32
- | '1h'
33
- | '2h'
34
- | '4h'
35
- | '6h'
36
- | '12h'
37
- | '1d'
38
- | '1w'
39
- | '1M';
40
-
41
- export type KlineIntervalV3 =
42
- | '1'
43
- | '3'
44
- | '5'
45
- | '15'
46
- | '30'
47
- | '60'
48
- | '120'
49
- | '240'
50
- | '360'
51
- | '720'
52
- | 'D'
53
- | 'W'
54
- | 'M';
55
-
56
- export interface APIResponse<T> {
57
- ret_code: number;
58
- ret_msg: 'OK' | string;
59
- ext_code: string | null;
60
- ext_info: string | null;
61
- result: T;
62
- }
63
-
64
- export interface APIResponseV3<T> {
65
- retCode: number;
66
- retMsg: 'OK' | string;
67
- result: T;
68
- }
69
-
70
- export interface APIResponseV3WithTime<T> {
71
- retCode: number;
72
- retMsg: 'OK' | string;
73
- result: T;
74
- time: number;
75
- }
76
-
77
- export interface APIResponseWithTime<T = {}> extends APIResponse<T> {
78
- /** UTC timestamp */
79
- time_now: numberInString;
80
- }
81
-
82
- /**
83
- * Request Parameter Types
84
- */
85
- export interface SymbolParam {
86
- symbol: string;
87
- }
88
-
89
- export interface SymbolLimitParam<TLimit = number> {
90
- symbol: string;
91
- limit?: TLimit;
92
- }
93
-
94
- export interface SymbolPeriodLimitParam<TLimit = number> {
95
- symbol: string;
96
- period: string;
97
- limit?: TLimit;
98
- }
99
-
100
- export interface SymbolFromLimitParam {
101
- symbol: string;
102
- from?: number;
103
- limit?: number;
104
- }
105
-
106
- export interface SymbolIntervalFromLimitParam {
107
- symbol: string;
108
- interval: string;
109
- from: number;
110
- limit?: number;
111
- }
112
-
113
- export interface CoinParam {
114
- coin: string;
115
- }
116
-
117
- export interface WalletFundRecordsReq {
118
- start_date?: string;
119
- end_date?: string;
120
- currency?: string;
121
- coin?: string;
122
- wallet_fund_type?: string;
123
- page?: number;
124
- limit?: number;
125
- }
126
-
127
- export interface WithdrawRecordsReq {
128
- start_date?: string;
129
- end_date?: string;
130
- coin?: string;
131
- status?: string;
132
- page?: number;
133
- limit?: number;
134
- }
135
-
136
- export interface AssetExchangeRecordsReq {
137
- limit?: number;
138
- from?: number;
139
- direction?: string;
140
- }
141
-
142
- /**
143
- * Response types
144
- */
145
-
146
- export interface LeverageFilter {
147
- min_leverage: numberInString;
148
- max_leverage: numberInString;
149
- leverage_step: numberInString;
150
- }
151
- export interface PriceFilter {
152
- min_price: numberInString;
153
- max_price: numberInString;
154
- tick_size: numberInString;
155
- }
156
-
157
- export interface LotSizeFilter {
158
- max_trading_qty: number;
159
- min_trading_qty: number;
160
- qty_step: number;
161
- }
162
-
163
- export interface SymbolInfo {
164
- name: string;
165
- alias: string;
166
- status: 'Trading' | string;
167
- base_currency: string;
168
- quote_currency: string;
169
- price_scale: number;
170
- taker_fee: numberInString;
171
- maker_fee: numberInString;
172
- leverage_filter: LeverageFilter;
173
- price_filter: PriceFilter;
174
- lot_size_filter: LotSizeFilter;
175
- }
@@ -1,213 +0,0 @@
1
- export type CategoryV5 = 'spot' | 'linear' | 'inverse' | 'option';
2
- export type ContractTypeV5 =
3
- | 'InversePerpetual'
4
- | 'LinearPerpetual'
5
- | 'InverseFutures';
6
-
7
- export type InstrumentStatusV5 =
8
- | 'PreLaunch'
9
- | 'Trading'
10
- | 'Settling'
11
- | 'Delivering'
12
- | 'Closed';
13
-
14
- export type OrderFilterV5 = 'Order' | 'tpslOrder';
15
- export type OrderSideV5 = 'Buy' | 'Sell';
16
- export type OrderTypeV5 = 'Market' | 'Limit';
17
- export type OrderTimeInForceV5 = 'GTC' | 'IOC' | 'FOK' | 'PostOnly';
18
- export type OrderTriggerByV5 = 'LastPrice' | 'IndexPrice' | 'MarkPrice';
19
-
20
- export type OrderSMPTypeV5 =
21
- | 'None'
22
- | 'CancelMaker'
23
- | 'CancelTaker'
24
- | 'CancelBoth';
25
-
26
- export type OrderStatusV5 =
27
- | 'Created'
28
- | 'New'
29
- | 'Rejected'
30
- | 'PartiallyFilled'
31
- | 'PartiallyFilledCanceled'
32
- | 'Filled'
33
- | 'Cancelled'
34
- | 'Untriggered'
35
- | 'Triggered'
36
- | 'Deactivated'
37
- | 'Active';
38
-
39
- export type OrderCancelTypeV5 =
40
- | 'CancelByUser'
41
- | 'CancelByReduceOnly'
42
- | 'CancelByPrepareLiq'
43
- | 'CancelAllBeforeLiq'
44
- | 'CancelByPrepareAdl'
45
- | 'CancelAllBeforeAdl'
46
- | 'CancelByAdmin'
47
- | 'CancelByTpSlTsClear'
48
- | 'CancelByPzSideCh';
49
-
50
- export type OrderRejectReasonV5 =
51
- | 'EC_NoError'
52
- | 'EC_Others'
53
- | 'EC_UnknownMessageType'
54
- | 'EC_MissingClOrdID'
55
- | 'EC_MissingOrigClOrdID'
56
- | 'EC_ClOrdIDOrigClOrdIDAreTheSame'
57
- | 'EC_DuplicatedClOrdID'
58
- | 'EC_OrigClOrdIDDoesNotExist'
59
- | 'EC_TooLateToCancel'
60
- | 'EC_UnknownOrderType'
61
- | 'EC_UnknownSide'
62
- | 'EC_UnknownTimeInForce'
63
- | 'EC_WronglyRouted'
64
- | 'EC_MarketOrderPriceIsNotZero'
65
- | 'EC_LimitOrderInvalidPrice'
66
- | 'EC_NoEnoughQtyToFill'
67
- | 'EC_NoImmediateQtyToFill'
68
- | 'EC_PerCancelRequest'
69
- | 'EC_MarketOrderCannotBePostOnly'
70
- | 'EC_PostOnlyWillTakeLiquidity'
71
- | 'EC_CancelReplaceOrder'
72
- | 'EC_InvalidSymbolStatus';
73
-
74
- export type StopOrderTypeV5 =
75
- | 'TakeProfit'
76
- | 'StopLoss'
77
- | 'TrailingStop'
78
- | 'Stop'
79
- | 'PartialTakeProfit'
80
- | 'PartialStopLoss'
81
- | 'tpslOrder';
82
-
83
- /**
84
- * Position index. Used to identify positions in different position modes.
85
- *
86
- * - 0 one-way mode position
87
- * - 1 Buy side of hedge-mode position
88
- * - 2 Sell side of hedge-mode position
89
- */
90
- export type PositionIdx = 0 | 1 | 2;
91
-
92
- export type OptionTypeV5 = 'Call' | 'Put';
93
-
94
- /**
95
- * Trade mode.
96
- *
97
- * - 0 cross-margin,
98
- * - 1 isolated margin
99
- */
100
- export type TradeModeV5 = 0 | 1;
101
-
102
- export type TPSLModeV5 = 'Full' | 'Partial';
103
- export type AccountMarginModeV5 = 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN';
104
- export type UnifiedUpdateStatusV5 = 'FAIL' | 'PROCESS' | 'SUCCESS';
105
-
106
- export type AccountTypeV5 =
107
- | 'CONTRACT'
108
- | 'SPOT'
109
- | 'INVESTMENT'
110
- | 'OPTION'
111
- | 'UNIFIED'
112
- | 'FUND';
113
-
114
- export type TransactionTypeV5 =
115
- | 'TRANSFER_IN'
116
- | 'TRANSFER_OUT'
117
- | 'TRADE'
118
- | 'SETTLEMENT'
119
- | 'DELIVERY'
120
- | 'LIQUIDATION'
121
- | 'BONUS'
122
- | 'FEE_REFUND'
123
- | 'INTEREST'
124
- | 'CURRENCY_BUY'
125
- | 'CURRENCY_SELL';
126
-
127
- export type PermissionTypeV5 =
128
- | 'ContractTrade'
129
- | 'Spot'
130
- | 'Wallet'
131
- | 'Options'
132
- | 'Derivatives'
133
- | 'Exchange'
134
- | 'NFT';
135
-
136
- /**
137
- * Leveraged token status:
138
- *
139
- * - '1' LT can be purchased and redeemed
140
- * - '2' LT can be purchased, but not redeemed
141
- * - '3' LT can be redeemed, but not purchased
142
- * - '4' LT cannot be purchased nor redeemed
143
- * - '5' Adjusting position
144
- */
145
- export type LeverageTokenStatusV5 = '1' | '2' | '3' | '4' | '5';
146
-
147
- /**
148
- * Leveraged token order type: '1': purchase, '2': redeem
149
- */
150
- export type LTOrderTypeV5 = '1' | '2';
151
-
152
- /**
153
- * Leveraged token order status: '1': completed, '2': in progress, '3': failed
154
- */
155
- export type LTOrderStatusV5 = '1' | '2' | '3';
156
-
157
- export type ExecTypeV5 =
158
- | 'Trade'
159
- | 'AdlTrade'
160
- | 'Funding'
161
- | 'BustTrade'
162
- | 'Settle';
163
-
164
- /**
165
- * Withdraw type. 0(default): on chain. 1: off chain. 2: all.
166
- */
167
- export type WithdrawalTypeV5 = '0' | '1' | '2';
168
-
169
- export interface PermissionsV5 {
170
- ContractTrade?: string[];
171
- Spot?: string[];
172
- Wallet?: string[];
173
- Options?: string[];
174
- Derivatives?: string[];
175
- CopyTrading?: string[];
176
- BlockTrade?: string[];
177
- Exchange?: string[];
178
- NFT?: string[];
179
- }
180
-
181
- export interface CategoryCursorListV5<
182
- T extends unknown[],
183
- TCategory extends CategoryV5 = CategoryV5,
184
- > {
185
- category: TCategory;
186
- list: T;
187
- nextPageCursor?: string;
188
- }
189
-
190
- /**
191
- * Next page cursor does not exist for spot!
192
- */
193
- export interface CursorListV5<T extends unknown[]> {
194
- nextPageCursor: string;
195
- list: T;
196
- }
197
-
198
- export interface CategoryListV5<
199
- T extends unknown[],
200
- TCategory extends CategoryV5,
201
- > {
202
- category: TCategory;
203
- list: T;
204
- }
205
-
206
- export interface CategorySymbolListV5<
207
- T extends unknown[],
208
- TCategory extends CategoryV5,
209
- > {
210
- category: TCategory;
211
- symbol: string;
212
- list: T;
213
- }