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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +259 -0
- data/LICENSE +21 -0
- data/README.md +173 -0
- data/examples/quickstart.rb +35 -0
- data/lib/bybit/authentication.rb +16 -0
- data/lib/bybit/client.rb +71 -0
- data/lib/bybit/configuration.rb +74 -0
- data/lib/bybit/error.rb +67 -0
- data/lib/bybit/rest_api/account_service.rb +332 -0
- data/lib/bybit/rest_api/affiliate_service.rb +42 -0
- data/lib/bybit/rest_api/asset_service.rb +638 -0
- data/lib/bybit/rest_api/base_service.rb +11 -0
- data/lib/bybit/rest_api/bot_service.rb +386 -0
- data/lib/bybit/rest_api/broker_service.rb +109 -0
- data/lib/bybit/rest_api/crypto_loan_service.rb +375 -0
- data/lib/bybit/rest_api/earn_service.rb +1047 -0
- data/lib/bybit/rest_api/market_service.rb +359 -0
- data/lib/bybit/rest_api/p2p_service.rb +256 -0
- data/lib/bybit/rest_api/position_service.rb +202 -0
- data/lib/bybit/rest_api/rfq_service.rb +221 -0
- data/lib/bybit/rest_api/spot_margin_service.rb +62 -0
- data/lib/bybit/rest_api/trade_service.rb +289 -0
- data/lib/bybit/rest_api/user_service.rb +254 -0
- data/lib/bybit/session.rb +199 -0
- data/lib/bybit/utils/wire_keys.rb +66 -0
- data/lib/bybit/version.rb +5 -0
- data/lib/bybit.rb +10 -0
- metadata +158 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bybit
|
|
4
|
+
module RestApi
|
|
5
|
+
class PositionService < BaseService
|
|
6
|
+
# Manually add or reduce margin for an isolated margin position
|
|
7
|
+
#
|
|
8
|
+
# POST /v5/position/add-margin
|
|
9
|
+
#
|
|
10
|
+
# @param category [String] Product type
|
|
11
|
+
# @param symbol [String] Symbol name
|
|
12
|
+
# @param margin [String] Add or reduce. To add, then 10; to reduce, then -10
|
|
13
|
+
# @option kwargs [Integer] :position_idx Used to identify positions in different position modes
|
|
14
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
15
|
+
# @see https://bybit-exchange.github.io/docs/v5/position/manual-add-margin
|
|
16
|
+
def add_reduce_margin(category:, symbol:, margin:, **kwargs)
|
|
17
|
+
params = kwargs.merge(category: category, symbol: symbol, margin: margin)
|
|
18
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
19
|
+
@session.sign_request(method: :post, path: '/v5/position/add-margin', body: params)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Confirm new risk limit to remove reduce-only restriction
|
|
23
|
+
#
|
|
24
|
+
# POST /v5/position/confirm-pending-mmr
|
|
25
|
+
#
|
|
26
|
+
# @param category [String] Product type
|
|
27
|
+
# @param symbol [String] Symbol name
|
|
28
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
29
|
+
# @see https://bybit-exchange.github.io/docs/v5/position/confirm-mmr
|
|
30
|
+
def confirm_new_risk_limit(category:, symbol:, **kwargs)
|
|
31
|
+
params = kwargs.merge(category: category, symbol: symbol)
|
|
32
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
33
|
+
@session.sign_request(method: :post, path: '/v5/position/confirm-pending-mmr', body: params)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Get closed option position records
|
|
37
|
+
#
|
|
38
|
+
# GET /v5/position/get-closed-positions
|
|
39
|
+
#
|
|
40
|
+
# @param category [String] Product type
|
|
41
|
+
# @option kwargs [String] :symbol Symbol name
|
|
42
|
+
# @option kwargs [Integer] :start_time Start timestamp in ms
|
|
43
|
+
# @option kwargs [Integer] :end_time End timestamp in ms
|
|
44
|
+
# @option kwargs [Integer] :limit Limit for data size per page
|
|
45
|
+
# @option kwargs [String] :cursor Cursor for pagination
|
|
46
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
47
|
+
# @see https://bybit-exchange.github.io/docs/v5/position/close-position
|
|
48
|
+
def get_closed_positions(category:, **kwargs)
|
|
49
|
+
params = kwargs.merge(category: category)
|
|
50
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
51
|
+
@session.sign_request(method: :get, path: '/v5/position/get-closed-positions', params: params)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Get closed profit and loss records
|
|
55
|
+
#
|
|
56
|
+
# GET /v5/position/closed-pnl
|
|
57
|
+
#
|
|
58
|
+
# @param category [String] Product type
|
|
59
|
+
# @option kwargs [String] :symbol Symbol name
|
|
60
|
+
# @option kwargs [Integer] :start_time Start timestamp in ms
|
|
61
|
+
# @option kwargs [Integer] :end_time End timestamp in ms
|
|
62
|
+
# @option kwargs [Integer] :limit Limit for data size per page
|
|
63
|
+
# @option kwargs [String] :cursor Cursor for pagination
|
|
64
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
65
|
+
# @see https://bybit-exchange.github.io/docs/v5/position/close-pnl
|
|
66
|
+
def get_closed_pnl(category:, **kwargs)
|
|
67
|
+
params = kwargs.merge(category: category)
|
|
68
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
69
|
+
@session.sign_request(method: :get, path: '/v5/position/closed-pnl', params: params)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Get move position (block trade) history
|
|
73
|
+
#
|
|
74
|
+
# GET /v5/position/move-history
|
|
75
|
+
#
|
|
76
|
+
# @option kwargs [String] :category Product type
|
|
77
|
+
# @option kwargs [String] :symbol Symbol name
|
|
78
|
+
# @option kwargs [Integer] :start_time Start timestamp in ms
|
|
79
|
+
# @option kwargs [Integer] :end_time End timestamp in ms
|
|
80
|
+
# @option kwargs [String] :status Move position status
|
|
81
|
+
# @option kwargs [String] :block_trade_id Block trade ID
|
|
82
|
+
# @option kwargs [String] :limit Limit for data size per page
|
|
83
|
+
# @option kwargs [String] :cursor Cursor for pagination
|
|
84
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
85
|
+
# @see https://bybit-exchange.github.io/docs/v5/position/move-position-history
|
|
86
|
+
def get_move_position_history(**kwargs)
|
|
87
|
+
params = kwargs.dup
|
|
88
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
89
|
+
@session.sign_request(method: :get, path: '/v5/position/move-history', params: params)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Get position info (real-time)
|
|
93
|
+
#
|
|
94
|
+
# GET /v5/position/list
|
|
95
|
+
#
|
|
96
|
+
# @param category [String] Product type
|
|
97
|
+
# @option kwargs [String] :symbol Symbol name
|
|
98
|
+
# @option kwargs [String] :base_coin Base coin
|
|
99
|
+
# @option kwargs [String] :settle_coin Settle coin
|
|
100
|
+
# @option kwargs [Integer] :limit Limit for data size per page
|
|
101
|
+
# @option kwargs [String] :cursor Cursor for pagination
|
|
102
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
103
|
+
# @see https://bybit-exchange.github.io/docs/v5/position
|
|
104
|
+
def get_positions(category:, **kwargs)
|
|
105
|
+
params = kwargs.merge(category: category)
|
|
106
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
107
|
+
@session.sign_request(method: :get, path: '/v5/position/list', params: params)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Move positions between UIDs via block trade
|
|
111
|
+
#
|
|
112
|
+
# POST /v5/position/move-positions
|
|
113
|
+
#
|
|
114
|
+
# @param from_uid [String] Original UID (from which the position is moved)
|
|
115
|
+
# @param to_uid [String] Target UID (to which the position is moved)
|
|
116
|
+
# @param list [Array] Positions to move (array of objects)
|
|
117
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
118
|
+
# @see https://bybit-exchange.github.io/docs/v5/position/move-position
|
|
119
|
+
def move_position(from_uid:, to_uid:, list:, **kwargs)
|
|
120
|
+
params = kwargs.merge(from_uid: from_uid, to_uid: to_uid, list: list)
|
|
121
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
122
|
+
@session.sign_request(method: :post, path: '/v5/position/move-positions', body: params)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Enable or disable auto-add-margin for a position
|
|
126
|
+
#
|
|
127
|
+
# POST /v5/position/set-auto-add-margin
|
|
128
|
+
#
|
|
129
|
+
# @param category [String] Product type
|
|
130
|
+
# @param symbol [String] Symbol name
|
|
131
|
+
# @param auto_add_margin [Integer] 0: disable, 1: enable
|
|
132
|
+
# @option kwargs [Integer] :position_idx Used to identify positions in different position modes
|
|
133
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
134
|
+
# @see https://bybit-exchange.github.io/docs/v5/position/auto-add-margin
|
|
135
|
+
def set_auto_add_margin(category:, symbol:, auto_add_margin:, **kwargs)
|
|
136
|
+
params = kwargs.merge(category: category, symbol: symbol, auto_add_margin: auto_add_margin)
|
|
137
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
138
|
+
@session.sign_request(method: :post, path: '/v5/position/set-auto-add-margin', body: params)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Set leverage for a position
|
|
142
|
+
#
|
|
143
|
+
# POST /v5/position/set-leverage
|
|
144
|
+
#
|
|
145
|
+
# @param category [String] Product type
|
|
146
|
+
# @param symbol [String] Symbol name
|
|
147
|
+
# @param buy_leverage [String] Buy leverage
|
|
148
|
+
# @param sell_leverage [String] Sell leverage
|
|
149
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
150
|
+
# @see https://bybit-exchange.github.io/docs/v5/position/leverage
|
|
151
|
+
def set_leverage(category:, symbol:, buy_leverage:, sell_leverage:, **kwargs)
|
|
152
|
+
params = kwargs.merge(category: category, symbol: symbol, buy_leverage: buy_leverage, sell_leverage: sell_leverage)
|
|
153
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
154
|
+
@session.sign_request(method: :post, path: '/v5/position/set-leverage', body: params)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Set take profit, stop loss, and trailing stop for a position
|
|
158
|
+
#
|
|
159
|
+
# POST /v5/position/trading-stop
|
|
160
|
+
#
|
|
161
|
+
# @param category [String] Product type
|
|
162
|
+
# @param symbol [String] Symbol name
|
|
163
|
+
# @param tpsl_mode [String] TP/SL mode: Full or Partial
|
|
164
|
+
# @param position_idx [Integer] Used to identify positions in different position modes
|
|
165
|
+
# @option kwargs [String] :take_profit Take profit price
|
|
166
|
+
# @option kwargs [String] :stop_loss Stop loss price
|
|
167
|
+
# @option kwargs [String] :trailing_stop Trailing stop
|
|
168
|
+
# @option kwargs [String] :tp_trigger_by Take profit trigger price type
|
|
169
|
+
# @option kwargs [String] :sl_trigger_by Stop loss trigger price type
|
|
170
|
+
# @option kwargs [String] :active_price Trailing stop trigger price
|
|
171
|
+
# @option kwargs [String] :tp_size Take profit size (Partial mode)
|
|
172
|
+
# @option kwargs [String] :sl_size Stop loss size (Partial mode)
|
|
173
|
+
# @option kwargs [String] :tp_limit_price The limit order price when take profit price is triggered
|
|
174
|
+
# @option kwargs [String] :sl_limit_price The limit order price when stop loss price is triggered
|
|
175
|
+
# @option kwargs [String] :tp_order_type Take profit order type: Market or Limit
|
|
176
|
+
# @option kwargs [String] :sl_order_type Stop loss order type: Market or Limit
|
|
177
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
178
|
+
# @see https://bybit-exchange.github.io/docs/v5/position/trading-stop
|
|
179
|
+
def set_trading_stop(category:, symbol:, tpsl_mode:, position_idx:, **kwargs)
|
|
180
|
+
params = kwargs.merge(category: category, symbol: symbol, tpsl_mode: tpsl_mode, position_idx: position_idx)
|
|
181
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
182
|
+
@session.sign_request(method: :post, path: '/v5/position/trading-stop', body: params)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Switch position mode between one-way and hedge mode
|
|
186
|
+
#
|
|
187
|
+
# POST /v5/position/switch-mode
|
|
188
|
+
#
|
|
189
|
+
# @param category [String] Product type
|
|
190
|
+
# @param mode [Integer] Position mode: 0 (Merged Single), 3 (Both Sides)
|
|
191
|
+
# @option kwargs [String] :symbol Symbol name
|
|
192
|
+
# @option kwargs [String] :coin Coin
|
|
193
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
194
|
+
# @see https://bybit-exchange.github.io/docs/v5/position/position-mode
|
|
195
|
+
def switch_position_mode(category:, mode:, **kwargs)
|
|
196
|
+
params = kwargs.merge(category: category, mode: mode)
|
|
197
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
198
|
+
@session.sign_request(method: :post, path: '/v5/position/switch-mode', body: params)
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
end
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bybit
|
|
4
|
+
module RestApi
|
|
5
|
+
class RfqService < BaseService
|
|
6
|
+
# Accept a non-LP quote for an RFQ.
|
|
7
|
+
#
|
|
8
|
+
# POST /v5/rfq/accept-other-quote
|
|
9
|
+
#
|
|
10
|
+
# @param rfq_id [String] RFQ ID
|
|
11
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
12
|
+
def accept_non_lp_quote(rfq_id:, **kwargs)
|
|
13
|
+
params = kwargs.merge(rfq_id: rfq_id)
|
|
14
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
15
|
+
@session.sign_request(method: :post, path: '/v5/rfq/accept-other-quote', body: params)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Cancel all active quotes.
|
|
19
|
+
#
|
|
20
|
+
# POST /v5/rfq/cancel-all-quotes
|
|
21
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
22
|
+
def cancel_all_quotes(**kwargs)
|
|
23
|
+
params = kwargs.dup
|
|
24
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
25
|
+
@session.sign_request(method: :post, path: '/v5/rfq/cancel-all-quotes', body: params)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Cancel all active RFQs.
|
|
29
|
+
#
|
|
30
|
+
# POST /v5/rfq/cancel-all-rfq
|
|
31
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
32
|
+
def cancel_all_rfqs(**kwargs)
|
|
33
|
+
params = kwargs.dup
|
|
34
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
35
|
+
@session.sign_request(method: :post, path: '/v5/rfq/cancel-all-rfq', body: params)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Cancel a specific quote by quote ID, RFQ ID, or quote link ID.
|
|
39
|
+
#
|
|
40
|
+
# POST /v5/rfq/cancel-quote
|
|
41
|
+
#
|
|
42
|
+
# @option kwargs [String] :quote_id Quote ID
|
|
43
|
+
# @option kwargs [String] :rfq_id RFQ ID
|
|
44
|
+
# @option kwargs [String] :quote_link_id User-defined quote link ID
|
|
45
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
46
|
+
def cancel_quote(**kwargs)
|
|
47
|
+
params = kwargs.dup
|
|
48
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
49
|
+
@session.sign_request(method: :post, path: '/v5/rfq/cancel-quote', body: params)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Cancel a specific RFQ by RFQ ID or RFQ link ID.
|
|
53
|
+
#
|
|
54
|
+
# POST /v5/rfq/cancel-rfq
|
|
55
|
+
#
|
|
56
|
+
# @option kwargs [String] :rfq_id RFQ ID
|
|
57
|
+
# @option kwargs [String] :rfq_link_id User-defined RFQ link ID
|
|
58
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
59
|
+
def cancel_rfq(**kwargs)
|
|
60
|
+
params = kwargs.dup
|
|
61
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
62
|
+
@session.sign_request(method: :post, path: '/v5/rfq/cancel-rfq', body: params)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Create a quote in response to an RFQ.
|
|
66
|
+
#
|
|
67
|
+
# POST /v5/rfq/create-quote
|
|
68
|
+
#
|
|
69
|
+
# @param rfq_id [String] RFQ ID
|
|
70
|
+
# @option kwargs [String] :quote_link_id User-defined quote link ID
|
|
71
|
+
# @option kwargs [Boolean] :anonymous Whether to submit the quote anonymously
|
|
72
|
+
# @option kwargs [Integer] :expire_in Expiration time in seconds
|
|
73
|
+
# @option kwargs [Array] :quote_buy_list Buy side quote entries
|
|
74
|
+
# @option kwargs [Array] :quote_sell_list Sell side quote entries
|
|
75
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
76
|
+
def create_quote(rfq_id:, **kwargs)
|
|
77
|
+
params = kwargs.merge(rfq_id: rfq_id)
|
|
78
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
79
|
+
@session.sign_request(method: :post, path: '/v5/rfq/create-quote', body: params)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Create a new RFQ (Request for Quote).
|
|
83
|
+
#
|
|
84
|
+
# POST /v5/rfq/create-rfq
|
|
85
|
+
#
|
|
86
|
+
# @param counterparties [Array] List of counterparties to receive the RFQ
|
|
87
|
+
# @param list [Array] List of legs for the RFQ
|
|
88
|
+
# @option kwargs [String] :rfq_link_id User-defined RFQ link ID
|
|
89
|
+
# @option kwargs [Boolean] :anonymous Whether to submit the RFQ anonymously
|
|
90
|
+
# @option kwargs [String] :strategy_type Strategy type
|
|
91
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
92
|
+
def create_rfq(counterparties:, list:, **kwargs)
|
|
93
|
+
params = kwargs.merge(counterparties: counterparties, list: list)
|
|
94
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
95
|
+
@session.sign_request(method: :post, path: '/v5/rfq/create-rfq', body: params)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Execute a quote to complete the trade.
|
|
99
|
+
#
|
|
100
|
+
# POST /v5/rfq/execute-quote
|
|
101
|
+
#
|
|
102
|
+
# @param rfq_id [String] RFQ ID
|
|
103
|
+
# @param quote_id [String] Quote ID
|
|
104
|
+
# @param quote_side [String] Quote side (Buy or Sell)
|
|
105
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
106
|
+
def execute_quote(rfq_id:, quote_id:, quote_side:, **kwargs)
|
|
107
|
+
params = kwargs.merge(rfq_id: rfq_id, quote_id: quote_id, quote_side: quote_side)
|
|
108
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
109
|
+
@session.sign_request(method: :post, path: '/v5/rfq/execute-quote', body: params)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Query public RFQ trades.
|
|
113
|
+
#
|
|
114
|
+
# GET /v5/rfq/public-trades
|
|
115
|
+
#
|
|
116
|
+
# @option kwargs [Integer] :start_time Start timestamp in milliseconds
|
|
117
|
+
# @option kwargs [Integer] :end_time End timestamp in milliseconds
|
|
118
|
+
# @option kwargs [Integer] :limit Maximum number of records to return
|
|
119
|
+
# @option kwargs [String] :cursor Pagination cursor
|
|
120
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
121
|
+
def get_public_trades(**kwargs)
|
|
122
|
+
params = kwargs.dup
|
|
123
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
124
|
+
@session.sign_request(method: :get, path: '/v5/rfq/public-trades', params: params)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Query historical quotes.
|
|
128
|
+
#
|
|
129
|
+
# GET /v5/rfq/quote-list
|
|
130
|
+
#
|
|
131
|
+
# @option kwargs [String] :rfq_id RFQ ID
|
|
132
|
+
# @option kwargs [String] :quote_id Quote ID
|
|
133
|
+
# @option kwargs [String] :quote_link_id User-defined quote link ID
|
|
134
|
+
# @option kwargs [String] :trader_type Trader type (Taker or Maker)
|
|
135
|
+
# @option kwargs [String] :status Quote status filter
|
|
136
|
+
# @option kwargs [Integer] :limit Maximum number of records to return
|
|
137
|
+
# @option kwargs [String] :cursor Pagination cursor
|
|
138
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
139
|
+
def get_quotes(**kwargs)
|
|
140
|
+
params = kwargs.dup
|
|
141
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
142
|
+
@session.sign_request(method: :get, path: '/v5/rfq/quote-list', params: params)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Query realtime (active) quotes.
|
|
146
|
+
#
|
|
147
|
+
# GET /v5/rfq/quote-realtime
|
|
148
|
+
#
|
|
149
|
+
# @option kwargs [String] :rfq_id RFQ ID
|
|
150
|
+
# @option kwargs [String] :quote_id Quote ID
|
|
151
|
+
# @option kwargs [String] :quote_link_id User-defined quote link ID
|
|
152
|
+
# @option kwargs [String] :trader_type Trader type (Taker or Maker)
|
|
153
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
154
|
+
def get_quotes_realtime(**kwargs)
|
|
155
|
+
params = kwargs.dup
|
|
156
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
157
|
+
@session.sign_request(method: :get, path: '/v5/rfq/quote-realtime', params: params)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Query RFQ configuration information.
|
|
161
|
+
#
|
|
162
|
+
# GET /v5/rfq/config
|
|
163
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
164
|
+
def get_config(**kwargs)
|
|
165
|
+
params = kwargs.dup
|
|
166
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
167
|
+
@session.sign_request(method: :get, path: '/v5/rfq/config', params: params)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Query historical RFQs.
|
|
171
|
+
#
|
|
172
|
+
# GET /v5/rfq/rfq-list
|
|
173
|
+
#
|
|
174
|
+
# @option kwargs [String] :rfq_id RFQ ID
|
|
175
|
+
# @option kwargs [String] :rfq_link_id User-defined RFQ link ID
|
|
176
|
+
# @option kwargs [String] :trader_type Trader type (Taker or Maker)
|
|
177
|
+
# @option kwargs [String] :status RFQ status filter
|
|
178
|
+
# @option kwargs [Integer] :limit Maximum number of records to return
|
|
179
|
+
# @option kwargs [String] :cursor Pagination cursor
|
|
180
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
181
|
+
def get_rfqs(**kwargs)
|
|
182
|
+
params = kwargs.dup
|
|
183
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
184
|
+
@session.sign_request(method: :get, path: '/v5/rfq/rfq-list', params: params)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Query realtime (active) RFQs.
|
|
188
|
+
#
|
|
189
|
+
# GET /v5/rfq/rfq-realtime
|
|
190
|
+
#
|
|
191
|
+
# @option kwargs [String] :rfq_id RFQ ID
|
|
192
|
+
# @option kwargs [String] :rfq_link_id User-defined RFQ link ID
|
|
193
|
+
# @option kwargs [String] :trader_type Trader type (Taker or Maker)
|
|
194
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
195
|
+
def get_rfqs_realtime(**kwargs)
|
|
196
|
+
params = kwargs.dup
|
|
197
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
198
|
+
@session.sign_request(method: :get, path: '/v5/rfq/rfq-realtime', params: params)
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Query RFQ trade history.
|
|
202
|
+
#
|
|
203
|
+
# GET /v5/rfq/trade-list
|
|
204
|
+
#
|
|
205
|
+
# @option kwargs [String] :rfq_id RFQ ID
|
|
206
|
+
# @option kwargs [String] :rfq_link_id User-defined RFQ link ID
|
|
207
|
+
# @option kwargs [String] :quote_id Quote ID
|
|
208
|
+
# @option kwargs [String] :quote_link_id User-defined quote link ID
|
|
209
|
+
# @option kwargs [String] :trader_type Trader type (Taker or Maker)
|
|
210
|
+
# @option kwargs [String] :status Trade status filter
|
|
211
|
+
# @option kwargs [Integer] :limit Maximum number of records to return
|
|
212
|
+
# @option kwargs [String] :cursor Pagination cursor
|
|
213
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
214
|
+
def get_trade_history(**kwargs)
|
|
215
|
+
params = kwargs.dup
|
|
216
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
217
|
+
@session.sign_request(method: :get, path: '/v5/rfq/trade-list', params: params)
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bybit
|
|
4
|
+
module RestApi
|
|
5
|
+
class SpotMarginService < BaseService
|
|
6
|
+
# Get historical interest rate for spot margin trading.
|
|
7
|
+
#
|
|
8
|
+
# GET /v5/spot-margin-trade/interest-rate-history
|
|
9
|
+
#
|
|
10
|
+
# @param currency [String] Currency
|
|
11
|
+
# @option kwargs [String] :vip_level VIP level
|
|
12
|
+
# @option kwargs [Integer] :start_time Start time in milliseconds
|
|
13
|
+
# @option kwargs [Integer] :end_time End time in milliseconds
|
|
14
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
15
|
+
# @see https://bybit-exchange.github.io/docs/v5/spot-margin-uta/historical-interest
|
|
16
|
+
def get_historical_interest_rate(currency:, **kwargs)
|
|
17
|
+
params = kwargs.merge(currency: currency)
|
|
18
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
19
|
+
@session.sign_request(method: :get, path: '/v5/spot-margin-trade/interest-rate-history', params: params)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Get spot margin position tiers.
|
|
23
|
+
#
|
|
24
|
+
# GET /v5/spot-margin-trade/position-tiers
|
|
25
|
+
#
|
|
26
|
+
# @option kwargs [String] :currency Currency
|
|
27
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
28
|
+
# @see https://bybit-exchange.github.io/docs/v5/spot-margin-uta/position-tiers
|
|
29
|
+
def get_position_tiers(**kwargs)
|
|
30
|
+
params = kwargs.dup
|
|
31
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
32
|
+
@session.sign_request(method: :get, path: '/v5/spot-margin-trade/position-tiers', params: params)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Get tiered collateral ratio for spot margin trading.
|
|
36
|
+
#
|
|
37
|
+
# GET /v5/spot-margin-trade/collateral
|
|
38
|
+
#
|
|
39
|
+
# @option kwargs [String] :currency Currency
|
|
40
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
41
|
+
def get_tiered_collateral_ratio(**kwargs)
|
|
42
|
+
params = kwargs.dup
|
|
43
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
44
|
+
@session.public_request(path: '/v5/spot-margin-trade/collateral', params: params)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Get VIP margin data for spot margin trading.
|
|
48
|
+
#
|
|
49
|
+
# GET /v5/spot-margin-trade/data
|
|
50
|
+
#
|
|
51
|
+
# @option kwargs [String] :vip_level VIP level
|
|
52
|
+
# @option kwargs [String] :currency Currency
|
|
53
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
54
|
+
# @see https://bybit-exchange.github.io/docs/v5/spot-margin-uta/vip-margin
|
|
55
|
+
def get_vip_margin_data(**kwargs)
|
|
56
|
+
params = kwargs.dup
|
|
57
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
58
|
+
@session.public_request(path: '/v5/spot-margin-trade/data', params: params)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|