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 ticker data requests.
48///
49/// 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.
50pub type TickerResponse = BybitApiResponse<TickersInfo>;
51
52/// Response structure for funding rate history requests.
53///
54/// 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.
55pub type FundingRateResponse = BybitApiResponse<FundingRateSummary>;
56
57/// Response structure for recent trading records requests.
58///
59/// 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.
60pub type RecentTradesResponse = BybitApiResponse<RecentTrades>;
61
62/// Response structure for open interest data requests.
63///
64/// 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.
65pub type OpenInterestResponse = BybitApiResponse<OpenInterestSummary>;
66
67/// Represents the response from Bybit’s historical volatility API endpoint.
68/// Contains metadata and a list of volatility data points for the requested cryptocurrency.
69/// This is critical for bots analyzing price stability in perpetual futures markets.
70pub type HistoricalVolatilityResponse = BybitApiResponse<Vec<HistoricalVolatility>>;
71
72/// Represents the response from Bybit’s insurance fund API endpoint.
73/// The insurance fund covers losses from bankrupt positions in perpetual futures, ensuring
74/// market stability. Bots use this to assess exchange risk and counterparty exposure.
75pub type InsuranceResponse = BybitApiResponse<InsuranceSummary>;
76
77/// Represents the response from Bybit’s risk limit API endpoint.
78/// Provides details on position size and leverage constraints for perpetual futures trading.
79pub type RiskLimitResponse = BybitApiResponse<RiskLimitSummary>;
80
81/// Represents the response from Bybit’s delivery price API endpoint.
82/// Delivery prices apply to futures with settlement dates, but for perpetual futures, this may
83/// be used for reference or historical analysis by bots.
84pub type DeliveryPriceResponse = BybitApiResponse<DeliveryPriceSummary>;
85
86/// Represents the response from Bybit’s long/short ratio API endpoint.
87/// The long/short ratio shows the balance of bullish vs. bearish positions in the market,
88/// critical for sentiment analysis in perpetual futures trading.
89pub type LongShortRatioResponse = BybitApiResponse<LongShortRatioSummary>;
90
91/// Represents the response from Bybit when amending an order.
92///
93/// This struct captures the result of an order amendment request, including success
94/// status and updated order details. In perpetual futures, amending orders (e.g.,
95/// changing price, quantity, or TP/SL) is common to adapt to market conditions. Bots
96/// should check `ret_code` and `ret_msg` to confirm success and handle errors (e.g.,
97/// invalid price, insufficient margin). The `result` field provides the updated order
98/// status, which bots can use to track changes.
99pub type AmendOrderResponse = BybitApiResponse<OrderStatus>;
100
101/// Represents the response from Bybit when canceling an order.
102///
103/// This struct captures the result of an order cancellation request. Bots should check
104/// `ret_code` and `ret_msg` to confirm success and handle errors (e.g., order already
105/// filled). The `result` field provides the canceled order’s status, aiding in state
106/// management for perpetual futures trading.
107pub type CancelOrderResponse = BybitApiResponse<OrderStatus>;
108
109/// Represents the response from Bybit when querying open orders.
110///
111/// This struct captures the list of open orders and metadata. Bots should parse the
112/// `result` field to track active orders and use `next_page_cursor` for pagination
113/// in perpetual futures trading. Check `ret_code` and `ret_msg` to handle errors.
114pub type OpenOrdersResponse = BybitApiResponse<OrderHistory>;
115
116/// Represents the response from Bybit when placing an order.
117///
118/// This struct captures the result of an order placement request. Bots should check
119/// `ret_code` and `ret_msg` to confirm success and handle errors (e.g., insufficient
120/// margin). The `result` field provides the new order’s status for tracking in
121/// perpetual futures trading.
122pub type OrderResponse = BybitApiResponse<OrderStatus>;
123
124/// Represents the response from Bybit when querying order history.
125///
126/// This struct captures the list of past orders and metadata. Bots should parse the
127/// `result` field to analyze executed orders and use `next_page_cursor` for pagination
128/// in perpetual futures trading. Check `ret_code` and `ret_msg` to handle errors.
129pub type OrderHistoryResponse = BybitApiResponse<OrderHistory>;
130
131/// Response structure for the cancel-all orders request.
132///
133/// 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.
134pub type CancelAllResponse = BybitApiResponse<CancelledList>;
135
136/// Response structure for trade history requests.
137///
138/// 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.
139pub type TradeHistoryResponse = BybitApiResponse<TradeHistorySummary>;
140
141/// Response structure for setting margin mode requests.
142///
143/// 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.
144pub type SetMarginModeResponse = BybitApiResponse<MarginModeResult>;
145
146/// Response structure for transaction log requests.
147///
148/// 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.
149pub type TransactionLogResponse = BybitApiResponse<TransactionLogResult>;
150
151/// Response structure for Self-Managed Portfolio (SMP) group requests.
152///
153/// 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.
154pub type SmpResponse = BybitApiResponse<SmpResult>;
155
156/// Response structure for account information requests.
157///
158/// 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.
159pub type AccountInfoResponse = BybitApiResponse<AccountInfo, Empty, Option<u64>>;
160
161/// Response structure for fee rate requests.
162///
163/// 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.
164pub type FeeRateResponse = BybitApiResponse<FeeRateList>;
165
166/// Response structure for wallet balance requests.
167///
168/// 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.
169pub type WalletResponse = BybitApiResponse<WalletList>;
170
171/// Response structure for Unified Trading Account (UTA) status updates.
172///
173/// 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.
174pub type UTAResponse = BybitApiResponse<UTAUpdateStatus>;
175
176/// Response structure for borrow history requests.
177///
178/// 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.
179pub type BorrowHistoryResponse = BybitApiResponse<BorrowHistory>;
180
181/// Response structure for repaying borrowed liabilities.
182///
183/// 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.
184pub type RepayLiabilityResponse = BybitApiResponse<LiabilityQty>;
185
186/// Response structure for setting collateral coin status.
187///
188/// 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.
189pub type SetCollateralCoinResponse = BybitApiResponse<Empty>;
190
191/// Response structure for batch setting collateral coin statuses.
192///
193/// 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.
194pub type BatchSetCollateralCoinResponse = BybitApiResponse<SwitchList>;
195
196/// Response structure for position information requests.
197///
198/// 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.
199pub type InfoResponse = BybitApiResponse<InfoResult>;
200
201/// Response structure for leverage setting requests.
202///
203/// 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.
204pub type LeverageResponse = BybitApiResponse<Empty>;
205
206/// Response structure for margin change requests.
207///
208/// 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.
209pub type ChangeMarginResponse = BybitApiResponse<Empty>;
210
211/// Response structure for margin mode setting requests.
212///
213/// 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.
214pub type MarginModeResponse = BybitApiResponse<Empty>;
215
216/// Response structure for risk limit setting requests.
217///
218/// 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.
219pub type SetRiskLimitResponse = BybitApiResponse<SetRiskLimitResult>;
220
221/// Response structure for trading stop setting requests.
222///
223/// Returned by the `/v5/position/trading-stop` endpoint, this struct confirms the result of setting take-profit and stop-loss
224pub type TradingStopResponse = BybitApiResponse<Empty>;
225
226/// Response structure for auto-add margin setting requests.
227///
228/// 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.
229pub type AddMarginResponse = BybitApiResponse<Empty>;
230
231/// Response structure for margin adjustment requests.
232///
233/// 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.
234pub type AddReduceMarginResponse = BybitApiResponse<AddReduceMarginResult>;
235
236/// Response structure for closed P&L data requests.
237///
238/// 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.
239pub type ClosedPnlResponse = BybitApiResponse<ClosedPnlResult>;
240
241/// Response structure for position move requests.
242///
243/// 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.
244pub type MovePositionResponse = BybitApiResponse<MovePositionResult>;
245
246/// Response structure for position move history requests.
247///
248/// 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.
249pub type MoveHistoryResponse = BybitApiResponse<MoveHistoryResult>;
250
251/// Response structure for batch order placement.
252///
253/// 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.
254pub type BatchPlaceResponse = BybitApiResponse<BatchedOrderList, OrderConfirmationList>;
255
256/// Response structure for batch order amendment.
257///
258/// 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.
259pub type BatchAmendResponse = BybitApiResponse<AmendedOrderList, OrderConfirmationList>;