bybit/models/responses.rs
1use crate::prelude::*;
2
3/// Response structure for collateral information requests.
4///
5/// Returned by the `/v5/account/collateral-info` endpoint, this struct provides details about coins available as collateral for margin trading. Bots use this to assess collateral eligibility, borrowing limits, and margin requirements.
6pub type CollateralInfoResponse = BybitApiResponse<CollateralInfoList>;
7
8/// An opaque response where the payload is `serde_json::Value`. Used internally by decoding
9/// to check ret_code and then conditionally try to deserialize the `result` field.
10pub type BybitApiResponseOpaquePayload = BybitApiResponse<Value, Value, u64>;
11
12/// Represents the response from Bybit's server time endpoint.
13///
14/// This struct is returned when querying the server time via the Bybit API (`/v5/market/time`). It provides the current server time, which is critical for synchronizing trading bot operations with Bybit's server to avoid timestamp-related errors in API requests.
15pub type ServerTimeResponse = BybitApiResponse<ServerTime>;
16
17/// Response structure for Kline (candlestick) data requests.
18///
19/// Returned by the `/v5/market/kline` endpoint, this struct contains Kline data for a specified trading pair and interval. For perpetual futures, Kline data is essential for technical indicators (e.g., moving averages, RSI) used in trading bots.
20pub type KlineResponse = BybitApiResponse<KlineSummary>;
21
22/// Response structure for Mark Price Kline data requests.
23///
24/// Returned by the `/v5/market/mark-price-kline` endpoint, this struct provides Kline data based on the mark price, which is a reference price used in perpetual futures to avoid manipulation and ensure fair liquidation. Mark price Klines are critical for bots to assess funding rates and liquidation risks.
25pub type MarkPriceKlineResponse = BybitApiResponse<MarkPriceKlineSummary>;
26
27/// Response structure for Index Price Kline data requests.
28///
29/// Returned by the `/v5/market/index-price-kline` endpoint, this struct provides Kline data based on the index price, which tracks the underlying asset’s spot price across multiple exchanges. For perpetual futures, the index price is used to anchor the mark price, ensuring it reflects market conditions.
30pub type IndexPriceKlineResponse = BybitApiResponse<IndexPriceKlineSummary>;
31
32/// Response structure for Premium Index Price Kline data requests.
33///
34/// Returned by the `/v5/market/premium-index-price-kline` endpoint, this struct provides Kline data based on the premium index price, which reflects the premium or discount of the perpetual futures price relative to the spot index price. This is key for understanding funding rate dynamics.
35pub type PremiumIndexPriceKlineResponse = BybitApiResponse<PremiumIndexPriceKlineSummary>;
36
37/// Response structure for instrument information requests.
38///
39/// Returned by the `/v5/market/instruments-info` endpoint, this struct provides details about trading instruments, including perpetual futures contracts. Bots use this to configure trading parameters like leverage and order sizes.
40pub type InstrumentInfoResponse = BybitApiResponse<InstrumentInfo>;
41
42/// Response structure for order book data requests.
43///
44/// Returned by the `/v5/market/orderbook` endpoint, this struct provides the current order book for a trading pair, including bid and ask levels. Bots use this for liquidity analysis and to optimize order placement in perpetual futures.
45pub type OrderBookResponse = BybitApiResponse<OrderBook>;
46
47/// Response structure for RPI (Real-time Price Improvement) order book data requests.
48///
49/// Returned by the `/v5/market/rpi_orderbook` endpoint, this struct provides the current RPI order book for a trading pair, including bid and ask levels with RPI size information. RPI orders can provide price improvement for takers.
50pub type RPIOrderbookResponse = BybitApiResponse<RPIOrderbook>;
51
52/// Response structure for ticker data requests.
53///
54/// Returned by the `/v5/market/tickers` endpoint, this struct provides real-time market data for a trading pair, such as current price, volume, and funding rates. For perpetual futures, this is critical for monitoring market conditions and funding costs.
55pub type TickerResponse = BybitApiResponse<TickersInfo>;
56
57/// Response structure for funding rate history requests.
58///
59/// Returned by the `/v5/market/funding/history` endpoint, this struct provides historical funding rate data for a perpetual futures contract. Bots use this to analyze funding costs and optimize position timing.
60pub type FundingRateResponse = BybitApiResponse<FundingRateSummary>;
61
62/// Response structure for recent trading records requests.
63///
64/// Returned by the `/v5/market/recent-trade` endpoint, this struct provides a list of recently executed trades for a specified trading pair. Bots use this data to analyze trade volume, price trends, and market sentiment in perpetual futures, which can inform short-term trading decisions.
65pub type RecentTradesResponse = BybitApiResponse<RecentTrades>;
66
67/// Response structure for open interest data requests.
68///
69/// Returned by the `/v5/market/open-interest` endpoint, this struct provides historical or real-time open interest data for a perpetual futures contract. Bots use this to gauge market sentiment, as high open interest often indicates strong participation and potential for larger price moves.
70pub type OpenInterestResponse = BybitApiResponse<OpenInterestSummary>;
71
72/// Represents the response from Bybit’s historical volatility API endpoint.
73/// Contains metadata and a list of volatility data points for the requested cryptocurrency.
74/// This is critical for bots analyzing price stability in perpetual futures markets.
75pub type HistoricalVolatilityResponse = BybitApiResponse<Vec<HistoricalVolatility>>;
76
77/// Represents the response from Bybit’s insurance fund API endpoint.
78/// The insurance fund covers losses from bankrupt positions in perpetual futures, ensuring
79/// market stability. Bots use this to assess exchange risk and counterparty exposure.
80pub type InsuranceResponse = BybitApiResponse<InsuranceSummary>;
81
82/// Represents the response from Bybit’s risk limit API endpoint.
83/// Provides details on position size and leverage constraints for perpetual futures trading.
84pub type RiskLimitResponse = BybitApiResponse<RiskLimitSummary>;
85
86/// Represents the response from Bybit’s delivery price API endpoint.
87/// Delivery prices apply to futures with settlement dates, but for perpetual futures, this may
88/// be used for reference or historical analysis by bots.
89pub type DeliveryPriceResponse = BybitApiResponse<DeliveryPriceSummary>;
90
91/// Response structure for new delivery price data requests (options only).
92///
93/// Returned by the `/v5/market/new-delivery-price` endpoint, this struct provides
94/// historical option delivery prices. This endpoint is specifically for options contracts
95/// and returns the most recent 50 records in reverse order of delivery time by default.
96pub type NewDeliveryPriceResponse = BybitApiResponse<NewDeliveryPriceSummary>;
97
98/// Response structure for ADL (Auto-Deleveraging) alert data requests.
99///
100/// Returned by the `/v5/market/adlAlert` endpoint, this struct provides
101/// ADL alert information and insurance pool data. ADL is a risk management
102/// mechanism that automatically closes positions when the insurance pool
103/// balance reaches certain thresholds to prevent systemic risk.
104/// Data update frequency is every 1 minute.
105pub type ADLAlertResponse = BybitApiResponse<ADLAlertSummary>;
106
107/// Represents the response from Bybit’s long/short ratio API endpoint.
108/// The long/short ratio shows the balance of bullish vs. bearish positions in the market,
109/// critical for sentiment analysis in perpetual futures trading.
110pub type LongShortRatioResponse = BybitApiResponse<LongShortRatioSummary>;
111
112/// Represents the response from Bybit's system status API endpoint.
113/// This endpoint returns information about platform maintenance or service incidents.
114pub type SystemStatusResponse = BybitApiResponse<SystemStatusResult>;
115
116/// Represents the response from Bybit when amending an order.
117///
118/// This struct captures the result of an order amendment request, including success
119/// status and updated order details. In perpetual futures, amending orders (e.g.,
120/// changing price, quantity, or TP/SL) is common to adapt to market conditions. Bots
121/// should check `ret_code` and `ret_msg` to confirm success and handle errors (e.g.,
122/// invalid price, insufficient margin). The `result` field provides the updated order
123/// status, which bots can use to track changes.
124pub type AmendOrderResponse = BybitApiResponse<OrderStatus>;
125
126/// Represents the response from Bybit when canceling an order.
127///
128/// This struct captures the result of an order cancellation request. Bots should check
129/// `ret_code` and `ret_msg` to confirm success and handle errors (e.g., order already
130/// filled). The `result` field provides the canceled order’s status, aiding in state
131/// management for perpetual futures trading.
132pub type CancelOrderResponse = BybitApiResponse<OrderStatus>;
133
134/// Represents the response from Bybit when querying open orders.
135///
136/// This struct captures the list of open orders and metadata. Bots should parse the
137/// `result` field to track active orders and use `next_page_cursor` for pagination
138/// in perpetual futures trading. Check `ret_code` and `ret_msg` to handle errors.
139pub type OpenOrdersResponse = BybitApiResponse<OrderHistory>;
140
141/// Represents the response from Bybit when placing an order.
142///
143/// This struct captures the result of an order placement request. Bots should check
144/// `ret_code` and `ret_msg` to confirm success and handle errors (e.g., insufficient
145/// margin). The `result` field provides the new order’s status for tracking in
146/// perpetual futures trading.
147pub type OrderResponse = BybitApiResponse<OrderStatus>;
148
149/// Represents the response from Bybit when querying order history.
150///
151/// This struct captures the list of past orders and metadata. Bots should parse the
152/// `result` field to analyze executed orders and use `next_page_cursor` for pagination
153/// in perpetual futures trading. Check `ret_code` and `ret_msg` to handle errors.
154pub type OrderHistoryResponse = BybitApiResponse<OrderHistory>;
155
156/// Response structure for the cancel-all orders request.
157///
158/// Returned by the `/v5/order/cancel-all` endpoint, this struct provides the result of canceling all open orders. Bots use this to confirm successful cancellations and handle errors, ensuring proper risk management in perpetual futures trading.
159pub type CancelAllResponse = BybitApiResponse<CancelledList>;
160
161/// Response structure for trade history requests.
162///
163/// Returned by the `/v5/execution/list` endpoint, this struct provides historical trade execution data for a trading pair. Bots use this to analyze past trades, calculate realized P&L, and refine trading strategies for perpetual futures.
164pub type TradeHistoryResponse = BybitApiResponse<TradeHistorySummary>;
165
166/// Response structure for setting margin mode requests.
167///
168/// Returned by the `/v5/account/set-margin-mode` endpoint, this struct confirms the result of changing the account’s margin mode (e.g., isolated or cross). Bots use this to verify successful configuration and handle errors.
169pub type SetMarginModeResponse = BybitApiResponse<MarginModeResult>;
170
171/// Response structure for transaction log requests.
172///
173/// Returned by the `/v5/account/transaction-log` endpoint, this struct provides historical transaction data for an account. Bots use this to audit trades, calculate costs, and optimize strategies.
174pub type TransactionLogResponse = BybitApiResponse<TransactionLogResult>;
175
176/// Response structure for Self-Managed Portfolio (SMP) group requests.
177///
178/// Returned by the `/v5/account/smp-group` endpoint, this struct confirms the SMP group configuration for the account. Bots use this to verify copy trading or portfolio management settings.
179pub type SmpResponse = BybitApiResponse<SmpResult>;
180
181/// Response structure for account information requests.
182///
183/// Returned by the `/v5/account/info` endpoint, this struct provides details about the account's margin mode, unified margin status, and other configuration settings. Bots use this to verify account settings, manage margin modes, and ensure compliance with trading strategies in perpetual futures trading.
184pub type AccountInfoResponse = BybitApiResponse<AccountInfo, Empty, Option<u64>>;
185
186/// Response structure for fee rate requests.
187///
188/// Returned by the `/v5/account/fee-rate` endpoint, this struct provides the maker and taker fee rates for trading pairs. Bots use this to calculate trading costs and optimize execution strategies in perpetual futures trading.
189pub type FeeRateResponse = BybitApiResponse<FeeRateList>;
190
191/// Response structure for wallet balance requests.
192///
193/// Returned by the `/v5/account/wallet-balance` endpoint, this struct provides the current wallet balance and margin details for an account. Bots use this to monitor account health, calculate available margin, and manage risk in perpetual futures trading.
194pub type WalletResponse = BybitApiResponse<WalletList>;
195
196/// Response structure for Unified Trading Account (UTA) status updates.
197///
198/// Returned by the `/v5/account/set-unified-margin` endpoint, this struct confirms the result of updating the UTA status (e.g., enabling or disabling unified margin). Bots use this to verify successful configuration and handle errors, ensuring proper account settings for perpetual futures trading.
199pub type UTAResponse = BybitApiResponse<UTAUpdateStatus>;
200
201/// Response structure for borrow history requests.
202///
203/// Returned by the `/v5/account/borrow-history` endpoint, this struct provides historical borrowing data for an account. Bots use this to analyze borrowing costs and manage leverage effectively.
204pub type BorrowHistoryResponse = BybitApiResponse<BorrowHistory>;
205
206/// Response structure for repaying borrowed liabilities.
207///
208/// Returned by the `/v5/account/repay-liability` endpoint, this struct confirms the result of repaying borrowed funds for an account. Bots use this to verify successful repayments and update account balance tracking.
209pub type RepayLiabilityResponse = BybitApiResponse<LiabilityQty>;
210
211/// Response structure for setting collateral coin status.
212///
213/// Returned by the `/v5/account/set-collateral-coin` endpoint, this struct confirms the result of enabling or disabling a coin as collateral for margin trading. Bots use this to verify successful configuration and handle errors, ensuring proper collateral management.
214pub type SetCollateralCoinResponse = BybitApiResponse<Empty>;
215
216/// Response structure for batch setting collateral coin statuses.
217///
218/// Returned by the `/v5/account/batch-set-collateral-coin` endpoint, this struct confirms the result of enabling or disabling multiple coins as collateral. Bots use this to verify successful batch configuration and handle errors.
219pub type BatchSetCollateralCoinResponse = BybitApiResponse<SwitchList>;
220
221/// Response structure for position information requests.
222///
223/// Returned by the `/v5/position/list` endpoint, this struct provides details of current open positions. Bots use this to monitor position size, unrealized P&L, and risk metrics in perpetual futures.
224pub type InfoResponse = BybitApiResponse<InfoResult>;
225
226/// Response structure for leverage setting requests.
227///
228/// Returned by the `/v5/position/set-leverage` endpoint, this struct confirms the result of setting leverage for a trading pair. Bots use this to verify successful leverage adjustments and handle errors.
229pub type LeverageResponse = BybitApiResponse<Empty>;
230
231/// Response structure for margin change requests.
232///
233/// Returned by the `/v5/position/switch-margin` endpoint, this struct confirms the result of changing margin settings for a position. Bots use this to verify successful margin adjustments and handle errors.
234pub type ChangeMarginResponse = BybitApiResponse<Empty>;
235
236/// Response structure for margin mode setting requests.
237///
238/// Returned by the `/v5/account/set-margin-mode` endpoint, this struct confirms the result of setting the margin mode. Bots use this to verify successful mode changes and handle errors.
239pub type MarginModeResponse = BybitApiResponse<Empty>;
240
241/// Response structure for risk limit setting requests.
242///
243/// Returned by the `/v5/position/set-risk-limit` endpoint, this struct confirms the result of setting risk limits for a position. Bots use this to verify successful risk limit adjustments and handle errors.
244pub type SetRiskLimitResponse = BybitApiResponse<SetRiskLimitResult>;
245
246/// Response structure for trading stop setting requests.
247///
248/// Returned by the `/v5/position/trading-stop` endpoint, this struct confirms the result of setting take-profit and stop-loss
249pub type TradingStopResponse = BybitApiResponse<Empty>;
250
251/// Response structure for auto-add margin setting requests.
252///
253/// Returned by the `/v5/position/set-auto-add-margin` endpoint, this struct confirms the result of enabling or disabling auto-add margin. Bots use this to verify successful configuration and handle errors, ensuring proper margin management.
254pub type AddMarginResponse = BybitApiResponse<Empty>;
255
256/// Response structure for margin adjustment requests.
257///
258/// Returned by the `/v5/position/add-margin` endpoint, this struct provides the result of adding or reducing margin for a position. Bots use this to confirm the new position state, including updated margin and risk metrics, and handle errors.
259pub type AddReduceMarginResponse = BybitApiResponse<AddReduceMarginResult>;
260
261/// Response structure for closed P&L data requests.
262///
263/// Returned by the `/v5/position/closed-pnl` endpoint, this struct provides historical P&L data for closed positions. Bots use this to analyze realized profits and losses, enabling performance evaluation and strategy optimization.
264pub type ClosedPnlResponse = BybitApiResponse<ClosedPnlResult>;
265
266/// Response structure for position move requests.
267///
268/// Returned by the `/v5/position/move-position` endpoint, this struct confirms the result of moving a position between accounts. Bots use this to verify successful transfers and handle errors, ensuring accurate portfolio management.
269pub type MovePositionResponse = BybitApiResponse<MovePositionResult>;
270
271/// Response structure for position move history requests.
272///
273/// Returned by the `/v5/position/move-history` endpoint, this struct provides historical data on position transfers between accounts. Bots use this to audit transfers and verify portfolio changes.
274pub type MoveHistoryResponse = BybitApiResponse<MoveHistoryResult>;
275
276/// Response structure for confirming pending MMR (Maintenance Margin Rate).
277///
278/// Returned by the `/v5/position/confirm-pending-mmr` endpoint, this struct confirms that the new risk limit has been accepted and the reduce-only restriction has been removed. Bots use this to verify successful risk limit adjustments and resume normal trading operations.
279pub type ConfirmPendingMmrResponse = BybitApiResponse<Empty>;
280
281/// Response structure for batch order placement.
282///
283/// Returned by the `/v5/order/create-batch` endpoint, this struct provides the result of placing multiple orders. Bots use this to confirm successful order placements and handle any errors for individual orders.
284pub type BatchPlaceResponse = BybitApiResponse<BatchedOrderList, OrderConfirmationList>;
285
286/// Response structure for batch order amendment.
287///
288/// Returned by the `/v5/order/amend-batch` endpoint, this struct provides the result of amending multiple orders. Bots use this to confirm successful amendments and handle any errors for individual orders.
289pub type BatchAmendResponse = BybitApiResponse<AmendedOrderList, OrderConfirmationList>;
290
291/// Response structure for pre-check order requests.
292///
293/// Returned by the `/v5/order/pre-check` endpoint, this struct provides margin calculation results
294/// before and after placing an order. Bots use this to validate order feasibility and manage
295/// risk by assessing the impact on initial margin requirement (IMR) and maintenance
296/// margin requirement (MMR) in perpetual futures trading.
297pub type PreCheckOrderResponse = BybitApiResponse<PreCheckResult>;
298
299/// Response structure for borrow quota check requests.
300///
301/// Returned by the `/v5/order/spot-borrow-check` endpoint, this struct provides information
302/// about maximum trade quantities and amounts available for spot trading, including both
303/// actual balances and borrowable amounts. Bots use this to determine available trading
304/// capacity and manage position sizing in spot and margin trading scenarios.
305pub type BorrowQuotaResponse = BybitApiResponse<BorrowQuotaResult>;
306
307/// Response structure for Disconnection Protection (DCP) configuration requests.
308///
309/// Returned by the `/v5/order/disconnected-cancel-all` endpoint, this struct confirms
310/// the result of setting disconnection protection parameters. DCP automatically cancels
311/// all active orders if the client remains disconnected from Bybit's WebSocket for
312/// longer than the specified time window. Bots use this to configure protection against
313/// unintended order execution during connection issues.
314pub type DcpResponse = BybitApiResponse<Empty>;