bybit-connector-ruby 0.1.0 → 0.1.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +203 -1
- data/README.md +159 -14
- data/examples/quickstart.rb +36 -7
- data/lib/bybit/client.rb +44 -16
- data/lib/bybit/error.rb +13 -5
- data/lib/bybit/rest_api/account_service.rb +50 -0
- data/lib/bybit/rest_api/alpha_service.rb +545 -0
- data/lib/bybit/rest_api/asset_service.rb +17 -0
- data/lib/bybit/rest_api/broker_service.rb +9 -4
- data/lib/bybit/rest_api/crypto_loan_service.rb +60 -0
- data/lib/bybit/rest_api/earn_service.rb +31 -0
- data/lib/bybit/rest_api/event_service.rb +92 -0
- data/lib/bybit/rest_api/fiat_service.rb +110 -0
- data/lib/bybit/rest_api/institutional_loan_service.rb +128 -0
- data/lib/bybit/rest_api/market_service.rb +17 -4
- data/lib/bybit/rest_api/misc_service.rb +36 -0
- data/lib/bybit/rest_api/position_service.rb +15 -0
- data/lib/bybit/rest_api/pre_upgrade_service.rb +130 -0
- data/lib/bybit/rest_api/referral_service.rb +61 -0
- data/lib/bybit/rest_api/spot_margin_service.rb +258 -0
- data/lib/bybit/rest_api/spot_x_service.rb +142 -0
- data/lib/bybit/rest_api/spread_trade_service.rb +202 -0
- data/lib/bybit/rest_api/strategy_service.rb +105 -0
- data/lib/bybit/rest_api/tax_service.rb +37 -0
- data/lib/bybit/rest_api/user_service.rb +10 -0
- data/lib/bybit/session.rb +18 -7
- data/lib/bybit/version.rb +1 -1
- data/lib/bybit/websocket/client.rb +294 -0
- data/lib/bybit/websocket.rb +9 -0
- metadata +62 -7
|
@@ -370,6 +370,66 @@ module Bybit
|
|
|
370
370
|
params = Bybit::Utils::WireKeys.camelize(params)
|
|
371
371
|
@session.sign_request(method: :post, path: '/v5/crypto-loan-flexible/repay-collateral', body: params)
|
|
372
372
|
end
|
|
373
|
+
|
|
374
|
+
# Get Available Inventory
|
|
375
|
+
#
|
|
376
|
+
# GET /v5/crypto-loan-fixed/available-inventory
|
|
377
|
+
#
|
|
378
|
+
# @param currency [String] Coin name, uppercase only
|
|
379
|
+
# @param term [String] Fixed term 7: 7 days; 14: 14 days; 30: 30 days; 90: 90 days; 180: 180 days
|
|
380
|
+
# @param annual_rate [String] Customizable annual interest rate, e.g., 0.02 means 2%
|
|
381
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
382
|
+
# @see https://bybit-exchange.github.io/docs/v5/new-crypto-loan/fixed/available-inventory
|
|
383
|
+
def get_fixed_available_inventory(currency:, term:, annual_rate:)
|
|
384
|
+
params = Bybit::Utils::WireKeys.camelize({ currency: currency, term: term, annualRate: annual_rate })
|
|
385
|
+
@session.sign_request(method: :get, path: '/v5/crypto-loan-fixed/available-inventory', params: params)
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
# Get Repayment History
|
|
389
|
+
#
|
|
390
|
+
# GET /v5/crypto-loan-fixed/repayment-history
|
|
391
|
+
#
|
|
392
|
+
# @option kwargs [String] :repay_id Repayment ID
|
|
393
|
+
# @option kwargs [String] :loan_currency Loan currency filter
|
|
394
|
+
# @option kwargs [String] :limit Page size
|
|
395
|
+
# @option kwargs [String] :cursor Page cursor
|
|
396
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
397
|
+
# @see https://bybit-exchange.github.io/docs/v5/new-crypto-loan/fixed/repay-history
|
|
398
|
+
def get_fixed_repayment_history(**kwargs)
|
|
399
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs)
|
|
400
|
+
@session.sign_request(method: :get, path: '/v5/crypto-loan-fixed/repayment-history', params: params)
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
# Create Supply Order
|
|
404
|
+
#
|
|
405
|
+
# POST /v5/crypto-loan-fixed/supply
|
|
406
|
+
#
|
|
407
|
+
# @param order_currency [String] Currency to lend
|
|
408
|
+
# @param order_amount [String] Amount to lend
|
|
409
|
+
# @param annual_rate [String] Annual interest rate
|
|
410
|
+
# @param term [String] Term in days (7, 14, 30, 90, 180)
|
|
411
|
+
# @option kwargs [String] :available_source Fund source for supply order:
|
|
412
|
+
# - `0`: Funding account (default)
|
|
413
|
+
# - `1`: Flexible savings
|
|
414
|
+
# - `2`: Mixed (funding account + flexible savings)
|
|
415
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
416
|
+
# @see https://bybit-exchange.github.io/docs/v5/new-crypto-loan/fixed/supply
|
|
417
|
+
def supply_fixed(order_currency:, order_amount:, annual_rate:, term:, **kwargs)
|
|
418
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(orderCurrency: order_currency, orderAmount: order_amount, annualRate: annual_rate, term: term))
|
|
419
|
+
@session.sign_request(method: :post, path: '/v5/crypto-loan-fixed/supply', body: params)
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
# Get Available Inventory
|
|
423
|
+
#
|
|
424
|
+
# GET /v5/crypto-loan-flexible/available-inventory
|
|
425
|
+
#
|
|
426
|
+
# @param currency [String] Coin name, uppercase only
|
|
427
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
428
|
+
# @see https://bybit-exchange.github.io/docs/v5/new-crypto-loan/flexible/available-inventory
|
|
429
|
+
def get_flexible_available_inventory(currency:)
|
|
430
|
+
params = Bybit::Utils::WireKeys.camelize({ currency: currency })
|
|
431
|
+
@session.sign_request(method: :get, path: '/v5/crypto-loan-flexible/available-inventory', params: params)
|
|
432
|
+
end
|
|
373
433
|
end
|
|
374
434
|
end
|
|
375
435
|
end
|
|
@@ -1042,6 +1042,37 @@ module Bybit
|
|
|
1042
1042
|
params = Bybit::Utils::WireKeys.camelize(params)
|
|
1043
1043
|
@session.sign_request(method: :post, path: '/v5/earn/fixed-term/position/auto-invest', body: params)
|
|
1044
1044
|
end
|
|
1045
|
+
|
|
1046
|
+
# Get Auto Savings Settings
|
|
1047
|
+
#
|
|
1048
|
+
# GET /v5/earn/flexible-saving/auto-savings
|
|
1049
|
+
#
|
|
1050
|
+
# @option kwargs [Array] :coins Coin names to query, for example `coins=BTC&coins=ETH`. Omit for all supported coins.
|
|
1051
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
1052
|
+
# @see https://bybit-exchange.github.io/docs/v5/finance/earn/flexible-saving/auto-savings
|
|
1053
|
+
def list_auto_savings(**kwargs)
|
|
1054
|
+
coins = kwargs[:coins]
|
|
1055
|
+
if coins.is_a?(Array) && coins.length > 50
|
|
1056
|
+
raise Bybit::ConfigurationError,
|
|
1057
|
+
'coins supports at most 50 values'
|
|
1058
|
+
end
|
|
1059
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs)
|
|
1060
|
+
@session.sign_request(method: :get, path: '/v5/earn/flexible-saving/auto-savings', params: params)
|
|
1061
|
+
end
|
|
1062
|
+
|
|
1063
|
+
# Edit Auto Savings Settings
|
|
1064
|
+
#
|
|
1065
|
+
# POST /v5/earn/flexible-saving/auto-savings
|
|
1066
|
+
#
|
|
1067
|
+
# @param is_selected [Boolean] Whether to enable auto savings
|
|
1068
|
+
# @option kwargs [String] :coin Coin to change; omit or pass an empty string to change the global setting
|
|
1069
|
+
# @option kwargs [Boolean] :purchase_immediately When enabling, asynchronously attempt to subscribe the available Funding Account balance; ignored when disabling
|
|
1070
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
1071
|
+
# @see https://bybit-exchange.github.io/docs/v5/finance/earn/flexible-saving/auto-savings
|
|
1072
|
+
def edit_earn_auto_savings(is_selected:, **kwargs)
|
|
1073
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(isSelected: is_selected))
|
|
1074
|
+
@session.sign_request(method: :post, path: '/v5/earn/flexible-saving/auto-savings', body: params)
|
|
1075
|
+
end
|
|
1045
1076
|
end
|
|
1046
1077
|
end
|
|
1047
1078
|
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bybit
|
|
4
|
+
module RestApi
|
|
5
|
+
class EventService < BaseService
|
|
6
|
+
# Get Event Contract Order History
|
|
7
|
+
#
|
|
8
|
+
# GET /v5/event/order-list
|
|
9
|
+
#
|
|
10
|
+
# @option kwargs [String] :symbol Symbol name, e.g. `BTCUSDT-EC`
|
|
11
|
+
# @option kwargs [String] :order_id Order ID
|
|
12
|
+
# @option kwargs [String] :order_link_id User-defined order ID
|
|
13
|
+
# @option kwargs [Integer] :start_time Start time in milliseconds. Default: 7 days ago
|
|
14
|
+
# @option kwargs [Integer] :end_time End time in milliseconds. Default: now
|
|
15
|
+
# @option kwargs [Integer] :limit Number of items per page. Default: `50`, Range: [`1`, `100`]
|
|
16
|
+
# @option kwargs [String] :cursor Pagination cursor
|
|
17
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
18
|
+
# @see https://bybit-exchange.github.io/docs/v5/event/trade/order-list
|
|
19
|
+
def get_ec_order_history(**kwargs)
|
|
20
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs)
|
|
21
|
+
@session.sign_request(method: :get, path: '/v5/event/order-list', params: params)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Get Event Contract Active Orders
|
|
25
|
+
#
|
|
26
|
+
# GET /v5/event/order-realtime
|
|
27
|
+
#
|
|
28
|
+
# @option kwargs [String] :symbol Symbol name, e.g. `BTCUSDT-EC`
|
|
29
|
+
# @option kwargs [String] :order_id Order ID. If both `orderId` and `orderLinkId` are passed, `orderId` takes priority
|
|
30
|
+
# @option kwargs [String] :order_link_id User-defined order ID
|
|
31
|
+
# @option kwargs [Integer] :limit Number of items per page. Default: `20`, Range: [`1`, `50`]
|
|
32
|
+
# @option kwargs [String] :cursor Pagination cursor. Use `nextPageCursor` from the response to retrieve the next page
|
|
33
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
34
|
+
# @see https://bybit-exchange.github.io/docs/v5/event/trade/open-order
|
|
35
|
+
def get_ec_active_orders(**kwargs)
|
|
36
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs)
|
|
37
|
+
@session.sign_request(method: :get, path: '/v5/event/order-realtime', params: params)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Get Event Contract Position Info
|
|
41
|
+
#
|
|
42
|
+
# GET /v5/event/positions
|
|
43
|
+
#
|
|
44
|
+
# @option kwargs [String] :symbol Symbol name, e.g. `BTCUSDT-EC`. If not passed, returns all EC positions
|
|
45
|
+
# @option kwargs [String] :base_coin Base coin filter, e.g. `BTC`
|
|
46
|
+
# @option kwargs [String] :settle_coin Settle coin filter, e.g. `USDT`
|
|
47
|
+
# @option kwargs [Integer] :limit Number of items per page. Default: `20`, Range: [`1`, `50`]
|
|
48
|
+
# @option kwargs [String] :cursor Pagination cursor. Use `nextPageCursor` from the response to retrieve the next page
|
|
49
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
50
|
+
# @see https://bybit-exchange.github.io/docs/v5/event/trade/position
|
|
51
|
+
def get_ec_position_info(**kwargs)
|
|
52
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs)
|
|
53
|
+
@session.sign_request(method: :get, path: '/v5/event/positions', params: params)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Get Event Contract Settlement Records
|
|
57
|
+
#
|
|
58
|
+
# GET /v5/event/settlements
|
|
59
|
+
#
|
|
60
|
+
# @param symbol [String] Symbol name, e.g. `BTCUSDT-EC`
|
|
61
|
+
# @option kwargs [String] :order_id Order ID filter
|
|
62
|
+
# @option kwargs [Integer] :start_time Start time in milliseconds. Default: 7 days ago
|
|
63
|
+
# @option kwargs [Integer] :end_time End time in milliseconds. Default: now
|
|
64
|
+
# @option kwargs [Integer] :limit Number of items per page. Default: `50`, Range: [`1`, `100`]
|
|
65
|
+
# @option kwargs [String] :cursor Pagination cursor
|
|
66
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
67
|
+
# @see https://bybit-exchange.github.io/docs/v5/event/trade/settlement
|
|
68
|
+
def get_ec_settlements(symbol:, **kwargs)
|
|
69
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(symbol: symbol))
|
|
70
|
+
@session.sign_request(method: :get, path: '/v5/event/settlements', params: params)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Get Event Contract Trade History
|
|
74
|
+
#
|
|
75
|
+
# GET /v5/event/trades
|
|
76
|
+
#
|
|
77
|
+
# @param symbol [String] Symbol name, e.g. `BTCUSDT-EC`
|
|
78
|
+
# @option kwargs [String] :order_id Order ID filter
|
|
79
|
+
# @option kwargs [String] :order_link_id User-defined order ID
|
|
80
|
+
# @option kwargs [Integer] :start_time Start time in milliseconds. Default: 7 days ago
|
|
81
|
+
# @option kwargs [Integer] :end_time End time in milliseconds. Default: now
|
|
82
|
+
# @option kwargs [Integer] :limit Number of items per page. Default: `50`, Range: [`1`, `100`]
|
|
83
|
+
# @option kwargs [String] :cursor Pagination cursor
|
|
84
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
85
|
+
# @see https://bybit-exchange.github.io/docs/v5/event/trade/execution
|
|
86
|
+
def get_ec_trade_history(symbol:, **kwargs)
|
|
87
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(symbol: symbol))
|
|
88
|
+
@session.sign_request(method: :get, path: '/v5/event/trades', params: params)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bybit
|
|
4
|
+
module RestApi
|
|
5
|
+
class FiatService < BaseService
|
|
6
|
+
# Query Account Balance
|
|
7
|
+
#
|
|
8
|
+
# GET /v5/fiat/balance-query
|
|
9
|
+
#
|
|
10
|
+
# @option kwargs [String] :account_category Account type (reserved field)
|
|
11
|
+
# @option kwargs [String] :currency Currency code:
|
|
12
|
+
# - Fiat: ISO 4217 standard code, e.g., EUR, GEL, KZT
|
|
13
|
+
# - Crypto: e.g., USDT, BTC, ETH
|
|
14
|
+
# - Omit to query all balances
|
|
15
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
16
|
+
# @see https://bybit-exchange.github.io/docs/v5/asset/fiat-convert/balance-query
|
|
17
|
+
def query_balance(**kwargs)
|
|
18
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs)
|
|
19
|
+
@session.sign_request(method: :get, path: '/v5/fiat/balance-query', params: params)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Get Trading Pairs
|
|
23
|
+
#
|
|
24
|
+
# GET /v5/fiat/query-coin-list
|
|
25
|
+
#
|
|
26
|
+
# @option kwargs [Integer] :side Trading direction:
|
|
27
|
+
# - `0`: buy - Buy crypto, sell fiat
|
|
28
|
+
# - `1`: sell - Sell crypto, buy fiat
|
|
29
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
30
|
+
# @see https://bybit-exchange.github.io/docs/v5/asset/fiat-convert/query-coin-list
|
|
31
|
+
def query_coin_list(**kwargs)
|
|
32
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs)
|
|
33
|
+
@session.sign_request(method: :get, path: '/v5/fiat/query-coin-list', params: params)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Query Trade History
|
|
37
|
+
#
|
|
38
|
+
# GET /v5/fiat/query-trade-history
|
|
39
|
+
#
|
|
40
|
+
# @option kwargs [Integer] :index Page number, starts from 1
|
|
41
|
+
# @option kwargs [Integer] :limit Page size, maximum 100
|
|
42
|
+
# @option kwargs [String] :start_time Query start time (millisecond timestamp)
|
|
43
|
+
# @option kwargs [String] :end_time Query end time (millisecond timestamp)
|
|
44
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
45
|
+
# @see https://bybit-exchange.github.io/docs/v5/asset/fiat-convert/query-trade-history
|
|
46
|
+
def query_trade_history(**kwargs)
|
|
47
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs)
|
|
48
|
+
@session.sign_request(method: :get, path: '/v5/fiat/query-trade-history', params: params)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Request a Quote
|
|
52
|
+
#
|
|
53
|
+
# POST /v5/fiat/quote-apply
|
|
54
|
+
#
|
|
55
|
+
# @param from_coin [String] Convert from coin (coin to sell)
|
|
56
|
+
# @param from_coin_type [String] From coin type
|
|
57
|
+
# @param to_coin [String] Convert to coin (coin to buy)
|
|
58
|
+
# @param to_coin_type [String] To coin type
|
|
59
|
+
# @param request_amount [String] Request coin amount (the amount you want to sell)
|
|
60
|
+
# @option kwargs [String] :request_coin_type Coin type you want to sell, defaults to fiat
|
|
61
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
62
|
+
# @see https://bybit-exchange.github.io/docs/v5/asset/fiat-convert/quote-apply
|
|
63
|
+
def apply_quote(from_coin:, from_coin_type:, to_coin:, to_coin_type:, request_amount:, **kwargs)
|
|
64
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(fromCoin: from_coin, fromCoinType: from_coin_type, toCoin: to_coin, toCoinType: to_coin_type, requestAmount: request_amount))
|
|
65
|
+
@session.sign_request(method: :post, path: '/v5/fiat/quote-apply', body: params)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Get Reference Price
|
|
69
|
+
#
|
|
70
|
+
# GET /v5/fiat/reference-price
|
|
71
|
+
#
|
|
72
|
+
# @param symbol [String] Coin pair, format: "FIAT-CRYPTO", e.g., "EUR-USDT"
|
|
73
|
+
# @option kwargs [String] :payment_method Payment method (reserved field)
|
|
74
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
75
|
+
# @see https://bybit-exchange.github.io/docs/v5/asset/fiat-convert/reference-price
|
|
76
|
+
def get_reference_price(symbol:, **kwargs)
|
|
77
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(symbol: symbol))
|
|
78
|
+
@session.sign_request(method: :get, path: '/v5/fiat/reference-price', params: params)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Confirm Quote and Execute Trade
|
|
82
|
+
#
|
|
83
|
+
# POST /v5/fiat/trade-execute
|
|
84
|
+
#
|
|
85
|
+
# @param quote_tx_id [String] Quote transaction ID from the quote request
|
|
86
|
+
# @param sub_user_id [String] The user's sub userId in Bybit
|
|
87
|
+
# @option kwargs [String] :webhook_url Optional webhook URL to receive trade status notifications (max 256 characters)
|
|
88
|
+
# @option kwargs [String] :merchant_request_id Customised request ID (max 36 characters). Generally it is useless, but convenient for internal tracking
|
|
89
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
90
|
+
# @see https://bybit-exchange.github.io/docs/v5/asset/fiat-convert/confirm-quote
|
|
91
|
+
def confirm_quote(quote_tx_id:, sub_user_id:, **kwargs)
|
|
92
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(quoteTxId: quote_tx_id, subUserId: sub_user_id))
|
|
93
|
+
@session.sign_request(method: :post, path: '/v5/fiat/trade-execute', body: params)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Query Trade Status
|
|
97
|
+
#
|
|
98
|
+
# GET /v5/fiat/trade-query
|
|
99
|
+
#
|
|
100
|
+
# @option kwargs [String] :trade_no Trade order number (either tradeNo or merchantRequestId must be provided)
|
|
101
|
+
# @option kwargs [String] :merchant_request_id Merchant request ID (either tradeNo or merchantRequestId must be provided)
|
|
102
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
103
|
+
# @see https://bybit-exchange.github.io/docs/v5/asset/fiat-convert/query-trade
|
|
104
|
+
def query_trade(**kwargs)
|
|
105
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs)
|
|
106
|
+
@session.sign_request(method: :get, path: '/v5/fiat/trade-query', params: params)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bybit
|
|
4
|
+
module RestApi
|
|
5
|
+
# /v5/ins-loan/* — institutional (OTC) loan namespace. Distinct from
|
|
6
|
+
# `crypto_loan` (retail flexible / fixed loans): these endpoints require
|
|
7
|
+
# a Bybit-provisioned institutional risk-unit UID and are read-only for
|
|
8
|
+
# non-institutional keys.
|
|
9
|
+
class InstitutionalLoanService < BaseService
|
|
10
|
+
# Get Product Info
|
|
11
|
+
#
|
|
12
|
+
# GET /v5/ins-loan/product-infos
|
|
13
|
+
#
|
|
14
|
+
# @option kwargs [String] :product_id Product ID; omit to return all products.
|
|
15
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
16
|
+
# @see https://bybit-exchange.github.io/docs/v5/otc/margin-product-info
|
|
17
|
+
def get_product_info(**kwargs)
|
|
18
|
+
params = kwargs.dup
|
|
19
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
20
|
+
@session.public_request(path: '/v5/ins-loan/product-infos', params: params)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Get Margin Coin Info (ensure-tokens-convert)
|
|
24
|
+
#
|
|
25
|
+
# GET /v5/ins-loan/ensure-tokens-convert
|
|
26
|
+
#
|
|
27
|
+
# @option kwargs [String] :product_id Product ID
|
|
28
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
29
|
+
# @see https://bybit-exchange.github.io/docs/v5/otc/margin-coin-convert-info
|
|
30
|
+
def get_margin_coin_info(**kwargs)
|
|
31
|
+
params = kwargs.dup
|
|
32
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
33
|
+
@session.public_request(path: '/v5/ins-loan/ensure-tokens-convert', params: params)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Get Loan Orders
|
|
37
|
+
#
|
|
38
|
+
# GET /v5/ins-loan/loan-order
|
|
39
|
+
#
|
|
40
|
+
# @option kwargs [Integer] :order_id Loan order ID
|
|
41
|
+
# @option kwargs [Integer] :start_time Start timestamp in ms
|
|
42
|
+
# @option kwargs [Integer] :end_time End timestamp in ms
|
|
43
|
+
# @option kwargs [Integer] :limit Records per page (default/max 100)
|
|
44
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
45
|
+
# @see https://bybit-exchange.github.io/docs/v5/otc/loan-info
|
|
46
|
+
def get_loan_orders(**kwargs)
|
|
47
|
+
params = kwargs.dup
|
|
48
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
49
|
+
@session.sign_request(method: :get, path: '/v5/ins-loan/loan-order', params: params)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Get Repayment Orders
|
|
53
|
+
#
|
|
54
|
+
# GET /v5/ins-loan/repaid-history
|
|
55
|
+
#
|
|
56
|
+
# @option kwargs [Integer] :start_time Start timestamp in ms
|
|
57
|
+
# @option kwargs [Integer] :end_time End timestamp in ms
|
|
58
|
+
# @option kwargs [Integer] :limit Records per page
|
|
59
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
60
|
+
# @see https://bybit-exchange.github.io/docs/v5/otc/repay-info
|
|
61
|
+
def get_repayment_orders(**kwargs)
|
|
62
|
+
params = kwargs.dup
|
|
63
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
64
|
+
@session.sign_request(method: :get, path: '/v5/ins-loan/repaid-history', params: params)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Get Loan-to-Value
|
|
68
|
+
#
|
|
69
|
+
# GET /v5/ins-loan/ltv-convert
|
|
70
|
+
#
|
|
71
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
72
|
+
# @see https://bybit-exchange.github.io/docs/v5/otc/ltv-convert
|
|
73
|
+
def get_ltv
|
|
74
|
+
@session.sign_request(method: :get, path: '/v5/ins-loan/ltv-convert')
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Bind Or Unbind UID (institutional risk unit)
|
|
78
|
+
#
|
|
79
|
+
# POST /v5/ins-loan/association-uid
|
|
80
|
+
#
|
|
81
|
+
# @param uid [String] Sub UID to bind or unbind
|
|
82
|
+
# @param operate [String] `0` bind, `1` unbind
|
|
83
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
84
|
+
# @see https://bybit-exchange.github.io/docs/v5/otc/bind-uid
|
|
85
|
+
def bind_or_unbind_uid(uid:, operate:, **kwargs)
|
|
86
|
+
params = kwargs.merge(uid: uid, operate: operate)
|
|
87
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
88
|
+
@session.sign_request(method: :post, path: '/v5/ins-loan/association-uid', body: params)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Repay Loan
|
|
92
|
+
#
|
|
93
|
+
# POST /v5/ins-loan/repay-loan
|
|
94
|
+
#
|
|
95
|
+
# @param order_id [String] Loan order ID to repay
|
|
96
|
+
# @param amount [String] Repayment amount
|
|
97
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
98
|
+
# @see https://bybit-exchange.github.io/docs/v5/otc/repay
|
|
99
|
+
def repay_loan(order_id:, amount:, **kwargs)
|
|
100
|
+
params = kwargs.merge(order_id: order_id, amount: amount)
|
|
101
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
102
|
+
@session.sign_request(method: :post, path: '/v5/ins-loan/repay-loan', body: params)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Get Coin Delta Amount
|
|
106
|
+
#
|
|
107
|
+
# GET /v5/ins-loan/coin-delta-amount
|
|
108
|
+
#
|
|
109
|
+
# @option kwargs [String] :coin Coin name to filter, uppercase only. e.g. `BTC`. If not passed, returns all coins.
|
|
110
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
111
|
+
# @see https://bybit-exchange.github.io/docs/v5/otc/coin-delta-amount
|
|
112
|
+
def ins_loan_coin_delta_amount(**kwargs)
|
|
113
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs)
|
|
114
|
+
@session.sign_request(method: :get, path: '/v5/ins-loan/coin-delta-amount', params: params)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Get Delay Liquidation Status
|
|
118
|
+
#
|
|
119
|
+
# GET /v5/ins-loan/delay-liq-status
|
|
120
|
+
#
|
|
121
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
122
|
+
# @see https://bybit-exchange.github.io/docs/v5/otc/delay-liq-status
|
|
123
|
+
def ins_loan_delay_liq_status
|
|
124
|
+
@session.sign_request(method: :get, path: '/v5/ins-loan/delay-liq-status')
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -109,7 +109,6 @@ module Bybit
|
|
|
109
109
|
# @see https://bybit-exchange.github.io/docs/v5/market/index-kline
|
|
110
110
|
def get_index_price_kline(symbol:, interval:, **kwargs)
|
|
111
111
|
params = kwargs.merge(symbol: symbol, interval: interval)
|
|
112
|
-
params[:end] = params.delete(:end_) if params.key?(:end_)
|
|
113
112
|
params = Bybit::Utils::WireKeys.camelize(params)
|
|
114
113
|
@session.public_request(path: '/v5/market/index-price-kline', params: params)
|
|
115
114
|
end
|
|
@@ -178,7 +177,6 @@ module Bybit
|
|
|
178
177
|
# @see https://bybit-exchange.github.io/docs/v5/market/mark-kline
|
|
179
178
|
def get_mark_price_kline(symbol:, interval:, **kwargs)
|
|
180
179
|
params = kwargs.merge(symbol: symbol, interval: interval)
|
|
181
|
-
params[:end] = params.delete(:end_) if params.key?(:end_)
|
|
182
180
|
params = Bybit::Utils::WireKeys.camelize(params)
|
|
183
181
|
@session.public_request(path: '/v5/market/mark-price-kline', params: params)
|
|
184
182
|
end
|
|
@@ -197,7 +195,6 @@ module Bybit
|
|
|
197
195
|
# @see https://bybit-exchange.github.io/docs/v5/market/kline
|
|
198
196
|
def get_kline(symbol:, interval:, **kwargs)
|
|
199
197
|
params = kwargs.merge(symbol: symbol, interval: interval)
|
|
200
|
-
params[:end] = params.delete(:end_) if params.key?(:end_)
|
|
201
198
|
params = Bybit::Utils::WireKeys.camelize(params)
|
|
202
199
|
@session.public_request(path: '/v5/market/kline', params: params)
|
|
203
200
|
end
|
|
@@ -278,7 +275,6 @@ module Bybit
|
|
|
278
275
|
# @see https://bybit-exchange.github.io/docs/v5/market/premium-index-kline
|
|
279
276
|
def get_premium_index_price_kline(symbol:, interval:, **kwargs)
|
|
280
277
|
params = kwargs.merge(symbol: symbol, interval: interval)
|
|
281
|
-
params[:end] = params.delete(:end_) if params.key?(:end_)
|
|
282
278
|
params = Bybit::Utils::WireKeys.camelize(params)
|
|
283
279
|
@session.public_request(path: '/v5/market/premium-index-price-kline', params: params)
|
|
284
280
|
end
|
|
@@ -354,6 +350,23 @@ module Bybit
|
|
|
354
350
|
params = Bybit::Utils::WireKeys.camelize(params)
|
|
355
351
|
@session.public_request(path: '/v5/market/tickers', params: params)
|
|
356
352
|
end
|
|
353
|
+
|
|
354
|
+
# Get Option Base Coins
|
|
355
|
+
#
|
|
356
|
+
# GET /v5/market/option-base-coins
|
|
357
|
+
#
|
|
358
|
+
# @option kwargs [String] :underlying_type Underlying asset type. Supports comma-separated values, e.g. `0,2`.
|
|
359
|
+
# - `0`: Crypto
|
|
360
|
+
# - `1`: Commodity
|
|
361
|
+
# - `2`: Stock
|
|
362
|
+
# - `3`: Forex
|
|
363
|
+
# - `4`: Oil
|
|
364
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
365
|
+
# @see https://bybit-exchange.github.io/docs/v5/market/option-base-coins
|
|
366
|
+
def get_option_base_coins(**kwargs)
|
|
367
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs)
|
|
368
|
+
@session.public_request(path: '/v5/market/option-base-coins', params: params)
|
|
369
|
+
end
|
|
357
370
|
end
|
|
358
371
|
end
|
|
359
372
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bybit
|
|
4
|
+
module RestApi
|
|
5
|
+
# Endpoints that don't cleanly belong under a per-domain service:
|
|
6
|
+
# announcement feed and system status.
|
|
7
|
+
class MiscService < BaseService
|
|
8
|
+
# Get Announcements
|
|
9
|
+
#
|
|
10
|
+
# GET /v5/announcements/index
|
|
11
|
+
#
|
|
12
|
+
# @param locale [String] Language code, e.g. `en-US`, `zh-TW`.
|
|
13
|
+
# @option kwargs [String] :type Announcement type filter
|
|
14
|
+
# @option kwargs [String] :tag Tag filter
|
|
15
|
+
# @option kwargs [Integer] :page Page number
|
|
16
|
+
# @option kwargs [Integer] :limit Records per page (max 100)
|
|
17
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
18
|
+
# @see https://bybit-exchange.github.io/docs/v5/announcement
|
|
19
|
+
def get_announcements(locale:, **kwargs)
|
|
20
|
+
params = kwargs.merge(locale: locale)
|
|
21
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
22
|
+
@session.public_request(path: '/v5/announcements/index', params: params)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Get System Status
|
|
26
|
+
#
|
|
27
|
+
# GET /v5/system/status
|
|
28
|
+
#
|
|
29
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
30
|
+
# @see https://bybit-exchange.github.io/docs/v5/system-status
|
|
31
|
+
def get_system_status
|
|
32
|
+
@session.public_request(path: '/v5/system/status')
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -197,6 +197,21 @@ module Bybit
|
|
|
197
197
|
params = Bybit::Utils::WireKeys.camelize(params)
|
|
198
198
|
@session.sign_request(method: :post, path: '/v5/position/switch-mode', body: params)
|
|
199
199
|
end
|
|
200
|
+
|
|
201
|
+
# Get Futures Leverage
|
|
202
|
+
#
|
|
203
|
+
# GET /v5/position/symbol-info
|
|
204
|
+
#
|
|
205
|
+
# @param category [String] Product type:
|
|
206
|
+
# - `linear`: USDT perpetual, USDC contract
|
|
207
|
+
# - `inverse`: Inverse perpetual, Inverse futures
|
|
208
|
+
# @option kwargs [String] :symbol Symbol name, e.g. `BTCUSDT`, uppercase only
|
|
209
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
210
|
+
# @see https://bybit-exchange.github.io/docs/v5/position/batch-lvg
|
|
211
|
+
def get_symbol_info(category:, **kwargs)
|
|
212
|
+
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(category: category))
|
|
213
|
+
@session.sign_request(method: :get, path: '/v5/position/symbol-info', params: params)
|
|
214
|
+
end
|
|
200
215
|
end
|
|
201
216
|
end
|
|
202
217
|
end
|