/*
* Prediction Trading REST API
*
* Place and manage prediction market orders, query positions, and transfer funds via the Prediction Trading REST API.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#![allow(unused_imports)]
use http::Method;
use serde::de::DeserializeOwned;
use serde_json::Value;
use std::collections::BTreeMap;
use crate::common::{config::ConfigurationRestApi, models::RestApiResponse, utils::send_request};
mod apis;
mod models;
pub use apis::*;
pub use models::*;
#[derive(Debug, Clone)]
pub struct RestApi {
configuration: ConfigurationRestApi,
market_data_api_client: MarketDataApiClient,
otc_api_client: OtcApiClient,
position_api_client: PositionApiClient,
redeem_api_client: RedeemApiClient,
trade_api_client: TradeApiClient,
transfer_api_client: TransferApiClient,
wallet_api_client: WalletApiClient,
}
impl RestApi {
pub fn new(configuration: ConfigurationRestApi) -> Self {
let market_data_api_client = MarketDataApiClient::new(configuration.clone());
let otc_api_client = OtcApiClient::new(configuration.clone());
let position_api_client = PositionApiClient::new(configuration.clone());
let redeem_api_client = RedeemApiClient::new(configuration.clone());
let trade_api_client = TradeApiClient::new(configuration.clone());
let transfer_api_client = TransferApiClient::new(configuration.clone());
let wallet_api_client = WalletApiClient::new(configuration.clone());
Self {
configuration,
market_data_api_client,
otc_api_client,
position_api_client,
redeem_api_client,
trade_api_client,
transfer_api_client,
wallet_api_client,
}
}
/// Send an unsigned request to the API
///
/// # Arguments
///
/// * `endpoint` - The API endpoint to send the request to
/// * `method` - The HTTP method to use for the request
/// * `query_params` - A map of query parameters to send with the request
/// * `body_params` - A map of body parameters to send with the request
///
/// # Returns
///
/// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
///
/// # Errors
///
/// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
pub async fn send_request<R: DeserializeOwned + Send + 'static>(
&self,
endpoint: &str,
method: Method,
query_params: BTreeMap<String, Value>,
body_params: BTreeMap<String, Value>,
) -> anyhow::Result<RestApiResponse<R>> {
send_request::<R>(
&self.configuration,
endpoint,
method,
query_params,
body_params,
None,
false,
)
.await
}
/// Send a signed request to the API
///
/// # Arguments
///
/// * `endpoint` - The API endpoint to send the request to
/// * `method` - The HTTP method to use for the request
/// * `query_params` - A map of query parameters to send with the request
/// * `body_params` - A map of body parameters to send with the request
///
/// # Returns
///
/// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
///
/// # Errors
///
/// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
pub async fn send_signed_request<R: DeserializeOwned + Send + 'static>(
&self,
endpoint: &str,
method: Method,
query_params: BTreeMap<String, Value>,
body_params: BTreeMap<String, Value>,
) -> anyhow::Result<RestApiResponse<R>> {
send_request::<R>(
&self.configuration,
endpoint,
method,
query_params,
body_params,
None,
true,
)
.await
}
/// Get Market Detail
///
/// Get full details for a specific prediction market topic, including variant data and timeline.
///
/// Weight(IP): 200
///
/// # Arguments
///
/// - `params`: [`GetMarketDetailParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetMarketDetailResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/market-data#get-market-detail).
///
pub async fn get_market_detail(
&self,
params: GetMarketDetailParams,
) -> anyhow::Result<RestApiResponse<models::GetMarketDetailResponse>> {
self.market_data_api_client.get_market_detail(params).await
}
/// List Prediction Categories
///
/// Get all available prediction market categories (L1 and L2).
///
/// Weight(IP): 200
///
/// # Arguments
///
/// - `params`: [`ListPredictionCategoriesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ListPredictionCategoriesResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/market-data#list-prediction-categories).
///
pub async fn list_prediction_categories(
&self,
) -> anyhow::Result<RestApiResponse<models::ListPredictionCategoriesResponse>> {
self.market_data_api_client
.list_prediction_categories()
.await
}
/// List Prediction Markets
///
/// Get a paginated list of prediction market topics, with optional category and sort filters.
///
/// Weight(IP): 200
///
/// # Arguments
///
/// - `params`: [`ListPredictionMarketsParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ListPredictionMarketsResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/market-data#list-prediction-markets).
///
pub async fn list_prediction_markets(
&self,
params: ListPredictionMarketsParams,
) -> anyhow::Result<RestApiResponse<models::ListPredictionMarketsResponse>> {
self.market_data_api_client
.list_prediction_markets(params)
.await
}
/// Market Search
///
/// Semantic search for prediction market topics by keyword.
///
/// Weight(IP): 200
///
/// # Arguments
///
/// - `params`: [`MarketSearchParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::MarketSearchResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/market-data#market-search).
///
pub async fn market_search(
&self,
params: MarketSearchParams,
) -> anyhow::Result<RestApiResponse<Vec<models::MarketSearchResponseInner>>> {
self.market_data_api_client.market_search(params).await
}
/// Query Last Trade Price
///
/// Get the most recent trade price for a prediction market.
///
/// Weight(IP): 200
///
/// # Arguments
///
/// - `params`: [`QueryLastTradePriceParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryLastTradePriceResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/market-data#query-last-trade-price).
///
pub async fn query_last_trade_price(
&self,
params: QueryLastTradePriceParams,
) -> anyhow::Result<RestApiResponse<models::QueryLastTradePriceResponse>> {
self.market_data_api_client
.query_last_trade_price(params)
.await
}
/// Query Order Book
///
/// Get the current order book (bids and asks) for a specific prediction market outcome token.
///
/// Weight(IP): 200
///
/// # Arguments
///
/// - `params`: [`QueryOrderBookParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryOrderBookResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/market-data#query-order-book).
///
pub async fn query_order_book(
&self,
params: QueryOrderBookParams,
) -> anyhow::Result<RestApiResponse<models::QueryOrderBookResponse>> {
self.market_data_api_client.query_order_book(params).await
}
/// Create OTC Blocktrade (`PREDICTION_TRADE`)
///
/// Create an OTC blocktrade as the maker (BID to buy outcome shares with USDT, or ASK to sell outcome shares for USDT). The maker wallet is resolved server-side by `userId`; signing is done server-side via SAS `typedDataSign`. Returns `orderId` and a one-time `secretToken` to share out-of-band with the intended taker.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Notes:
/// - Restricted to authorized market makers. Requests from unauthorized accounts are rejected — contact BD to request access.
/// - Side & Amount Rules:
///
/// | side | makerAmount | takerAmount |
/// | ------ | ------------- | ------------- |
/// | `BUY` | USDT (wei) | shares (wei) |
/// | `SELL` | shares (wei) | USDT (wei) |
/// - "Note on `side` encoding: this request uses a string enum (`BUY`/`SELL`). Responses from Get Blocktrade Detail / Preview / List return `side` as an integer and also include a `quoteType` string — both encode the same concept."
///
/// | Request `side` | Response `side` (Integer) | Response `quoteType` |
/// | --------------- | -------------------------- | ---------------------- |
/// | `BUY` | `0` | `"Bid"` |
/// | `SELL` | `1` | `"Ask"` |
///
/// # Arguments
///
/// - `params`: [`CreateOtcBlocktradeParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CreateOtcBlocktradeResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/otc#create-otc-blocktrade).
///
pub async fn create_otc_blocktrade(
&self,
params: CreateOtcBlocktradeParams,
) -> anyhow::Result<RestApiResponse<models::CreateOtcBlocktradeResponse>> {
self.otc_api_client.create_otc_blocktrade(params).await
}
/// Fulfil OTC Blocktrade (`PREDICTION_TRADE`)
///
/// Fulfil an open maker blocktrade as the taker, using the `secretToken` the maker shared out-of-band. All-or-nothing fill (no partial fill); the taker order is the server-derived symmetric inverse of the maker order.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Notes:
/// - Restricted to authorized market makers. Requests from unauthorized accounts are rejected — contact BD to request access.
///
/// # Arguments
///
/// - `params`: [`FulfilOtcBlocktradeParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::FulfilOtcBlocktradeResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/otc#fulfil-otc-blocktrade).
///
pub async fn fulfil_otc_blocktrade(
&self,
params: FulfilOtcBlocktradeParams,
) -> anyhow::Result<RestApiResponse<models::FulfilOtcBlocktradeResponse>> {
self.otc_api_client.fulfil_otc_blocktrade(params).await
}
/// Get OTC Blocktrade Detail (`PREDICTION_TRADE`)
///
/// Query the maker's own blocktrade by `orderId`. Returns full order data including status and `secretToken`.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Notes:
/// - Restricted to authorized market makers. Requests from unauthorized accounts are rejected — contact BD to request access.
///
/// # Arguments
///
/// - `params`: [`GetOtcBlocktradeDetailParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetOtcBlocktradeDetailResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/otc#get-otc-blocktrade-detail).
///
pub async fn get_otc_blocktrade_detail(
&self,
params: GetOtcBlocktradeDetailParams,
) -> anyhow::Result<RestApiResponse<models::GetOtcBlocktradeDetailResponse>> {
self.otc_api_client.get_otc_blocktrade_detail(params).await
}
/// Get OTC Blocktrade Events (`PREDICTION_TRADE`)
///
/// Paginated feed of blocktrade lifecycle and settlement events (CREATE, FULFIL, `MATCH_SUBMIT`, `MATCH_SUCCESS`, EXPIRE, FAILED, etc.).
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Notes:
/// - Restricted to authorized market makers. Requests from unauthorized accounts are rejected — contact BD to request access.
///
/// # Arguments
///
/// - `params`: [`GetOtcBlocktradeEventsParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetOtcBlocktradeEventsResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/otc#get-otc-blocktrade-events).
///
pub async fn get_otc_blocktrade_events(
&self,
params: GetOtcBlocktradeEventsParams,
) -> anyhow::Result<RestApiResponse<models::GetOtcBlocktradeEventsResponse>> {
self.otc_api_client.get_otc_blocktrade_events(params).await
}
/// Get OTC Reserved Balances (`PREDICTION_TRADE`)
///
/// Query `PredictFun` reserved balances for the caller's bound wallet — these are funds locked by the caller's open OTC blocktrade orders (maker BID locks USDT, maker ASK locks shares). Not tied to a specific blocktrade id; the path nesting under `otc/blocktrade` reflects the cause of the lock, not a per-order query. Returns one entry per requested asset, aligned with the request order. Pass `{type:"USDT"}` for reserved USDT, or `{type:"SHARE", tokenId:"..."}` for a specific outcome token's reserved shares.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Notes:
/// - Restricted to authorized market makers. Requests from unauthorized accounts are rejected — contact BD to request access.
/// - `AssetQuery`:
///
/// | Name | Type | Mandatory | Description |
/// | ------- | ------ | --------- | ----------- |
/// | type | STRING | YES | Asset type. Enum: `USDT`, `SHARE` |
/// | tokenId | STRING | NO | Outcome token id (present for `SHARE` entries only) |
///
/// # Arguments
///
/// - `params`: [`GetOtcReservedBalancesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetOtcReservedBalancesResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/otc#get-otc-reserved-balances).
///
pub async fn get_otc_reserved_balances(
&self,
params: GetOtcReservedBalancesParams,
) -> anyhow::Result<RestApiResponse<models::GetOtcReservedBalancesResponse>> {
self.otc_api_client.get_otc_reserved_balances(params).await
}
/// List OTC Blocktrades (`PREDICTION_TRADE`)
///
/// List the maker's own blocktrades with optional status filter and cursor pagination.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Notes:
/// - Restricted to authorized market makers. Requests from unauthorized accounts are rejected — contact BD to request access.
///
/// # Arguments
///
/// - `params`: [`ListOtcBlocktradesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ListOtcBlocktradesResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/otc#list-otc-blocktrades).
///
pub async fn list_otc_blocktrades(
&self,
params: ListOtcBlocktradesParams,
) -> anyhow::Result<RestApiResponse<models::ListOtcBlocktradesResponse>> {
self.otc_api_client.list_otc_blocktrades(params).await
}
/// Preview OTC Blocktrade (`PREDICTION_TRADE`)
///
/// Inspect an open blocktrade by `secretToken` (no `orderId` needed). Taker uses this to preview the maker order before fulfilling. Returns the same shape as `Get Blocktrade Detail`, but `orderId` is `null` and `secretToken` is never returned from this endpoint.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Notes:
/// - Restricted to authorized market makers. Requests from unauthorized accounts are rejected — contact BD to request access.
///
/// # Arguments
///
/// - `params`: [`PreviewOtcBlocktradeParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::PreviewOtcBlocktradeResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/otc#preview-otc-blocktrade).
///
pub async fn preview_otc_blocktrade(
&self,
params: PreviewOtcBlocktradeParams,
) -> anyhow::Result<RestApiResponse<models::PreviewOtcBlocktradeResponse>> {
self.otc_api_client.preview_otc_blocktrade(params).await
}
/// Remove OTC Blocktrades (`PREDICTION_TRADE`)
///
/// Cancel open or fulfilled-but-unsettled blocktrades. Terminal orders (already `MATCHED`/`CANCELLED`/`EXPIRED`/`FAILED`) are returned in `noop` instead of `removed`.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Notes:
/// - Restricted to authorized market makers. Requests from unauthorized accounts are rejected — contact BD to request access.
///
/// # Arguments
///
/// - `params`: [`RemoveOtcBlocktradesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::RemoveOtcBlocktradesResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/otc#remove-otc-blocktrades).
///
pub async fn remove_otc_blocktrades(
&self,
params: RemoveOtcBlocktradesParams,
) -> anyhow::Result<RestApiResponse<models::RemoveOtcBlocktradesResponse>> {
self.otc_api_client.remove_otc_blocktrades(params).await
}
/// Get Position by Token (`PREDICTION_TRADE`)
///
/// Get the authenticated user's position detail for a specific prediction token.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`GetPositionByTokenParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetPositionByTokenResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/position#get-position-by-token).
///
pub async fn get_position_by_token(
&self,
params: GetPositionByTokenParams,
) -> anyhow::Result<RestApiResponse<models::GetPositionByTokenResponse>> {
self.position_api_client.get_position_by_token(params).await
}
/// Query `PnL` (`PREDICTION_TRADE`)
///
/// Query profit and loss records for the authenticated user's prediction positions. When `tokenId` is provided, returns a single record in `pnl`; otherwise returns a list in `pnlList`.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`QueryPnLParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryPnLResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/position#query-pn-l).
///
pub async fn query_pn_l(
&self,
params: QueryPnLParams,
) -> anyhow::Result<RestApiResponse<models::QueryPnLResponse>> {
self.position_api_client.query_pn_l(params).await
}
/// Query Positions (`PREDICTION_TRADE`)
///
/// Get the authenticated user's prediction token positions with portfolio summary and tab-based filtering.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`QueryPositionsParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryPositionsResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/position#query-positions).
///
pub async fn query_positions(
&self,
params: QueryPositionsParams,
) -> anyhow::Result<RestApiResponse<models::QueryPositionsResponse>> {
self.position_api_client.query_positions(params).await
}
/// Query Positions by Filter (`PREDICTION_TRADE`)
///
/// Get prediction positions filtered by wallet address and/or market topic ID. Both parameters are optional.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`QueryPositionsByFilterParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryPositionsByFilterResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/position#query-positions-by-filter).
///
pub async fn query_positions_by_filter(
&self,
params: QueryPositionsByFilterParams,
) -> anyhow::Result<RestApiResponse<models::QueryPositionsByFilterResponse>> {
self.position_api_client
.query_positions_by_filter(params)
.await
}
/// Query Settled Position History (`PREDICTION_TRADE`)
///
/// Get the authenticated user's settled (resolved) prediction position history with optional filters.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`QuerySettledPositionHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QuerySettledPositionHistoryResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/position#query-settled-position-history).
///
pub async fn query_settled_position_history(
&self,
params: QuerySettledPositionHistoryParams,
) -> anyhow::Result<RestApiResponse<models::QuerySettledPositionHistoryResponse>> {
self.position_api_client
.query_settled_position_history(params)
.await
}
/// Batch Redeem (`PREDICTION_TRADE`)
///
/// Redeem one or more settled prediction tokens on-chain to claim winnings. Requires SAS authorization.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`BatchRedeemParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::BatchRedeemResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/redeem#batch-redeem).
///
pub async fn batch_redeem(
&self,
params: BatchRedeemParams,
) -> anyhow::Result<RestApiResponse<models::BatchRedeemResponse>> {
self.redeem_api_client.batch_redeem(params).await
}
/// Get Redeem Status (`PREDICTION_TRADE`)
///
/// Query the on-chain transaction status of a previously submitted redeem request.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Response Notes:
/// - Status values:
///
/// | Value | Description |
/// | ----------- | -------------------------------------------- |
/// | `PENDING` | Transaction submitted, awaiting confirmation |
/// | `CONFIRMED` | Transaction confirmed on-chain |
/// | `FAILED` | Transaction failed |
/// | `NOT_FOUND` | Transaction hash not found |
///
/// # Arguments
///
/// - `params`: [`GetRedeemStatusParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetRedeemStatusResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/redeem#get-redeem-status).
///
pub async fn get_redeem_status(
&self,
params: GetRedeemStatusParams,
) -> anyhow::Result<RestApiResponse<models::GetRedeemStatusResponse>> {
self.redeem_api_client.get_redeem_status(params).await
}
/// Batch Cancel Orders (`PREDICTION_TRADE`)
///
/// Cancel one or more active prediction orders in a single request. Requires SAS authorization.
///
/// **Known Issue — Bracket Encoding Incompatibility:**
/// This endpoint uses indexed bracket notation (`cancelInfoList[0].orderId`). Binance SAPI signature verification runs over the **raw, unencoded** canonical string. However, mainstream HTTP libraries (Python `requests`, Java `HttpURLConnection`/`URI`, Go `net/url`, Node.js `url`) automatically percent-encode `[` → `%5B` and `]` → `%5D`, producing a signature mismatch with error `-1022 Signature for this request is not valid`. Postman is unaffected because it does not encode keys.
///
/// **Workarounds** (use low-level HTTP APIs that do not normalize URLs):
/// - **Python:** use `http.client` (stdlib) and hand-build the body string.
/// - **Java:** use `HttpURLConnection` and write the raw body bytes directly.
/// - **Go:** use `strings.NewReader` with a hand-built body instead of `url.Values.Encode()`.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Notes:
/// - Use dot notation for nested list fields: `cancelInfoList[0].orderId`, `cancelInfoList[1].orderId`, etc.
/// - `vendor` does not need to be supplied. The server automatically sets the correct vendor (`predict_fun`) for every item in the batch.
///
/// # Arguments
///
/// - `params`: [`BatchCancelOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::BatchCancelOrdersResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#batch-cancel-orders).
///
pub async fn batch_cancel_orders(
&self,
params: BatchCancelOrdersParams,
) -> anyhow::Result<RestApiResponse<models::BatchCancelOrdersResponse>> {
self.trade_api_client.batch_cancel_orders(params).await
}
/// Get Quote (`PREDICTION_TRADE`)
///
/// Get a price quote for a prediction order. The returned `quoteId` must be used in the subsequent Place Order request.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Response Notes:
/// - `feeAmount` is a string because it is denominated in wei (18 decimals) and may exceed JavaScript's safe integer range. `feeDiscountBps` is also a string to allow fractional basis-point values in the future. `feeRateBps` and `slippageBps` are integers and will never exceed safe integer bounds.
/// - **MARKET order minimum amount:** For `MARKET` orders, `amountIn` must be at least approximately **1.5 USDT** (in wei: `1500000000000000000`). The exact minimum varies by market liquidity. If the amount is too small, the server returns `-9000 Your order amount is too small`. This limit does **not** apply to `LIMIT` orders.
///
/// # Arguments
///
/// - `params`: [`GetQuoteParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetQuoteResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#get-quote).
///
pub async fn get_quote(
&self,
params: GetQuoteParams,
) -> anyhow::Result<RestApiResponse<models::GetQuoteResponse>> {
self.trade_api_client.get_quote(params).await
}
/// Place Order (`PREDICTION_TRADE`)
///
/// Place a prediction order using a previously obtained quote. Requires SAS authorization.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Notes:
/// - Validation rules:
///
/// | orderType | timeInForce | priceLimit |
/// | --------- | ------------- | --------------------- |
/// | `MARKET` | Must be `FOK` | Not required |
/// | `LIMIT` | Must be `GTC` | Required, must be > 0 |
///
/// # Arguments
///
/// - `params`: [`PlaceOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::PlaceOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#place-order).
///
pub async fn place_order(
&self,
params: PlaceOrderParams,
) -> anyhow::Result<RestApiResponse<models::PlaceOrderResponse>> {
self.trade_api_client.place_order(params).await
}
/// Query Active Orders (`PREDICTION_TRADE`)
///
/// Get active (open) prediction orders for the authenticated user.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`QueryActiveOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryActiveOrdersResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#query-active-orders).
///
pub async fn query_active_orders(
&self,
params: QueryActiveOrdersParams,
) -> anyhow::Result<RestApiResponse<models::QueryActiveOrdersResponse>> {
self.trade_api_client.query_active_orders(params).await
}
/// Query Order History (`PREDICTION_TRADE`)
///
/// Get historical prediction orders (all statuses) for the authenticated user, with optional filters.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`QueryOrderHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryOrderHistoryResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#query-order-history).
///
pub async fn query_order_history(
&self,
params: QueryOrderHistoryParams,
) -> anyhow::Result<RestApiResponse<models::QueryOrderHistoryResponse>> {
self.trade_api_client.query_order_history(params).await
}
/// Apply MM Deposit (`PREDICTION_TRADE`)
///
/// Move funds from the user's bound `CeDeFi` MPC wallet to their CEX account (SPOT/FUNDING) via a contract escrow + credit flow. The maker wallet is resolved server-side by `userId`; the caller does not pass wallet or signature.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Notes:
/// - Restricted to authorized market makers. Requests from unauthorized accounts are rejected — contact BD to request access.
/// - "Note on `fromToken` / `toToken`: typically the same symbol (e.g. both `USDT`). When they differ, the backend may attempt a swap, but cross-symbol conversion is not guaranteed for all pairs — prefer using the same symbol."
///
/// # Arguments
///
/// - `params`: [`ApplyMmDepositParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ApplyMmDepositResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/transfer#apply-mm-deposit).
///
pub async fn apply_mm_deposit(
&self,
params: ApplyMmDepositParams,
) -> anyhow::Result<RestApiResponse<models::ApplyMmDepositResponse>> {
self.transfer_api_client.apply_mm_deposit(params).await
}
/// Apply MM Withdraw (`PREDICTION_TRADE`)
///
/// Withdraw funds from the user's CEX account (SPOT/FUNDING) to their bound `CeDeFi` MPC wallet address. Unlike `v1/capital/withdraw/apply`, the caller does NOT pass `address`; the backend resolves the user's bound `CeDeFi` MPC wallet address by `userId` and reuses the existing capital withdraw flow with that address as the target.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// Notes:
/// - Restricted to authorized market makers. Requests from unauthorized accounts are rejected — contact BD to request access.
/// - walletType Validation:
///
/// | Value | Behavior |
/// | --------------- | ------------------------------- |
/// | `null` | Allowed — defaults to SPOT |
/// | `0` | Allowed — source = SPOT |
/// | `1` | Allowed — source = FUNDING |
/// | Other (e.g. `99`) | Rejected — returns validation error |
/// - "Note on field naming: this endpoint uses `walletType` (INT `0`/`1`) for the source CEX account, while Apply MM Deposit uses `accountType` (STRING `SPOT`/`FUNDING`) for the target. The difference is intentional: withdraw reuses the existing `v1/capital/withdraw/apply` flow, which inherits that flow's integer `walletType` field."
///
/// # Arguments
///
/// - `params`: [`ApplyMmWithdrawParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ApplyMmWithdrawResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/transfer#apply-mm-withdraw).
///
pub async fn apply_mm_withdraw(
&self,
params: ApplyMmWithdrawParams,
) -> anyhow::Result<RestApiResponse<models::ApplyMmWithdrawResponse>> {
self.transfer_api_client.apply_mm_withdraw(params).await
}
/// Create Inbound Transfer (`PREDICTION_TRADE`)
///
/// Transfer funds from the prediction wallet back to the user's CEX account (SPOT or FUNDING). Requires SAS authorization.
///
/// ⚠️ **SAS Authorization Required:** This endpoint enforces SAS (Self-Authorization Service) authorization. If SAS is not enabled for the wallet, the request will be rejected with `-31003 SAS authorization required`. Enable SAS for your wallet before calling this endpoint.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`CreateInboundTransferParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CreateInboundTransferResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/transfer#create-inbound-transfer).
///
pub async fn create_inbound_transfer(
&self,
params: CreateInboundTransferParams,
) -> anyhow::Result<RestApiResponse<models::CreateInboundTransferResponse>> {
self.transfer_api_client
.create_inbound_transfer(params)
.await
}
/// Create Outbound Transfer (`PREDICTION_TRADE`)
///
/// Transfer funds from the user's CEX account (SPOT or FUNDING) into the prediction wallet. Requires SAS authorization.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`CreateOutboundTransferParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CreateOutboundTransferResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/transfer#create-outbound-transfer).
///
pub async fn create_outbound_transfer(
&self,
params: CreateOutboundTransferParams,
) -> anyhow::Result<RestApiResponse<models::CreateOutboundTransferResponse>> {
self.transfer_api_client
.create_outbound_transfer(params)
.await
}
/// Query Transfer List (`PREDICTION_TRADE`)
///
/// Get the authenticated user's prediction wallet transfer history within a date range.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`QueryTransferListParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryTransferListResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/transfer#query-transfer-list).
///
pub async fn query_transfer_list(
&self,
params: QueryTransferListParams,
) -> anyhow::Result<RestApiResponse<models::QueryTransferListResponse>> {
self.transfer_api_client.query_transfer_list(params).await
}
/// Query Transfer Status (`PREDICTION_TRADE`)
///
/// Query the current status of a prediction wallet transfer by transfer ID.
///
/// **`status` values:** Terminal states are `COMPLETED` and `FAILED`. Intermediate states are `PROCESSING` and `PENDING`. **Do not** poll for `SUCCESS` — it is not a valid terminal state.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`QueryTransferStatusParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryTransferStatusResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/transfer#query-transfer-status).
///
pub async fn query_transfer_status(
&self,
params: QueryTransferStatusParams,
) -> anyhow::Result<RestApiResponse<models::QueryTransferStatusResponse>> {
self.transfer_api_client.query_transfer_status(params).await
}
/// Get Portfolio (`PREDICTION_TRADE`)
///
/// Get the authenticated user's prediction portfolio overview including active positions count, aggregated `PnL`, and full position list.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`GetPortfolioParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetPortfolioResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/wallet#get-portfolio).
///
pub async fn get_portfolio(
&self,
params: GetPortfolioParams,
) -> anyhow::Result<RestApiResponse<models::GetPortfolioResponse>> {
self.wallet_api_client.get_portfolio(params).await
}
/// Get Quota Status (`PREDICTION_TRADE`)
///
/// Query the current user's daily trading quota limit and remaining allowance for prediction markets.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`GetQuotaStatusParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetQuotaStatusResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/wallet#get-quota-status).
///
pub async fn get_quota_status(
&self,
params: GetQuotaStatusParams,
) -> anyhow::Result<RestApiResponse<models::GetQuotaStatusResponse>> {
self.wallet_api_client.get_quota_status(params).await
}
/// List Prediction Wallets (`PREDICTION_TRADE`)
///
/// Get all prediction wallets registered for the authenticated user.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`ListPredictionWalletsParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ListPredictionWalletsResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/wallet#list-prediction-wallets).
///
pub async fn list_prediction_wallets(
&self,
params: ListPredictionWalletsParams,
) -> anyhow::Result<RestApiResponse<models::ListPredictionWalletsResponse>> {
self.wallet_api_client.list_prediction_wallets(params).await
}
/// Query Payment Option Balances (`PREDICTION_TRADE`)
///
/// Get available balances for each payment option that can be used for prediction trading.
///
/// Weight(IP): 200
///
/// Security Type: `PREDICTION_TRADE`
///
/// # Arguments
///
/// - `params`: [`QueryPaymentOptionBalancesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryPaymentOptionBalancesResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/wallet#query-payment-option-balances).
///
pub async fn query_payment_option_balances(
&self,
params: QueryPaymentOptionBalancesParams,
) -> anyhow::Result<RestApiResponse<models::QueryPaymentOptionBalancesResponse>> {
self.wallet_api_client
.query_payment_option_balances(params)
.await
}
}