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,386 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bybit
|
|
4
|
+
module RestApi
|
|
5
|
+
class BotService < BaseService
|
|
6
|
+
# Close a running DCA bot with a specified settlement mode
|
|
7
|
+
#
|
|
8
|
+
# POST /v5/dca/close-bot
|
|
9
|
+
#
|
|
10
|
+
# @param bot_id [Integer] Identifier of the DCA bot to close
|
|
11
|
+
# @param close_mode [Integer] Settlement mode used to close the bot
|
|
12
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
13
|
+
def close_dca_bot(bot_id:, close_mode:, **kwargs)
|
|
14
|
+
body = kwargs.merge(bot_id: bot_id, close_mode: close_mode)
|
|
15
|
+
@session.sign_request(method: :post, path: '/v5/dca/close-bot', body: body)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Create a new DCA (Dollar-Cost Averaging) bot with custom parameters
|
|
19
|
+
#
|
|
20
|
+
# POST /v5/dca/create-bot
|
|
21
|
+
#
|
|
22
|
+
# @param parameters [Hash] DCA bot configuration parameters
|
|
23
|
+
# @option kwargs [Hash] :tools_discovery_parameter Tools discovery parameter object
|
|
24
|
+
# @option kwargs [String] :channel Channel identifier
|
|
25
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
26
|
+
def create_dca_bot(parameters:, **kwargs)
|
|
27
|
+
body = kwargs.merge(parameters: parameters)
|
|
28
|
+
@session.sign_request(method: :post, path: '/v5/dca/create-bot', body: body)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Close a running futures combo bot by bot ID
|
|
32
|
+
#
|
|
33
|
+
# POST /v5/fcombobot/close
|
|
34
|
+
#
|
|
35
|
+
# @param bot_id [Integer] Combo bot ID to close
|
|
36
|
+
# @option kwargs [Integer] :stop_type Stop type identifier
|
|
37
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
38
|
+
def close_combo_bot(bot_id:, **kwargs)
|
|
39
|
+
body = kwargs.merge(bot_id: bot_id)
|
|
40
|
+
@session.sign_request(method: :post, path: '/v5/fcombobot/close', body: body)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Create a new futures combo bot with multi-symbol portfolio and rebalancing
|
|
44
|
+
#
|
|
45
|
+
# POST /v5/fcombobot/create
|
|
46
|
+
#
|
|
47
|
+
# @param leverage [String] Leverage setting for the combo bot
|
|
48
|
+
# @param init_margin [String] Initial margin for the combo bot
|
|
49
|
+
# @param adjust_position_mode [Integer] Position adjustment mode
|
|
50
|
+
# @param symbol_settings [Array] Per-symbol configuration settings for the combo bot
|
|
51
|
+
# @option kwargs [String] :adjust_position_percent Position adjustment percent
|
|
52
|
+
# @option kwargs [Integer] :adjust_position_time_interval Position adjustment time interval
|
|
53
|
+
# @option kwargs [String] :sl_percent Stop loss percent
|
|
54
|
+
# @option kwargs [String] :tp_percent Take profit percent
|
|
55
|
+
# @option kwargs [Integer] :source Source identifier
|
|
56
|
+
# @option kwargs [Integer] :block_source Block source identifier
|
|
57
|
+
# @option kwargs [Integer] :create_type Bot creation type
|
|
58
|
+
# @option kwargs [Integer] :followed_bot_id ID of the bot being followed
|
|
59
|
+
# @option kwargs [String] :init_bonus Initial bonus amount
|
|
60
|
+
# @option kwargs [String] :trailing_stop_percent Trailing stop percent
|
|
61
|
+
# @option kwargs [String] :channel Channel identifier
|
|
62
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
63
|
+
def create_combo_bot(leverage:, init_margin:, adjust_position_mode:, symbol_settings:, **kwargs)
|
|
64
|
+
body = kwargs.merge(
|
|
65
|
+
leverage: leverage,
|
|
66
|
+
init_margin: init_margin,
|
|
67
|
+
adjust_position_mode: adjust_position_mode,
|
|
68
|
+
symbol_settings: symbol_settings
|
|
69
|
+
)
|
|
70
|
+
@session.sign_request(method: :post, path: '/v5/fcombobot/create', body: body)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Get full details of a futures combo bot including PnL, positions, and status
|
|
74
|
+
#
|
|
75
|
+
# POST /v5/fcombobot/detail
|
|
76
|
+
#
|
|
77
|
+
# @param bot_id [Integer] Combo bot ID
|
|
78
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
79
|
+
def get_combo_detail(bot_id:, **kwargs)
|
|
80
|
+
body = kwargs.merge(bot_id: bot_id)
|
|
81
|
+
@session.sign_request(method: :post, path: '/v5/fcombobot/detail', body: body)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Validate combo bot input parameters and return allowable ranges
|
|
85
|
+
#
|
|
86
|
+
# POST /v5/fcombobot/getlimit
|
|
87
|
+
#
|
|
88
|
+
# @param leverage [String] Leverage setting
|
|
89
|
+
# @param init_margin [String] Initial margin
|
|
90
|
+
# @param adjust_position_mode [Integer] Position adjustment mode
|
|
91
|
+
# @param symbol_settings [Array] Per-symbol configuration settings
|
|
92
|
+
# @option kwargs [String] :adjust_position_percent Position adjustment percent
|
|
93
|
+
# @option kwargs [Integer] :adjust_position_time_interval Position adjustment time interval
|
|
94
|
+
# @option kwargs [String] :sl_percent Stop loss percent
|
|
95
|
+
# @option kwargs [String] :tp_percent Take profit percent
|
|
96
|
+
# @option kwargs [Boolean] :need_to_slippage Whether to include slippage in validation
|
|
97
|
+
# @option kwargs [String] :app_name Application name identifier
|
|
98
|
+
# @option kwargs [String] :trailing_stop_percent Trailing stop percent
|
|
99
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
100
|
+
def get_combo_limit(leverage:, init_margin:, adjust_position_mode:, symbol_settings:, **kwargs)
|
|
101
|
+
body = kwargs.merge(
|
|
102
|
+
leverage: leverage,
|
|
103
|
+
init_margin: init_margin,
|
|
104
|
+
adjust_position_mode: adjust_position_mode,
|
|
105
|
+
symbol_settings: symbol_settings
|
|
106
|
+
)
|
|
107
|
+
@session.sign_request(method: :post, path: '/v5/fcombobot/getlimit', body: body)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Close a running futures grid bot by bot ID
|
|
111
|
+
#
|
|
112
|
+
# POST /v5/fgridbot/close
|
|
113
|
+
#
|
|
114
|
+
# @param bot_id [Integer] Bot ID of the futures grid bot to close
|
|
115
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
116
|
+
def close_futures_grid_bot(bot_id:, **kwargs)
|
|
117
|
+
body = kwargs.merge(bot_id: bot_id)
|
|
118
|
+
@session.sign_request(method: :post, path: '/v5/fgridbot/close', body: body)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Create a new futures grid trading bot with specified parameters
|
|
122
|
+
#
|
|
123
|
+
# POST /v5/fgridbot/create
|
|
124
|
+
#
|
|
125
|
+
# @param symbol [String] Trading symbol
|
|
126
|
+
# @param grid_mode [Integer] Grid mode selector
|
|
127
|
+
# @param min_price [String] Lower bound of the grid price range
|
|
128
|
+
# @param max_price [String] Upper bound of the grid price range
|
|
129
|
+
# @param cell_number [Integer] Number of grid cells
|
|
130
|
+
# @param leverage [String] Leverage to use for the grid bot
|
|
131
|
+
# @param grid_type [Integer] Grid type (arithmetic/geometric)
|
|
132
|
+
# @param total_investment [String] Total investment amount
|
|
133
|
+
# @option kwargs [String] :take_profit_per Take profit percentage
|
|
134
|
+
# @option kwargs [String] :stop_loss_per Stop loss percentage
|
|
135
|
+
# @option kwargs [String] :entry_price Entry price for the bot
|
|
136
|
+
# @option kwargs [Integer] :source Source identifier
|
|
137
|
+
# @option kwargs [Integer] :followed_grid_id ID of the grid bot being copied
|
|
138
|
+
# @option kwargs [Hash] :tools_discovery_parameter Tools discovery parameter payload
|
|
139
|
+
# @option kwargs [String] :stop_loss_price Stop loss trigger price
|
|
140
|
+
# @option kwargs [String] :take_profit_price Take profit trigger price
|
|
141
|
+
# @option kwargs [Integer] :tp_sl_type Take-profit/stop-loss type
|
|
142
|
+
# @option kwargs [Integer] :block_source Block source identifier
|
|
143
|
+
# @option kwargs [Integer] :create_type Create type identifier
|
|
144
|
+
# @option kwargs [String] :init_bonus Initial bonus amount
|
|
145
|
+
# @option kwargs [String] :business_remark Business remark note
|
|
146
|
+
# @option kwargs [String] :trailing_stop_per Trailing stop percentage
|
|
147
|
+
# @option kwargs [String] :move_up_price Move-up trigger price
|
|
148
|
+
# @option kwargs [String] :move_down_price Move-down trigger price
|
|
149
|
+
# @option kwargs [String] :channel Client channel identifier
|
|
150
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
151
|
+
def create_futures_grid_bot(symbol:, grid_mode:, min_price:, max_price:, cell_number:, leverage:, grid_type:, total_investment:, **kwargs)
|
|
152
|
+
body = kwargs.merge(
|
|
153
|
+
symbol: symbol,
|
|
154
|
+
grid_mode: grid_mode,
|
|
155
|
+
min_price: min_price,
|
|
156
|
+
max_price: max_price,
|
|
157
|
+
cell_number: cell_number,
|
|
158
|
+
leverage: leverage,
|
|
159
|
+
grid_type: grid_type,
|
|
160
|
+
total_investment: total_investment
|
|
161
|
+
)
|
|
162
|
+
@session.sign_request(method: :post, path: '/v5/fgridbot/create', body: body)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Get full details of a futures grid bot including PnL, positions, and status
|
|
166
|
+
#
|
|
167
|
+
# POST /v5/fgridbot/detail
|
|
168
|
+
#
|
|
169
|
+
# @param bot_id [Integer] Bot ID of the futures grid bot
|
|
170
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
171
|
+
def get_futures_grid_detail(bot_id:, **kwargs)
|
|
172
|
+
body = kwargs.merge(bot_id: bot_id)
|
|
173
|
+
@session.sign_request(method: :post, path: '/v5/fgridbot/detail', body: body)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Validate futures grid bot input parameters and return allowable ranges
|
|
177
|
+
#
|
|
178
|
+
# POST /v5/fgridbot/validate
|
|
179
|
+
#
|
|
180
|
+
# @param symbol [String] Trading symbol
|
|
181
|
+
# @param cell_number [Integer] Number of grid cells
|
|
182
|
+
# @param min_price [String] Lower bound of the grid price range
|
|
183
|
+
# @param max_price [String] Upper bound of the grid price range
|
|
184
|
+
# @param leverage [String] Leverage to validate
|
|
185
|
+
# @param grid_type [Integer] Grid type (arithmetic/geometric)
|
|
186
|
+
# @param grid_mode [Integer] Grid mode selector
|
|
187
|
+
# @option kwargs [String] :stop_loss_price Stop loss trigger price
|
|
188
|
+
# @option kwargs [String] :take_profit_price Take profit trigger price
|
|
189
|
+
# @option kwargs [Integer] :tp_sl_type Take-profit/stop-loss type
|
|
190
|
+
# @option kwargs [String] :entry_price Entry price
|
|
191
|
+
# @option kwargs [String] :stop_loss_per Stop loss percentage
|
|
192
|
+
# @option kwargs [String] :take_profit_per Take profit percentage
|
|
193
|
+
# @option kwargs [String] :trailing_stop_per Trailing stop percentage
|
|
194
|
+
# @option kwargs [String] :init_margin Initial margin amount
|
|
195
|
+
# @option kwargs [String] :move_up_price Move-up trigger price
|
|
196
|
+
# @option kwargs [String] :move_down_price Move-down trigger price
|
|
197
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
198
|
+
def validate_futures_grid_input(symbol:, cell_number:, min_price:, max_price:, leverage:, grid_type:, grid_mode:, **kwargs)
|
|
199
|
+
body = kwargs.merge(
|
|
200
|
+
symbol: symbol,
|
|
201
|
+
cell_number: cell_number,
|
|
202
|
+
min_price: min_price,
|
|
203
|
+
max_price: max_price,
|
|
204
|
+
leverage: leverage,
|
|
205
|
+
grid_type: grid_type,
|
|
206
|
+
grid_mode: grid_mode
|
|
207
|
+
)
|
|
208
|
+
@session.sign_request(method: :post, path: '/v5/fgridbot/validate', body: body)
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Close a running futures Martingale bot by bot ID
|
|
212
|
+
#
|
|
213
|
+
# POST /v5/fmartingalebot/close
|
|
214
|
+
#
|
|
215
|
+
# @param bot_id [Integer] Bot ID
|
|
216
|
+
# @option kwargs [String] :stop_type Stop type
|
|
217
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
218
|
+
def close_futures_martingale_bot(bot_id:, **kwargs)
|
|
219
|
+
body = kwargs.merge(bot_id: bot_id)
|
|
220
|
+
@session.sign_request(method: :post, path: '/v5/fmartingalebot/close', body: body)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Create a new futures Martingale bot with DCA averaging strategy
|
|
224
|
+
#
|
|
225
|
+
# POST /v5/fmartingalebot/create
|
|
226
|
+
#
|
|
227
|
+
# @param symbol [String] Trading symbol
|
|
228
|
+
# @param martingale_mode [String] Martingale mode
|
|
229
|
+
# @param leverage [String] Leverage
|
|
230
|
+
# @param price_float_percent [String] Price float percent triggering next add position
|
|
231
|
+
# @param add_position_percent [String] Add position percent per averaging step
|
|
232
|
+
# @param add_position_num [Integer] Number of add position steps
|
|
233
|
+
# @param init_margin [String] Initial margin
|
|
234
|
+
# @param round_tp_percent [String] Round take-profit percent
|
|
235
|
+
# @option kwargs [String] :auto_cycle_toggle Auto cycle toggle
|
|
236
|
+
# @option kwargs [String] :sl_percent Stop-loss percent
|
|
237
|
+
# @option kwargs [String] :entry_price Entry price
|
|
238
|
+
# @option kwargs [String] :source Source
|
|
239
|
+
# @option kwargs [Integer] :followed_bot_id Followed bot ID
|
|
240
|
+
# @option kwargs [String] :block_source Block source
|
|
241
|
+
# @option kwargs [String] :create_type Create type
|
|
242
|
+
# @option kwargs [String] :init_bonus Initial bonus
|
|
243
|
+
# @option kwargs [String] :channel Channel
|
|
244
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
245
|
+
def create_futures_martingale_bot(symbol:, martingale_mode:, leverage:, price_float_percent:, add_position_percent:, add_position_num:, init_margin:, round_tp_percent:, **kwargs)
|
|
246
|
+
body = kwargs.merge(
|
|
247
|
+
symbol: symbol,
|
|
248
|
+
martingale_mode: martingale_mode,
|
|
249
|
+
leverage: leverage,
|
|
250
|
+
price_float_percent: price_float_percent,
|
|
251
|
+
add_position_percent: add_position_percent,
|
|
252
|
+
add_position_num: add_position_num,
|
|
253
|
+
init_margin: init_margin,
|
|
254
|
+
round_tp_percent: round_tp_percent
|
|
255
|
+
)
|
|
256
|
+
@session.sign_request(method: :post, path: '/v5/fmartingalebot/create', body: body)
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# Get full details of a futures Martingale bot including PnL, positions, and round progress
|
|
260
|
+
#
|
|
261
|
+
# POST /v5/fmartingalebot/detail
|
|
262
|
+
#
|
|
263
|
+
# @param bot_id [Integer] Bot ID
|
|
264
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
265
|
+
def get_futures_martingale_detail(bot_id:, **kwargs)
|
|
266
|
+
body = kwargs.merge(bot_id: bot_id)
|
|
267
|
+
@session.sign_request(method: :post, path: '/v5/fmartingalebot/detail', body: body)
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# Validate Martingale bot input parameters and return allowable ranges
|
|
271
|
+
#
|
|
272
|
+
# POST /v5/fmartingalebot/getlimit
|
|
273
|
+
#
|
|
274
|
+
# @param symbol [String] Trading symbol
|
|
275
|
+
# @param martingale_mode [String] Martingale mode
|
|
276
|
+
# @param leverage [String] Leverage
|
|
277
|
+
# @option kwargs [String] :price_float_percent Price float percent
|
|
278
|
+
# @option kwargs [String] :add_position_percent Add position percent
|
|
279
|
+
# @option kwargs [Integer] :add_position_num Number of add position steps
|
|
280
|
+
# @option kwargs [String] :init_margin Initial margin
|
|
281
|
+
# @option kwargs [String] :round_tp_percent Round take-profit percent
|
|
282
|
+
# @option kwargs [String] :sl_percent Stop-loss percent
|
|
283
|
+
# @option kwargs [String] :entry_price Entry price
|
|
284
|
+
# @option kwargs [Boolean] :need_to_slippage Whether to include slippage
|
|
285
|
+
# @option kwargs [String] :app_name App name
|
|
286
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
287
|
+
def get_futures_martingale_limit(symbol:, martingale_mode:, leverage:, **kwargs)
|
|
288
|
+
body = kwargs.merge(
|
|
289
|
+
symbol: symbol,
|
|
290
|
+
martingale_mode: martingale_mode,
|
|
291
|
+
leverage: leverage
|
|
292
|
+
)
|
|
293
|
+
@session.sign_request(method: :post, path: '/v5/fmartingalebot/getlimit', body: body)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
# Close a running spot grid bot with a specified settlement mode
|
|
297
|
+
#
|
|
298
|
+
# POST /v5/grid/close-grid
|
|
299
|
+
#
|
|
300
|
+
# @param grid_id [Integer] Grid bot ID
|
|
301
|
+
# @param close_mode [Integer] Close/settlement mode
|
|
302
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
303
|
+
def close_grid_bot(grid_id:, close_mode:, **kwargs)
|
|
304
|
+
body = kwargs.merge(grid_id: grid_id, close_mode: close_mode)
|
|
305
|
+
@session.sign_request(method: :post, path: '/v5/grid/close-grid', body: body)
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# Create a new spot grid trading bot
|
|
309
|
+
#
|
|
310
|
+
# POST /v5/grid/create-grid
|
|
311
|
+
#
|
|
312
|
+
# @param symbol [String] Trading pair symbol
|
|
313
|
+
# @param max_price [String] Upper bound price of the grid
|
|
314
|
+
# @param min_price [String] Lower bound price of the grid
|
|
315
|
+
# @param total_investment [String] Total investment amount
|
|
316
|
+
# @param cell_number [Integer] Number of grid cells
|
|
317
|
+
# @option kwargs [Integer] :followed_grid_id ID of the grid bot being copied/followed
|
|
318
|
+
# @option kwargs [Integer] :source Creation source identifier
|
|
319
|
+
# @option kwargs [String] :entry_price Entry price for the bot
|
|
320
|
+
# @option kwargs [String] :stop_loss_price Stop loss price
|
|
321
|
+
# @option kwargs [String] :take_profit_price Take profit price
|
|
322
|
+
# @option kwargs [Hash] :tools_discovery_parameter Tools discovery parameter object
|
|
323
|
+
# @option kwargs [String] :base_investment Base asset investment amount
|
|
324
|
+
# @option kwargs [String] :quote_investment Quote asset investment amount
|
|
325
|
+
# @option kwargs [Integer] :invest_mode Investment mode
|
|
326
|
+
# @option kwargs [Integer] :block_source Block source identifier
|
|
327
|
+
# @option kwargs [Integer] :create_type Creation type
|
|
328
|
+
# @option kwargs [String] :ts_percent Trailing stop percent
|
|
329
|
+
# @option kwargs [Boolean] :enable_trailing Whether to enable trailing
|
|
330
|
+
# @option kwargs [String] :limit_up_price Upper limit price
|
|
331
|
+
# @option kwargs [String] :channel Channel identifier
|
|
332
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
333
|
+
def create_grid_bot(symbol:, max_price:, min_price:, total_investment:, cell_number:, **kwargs)
|
|
334
|
+
body = kwargs.merge(
|
|
335
|
+
symbol: symbol,
|
|
336
|
+
max_price: max_price,
|
|
337
|
+
min_price: min_price,
|
|
338
|
+
total_investment: total_investment,
|
|
339
|
+
cell_number: cell_number
|
|
340
|
+
)
|
|
341
|
+
@session.sign_request(method: :post, path: '/v5/grid/create-grid', body: body)
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
# Query full details of a specific grid bot by grid_id
|
|
345
|
+
#
|
|
346
|
+
# POST /v5/grid/query-grid-detail
|
|
347
|
+
#
|
|
348
|
+
# @param grid_id [Integer] Grid bot ID
|
|
349
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
350
|
+
def get_grid_detail(grid_id:, **kwargs)
|
|
351
|
+
body = kwargs.merge(grid_id: grid_id)
|
|
352
|
+
@session.sign_request(method: :post, path: '/v5/grid/query-grid-detail', body: body)
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
# Validate spot grid bot parameters before creation
|
|
356
|
+
#
|
|
357
|
+
# POST /v5/grid/validate-input
|
|
358
|
+
#
|
|
359
|
+
# @param symbol [String] Trading pair symbol
|
|
360
|
+
# @param cell_number [Integer] Number of grid cells
|
|
361
|
+
# @param min_price [String] Lower bound price of the grid
|
|
362
|
+
# @param max_price [String] Upper bound price of the grid
|
|
363
|
+
# @param total_investment [String] Total investment amount
|
|
364
|
+
# @option kwargs [String] :stop_loss Stop loss price
|
|
365
|
+
# @option kwargs [String] :take_profit Take profit price
|
|
366
|
+
# @option kwargs [String] :entry_price Entry price for the bot
|
|
367
|
+
# @option kwargs [String] :base_investment Base asset investment amount
|
|
368
|
+
# @option kwargs [String] :quote_investment Quote asset investment amount
|
|
369
|
+
# @option kwargs [Integer] :invest_mode Investment mode
|
|
370
|
+
# @option kwargs [String] :ts_percent Trailing stop percent
|
|
371
|
+
# @option kwargs [Boolean] :enable_trailing Whether to enable trailing
|
|
372
|
+
# @option kwargs [String] :limit_up_price Upper limit price
|
|
373
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
374
|
+
def validate_grid_input(symbol:, cell_number:, min_price:, max_price:, total_investment:, **kwargs)
|
|
375
|
+
body = kwargs.merge(
|
|
376
|
+
symbol: symbol,
|
|
377
|
+
cell_number: cell_number,
|
|
378
|
+
min_price: min_price,
|
|
379
|
+
max_price: max_price,
|
|
380
|
+
total_investment: total_investment
|
|
381
|
+
)
|
|
382
|
+
@session.sign_request(method: :post, path: '/v5/grid/validate-input', body: body)
|
|
383
|
+
end
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bybit
|
|
4
|
+
module RestApi
|
|
5
|
+
class BrokerService < BaseService
|
|
6
|
+
# Distribute voucher
|
|
7
|
+
#
|
|
8
|
+
# POST /v5/broker/award/distribute-award
|
|
9
|
+
#
|
|
10
|
+
# @param account_id [String] Account ID
|
|
11
|
+
# @param award_id [String] Award ID
|
|
12
|
+
# @param spec_code [String] Spec code
|
|
13
|
+
# @param amount [String] Distribution amount
|
|
14
|
+
# @param broker_id [String] Broker ID
|
|
15
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
16
|
+
def distribute_award(account_id:, award_id:, spec_code:, amount:, broker_id:, **kwargs)
|
|
17
|
+
params = kwargs.merge(account_id: account_id, award_id: award_id, spec_code: spec_code, amount: amount, broker_id: broker_id)
|
|
18
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
19
|
+
@session.sign_request(method: :post, path: '/v5/broker/award/distribute-award', body: params)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Get voucher details
|
|
23
|
+
#
|
|
24
|
+
# POST /v5/broker/award/info
|
|
25
|
+
#
|
|
26
|
+
# @param id [String] Voucher ID
|
|
27
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
28
|
+
def get_award_info(id:, **kwargs)
|
|
29
|
+
params = kwargs.merge(id: id)
|
|
30
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
31
|
+
@session.sign_request(method: :post, path: '/v5/broker/award/info', body: params)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Query voucher distribution record
|
|
35
|
+
#
|
|
36
|
+
# POST /v5/broker/award/distribution-record
|
|
37
|
+
#
|
|
38
|
+
# @param account_id [String] Account ID
|
|
39
|
+
# @param award_id [String] Award ID
|
|
40
|
+
# @param spec_code [String] Spec code
|
|
41
|
+
# @option kwargs [Boolean] :with_used_amount Include used amount flag
|
|
42
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
43
|
+
def get_distribution_record(account_id:, award_id:, spec_code:, **kwargs)
|
|
44
|
+
params = kwargs.merge(account_id: account_id, award_id: award_id, spec_code: spec_code)
|
|
45
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
46
|
+
@session.sign_request(method: :post, path: '/v5/broker/award/distribution-record', body: params)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Get Broker Account Info
|
|
50
|
+
#
|
|
51
|
+
# GET /v5/broker/account-info
|
|
52
|
+
def get_broker_account_info
|
|
53
|
+
@session.sign_request(method: :get, path: '/v5/broker/account-info')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Query Broker All UID Rate Limits
|
|
57
|
+
#
|
|
58
|
+
# GET /v5/broker/apilimit/query-all
|
|
59
|
+
#
|
|
60
|
+
# @option kwargs [String] :uids UIDs to query
|
|
61
|
+
# @option kwargs [Integer] :limit Result limit
|
|
62
|
+
# @option kwargs [String] :cursor Pagination cursor
|
|
63
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
64
|
+
def list_broker_sub_uids(**kwargs)
|
|
65
|
+
params = kwargs.dup
|
|
66
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
67
|
+
@session.sign_request(method: :get, path: '/v5/broker/apilimit/query-all', params: params)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Query Broker Rate Limit Cap
|
|
71
|
+
#
|
|
72
|
+
# GET /v5/broker/apilimit/query-cap
|
|
73
|
+
def get_broker_rate_limit_cap
|
|
74
|
+
@session.sign_request(method: :get, path: '/v5/broker/apilimit/query-cap')
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Get Broker Earnings Info
|
|
78
|
+
#
|
|
79
|
+
# GET /v5/broker/earnings-info
|
|
80
|
+
#
|
|
81
|
+
# @option kwargs [String] :biz_type Business type
|
|
82
|
+
# @option kwargs [String] :begin_ Begin date
|
|
83
|
+
# @option kwargs [String] :end_ End date
|
|
84
|
+
# @option kwargs [String] :uid Sub UID
|
|
85
|
+
# @option kwargs [Integer] :limit Result limit
|
|
86
|
+
# @option kwargs [String] :cursor Pagination cursor
|
|
87
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
88
|
+
def list_broker_earnings(**kwargs)
|
|
89
|
+
params = kwargs.dup
|
|
90
|
+
params[:begin] = params.delete(:begin_) if params.key?(:begin_)
|
|
91
|
+
params[:end] = params.delete(:end_) if params.key?(:end_)
|
|
92
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
93
|
+
@session.sign_request(method: :get, path: '/v5/broker/earnings-info', params: params)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Set Broker API Rate Limit
|
|
97
|
+
#
|
|
98
|
+
# POST /v5/broker/apilimit/set
|
|
99
|
+
#
|
|
100
|
+
# @option kwargs [Array] :list List of rate limit config entries
|
|
101
|
+
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
|
|
102
|
+
def set_api_limit(**kwargs)
|
|
103
|
+
params = kwargs.dup
|
|
104
|
+
params = Bybit::Utils::WireKeys.camelize(params)
|
|
105
|
+
@session.sign_request(method: :post, path: '/v5/broker/apilimit/set', body: params)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|