bybit-connector-ruby 0.1.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.
@@ -0,0 +1,638 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bybit
4
+ module RestApi
5
+ class AssetService < BaseService
6
+ # Get Coin Balance
7
+ #
8
+ # GET /v5/asset/transfer/query-account-coins-balance
9
+ #
10
+ # @param account_type [String] Account type
11
+ # @option kwargs [String] :member_id User ID. Required when querying sub UID balance with master API key
12
+ # @option kwargs [String] :coin Coin name(s). Multiple coins separated by comma. If not passed, returns all coins
13
+ # @option kwargs [Integer] :with_bonus 0(default): not include bonus; 1: include bonus
14
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
15
+ def get_coin_balance(account_type:, **kwargs)
16
+ params = kwargs.merge(account_type: account_type)
17
+ params = Bybit::Utils::WireKeys.camelize(params)
18
+ @session.sign_request(method: :get, path: '/v5/asset/transfer/query-account-coins-balance', params: params)
19
+ end
20
+
21
+ # Get Coin Greeks
22
+ #
23
+ # GET /v5/asset/coin-greeks
24
+ #
25
+ # @option kwargs [String] :base_coin Base coin. Default: return all your coins greek data
26
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
27
+ def get_coin_greeks(**kwargs)
28
+ params = kwargs.dup
29
+ params = Bybit::Utils::WireKeys.camelize(params)
30
+ @session.sign_request(method: :get, path: '/v5/asset/coin-greeks', params: params)
31
+ end
32
+
33
+ # Get Funding History
34
+ #
35
+ # GET /v5/asset/fundinghistory
36
+ #
37
+ # @option kwargs [String] :create_time_from Start timestamp (ms)
38
+ # @option kwargs [String] :create_time_to End timestamp (ms)
39
+ # @option kwargs [String] :limit Limit for data size per page. [1, 50]. Default: 20
40
+ # @option kwargs [String] :cursor Cursor. Used for pagination
41
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
42
+ def list_funding_history(**kwargs)
43
+ params = kwargs.dup
44
+ params = Bybit::Utils::WireKeys.camelize(params)
45
+ @session.sign_request(method: :get, path: '/v5/asset/fundinghistory', params: params)
46
+ end
47
+
48
+ # Get Coin Info
49
+ #
50
+ # GET /v5/asset/coin/query-info
51
+ #
52
+ # @option kwargs [String] :coin Coin name, uppercase only. e.g. BTC, ETH. If not passed, return all coin info.
53
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
54
+ # @see https://bybit-exchange.github.io/docs/v5/asset/coin/query-info
55
+ def get_coin_info(**kwargs)
56
+ params = kwargs.dup
57
+ params = Bybit::Utils::WireKeys.camelize(params)
58
+ @session.sign_request(method: :get, path: '/v5/asset/coin/query-info', params: params)
59
+ end
60
+
61
+ # Get Deposit Records (on-chain)
62
+ #
63
+ # GET /v5/asset/deposit/query-record
64
+ #
65
+ # @option kwargs [String] :id Internal ID. Takes highest priority when combined with other params.
66
+ # @option kwargs [String] :tx_id Transaction ID. Only works for data from Jan 1, 2024 onward.
67
+ # @option kwargs [String] :coin Coin symbol (uppercase only), e.g. `BTC`, `USDT`. Empty means query all coins.
68
+ # @option kwargs [Integer] :start_time Start timestamp in milliseconds. Defaults to 30 days ago if not provided.
69
+ # @option kwargs [Integer] :end_time End timestamp in milliseconds. Defaults to current time if not provided.
70
+ # @option kwargs [Integer] :limit Records per page. Range `[1, 50]`, default `50`.
71
+ # @option kwargs [String] :cursor Pagination cursor from `nextPageCursor` in prior response.
72
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
73
+ # @see https://bybit-exchange.github.io/docs/v5/asset/deposit/query-record
74
+ def list_deposit_records(**kwargs)
75
+ params = kwargs.dup
76
+ params = Bybit::Utils::WireKeys.camelize(params)
77
+ @session.sign_request(method: :get, path: '/v5/asset/deposit/query-record', params: params)
78
+ end
79
+
80
+ # Get Master Deposit Address
81
+ #
82
+ # GET /v5/asset/deposit/query-address
83
+ #
84
+ # @param coin [String] Coin symbol (uppercase only), e.g. `USDT`.
85
+ # @option kwargs [String] :chain_type Chain type. Use `chain` value from the coin-info endpoint. If not provided, returns all chains.
86
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
87
+ # @see https://bybit-exchange.github.io/docs/v5/asset/deposit/query-address
88
+ def get_deposit_address(coin:, **kwargs)
89
+ params = kwargs.merge(coin: coin)
90
+ params = Bybit::Utils::WireKeys.camelize(params)
91
+ @session.sign_request(method: :get, path: '/v5/asset/deposit/query-address', params: params)
92
+ end
93
+
94
+ # Get Sub Deposit Address
95
+ #
96
+ # GET /v5/asset/deposit/query-sub-member-address
97
+ #
98
+ # @param coin [String] Coin symbol (uppercase only).
99
+ # @param chain_type [String] Chain type. Use `chain` value from the coin-info endpoint.
100
+ # @param sub_member_id [String] Sub-account user ID.
101
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
102
+ # @see https://bybit-exchange.github.io/docs/v5/asset/deposit/query-sub-member-address
103
+ def get_sub_member_deposit_address(coin:, chain_type:, sub_member_id:, **kwargs)
104
+ params = kwargs.merge(coin: coin, chain_type: chain_type, sub_member_id: sub_member_id)
105
+ params = Bybit::Utils::WireKeys.camelize(params)
106
+ @session.sign_request(method: :get, path: '/v5/asset/deposit/query-sub-member-address', params: params)
107
+ end
108
+
109
+ # Get Sub Deposit Records (on-chain)
110
+ #
111
+ # GET /v5/asset/deposit/query-sub-member-record
112
+ #
113
+ # @param sub_member_id [String] Sub-account UID.
114
+ # @option kwargs [String] :id Internal ID. Takes highest priority when combined with other params.
115
+ # @option kwargs [String] :tx_id Transaction ID (data before Jan 1, 2024 not queryable via txID).
116
+ # @option kwargs [String] :coin Coin symbol (uppercase only). Empty means query all.
117
+ # @option kwargs [Integer] :start_time Start timestamp in milliseconds. Defaults to 30 days ago.
118
+ # @option kwargs [Integer] :end_time End timestamp in milliseconds. Defaults to current time.
119
+ # @option kwargs [Integer] :limit Records per page. Range `[1, 50]`, default `50`.
120
+ # @option kwargs [String] :cursor Pagination cursor from `nextPageCursor`.
121
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
122
+ # @see https://bybit-exchange.github.io/docs/v5/asset/deposit/query-sub-member-record
123
+ def list_sub_member_deposit_records(sub_member_id:, **kwargs)
124
+ params = kwargs.merge(sub_member_id: sub_member_id)
125
+ params = Bybit::Utils::WireKeys.camelize(params)
126
+ @session.sign_request(method: :get, path: '/v5/asset/deposit/query-sub-member-record', params: params)
127
+ end
128
+
129
+ # Get Internal Deposit Records (off-chain)
130
+ #
131
+ # GET /v5/asset/deposit/query-internal-record
132
+ #
133
+ # @option kwargs [String] :tx_id Internal transfer transaction ID.
134
+ # @option kwargs [Integer] :start_time Start timestamp in milliseconds. Defaults to 30 days ago.
135
+ # @option kwargs [Integer] :end_time End timestamp in milliseconds. Defaults to current time.
136
+ # @option kwargs [String] :coin Coin symbol (uppercase only). Empty means query all.
137
+ # @option kwargs [String] :cursor Pagination cursor.
138
+ # @option kwargs [Integer] :limit Records per page. Range `[1, 50]`, default `50`.
139
+ # @option kwargs [String] :status Filter by status. `0` = all (default).
140
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
141
+ # @see https://bybit-exchange.github.io/docs/v5/asset/deposit/query-internal-record
142
+ def list_internal_deposit_records(**kwargs)
143
+ params = kwargs.dup
144
+ params = Bybit::Utils::WireKeys.camelize(params)
145
+ @session.sign_request(method: :get, path: '/v5/asset/deposit/query-internal-record', params: params)
146
+ end
147
+
148
+ # Set Deposit Account
149
+ #
150
+ # POST /v5/asset/deposit/deposit-to-account
151
+ #
152
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
153
+ # @see https://bybit-exchange.github.io/docs/v5/asset/deposit/deposit-to-account
154
+ def set_default_deposit_to_account(**kwargs)
155
+ params = kwargs.dup
156
+ params = Bybit::Utils::WireKeys.camelize(params)
157
+ @session.sign_request(method: :post, path: '/v5/asset/deposit/deposit-to-account', body: params)
158
+ end
159
+
160
+ # Create Internal Transfer
161
+ #
162
+ # POST /v5/asset/transfer/inter-transfer
163
+ #
164
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
165
+ # @see https://bybit-exchange.github.io/docs/v5/asset/transfer/inter-transfer
166
+ def inter_transfer(**kwargs)
167
+ params = kwargs.dup
168
+ params = Bybit::Utils::WireKeys.camelize(params)
169
+ @session.sign_request(method: :post, path: '/v5/asset/transfer/inter-transfer', body: params)
170
+ end
171
+
172
+ # Create Universal Transfer
173
+ #
174
+ # POST /v5/asset/transfer/universal-transfer
175
+ #
176
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
177
+ # @see https://bybit-exchange.github.io/docs/v5/asset/transfer/universal-transfer
178
+ def universal_transfer(**kwargs)
179
+ params = kwargs.dup
180
+ params = Bybit::Utils::WireKeys.camelize(params)
181
+ @session.sign_request(method: :post, path: '/v5/asset/transfer/universal-transfer', body: params)
182
+ end
183
+
184
+ # Save Transferable Sub Member List
185
+ #
186
+ # POST /v5/asset/transfer/save-transfer-sub-member
187
+ #
188
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
189
+ # @see https://bybit-exchange.github.io/docs/v5/asset/transfer/save-transfer-sub-member
190
+ def transfer_sub_member_save(**kwargs)
191
+ params = kwargs.dup
192
+ params = Bybit::Utils::WireKeys.camelize(params)
193
+ @session.sign_request(method: :post, path: '/v5/asset/transfer/save-transfer-sub-member', body: params)
194
+ end
195
+
196
+ # Get Internal Transfer Records
197
+ #
198
+ # GET /v5/asset/transfer/query-inter-transfer-list
199
+ #
200
+ # @option kwargs [String] :transfer_id UUID of the transfer. If provided, queries a single record by transferId.
201
+ # @option kwargs [String] :coin Coin name, uppercase (e.g. BTC, USDT)
202
+ # @option kwargs [String] :status Filter by transfer status
203
+ # @option kwargs [Integer] :start_time Start timestamp in milliseconds (effective at second level)
204
+ # @option kwargs [Integer] :end_time End timestamp in milliseconds (effective at second level)
205
+ # @option kwargs [Integer] :limit Number of records per page. Default: 20, Range: [1, 50]
206
+ # @option kwargs [String] :cursor Pagination cursor from `nextPageCursor` of previous response
207
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
208
+ # @see https://bybit-exchange.github.io/docs/v5/asset/transfer/query-inter-transfer-list
209
+ def inter_transfer_list_query(**kwargs)
210
+ params = kwargs.dup
211
+ params = Bybit::Utils::WireKeys.camelize(params)
212
+ @session.sign_request(method: :get, path: '/v5/asset/transfer/query-inter-transfer-list', params: params)
213
+ end
214
+
215
+ # Get Universal Transfer Records
216
+ #
217
+ # GET /v5/asset/transfer/query-universal-transfer-list
218
+ #
219
+ # @option kwargs [String] :transfer_id UUID of the transfer
220
+ # @option kwargs [String] :coin Coin name, uppercase
221
+ # @option kwargs [String] :status Filter by transfer status: SUCCESS, FAILED, PENDING
222
+ # @option kwargs [Integer] :start_time Start timestamp in milliseconds (effective at second level)
223
+ # @option kwargs [Integer] :end_time End timestamp in milliseconds (effective at second level)
224
+ # @option kwargs [Integer] :limit Number of records per page. Default: 20, Range: [1, 50]
225
+ # @option kwargs [String] :cursor Pagination cursor from `nextPageCursor`
226
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
227
+ # @see https://bybit-exchange.github.io/docs/v5/asset/transfer/query-universal-transfer-list
228
+ def universal_transfer_list_query(**kwargs)
229
+ params = kwargs.dup
230
+ params = Bybit::Utils::WireKeys.camelize(params)
231
+ @session.sign_request(method: :get, path: '/v5/asset/transfer/query-universal-transfer-list', params: params)
232
+ end
233
+
234
+ # Get Transferable Coin List
235
+ #
236
+ # GET /v5/asset/transfer/query-transfer-coin-list
237
+ #
238
+ # @param from_account_type [String] Source account type
239
+ # @param to_account_type [String] Destination account type
240
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
241
+ # @see https://bybit-exchange.github.io/docs/v5/asset/transfer/query-transfer-coin-list
242
+ def transfer_coin_list_query(from_account_type:, to_account_type:, **kwargs)
243
+ params = kwargs.merge(from_account_type: from_account_type, to_account_type: to_account_type)
244
+ params = Bybit::Utils::WireKeys.camelize(params)
245
+ @session.sign_request(method: :get, path: '/v5/asset/transfer/query-transfer-coin-list', params: params)
246
+ end
247
+
248
+ # Get Sub UID List
249
+ #
250
+ # GET /v5/asset/transfer/query-sub-member-list
251
+ #
252
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
253
+ # @see https://bybit-exchange.github.io/docs/v5/asset/transfer/query-sub-member-list
254
+ def sub_member_list_query(**kwargs)
255
+ params = kwargs.dup
256
+ params = Bybit::Utils::WireKeys.camelize(params)
257
+ @session.sign_request(method: :get, path: '/v5/asset/transfer/query-sub-member-list', params: params)
258
+ end
259
+
260
+ # Get Single Coin Balance
261
+ #
262
+ # GET /v5/asset/transfer/query-account-coin-balance
263
+ #
264
+ # @param account_type [String] Account type
265
+ # @param coin [String] Coin name, uppercase (e.g. USDT, BTC). Required.
266
+ # @option kwargs [Integer] :member_id UID. Required when querying sub UID balance with master API key
267
+ # @option kwargs [Integer] :to_member_id Target UID. Required for cross-UID transferable balance query
268
+ # @option kwargs [String] :to_account_type Destination account type. Required when `withLtvTransferSafeAmount=1`
269
+ # @option kwargs [Integer] :with_bonus `0` (default): exclude bonus; `1`: include bonus
270
+ # @option kwargs [Integer] :with_transfer_safe_amount `0` (default): not query; `1`: query delay-withdraw safe amount
271
+ # @option kwargs [Integer] :with_ltv_transfer_safe_amount `0` (default): not query; `1`: query OTC loan transferable amount. Requires `toAccountType`
272
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
273
+ # @see https://bybit-exchange.github.io/docs/v5/asset/transfer/query-account-coin-balance
274
+ def account_coin_balance_query(account_type:, coin:, **kwargs)
275
+ params = kwargs.merge(account_type: account_type, coin: coin)
276
+ params = Bybit::Utils::WireKeys.camelize(params)
277
+ @session.sign_request(method: :get, path: '/v5/asset/transfer/query-account-coin-balance', params: params)
278
+ end
279
+
280
+ # Get Spot Asset Info
281
+ #
282
+ # GET /v5/asset/transfer/query-asset-info
283
+ #
284
+ # @option kwargs [String] :account_type Account type. Currently only SPOT. Defaults to SPOT if empty.
285
+ # @option kwargs [String] :coin Coin name, uppercase. Optional; returns all coins if empty.
286
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
287
+ # @see https://bybit-exchange.github.io/docs/v5/asset/transfer/query-asset-info
288
+ def asset_info_query(**kwargs)
289
+ params = kwargs.dup
290
+ params = Bybit::Utils::WireKeys.camelize(params)
291
+ @session.sign_request(method: :get, path: '/v5/asset/transfer/query-asset-info', params: params)
292
+ end
293
+
294
+ # Withdraw
295
+ #
296
+ # POST /v5/asset/withdraw/create
297
+ #
298
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
299
+ # @see https://bybit-exchange.github.io/docs/v5/asset/withdraw/create
300
+ def send_withdraw(**kwargs)
301
+ params = kwargs.dup
302
+ params = Bybit::Utils::WireKeys.camelize(params)
303
+ @session.sign_request(method: :post, path: '/v5/asset/withdraw/create', body: params)
304
+ end
305
+
306
+ # Get Withdrawal Records
307
+ #
308
+ # GET /v5/asset/withdraw/query-record
309
+ #
310
+ # @option kwargs [String] :withdraw_id Withdrawal ID
311
+ # @option kwargs [String] :tx_id Transaction hash ID
312
+ # @option kwargs [String] :coin Coin name, uppercase, e.g. USDT
313
+ # @option kwargs [Integer] :withdraw_type Withdrawal type: - `0`: On-chain withdrawal (default) - `1`: Off-chain (internal transfer) - `2`: Al
314
+ # @option kwargs [Integer] :start_time Start timestamp in milliseconds. Default: 30 days before current time
315
+ # @option kwargs [Integer] :end_time End timestamp in milliseconds. Default: current time
316
+ # @option kwargs [Integer] :limit Results per page, range [1, 50], default 50
317
+ # @option kwargs [String] :cursor Pagination cursor from `nextPageCursor` in prior response
318
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
319
+ # @see https://bybit-exchange.github.io/docs/v5/asset/withdraw/query-record
320
+ def list_withdraw_records(**kwargs)
321
+ params = kwargs.dup
322
+ params = Bybit::Utils::WireKeys.camelize(params)
323
+ @session.sign_request(method: :get, path: '/v5/asset/withdraw/query-record', params: params)
324
+ end
325
+
326
+ # Cancel Withdrawal
327
+ #
328
+ # POST /v5/asset/withdraw/cancel
329
+ #
330
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
331
+ # @see https://bybit-exchange.github.io/docs/v5/asset/withdraw/cancel
332
+ def cancel_withdraw(**kwargs)
333
+ params = kwargs.dup
334
+ params = Bybit::Utils::WireKeys.camelize(params)
335
+ @session.sign_request(method: :post, path: '/v5/asset/withdraw/cancel', body: params)
336
+ end
337
+
338
+ # Get Withdrawable Amount
339
+ #
340
+ # GET /v5/asset/withdraw/withdrawable-amount
341
+ #
342
+ # @param coin [String] Coin name, uppercase, e.g. USDT
343
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
344
+ # @see https://bybit-exchange.github.io/docs/v5/asset/withdraw/withdrawable-amount
345
+ def get_withdrawable_amount_by_coin(coin:, **kwargs)
346
+ params = kwargs.merge(coin: coin)
347
+ params = Bybit::Utils::WireKeys.camelize(params)
348
+ @session.sign_request(method: :get, path: '/v5/asset/withdraw/withdrawable-amount', params: params)
349
+ end
350
+
351
+ # Get Available VASPs
352
+ #
353
+ # GET /v5/asset/withdraw/vasp/list
354
+ #
355
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
356
+ # @see https://bybit-exchange.github.io/docs/v5/asset/withdraw/vasp/list
357
+ def get_vasp_list(**kwargs)
358
+ params = kwargs.dup
359
+ params = Bybit::Utils::WireKeys.camelize(params)
360
+ @session.sign_request(method: :get, path: '/v5/asset/withdraw/vasp/list', params: params)
361
+ end
362
+
363
+ # Get Withdrawal Address List
364
+ #
365
+ # GET /v5/asset/withdraw/query-address
366
+ #
367
+ # @option kwargs [String] :coin Coin name; use `baseCoin` for universal addresses
368
+ # @option kwargs [String] :chain Chain name
369
+ # @option kwargs [Integer] :address_type Address type: - `0`: On-chain address (default) - `1`: Internal transfer address (coin/chain ignored
370
+ # @option kwargs [Integer] :limit Records per page, range [1, 50], default 50
371
+ # @option kwargs [String] :cursor Pagination cursor from `nextPageCursor` in prior response
372
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
373
+ # @see https://bybit-exchange.github.io/docs/v5/asset/withdraw/query-address
374
+ def list_withdraw_addresses(**kwargs)
375
+ params = kwargs.dup
376
+ params = Bybit::Utils::WireKeys.camelize(params)
377
+ @session.sign_request(method: :get, path: '/v5/asset/withdraw/query-address', params: params)
378
+ end
379
+
380
+ # Get Asset Overview
381
+ #
382
+ # GET /v5/asset/asset-overview
383
+ #
384
+ # @option kwargs [String] :account_type Account type filter. Multiple values separated by commas. If not passed, returns all account types.
385
+ # @option kwargs [String] :member_id Sub-account member ID. Used to query a specific sub-account's assets. - If API key belongs to a sub-
386
+ # @option kwargs [String] :valuation_currency Valuation currency. Defaults to `USD` if not provided.
387
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
388
+ # @see https://bybit-exchange.github.io/docs/v5/asset/asset-overview
389
+ def get_asset_overview(**kwargs)
390
+ params = kwargs.dup
391
+ params = Bybit::Utils::WireKeys.camelize(params)
392
+ @session.sign_request(method: :get, path: '/v5/asset/asset-overview', params: params)
393
+ end
394
+
395
+ # Get Delivery Record
396
+ #
397
+ # GET /v5/asset/delivery-record
398
+ #
399
+ # @param category [String] Product type: - `linear`: USDT / USDC futures - `inverse`: Inverse futures - `option`: Options
400
+ # @option kwargs [String] :symbol Symbol name, e.g. `BTCUSDT`, `BTC-29DEC22-16000-P`
401
+ # @option kwargs [Integer] :start_time Start timestamp in **milliseconds**. Default: 30 days before current time
402
+ # @option kwargs [Integer] :end_time End timestamp in **milliseconds**. Default: current time
403
+ # @option kwargs [String] :exp_date Expiry date. Format: `25DEC22`. Default: returns all expiry dates
404
+ # @option kwargs [Integer] :limit Number of items per page. Default: `20`, Range: [`1`, `50`]
405
+ # @option kwargs [String] :cursor Pagination cursor. Use `nextPageCursor` from the response to retrieve the next page
406
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
407
+ # @see https://bybit-exchange.github.io/docs/v5/asset/delivery-record
408
+ def get_delivery_record(category:, **kwargs)
409
+ params = kwargs.merge(category: category)
410
+ params = Bybit::Utils::WireKeys.camelize(params)
411
+ @session.sign_request(method: :get, path: '/v5/asset/delivery-record', params: params)
412
+ end
413
+
414
+ # Get Portfolio Margin Info
415
+ #
416
+ # GET /v5/asset/portfolio-margin
417
+ #
418
+ # @option kwargs [String] :base_coin Base coin, e.g. `BTC`, `ETH`. If not passed, returns all.
419
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
420
+ # @see https://bybit-exchange.github.io/docs/v5/asset/portfolio-margin
421
+ def get_portfolio_margin(**kwargs)
422
+ params = kwargs.dup
423
+ params = Bybit::Utils::WireKeys.camelize(params)
424
+ @session.sign_request(method: :get, path: '/v5/asset/portfolio-margin', params: params)
425
+ end
426
+
427
+ # Get USDC Session Settlement
428
+ #
429
+ # GET /v5/asset/settlement-record
430
+ #
431
+ # @param category [String] Product type: - `linear`: USDC contract
432
+ # @option kwargs [String] :symbol Symbol name, e.g. `BTCPERP`
433
+ # @option kwargs [Integer] :start_time Start timestamp in **milliseconds**. Default: 30 days before current time
434
+ # @option kwargs [Integer] :end_time End timestamp in **milliseconds**. Default: current time
435
+ # @option kwargs [Integer] :limit Number of items per page. Default: `20`, Range: [`1`, `50`]
436
+ # @option kwargs [String] :cursor Pagination cursor. Use `nextPageCursor` from the response to retrieve the next page
437
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
438
+ # @see https://bybit-exchange.github.io/docs/v5/asset/settlement-record
439
+ def get_settlement_record(category:, **kwargs)
440
+ params = kwargs.merge(category: category)
441
+ params = Bybit::Utils::WireKeys.camelize(params)
442
+ @session.sign_request(method: :get, path: '/v5/asset/settlement-record', params: params)
443
+ end
444
+
445
+ # Get Total Members Assets
446
+ #
447
+ # GET /v5/asset/total-members-assets
448
+ #
449
+ # @option kwargs [String] :coin Coin name, e.g. `BTC`, `USDT`. If specified, total assets are denominated in this coin.
450
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
451
+ # @see https://bybit-exchange.github.io/docs/v5/asset/total-members-assets
452
+ def get_total_members_assets(**kwargs)
453
+ params = kwargs.dup
454
+ params = Bybit::Utils::WireKeys.camelize(params)
455
+ @session.sign_request(method: :get, path: '/v5/asset/total-members-assets', params: params)
456
+ end
457
+
458
+ # Coin list query
459
+ #
460
+ # GET /v5/asset/exchange/query-coin-list
461
+ #
462
+ # @param account_type [String] Wallet type. Supported values: eb_convert_funding, eb_convert_uta, eb_convert_spot, eb_convert_contr
463
+ # @option kwargs [Integer] :side 0: fromCoin list (coins to sell); 1: toCoin list (coins to buy)
464
+ # @option kwargs [String] :coin Coin name, uppercase only. Used as fromCoin filter when side=0
465
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
466
+ # @see https://bybit-exchange.github.io/docs/v5/asset/exchange/query-coin-list
467
+ def coin_list_query(account_type:, **kwargs)
468
+ params = kwargs.merge(account_type: account_type)
469
+ params = Bybit::Utils::WireKeys.camelize(params)
470
+ @session.sign_request(method: :get, path: '/v5/asset/exchange/query-coin-list', params: params)
471
+ end
472
+
473
+ # Execute conversion
474
+ #
475
+ # POST /v5/asset/exchange/convert-execute
476
+ #
477
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
478
+ # @see https://bybit-exchange.github.io/docs/v5/asset/exchange/convert-execute
479
+ def convert_execute(**kwargs)
480
+ params = kwargs.dup
481
+ params = Bybit::Utils::WireKeys.camelize(params)
482
+ @session.sign_request(method: :post, path: '/v5/asset/exchange/convert-execute', body: params)
483
+ end
484
+
485
+ # Conversion history query
486
+ #
487
+ # GET /v5/asset/exchange/query-convert-history
488
+ #
489
+ # @option kwargs [String] :account_type Wallet type filter. Supported: eb_convert_funding, eb_convert_uta, funding, funding_fiat, funding_fb
490
+ # @option kwargs [Integer] :index Page number, starts at 1, defaults to 1
491
+ # @option kwargs [Integer] :limit Page size, default 20, max 100
492
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
493
+ # @see https://bybit-exchange.github.io/docs/v5/asset/exchange/query-convert-history
494
+ def convert_history_query(**kwargs)
495
+ params = kwargs.dup
496
+ params = Bybit::Utils::WireKeys.camelize(params)
497
+ @session.sign_request(method: :get, path: '/v5/asset/exchange/query-convert-history', params: params)
498
+ end
499
+
500
+ # Query coin conversion limit
501
+ #
502
+ # GET /v5/asset/exchange/query-convert-limit
503
+ #
504
+ # @param from_coin [String] From coin
505
+ # @param to_coin [String] To coin
506
+ # @param account_type [String] Account type (scene code), pass "funding" for funding account flash conversion
507
+ # @option kwargs [Integer] :from_coin_type From coin type: 0=crypto, 1=fiat
508
+ # @option kwargs [Integer] :to_coin_type To coin type: 0=crypto, 1=fiat
509
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
510
+ # @see https://bybit-exchange.github.io/docs/v5/asset/exchange/query-convert-limit
511
+ def coin_convert_limit_query(from_coin:, to_coin:, account_type:, **kwargs)
512
+ params = kwargs.merge(from_coin: from_coin, to_coin: to_coin, account_type: account_type)
513
+ params = Bybit::Utils::WireKeys.camelize(params)
514
+ @session.sign_request(method: :get, path: '/v5/asset/exchange/query-convert-limit', params: params)
515
+ end
516
+
517
+ # Query conversion result
518
+ #
519
+ # GET /v5/asset/exchange/convert-result-query
520
+ #
521
+ # @param quote_tx_id [String] Quote transaction ID
522
+ # @param account_type [String] Wallet type (scene code)
523
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
524
+ # @see https://bybit-exchange.github.io/docs/v5/asset/exchange/convert-result-query
525
+ def get_convert_result(quote_tx_id:, account_type:, **kwargs)
526
+ params = kwargs.merge(quote_tx_id: quote_tx_id, account_type: account_type)
527
+ params = Bybit::Utils::WireKeys.camelize(params)
528
+ @session.sign_request(method: :get, path: '/v5/asset/exchange/convert-result-query', params: params)
529
+ end
530
+
531
+ # Paginated conversion order query
532
+ #
533
+ # GET /v5/asset/exchange/order-record
534
+ #
535
+ # @option kwargs [String] :cursor Pagination cursor (omit on first request)
536
+ # @option kwargs [Integer] :limit Items per page
537
+ # @option kwargs [String] :to_coin To coin filter
538
+ # @option kwargs [String] :from_coin From coin filter
539
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
540
+ # @see https://bybit-exchange.github.io/docs/v5/asset/exchange/order-record
541
+ def list_convert_orders_by_page(**kwargs)
542
+ params = kwargs.dup
543
+ params = Bybit::Utils::WireKeys.camelize(params)
544
+ @session.sign_request(method: :get, path: '/v5/asset/exchange/order-record', params: params)
545
+ end
546
+
547
+ # Query conversion order list
548
+ #
549
+ # GET /v5/asset/exchange/query-order-list
550
+ #
551
+ # @option kwargs [Integer] :account_type Account type: 0=ASSET, 1=OBU
552
+ # @option kwargs [String] :cursor Pagination cursor
553
+ # @option kwargs [Integer] :limit Items per page
554
+ # @option kwargs [String] :to_coin To coin filter
555
+ # @option kwargs [String] :from_coin From coin filter
556
+ # @option kwargs [Integer] :start_time Start timestamp (seconds)
557
+ # @option kwargs [Integer] :end_time End timestamp (seconds)
558
+ # @option kwargs [Integer] :type Conversion type: 0=all, 1=auto conversion, 2=active conversion
559
+ # @option kwargs [Integer] :exchange_status Order status: 0=all, 1=init, 2=pending, 3=success, 4=failure
560
+ # @option kwargs [String] :direction Pagination direction
561
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
562
+ # @see https://bybit-exchange.github.io/docs/v5/asset/exchange/query-order-list
563
+ def list_convert_orders(**kwargs)
564
+ params = kwargs.dup
565
+ params = Bybit::Utils::WireKeys.camelize(params)
566
+ @session.sign_request(method: :get, path: '/v5/asset/exchange/query-order-list', params: params)
567
+ end
568
+
569
+ # Apply quote
570
+ #
571
+ # POST /v5/asset/exchange/quote-apply
572
+ #
573
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
574
+ # @see https://bybit-exchange.github.io/docs/v5/asset/exchange/quote-apply
575
+ def quote_apply(**kwargs)
576
+ params = kwargs.dup
577
+ params = Bybit::Utils::WireKeys.camelize(params)
578
+ @session.sign_request(method: :post, path: '/v5/asset/exchange/quote-apply', body: params)
579
+ end
580
+
581
+ # Small asset confirm conversion
582
+ #
583
+ # POST /v5/asset/covert/small-balance-execute
584
+ #
585
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
586
+ # @see https://bybit-exchange.github.io/docs/v5/asset/covert/small-balance-execute
587
+ def small_asset_convert(**kwargs)
588
+ params = kwargs.dup
589
+ params = Bybit::Utils::WireKeys.camelize(params)
590
+ @session.sign_request(method: :post, path: '/v5/asset/covert/small-balance-execute', body: params)
591
+ end
592
+
593
+ # Small asset conversion history query
594
+ #
595
+ # GET /v5/asset/covert/small-balance-history
596
+ #
597
+ # @option kwargs [String] :account_type Wallet type: eb_convert_uta or eb_convert_funding
598
+ # @option kwargs [String] :quote_id Quote ID. Highest priority filter when provided
599
+ # @option kwargs [String] :cursor Page number for pagination
600
+ # @option kwargs [String] :size Page size, default 50, max 100
601
+ # @option kwargs [String] :start_time Start timestamp in milliseconds
602
+ # @option kwargs [String] :end_time End timestamp in milliseconds
603
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
604
+ # @see https://bybit-exchange.github.io/docs/v5/asset/covert/small-balance-history
605
+ def list_small_balance_history(**kwargs)
606
+ params = kwargs.dup
607
+ params = Bybit::Utils::WireKeys.camelize(params)
608
+ @session.sign_request(method: :get, path: '/v5/asset/covert/small-balance-history', params: params)
609
+ end
610
+
611
+ # Small asset conversion list query
612
+ #
613
+ # GET /v5/asset/covert/small-balance-list
614
+ #
615
+ # @param account_type [String] Wallet type. Only supports eb_convert_uta (Unified wallet)
616
+ # @option kwargs [String] :from_coin Source currency filter (optional). Multiple coins separated by comma, e.g. "BTC,ETH"
617
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
618
+ # @see https://bybit-exchange.github.io/docs/v5/asset/covert/small-balance-list
619
+ def list_small_balance_coins(account_type:, **kwargs)
620
+ params = kwargs.merge(account_type: account_type)
621
+ params = Bybit::Utils::WireKeys.camelize(params)
622
+ @session.sign_request(method: :get, path: '/v5/asset/covert/small-balance-list', params: params)
623
+ end
624
+
625
+ # Small asset get quote
626
+ #
627
+ # POST /v5/asset/covert/get-quote
628
+ #
629
+ # @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
630
+ # @see https://bybit-exchange.github.io/docs/v5/asset/covert/get-quote
631
+ def small_asset_quote(**kwargs)
632
+ params = kwargs.dup
633
+ params = Bybit::Utils::WireKeys.camelize(params)
634
+ @session.sign_request(method: :post, path: '/v5/asset/covert/get-quote', body: params)
635
+ end
636
+ end
637
+ end
638
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bybit
4
+ module RestApi
5
+ class BaseService
6
+ def initialize(session)
7
+ @session = session
8
+ end
9
+ end
10
+ end
11
+ end