Class: Bybit::RestApi::AccountService

Inherits:
BaseService show all
Defined in:
lib/bybit/rest_api/account_service.rb

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Bybit::RestApi::BaseService

Instance Method Details

#batch_set_collateral(request:, **kwargs) ⇒ Hash

Batch Set Collateral

POST /v5/account/set-collateral-switch-batch

Parameters:

  • request (Array)

    Array of collateral switch objects

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



13
14
15
16
17
# File 'lib/bybit/rest_api/account_service.rb', line 13

def batch_set_collateral(request:, **kwargs)
  params = kwargs.merge(request: request)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/account/set-collateral-switch-batch', body: params)
end

#get_borrow_history(**kwargs) ⇒ Hash

Get Borrow History

GET /v5/account/borrow-history

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :currency (String)

    USDC, USDT, BTC, ETH

  • :start_time (Integer)

    The start timestamp (ms)

  • :end_time (Integer)

    The end timestamp (ms)

  • :limit (Integer)

    Limit for data size per page

  • :cursor (String)

    Cursor. Use the nextPageCursor token from the response to retrieve the next page

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



71
72
73
74
75
# File 'lib/bybit/rest_api/account_service.rb', line 71

def get_borrow_history(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/account/borrow-history', params: params)
end

#get_collateral_info(**kwargs) ⇒ Hash

Get Collateral Info

GET /v5/account/collateral-info

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :currency (String)

    Asset currency of all current collateral

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



84
85
86
87
88
# File 'lib/bybit/rest_api/account_service.rb', line 84

def get_collateral_info(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/account/collateral-info', params: params)
end

#get_dcp_info(**kwargs) ⇒ Hash

Get DCP Info

GET /v5/account/query-dcp-info

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



96
97
98
99
100
# File 'lib/bybit/rest_api/account_service.rb', line 96

def get_dcp_info(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/account/query-dcp-info', params: params)
end

#get_fee_rate(category:, **kwargs) ⇒ Hash

Get Fee Rate

GET /v5/account/fee-rate

Parameters:

  • category (String)

    Product type

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :symbol (String)

    Symbol name

  • :base_coin (String)

    Base coin. SOL, BTC, ETH. Apply to option only

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



111
112
113
114
115
# File 'lib/bybit/rest_api/account_service.rb', line 111

def get_fee_rate(category:, **kwargs)
  params = kwargs.merge(category: category)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/account/fee-rate', params: params)
end

#get_info(**kwargs) ⇒ Hash

Get Account Info

GET /v5/account/info

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



25
26
27
28
29
# File 'lib/bybit/rest_api/account_service.rb', line 25

def get_info(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/account/info', params: params)
end

#get_instruments(category:, **kwargs) ⇒ Hash

Get Account Instruments

GET /v5/account/instruments-info

Parameters:

  • category (String)

    Product type

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :symbol (String)

    Symbol name

  • :limit (Integer)

    Limit for data size per page

  • :cursor (String)

    Cursor. Use the nextPageCursor token from the response to retrieve the next page

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



54
55
56
57
58
# File 'lib/bybit/rest_api/account_service.rb', line 54

def get_instruments(category:, **kwargs)
  params = kwargs.merge(category: category)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/account/instruments-info', params: params)
end

#get_mmp_state(base_coin:, **kwargs) ⇒ Hash

Get MMP State

GET /v5/account/mmp-state

Parameters:

  • base_coin (String)

    Base coin

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



124
125
126
127
128
# File 'lib/bybit/rest_api/account_service.rb', line 124

def get_mmp_state(base_coin:, **kwargs)
  params = kwargs.merge(base_coin: base_coin)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/account/mmp-state', params: params)
end

#get_smp_group(**kwargs) ⇒ Hash

Get SMP Group

GET /v5/account/smp-group

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



136
137
138
139
140
# File 'lib/bybit/rest_api/account_service.rb', line 136

def get_smp_group(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/account/smp-group', params: params)
end

#get_transaction_log(**kwargs) ⇒ Hash

Get Transaction Log

GET /v5/account/transaction-log

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :account_type (String)

    Account type. UNIFIED

  • :category (String)

    Product type

  • :currency (String)

    Currency

  • :base_coin (String)

    BaseCoin. e.g., BTC of BTCPERP

  • :type (String)

    Types of transaction logs

  • :trans_sub_type (String)

    Transaction subtype

  • :start_time (Integer)

    The start timestamp (ms)

  • :end_time (Integer)

    The end timestamp (ms)

  • :limit (Integer)

    Limit for data size per page

  • :cursor (String)

    Cursor. Use the nextPageCursor token from the response to retrieve the next page

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



158
159
160
161
162
# File 'lib/bybit/rest_api/account_service.rb', line 158

def get_transaction_log(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/account/transaction-log', params: params)
end

#get_transferable_amount(coin_name:, **kwargs) ⇒ Hash

Get Transferable Amount

GET /v5/account/withdrawal

Parameters:

  • coin_name (String)

    Coin name

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



170
171
172
173
174
# File 'lib/bybit/rest_api/account_service.rb', line 170

def get_transferable_amount(coin_name:, **kwargs)
  params = kwargs.merge(coin_name: coin_name)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/account/withdrawal', params: params)
end

#get_user_settings(**kwargs) ⇒ Hash

Get User Settings

GET /v5/account/user-setting-config

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



180
181
182
183
184
# File 'lib/bybit/rest_api/account_service.rb', line 180

def (**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/account/user-setting-config', params: params)
end

#get_wallet_balance(account_type:, **kwargs) ⇒ Hash

Get Wallet Balance

GET /v5/account/wallet-balance

Parameters:

  • account_type (String)

    Account type: UNIFIED / CONTRACT / SPOT / FUND / OPTION.

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :coin (String)

    Coin filter — comma-separated, e.g. "USDT,BTC".

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



39
40
41
42
43
# File 'lib/bybit/rest_api/account_service.rb', line 39

def get_wallet_balance(account_type:, **kwargs)
  params = kwargs.merge(account_type: )
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/account/wallet-balance', params: params)
end

#manual_borrow(coin:, amount:, **kwargs) ⇒ Hash

Manual Borrow

POST /v5/account/borrow

Parameters:

  • coin (String)

    Coin name

  • amount (String)

    The amount to borrow

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



193
194
195
196
197
# File 'lib/bybit/rest_api/account_service.rb', line 193

def manual_borrow(coin:, amount:, **kwargs)
  params = kwargs.merge(coin: coin, amount: amount)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/account/borrow', body: params)
end

#manual_repay(**kwargs) ⇒ Hash

Manual Repay

POST /v5/account/repay

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :coin (String)

    Coin name. If not passed, repay all liabilities

  • :amount (String)

    The amount to repay

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



206
207
208
209
210
# File 'lib/bybit/rest_api/account_service.rb', line 206

def manual_repay(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/account/repay', body: params)
end

#no_convert_repay(coin:, **kwargs) ⇒ Hash

No-Convert Repay

POST /v5/account/no-convert-repay

Parameters:

  • coin (String)

    Coin name

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :amount (String)

    The amount to repay

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



220
221
222
223
224
# File 'lib/bybit/rest_api/account_service.rb', line 220

def no_convert_repay(coin:, **kwargs)
  params = kwargs.merge(coin: coin)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/account/no-convert-repay', body: params)
end

#one_click_repay(**kwargs) ⇒ Hash

One-Click Repay: convert small balance coins to a specified coin to repay debt in one click.

POST /v5/account/quick-repayment

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :coin (String)

    Coin to repay debt with

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



232
233
234
235
236
# File 'lib/bybit/rest_api/account_service.rb', line 232

def one_click_repay(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/account/quick-repayment', body: params)
end

#reset_mmp(base_coin:, **kwargs) ⇒ Hash

Reset MMP state for a given base coin.

POST /v5/account/mmp-reset

Parameters:

  • base_coin (String)

    Base coin

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



244
245
246
247
248
# File 'lib/bybit/rest_api/account_service.rb', line 244

def reset_mmp(base_coin:, **kwargs)
  params = kwargs.merge(base_coin: base_coin)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/account/mmp-reset', body: params)
end

#set_collateral_coin(coin:, collateral_switch:, **kwargs) ⇒ Hash

Enable or disable a coin as collateral for the unified account.

POST /v5/account/set-collateral-switch

Parameters:

  • coin (String)

    Coin symbol

  • collateral_switch (String)

    ON or OFF

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



257
258
259
260
261
# File 'lib/bybit/rest_api/account_service.rb', line 257

def set_collateral_coin(coin:, collateral_switch:, **kwargs)
  params = kwargs.merge(coin: coin, collateral_switch: collateral_switch)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/account/set-collateral-switch', body: params)
end

#set_margin_mode(set_margin_mode:, **kwargs) ⇒ Hash

Set margin mode for the unified account (ISOLATED_MARGIN, REGULAR_MARGIN, PORTFOLIO_MARGIN).

POST /v5/account/set-margin-mode

Parameters:

  • set_margin_mode (String)

    Margin mode to set

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



270
271
272
273
274
# File 'lib/bybit/rest_api/account_service.rb', line 270

def set_margin_mode(set_margin_mode:, **kwargs)
  params = kwargs.merge(set_margin_mode: set_margin_mode)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/account/set-margin-mode', body: params)
end

#set_mmp(base_coin:, window:, frozen_period:, qty_limit:, delta_limit:, **kwargs) ⇒ Hash

Configure Market Maker Protection parameters for a base coin.

POST /v5/account/mmp-modify

Parameters:

  • base_coin (String)

    Base coin

  • window (String)

    Time window (ms)

  • frozen_period (String)

    Frozen period (ms)

  • qty_limit (String)

    Quantity limit

  • delta_limit (String)

    Delta limit

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



287
288
289
290
291
# File 'lib/bybit/rest_api/account_service.rb', line 287

def set_mmp(base_coin:, window:, frozen_period:, qty_limit:, delta_limit:, **kwargs)
  params = kwargs.merge(base_coin: base_coin, window: window, frozen_period: frozen_period, qty_limit: qty_limit, delta_limit: delta_limit)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/account/mmp-modify', body: params)
end

#set_price_limit(category:, modify_enable:, **kwargs) ⇒ Hash

Toggle whether the price limit rule applies to modify order actions for a category.

POST /v5/account/set-limit-px-action

Parameters:

  • category (String)

    Product type

  • modify_enable (Boolean)

    Enable modify price limit check

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



300
301
302
303
304
# File 'lib/bybit/rest_api/account_service.rb', line 300

def set_price_limit(category:, modify_enable:, **kwargs)
  params = kwargs.merge(category: category, modify_enable: modify_enable)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/account/set-limit-px-action', body: params)
end

#set_spot_hedging(set_hedging_mode:, **kwargs) ⇒ Hash

Enable or disable spot hedging mode for the unified account.

POST /v5/account/set-hedging-mode

Parameters:

  • set_hedging_mode (String)

    ON or OFF

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



313
314
315
316
317
# File 'lib/bybit/rest_api/account_service.rb', line 313

def set_spot_hedging(set_hedging_mode:, **kwargs)
  params = kwargs.merge(set_hedging_mode: set_hedging_mode)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/account/set-hedging-mode', body: params)
end

#upgrade_to_uta_pro(**kwargs) ⇒ Hash

Upgrade the current account to Unified Trading Account (UTA) Pro.

POST /v5/account/upgrade-to-uta

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



325
326
327
328
329
# File 'lib/bybit/rest_api/account_service.rb', line 325

def upgrade_to_uta_pro(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/account/upgrade-to-uta', body: params)
end