/*
* Spot REST API
*
* Access market data, manage accounts, and trade on Binance Spot.
*
* 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,
account_api_client: AccountApiClient,
general_api_client: GeneralApiClient,
market_api_client: MarketApiClient,
trade_api_client: TradeApiClient,
}
impl RestApi {
pub fn new(configuration: ConfigurationRestApi) -> Self {
let account_api_client = AccountApiClient::new(configuration.clone());
let general_api_client = GeneralApiClient::new(configuration.clone());
let market_api_client = MarketApiClient::new(configuration.clone());
let trade_api_client = TradeApiClient::new(configuration.clone());
Self {
configuration,
account_api_client,
general_api_client,
market_api_client,
trade_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
}
/// Query Commission Rates (`USER_DATA`)
///
/// Get current account commission rates.
///
/// Weight(IP): 20
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Database
///
/// # Arguments
///
/// - `params`: [`AccountCommissionParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::AccountCommissionResponse>`] 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/core-trading-spot-trading/api/rest-api/account#account-commission).
///
pub async fn account_commission(
&self,
params: AccountCommissionParams,
) -> anyhow::Result<RestApiResponse<models::AccountCommissionResponse>> {
self.account_api_client.account_commission(params).await
}
/// Query all Order lists (`USER_DATA`)
///
/// Retrieves all order lists based on provided optional parameters.
///
/// Note that the time between `startTime` and `endTime` can't be longer
/// than 24 hours.
///
/// Weight(IP): 20
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Database
///
/// # Arguments
///
/// - `params`: [`AllOrderListParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::AllOrderListResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/account#all-order-list).
///
pub async fn all_order_list(
&self,
params: AllOrderListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::AllOrderListResponseInner>>> {
self.account_api_client.all_order_list(params).await
}
/// All orders (`USER_DATA`)
///
/// Get all account orders; active, canceled, or filled.
///
/// Weight(IP): 20
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Database
///
/// - If `orderId` is set, it will get orders >= that `orderId`. Otherwise most recent orders are returned.
/// - For some historical orders `cummulativeQuoteQty` will be < 0, meaning the data is not available at this time.
/// - If `startTime` and/or `endTime` provided, `orderId` is not required.
/// - The time between `startTime` and `endTime` can't be longer than 24 hours.
///
/// # Arguments
///
/// - `params`: [`AllOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::AllOrdersResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/account#all-orders).
///
pub async fn all_orders(
&self,
params: AllOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::AllOrdersResponseInner>>> {
self.account_api_client.all_orders(params).await
}
/// Account information (`USER_DATA`)
///
/// Get current account information.
///
/// Weight(IP): 20
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Memory => Database
///
/// # Arguments
///
/// - `params`: [`GetAccountParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetAccountResponse>`] 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/core-trading-spot-trading/api/rest-api/account#get-account).
///
pub async fn get_account(
&self,
params: GetAccountParams,
) -> anyhow::Result<RestApiResponse<models::GetAccountResponse>> {
self.account_api_client.get_account(params).await
}
/// Current open orders (`USER_DATA`)
///
/// Get all open orders on a symbol. **Careful** when accessing this with no symbol.
///
/// Weight: 6 for a single symbol; 80 when the symbol parameter is omitted
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Memory => Database
///
/// - If the symbol is not sent, orders for all symbols will be returned in an array.
///
/// # Arguments
///
/// - `params`: [`GetOpenOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::GetOpenOrdersResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/account#get-open-orders).
///
pub async fn get_open_orders(
&self,
params: GetOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::GetOpenOrdersResponseInner>>> {
self.account_api_client.get_open_orders(params).await
}
/// Query order (`USER_DATA`)
///
/// Check an order's status.
///
/// Weight(IP): 4
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Memory => Database
///
/// - Either `orderId` or `origClientOrderId` must be sent.
/// - If both `orderId` and `origClientOrderId` are provided, the `orderId` is searched first, then the `origClientOrderId` from that result is checked against that order. If both conditions are not met the request will be rejected.
/// - For some historical orders `cummulativeQuoteQty` will be < 0, meaning the data is not available at this time.
///
/// # Arguments
///
/// - `params`: [`GetOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetOrderResponse>`] 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/core-trading-spot-trading/api/rest-api/account#get-order).
///
pub async fn get_order(
&self,
params: GetOrderParams,
) -> anyhow::Result<RestApiResponse<models::GetOrderResponse>> {
self.account_api_client.get_order(params).await
}
/// Query Order list (`USER_DATA`)
///
/// Retrieves a specific order list based on provided optional parameters.
///
/// Weight(IP): 4
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Database
///
/// # Arguments
///
/// - `params`: [`GetOrderListParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetOrderListResponse>`] 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/core-trading-spot-trading/api/rest-api/account#get-order-list).
///
pub async fn get_order_list(
&self,
params: GetOrderListParams,
) -> anyhow::Result<RestApiResponse<models::GetOrderListResponse>> {
self.account_api_client.get_order_list(params).await
}
/// Query Allocations (`USER_DATA`)
///
/// Retrieves allocations resulting from SOR order placement.
///
/// Weight(IP): 20
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Database"
///
/// Supported parameter combinations:
///
/// Parameters | Response |
/// ------------------------------------------- | -------- |
/// `symbol` | allocations from oldest to newest |
/// `symbol` + `startTime` | oldest allocations since `startTime` |
/// `symbol` + `endTime` | newest allocations until `endTime` |
/// `symbol` + `startTime` + `endTime` | allocations within the time range |
/// `symbol` + `fromAllocationId` | allocations by allocation ID |
/// `symbol` + `orderId` | allocations related to an order starting with oldest |
/// `symbol` + `orderId` + `fromAllocationId` | allocations related to an order by allocation ID |
///
/// **Note:** The time between `startTime` and `endTime` can't be longer than 24 hours.
///
/// # Arguments
///
/// - `params`: [`MyAllocationsParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::MyAllocationsResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/account#my-allocations).
///
pub async fn my_allocations(
&self,
params: MyAllocationsParams,
) -> anyhow::Result<RestApiResponse<Vec<models::MyAllocationsResponseInner>>> {
self.account_api_client.my_allocations(params).await
}
/// Query relevant filters (`USER_DATA`)
///
/// Retrieves the list of filters relevant to an account on a given symbol. This is the only endpoint that shows if an account has `MAX_ASSET` filters applied to it.
///
/// Weight(IP): 40
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Memory
///
/// # Arguments
///
/// - `params`: [`MyFiltersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::MyFiltersResponse>`] 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/core-trading-spot-trading/api/rest-api/account#my-filters).
///
pub async fn my_filters(
&self,
params: MyFiltersParams,
) -> anyhow::Result<RestApiResponse<models::MyFiltersResponse>> {
self.account_api_client.my_filters(params).await
}
/// Query Prevented Matches (`USER_DATA`)
///
/// Displays the list of orders that were expired due to STP.
///
/// These are the combinations supported:
/// - `symbol` + `preventedMatchId`
/// - `symbol` + `orderId`
/// - `symbol` + `orderId` + `fromPreventedMatchId` (`limit` will default to 500)
/// - `symbol` + `orderId` + `fromPreventedMatchId` + `limit`
///
/// Weight: Case | Weight
/// ---- | -----
/// If `symbol` is invalid | 2
/// Querying by `preventedMatchId` | 2
/// Querying by `orderId` | 20
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Database
///
/// # Arguments
///
/// - `params`: [`MyPreventedMatchesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::MyPreventedMatchesResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/account#my-prevented-matches).
///
pub async fn my_prevented_matches(
&self,
params: MyPreventedMatchesParams,
) -> anyhow::Result<RestApiResponse<Vec<models::MyPreventedMatchesResponseInner>>> {
self.account_api_client.my_prevented_matches(params).await
}
/// Account trade list (`USER_DATA`)
///
/// Get trades for a specific account and symbol.
///
/// Weight: Condition| Weight|
/// ---| ---
/// |Without orderId|20|
/// |With orderId|5|
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Memory => Database
///
/// **Notes:**:
/// - If `fromId` is set, it will get trades >= that `fromId`. Otherwise most recent trades are returned.
/// - The time between `startTime` and `endTime` can't be longer than 24 hours.
/// - These are the supported combinations of all parameters:
/// - `symbol`
/// - `symbol` + `orderId`
/// - `symbol` + `startTime`
/// - `symbol` + `endTime`
/// - `symbol` + `fromId`
/// - `symbol` + `startTime` + `endTime`
/// - `symbol`+ `orderId` + `fromId`
///
/// # Arguments
///
/// - `params`: [`MyTradesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::MyTradesResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/account#my-trades).
///
pub async fn my_trades(
&self,
params: MyTradesParams,
) -> anyhow::Result<RestApiResponse<Vec<models::MyTradesResponseInner>>> {
self.account_api_client.my_trades(params).await
}
/// Query Open Order lists (`USER_DATA`)
///
/// Query Open Order lists
///
/// Weight(IP): 6
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Memory -> Database
///
/// # Arguments
///
/// - `params`: [`OpenOrderListParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::OpenOrderListResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/account#open-order-list).
///
pub async fn open_order_list(
&self,
params: OpenOrderListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::OpenOrderListResponseInner>>> {
self.account_api_client.open_order_list(params).await
}
/// Query Order Amendments (`USER_DATA`)
///
/// Queries all amendments of a single order.
///
/// Weight(IP): 4
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Database
///
/// # Arguments
///
/// - `params`: [`OrderAmendmentsParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::OrderAmendmentsResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/account#order-amendments).
///
pub async fn order_amendments(
&self,
params: OrderAmendmentsParams,
) -> anyhow::Result<RestApiResponse<Vec<models::OrderAmendmentsResponseInner>>> {
self.account_api_client.order_amendments(params).await
}
/// Query Unfilled Order Count (`USER_DATA`)
///
/// Displays the user's unfilled order count for all intervals.
///
/// Weight(IP): 40
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// **Data Source:** Memory
///
/// # Arguments
///
/// - `params`: [`RateLimitOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::RateLimitOrderResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/account#rate-limit-order).
///
pub async fn rate_limit_order(
&self,
params: RateLimitOrderParams,
) -> anyhow::Result<RestApiResponse<Vec<models::RateLimitOrderResponseInner>>> {
self.account_api_client.rate_limit_order(params).await
}
/// Exchange information
///
/// Current exchange trading rules and symbol information
///
/// Weight(IP): 20
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Memory
///
/// **Notes:**
/// * If the value provided to `symbol` or `symbols` do not exist, the endpoint will throw an error saying the symbol is invalid.
/// * All parameters are optional.
/// * `permissions` can support single or multiple values (e.g. `SPOT`, `["MARGIN","LEVERAGED"]`). This cannot be used in combination with `symbol` or `symbols`.
/// * If `permissions` parameter not provided, all symbols that have either `SPOT`, `MARGIN`, or `LEVERAGED` permission will be exposed.
/// * To display symbols with any permission you need to specify them explicitly in `permissions`: (e.g. `["SPOT","MARGIN",...]`.). See Account and Symbol Permissions for the full list.
///
/// **Examples of Symbol Permissions Interpretation from the Response:**
///
/// * `[["A","B"]]` means you may place an order if your account has either permission "A" **or** permission "B".
/// * `[["A"],["B"]]` means you can place an order if your account has permission "A" **and** permission "B".
/// * `[["A"],["B","C"]]` means you can place an order if your account has permission "A" **and** permission "B" or permission "C". (Inclusive or is applied here, not exclusive or, so your account may have both permission "B" and permission "C".)
///
/// # Arguments
///
/// - `params`: [`ExchangeInfoParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ExchangeInfoResponse>`] 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/core-trading-spot-trading/api/rest-api/general#exchange-info).
///
pub async fn exchange_info(
&self,
params: ExchangeInfoParams,
) -> anyhow::Result<RestApiResponse<models::ExchangeInfoResponse>> {
self.general_api_client.exchange_info(params).await
}
/// Query Execution Rules
///
/// Query execution rules for symbols.
///
/// Weight: Parameter | Weight
/// --- | ---
/// `symbol` | 2
/// `symbols` | 2 for each `symbol`, capped at a max of 40
/// `symbolStatus` | 40
/// None | 40
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Memory
///
/// **Note:**: No combination of multiple parameters is allowed.
///
/// # Arguments
///
/// - `params`: [`ExecutionRulesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ExecutionRulesResponse>`] 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/core-trading-spot-trading/api/rest-api/general#execution-rules).
///
pub async fn execution_rules(
&self,
params: ExecutionRulesParams,
) -> anyhow::Result<RestApiResponse<models::ExecutionRulesResponse>> {
self.general_api_client.execution_rules(params).await
}
/// Test connectivity
///
/// Test connectivity to the Rest API.
///
/// Weight(IP): 1
///
/// Security Type: NONE
///
/// # Arguments
///
/// - `params`: [`PingParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Value>`] 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/core-trading-spot-trading/api/rest-api/general#ping).
///
pub async fn ping(&self) -> anyhow::Result<RestApiResponse<Value>> {
self.general_api_client.ping().await
}
/// Check server time
///
/// Test connectivity to the Rest API and get the current server time.
///
/// Weight(IP): 1
///
/// Security Type: NONE
///
/// # Arguments
///
/// - `params`: [`TimeParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::TimeResponse>`] 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/core-trading-spot-trading/api/rest-api/general#time).
///
pub async fn time(&self) -> anyhow::Result<RestApiResponse<models::TimeResponse>> {
self.general_api_client.time().await
}
/// Compressed/Aggregate trades list
///
/// Get compressed, aggregate trades. Trades that fill at the time, from the same taker order, with the same price will have the quantity aggregated.
///
/// Weight(IP): 4
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Database
///
/// - If fromId, startTime, and endTime are not sent, the most recent aggregate trades will be returned.
///
/// # Arguments
///
/// - `params`: [`AggTradesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::AggTradesResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/market#agg-trades).
///
pub async fn agg_trades(
&self,
params: AggTradesParams,
) -> anyhow::Result<RestApiResponse<Vec<models::AggTradesResponseInner>>> {
self.market_api_client.agg_trades(params).await
}
/// Current average price
///
/// Current average price for a symbol.
///
/// Weight(IP): 2
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Memory
///
/// # Arguments
///
/// - `params`: [`AvgPriceParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::AvgPriceResponse>`] 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/core-trading-spot-trading/api/rest-api/market#avg-price).
///
pub async fn avg_price(
&self,
params: AvgPriceParams,
) -> anyhow::Result<RestApiResponse<models::AvgPriceResponse>> {
self.market_api_client.avg_price(params).await
}
/// Order book
///
/// Order book
///
/// Weight: Adjusted based on the limit:
///
/// |Limit|Request Weight
/// ------|-------
/// 1-100| 5
/// 101-500| 25
/// 501-1000| 50
/// 1001-5000| 250
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Memory
///
/// # Arguments
///
/// - `params`: [`DepthParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::DepthResponse>`] 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/core-trading-spot-trading/api/rest-api/market#depth).
///
pub async fn depth(
&self,
params: DepthParams,
) -> anyhow::Result<RestApiResponse<models::DepthResponse>> {
self.market_api_client.depth(params).await
}
/// Recent trades list
///
/// Get recent trades.
///
/// Weight(IP): 25
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Memory
///
/// # Arguments
///
/// - `params`: [`GetTradesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::GetTradesResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/market#get-trades).
///
pub async fn get_trades(
&self,
params: GetTradesParams,
) -> anyhow::Result<RestApiResponse<Vec<models::GetTradesResponseInner>>> {
self.market_api_client.get_trades(params).await
}
/// Historical Block Trades (`MARKET_DATA`)
///
/// Get block trades.
///
/// Weight(IP): 25
///
/// Security Type: `MARKET_DATA`
///
/// Notes:
/// - Data Source: Database
///
/// # Arguments
///
/// - `params`: [`HistoricalBlockTradesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::HistoricalBlockTradesResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/market#historical-block-trades).
///
pub async fn historical_block_trades(
&self,
params: HistoricalBlockTradesParams,
) -> anyhow::Result<RestApiResponse<Vec<models::HistoricalBlockTradesResponseInner>>> {
self.market_api_client.historical_block_trades(params).await
}
/// Old trade lookup
///
/// Get older trades.
///
/// Weight(IP): 25
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Database
///
/// # Arguments
///
/// - `params`: [`HistoricalTradesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::GetTradesResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/market#historical-trades).
///
pub async fn historical_trades(
&self,
params: HistoricalTradesParams,
) -> anyhow::Result<RestApiResponse<Vec<models::GetTradesResponseInner>>> {
self.market_api_client.historical_trades(params).await
}
/// Kline/Candlestick data
///
/// Kline/candlestick bars for a symbol.
/// Klines are uniquely identified by their open time.
///
/// Weight(IP): 2
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Database
///
/// Supported kline intervals (case-sensitive):
///
/// Interval | `interval` value
/// --------- | ----------------
/// seconds | `1s`
/// minutes | `1m`, `3m`, `5m`, `15m`, `30m`
/// hours | `1h`, `2h`, `4h`, `6h`, `8h`, `12h`
/// days | `1d`, `3d`
/// weeks | `1w`
/// months | `1M`
///
/// **Notes:**
///
/// * If `startTime` and `endTime` are not sent, the most recent klines are returned.
/// * Supported values for `timeZone`:
/// * Hours and minutes (e.g. `-1:00`, `05:45`)
/// * Only hours (e.g. `0`, `8`, `4`)
/// * Accepted range is strictly [-12:00 to +14:00] inclusive
/// * If `timeZone` provided, kline intervals are interpreted in that timezone instead of UTC.
/// * Note that `startTime` and `endTime` are always interpreted in UTC, regardless of `timeZone`.
///
/// # Arguments
///
/// - `params`: [`KlinesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<Vec<models::KlinesItemInner>>>`] 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/core-trading-spot-trading/api/rest-api/market#klines).
///
pub async fn klines(
&self,
params: KlinesParams,
) -> anyhow::Result<RestApiResponse<Vec<Vec<models::KlinesItemInner>>>> {
self.market_api_client.klines(params).await
}
/// Query Reference Price
///
/// Query the reference price for a symbol.
///
/// Weight(IP): 2
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Memory
///
/// # Arguments
///
/// - `params`: [`ReferencePriceParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ReferencePriceResponse>`] 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/core-trading-spot-trading/api/rest-api/market#reference-price).
///
pub async fn reference_price(
&self,
params: ReferencePriceParams,
) -> anyhow::Result<RestApiResponse<models::ReferencePriceResponse>> {
self.market_api_client.reference_price(params).await
}
/// Query Reference Price Calculation
///
/// Describes how reference price is calculated for a given symbol.
///
/// Weight(IP): 2
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Memory
///
/// # Arguments
///
/// - `params`: [`ReferencePriceCalculationParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ReferencePriceCalculationResponse>`] 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/core-trading-spot-trading/api/rest-api/market#reference-price-calculation).
///
pub async fn reference_price_calculation(
&self,
params: ReferencePriceCalculationParams,
) -> anyhow::Result<RestApiResponse<models::ReferencePriceCalculationResponse>> {
self.market_api_client
.reference_price_calculation(params)
.await
}
/// Rolling window price change statistics
///
/// **Note:** This endpoint differs from `GET /api/v3/ticker/24hr`.
///
/// The statistical time range of this endpoint can be up to 59999ms longer
/// than the requested `windowSize`.
///
/// `openTime` starts at the beginning of a minute, while the end time is
/// the current time. Therefore, the actual interval can be up to 59999ms
/// longer than the requested window.
///
/// For example, if `closeTime` is 1641287867099 (January 04, 2022
/// 09:17:47:099 UTC) and `windowSize` is `1d`, then `openTime` is
/// 1641201420000 (January 3, 2022, 09:17:00 UTC).
///
/// Weight: 4 for each requested symbol regardless of windowSize.
///
/// The weight for this request will cap at 200 once the number of `symbols` in the request is more than 50.
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Database
///
/// # Arguments
///
/// - `params`: [`TickerParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::TickerResponse>`] 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/core-trading-spot-trading/api/rest-api/market#ticker).
///
pub async fn ticker(
&self,
params: TickerParams,
) -> anyhow::Result<RestApiResponse<models::TickerResponse>> {
self.market_api_client.ticker(params).await
}
/// 24hr ticker price change statistics
///
/// 24 hour rolling window price change statistics. **Careful** when accessing this with no symbol.
///
/// Weight: <table>
/// <thead>
/// <tr>
/// <th>Parameter</th>
/// <th>Symbols Provided</th>
/// <th>Weight</th>
/// </tr>
/// </thead>
/// <tbody>
/// <tr>
/// <td rowspan="2">symbol</td>
/// <td>1</td>
/// <td>2</td>
/// </tr>
/// <tr>
/// <td>symbol parameter is omitted</td>
/// <td>80</td>
/// </tr>
/// <tr>
/// <td rowspan="4">symbols</td>
/// <td>1-20</td>
/// <td>2</td>
/// </tr>
/// <tr>
/// <td>21-100</td>
/// <td>40</td>
/// </tr>
/// <tr>
/// <td>101 or more</td>
/// <td>80</td>
/// </tr>
/// <tr>
/// <td>symbols parameter is omitted</td>
/// <td>80</td>
/// </tr>
/// </tbody>
/// </table>
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Memory
///
/// # Arguments
///
/// - `params`: [`Ticker24hrParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::Ticker24hrResponse>`] 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/core-trading-spot-trading/api/rest-api/market#ticker24hr).
///
pub async fn ticker24hr(
&self,
params: Ticker24hrParams,
) -> anyhow::Result<RestApiResponse<models::Ticker24hrResponse>> {
self.market_api_client.ticker24hr(params).await
}
/// Symbol order book ticker
///
/// Best price/qty on the order book for a symbol or symbols.
///
/// Weight: |Parameter|Symbols Provided|Weight|
/// |---|---|---|
/// |symbol| 1 |2|
/// | |omitted| 4|
/// |symbols| Any |4|
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Memory
///
/// # Arguments
///
/// - `params`: [`TickerBookTickerParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::TickerBookTickerResponse>`] 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/core-trading-spot-trading/api/rest-api/market#ticker-book-ticker).
///
pub async fn ticker_book_ticker(
&self,
params: TickerBookTickerParams,
) -> anyhow::Result<RestApiResponse<models::TickerBookTickerResponse>> {
self.market_api_client.ticker_book_ticker(params).await
}
/// Symbol price ticker
///
/// Latest price for a symbol or symbols.
///
/// Weight: |Parameter|Symbols Provided|Weight|
/// |---|---|---|
/// |symbol| 1 |2|
/// | |omitted| 4|
/// |symbols| Any |4|
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Memory
///
/// # Arguments
///
/// - `params`: [`TickerPriceParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::TickerPriceResponse>`] 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/core-trading-spot-trading/api/rest-api/market#ticker-price).
///
pub async fn ticker_price(
&self,
params: TickerPriceParams,
) -> anyhow::Result<RestApiResponse<models::TickerPriceResponse>> {
self.market_api_client.ticker_price(params).await
}
/// Trading Day Ticker
///
/// Price change statistics for a trading day.
///
/// Weight: 4 for each requested symbol. The weight for this request will cap at 200 once the number of symbols in the request is more than 50.
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Database
///
/// **Notes:**:
/// - Supported values for `timeZone`:
/// - Hours and minutes (e.g. `-1:00`, `05:45`)
/// - Only hours (e.g. `0`, `8`, `4`)
///
/// # Arguments
///
/// - `params`: [`TickerTradingDayParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::TickerTradingDayResponse>`] 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/core-trading-spot-trading/api/rest-api/market#ticker-trading-day).
///
pub async fn ticker_trading_day(
&self,
params: TickerTradingDayParams,
) -> anyhow::Result<RestApiResponse<models::TickerTradingDayResponse>> {
self.market_api_client.ticker_trading_day(params).await
}
/// `UIKlines`
///
/// The request is similar to klines having the same parameters and
/// response.
///
/// `uiKlines` return modified kline data, optimized for presentation of
/// candlestick charts.
///
/// Weight(IP): 2
///
/// Security Type: NONE
///
/// Notes:
/// **Data Source:** Database
///
/// - If `startTime` and `endTime` are not sent, the most recent klines are returned.
/// - Supported values for `timeZone`:
/// - Hours and minutes (e.g. `-1:00`, `05:45`)
/// - Only hours (e.g. `0`, `8`, `4`)
/// - Accepted range is strictly [-12:00 to +14:00] inclusive
/// - If `timeZone` provided, kline intervals are interpreted in that timezone instead of UTC.
/// - Note that `startTime` and `endTime` are always interpreted in UTC, regardless of `timeZone`.
///
/// # Arguments
///
/// - `params`: [`UiKlinesParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<Vec<models::KlinesItemInner>>>`] 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/core-trading-spot-trading/api/rest-api/market#ui-klines).
///
pub async fn ui_klines(
&self,
params: UiKlinesParams,
) -> anyhow::Result<RestApiResponse<Vec<Vec<models::KlinesItemInner>>>> {
self.market_api_client.ui_klines(params).await
}
/// Cancel All Open Orders on a Symbol (TRADE)
///
/// Cancels all active orders on a symbol.
/// This includes orders that are part of an order list.
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// # Arguments
///
/// - `params`: [`DeleteOpenOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::DeleteOpenOrdersResponseInner>>`] 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/core-trading-spot-trading/api/rest-api/trade#delete-open-orders).
///
pub async fn delete_open_orders(
&self,
params: DeleteOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::DeleteOpenOrdersResponseInner>>> {
self.trade_api_client.delete_open_orders(params).await
}
/// Cancel order (TRADE)
///
/// Cancel an active order.
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// - Either `orderId` or `origClientOrderId` must be sent.
/// - If both `orderId` and `origClientOrderId` are provided, the `orderId` is searched first, then the `origClientOrderId` from that result is checked against that order. If both conditions are not met the request will be rejected.
/// - The performance for canceling an order (single cancel or as part of a cancel-replace) is always better when only `orderId` is sent. Sending `origClientOrderId` or both `orderId` + `origClientOrderId` will be slower.
///
/// # Arguments
///
/// - `params`: [`DeleteOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::DeleteOrderResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#delete-order).
///
pub async fn delete_order(
&self,
params: DeleteOrderParams,
) -> anyhow::Result<RestApiResponse<models::DeleteOrderResponse>> {
self.trade_api_client.delete_order(params).await
}
/// Cancel Order list (TRADE)
///
/// Cancel an entire Order list
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// **Notes:**
/// - Canceling an individual order from an order list will cancel the entire order list.
/// - If both orderListId and listClientOrderId parameters are provided, the orderListId is searched first, then the listClientOrderId from that result is checked against that order. If both conditions are not met the request will be rejected.
///
/// # Arguments
///
/// - `params`: [`DeleteOrderListParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::DeleteOrderListResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#delete-order-list).
///
pub async fn delete_order_list(
&self,
params: DeleteOrderListParams,
) -> anyhow::Result<RestApiResponse<models::DeleteOrderListResponse>> {
self.trade_api_client.delete_order_list(params).await
}
/// New order (TRADE)
///
/// Send in a new order.
///
/// This adds 1 order to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
///
/// Weight(IP): 1
///
/// Unfilled Order Count: 1
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// Some additional mandatory parameters based on order `type`:
///
/// Type | Additional mandatory parameters | Additional Information
/// ------------ | ------------| ------
/// `LIMIT` | `timeInForce`, `quantity`, `price`|
/// `MARKET` | `quantity` or `quoteOrderQty`| `MARKET` orders using the `quantity` field specifies the amount of the `base asset` the user wants to buy or sell at the market price. <br/> E.g. MARKET order on BTCUSDT will specify how much BTC the user is buying or selling. <br/><br/> `MARKET` orders using `quoteOrderQty` specifies the amount the user wants to spend (when buying) or receive (when selling) the `quote` asset; the correct `quantity` will be determined based on the market liquidity and `quoteOrderQty`. <br/> E.g. Using the symbol BTCUSDT: <br/> `BUY` side, the order will buy as many BTC as `quoteOrderQty` USDT can. <br/> `SELL` side, the order will sell as much BTC needed to receive `quoteOrderQty` USDT.
/// `STOP_LOSS` | `quantity`, `stopPrice` or `trailingDelta`| This will execute a `MARKET` order when the conditions are met. (e.g. `stopPrice` is met or `trailingDelta` is activated)
/// `STOP_LOSS_LIMIT` | `timeInForce`, `quantity`, `price`, `stopPrice` or `trailingDelta`
/// `TAKE_PROFIT` | `quantity`, `stopPrice` or `trailingDelta` | This will execute a `MARKET` order when the conditions are met. (e.g. `stopPrice` is met or `trailingDelta` is activated)
/// `TAKE_PROFIT_LIMIT` | `timeInForce`, `quantity`, `price`, `stopPrice` or `trailingDelta` |
/// `LIMIT_MAKER` | `quantity`, `price`| This is a `LIMIT` order that will be rejected if the order immediately matches and trades as a taker. <br/> This is also known as a POST-ONLY order.
///
///
/// Notes on using parameters for Pegged Orders:
/// * These parameters are allowed for `LIMIT`, `LIMIT_MAKER`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT_LIMIT` orders.
/// * If `pegPriceType` is specified, `price` becomes optional. Otherwise, it is still mandatory.
/// * `pegPriceType=PRIMARY_PEG` means the primary peg, that is the best price on the same side of the order book as your order.
/// * `pegPriceType=MARKET_PEG` means the market peg, that is the best price on the opposite side of the order book from your order.
/// * Use `pegOffsetType` and `pegOffsetValue` to request a price level other than the best one. These parameters must be specified together.
///
/// Other info:
/// * Any `LIMIT` or `LIMIT_MAKER` type order can be made an iceberg order by sending an `icebergQty`.
/// * Any order with an `icebergQty` MUST have `timeInForce` set to `GTC`.
/// * For `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT_LIMIT` and `TAKE_PROFIT` orders, `trailingDelta` can be combined with `stopPrice`.
/// * `MARKET` orders using `quoteOrderQty` will not break `LOT_SIZE` filter rules; the order will execute a `quantity` that will have the notional value as close as possible to `quoteOrderQty`. Trigger order price rules against market price for both MARKET and LIMIT versions:
/// * Price above market price: `STOP_LOSS` `BUY`, `TAKE_PROFIT` `SELL`
/// * Price below market price: `STOP_LOSS` `SELL`, `TAKE_PROFIT` `BUY`
///
/// # Arguments
///
/// - `params`: [`NewOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::NewOrderResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#new-order).
///
pub async fn new_order(
&self,
params: NewOrderParams,
) -> anyhow::Result<RestApiResponse<models::NewOrderResponse>> {
self.trade_api_client.new_order(params).await
}
/// Order Amend Keep Priority (TRADE)
///
/// Reduce the quantity of an existing open order.
///
/// This adds 0 orders to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
///
/// Read Order Amend Keep Priority FAQ to learn more.
///
/// Weight(IP): 4
///
/// Unfilled Order Count: 0
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// # Arguments
///
/// - `params`: [`OrderAmendKeepPriorityParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::OrderAmendKeepPriorityResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#order-amend-keep-priority).
///
pub async fn order_amend_keep_priority(
&self,
params: OrderAmendKeepPriorityParams,
) -> anyhow::Result<RestApiResponse<models::OrderAmendKeepPriorityResponse>> {
self.trade_api_client
.order_amend_keep_priority(params)
.await
}
/// Cancel an Existing Order and Send a New Order (TRADE)
///
/// - Cancels an existing order and places a new order on the same symbol.
/// - Filters and Order Count are evaluated before the processing of the cancellation and order placement occurs.
/// - A new order that was not attempted (i.e. when `newOrderResult: NOT_ATTEMPTED`), will still increase the unfilled order count by 1.
/// - You can only cancel an individual order from an orderList using this endpoint, but the result is the same as canceling the entire orderList.
///
/// Weight(IP): 1
///
/// Unfilled Order Count: 1
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// Similar to `POST /api/v3/order`, additional mandatory parameters are determined by `type`.
/// Response format varies depending on whether the processing of the message succeeded, partially succeeded, or failed.
///
/// <table>
/// <thead>
/// <tr>
/// <th colspan=3 align=left>Request</th>
/// <th colspan=3 align=left>Response</th>
/// </tr>
/// <tr>
/// <th><code>cancelReplaceMode</code></th>
/// <th><code>orderRateLimitExceededMode</code></th>
/// <th>Unfilled Order Count</th>
/// <th><code>cancelResult</code></th>
/// <th><code>newOrderResult</code></th>
/// <th><code>status</code></th>
/// </tr>
/// </thead>
/// <tbody>
/// <tr>
/// <td rowspan="11"><code>STOP_ON_FAILURE</code></td>
/// <td rowspan="6"><code>DO_NOTHING</code></td>
/// <td rowspan="3">Within Limits</td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td align=right><code>200</code></td>
/// </tr>
/// <tr>
/// <td>❌ <code>FAILURE</code></td>
/// <td>➖ <code>NOT_ATTEMPTED</code></td>
/// <td align=right><code>400</code></td>
/// </tr>
/// <tr>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>❌ <code>FAILURE</code></td>
/// <td align=right><code>409</code></td>
/// </tr>
/// <tr>
/// <td rowspan="3">Exceeds Limits</td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td align=right>N/A</td>
/// </tr>
/// <tr>
/// <td>❌ <code>FAILURE</code></td>
/// <td>➖ <code>NOT_ATTEMPTED</code></td>
/// <td align=right>N/A</td>
/// </tr>
/// <tr>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>❌ <code>FAILURE</code></td>
/// <td align=right>N/A</td>
/// </tr>
/// <tr>
/// <td rowspan="5"><code>CANCEL_ONLY</code></td>
/// <td rowspan="3">Within Limits</td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td align=right><code>200</code></td>
/// </tr>
/// <tr>
/// <td>❌ <code>FAILURE</code></td>
/// <td>➖ <code>NOT_ATTEMPTED</code></td>
/// <td align=right><code>400</code></td>
/// </tr>
/// <tr>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>❌ <code>FAILURE</code></td>
/// <td align=right><code>409</code></td>
/// </tr>
/// <tr>
/// <td rowspan="2">Exceeds Limits</td>
/// <td>❌ <code>FAILURE</code></td>
/// <td>➖ <code>NOT_ATTEMPTED</code></td>
/// <td align=right><code>429</code></td>
/// </tr>
/// <tr>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>❌ <code>FAILURE</code></td>
/// <td align=right><code>429</code></td>
/// </tr>
/// <tr>
/// <td rowspan="16"><code>ALLOW_FAILURE</code></td>
/// <td rowspan="8"><code>DO_NOTHING</code></td>
/// <td rowspan="4">Within Limits</td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td align=right><code>200</code></td>
/// </tr>
/// <tr>
/// <td>❌ <code>FAILURE</code></td>
/// <td>❌ <code>FAILURE</code></td>
/// <td align=right><code>400</code></td>
/// </tr>
/// <tr>
/// <td>❌ <code>FAILURE</code></td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td align=right><code>409</code></td>
/// </tr>
/// <tr>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>❌ <code>FAILURE</code></td>
/// <td align=right><code>409</code></td>
/// </tr>
/// <tr>
/// <td rowspan="4">Exceeds Limits</td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td align=right>N/A</td>
/// </tr>
/// <tr>
/// <td>❌ <code>FAILURE</code></td>
/// <td>❌ <code>FAILURE</code></td>
/// <td align=right>N/A</td>
/// </tr>
/// <tr>
/// <td>❌ <code>FAILURE</code></td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td align=right>N/A</td>
/// </tr>
/// <tr>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>❌ <code>FAILURE</code></td>
/// <td align=right>N/A</td>
/// </tr>
/// <tr>
/// <td rowspan="8"><CODE>CANCEL_ONLY</CODE></td>
/// <td rowspan="4">Within Limits</td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td align=right><code>200</code></td>
/// </tr>
/// <tr>
/// <td>❌ <code>FAILURE</code></td>
/// <td>❌ <code>FAILURE</code></td>
/// <td align=right><code>400</code></td>
/// </tr>
/// <tr>
/// <td>❌ <code>FAILURE</code></td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td align=right><code>409</code></td>
/// </tr>
/// <tr>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>❌ <code>FAILURE</code></td>
/// <td align=right><code>409</code></td>
/// </tr>
/// <tr>
/// <td rowspan="4">Exceeds Limits</td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td align=right><code>N/A</code></td>
/// </tr>
/// <tr>
/// <td>❌ <code>FAILURE</code></td>
/// <td>❌ <code>FAILURE</code></td>
/// <td align=right><code>400</code></td>
/// </tr>
/// <tr>
/// <td>❌ <code>FAILURE</code></td>
/// <td>✅ <code>SUCCESS</code></td>
/// <td align=right>N/A</td>
/// </tr>
/// <tr>
/// <td>✅ <code>SUCCESS</code></td>
/// <td>❌ <code>FAILURE</code></td>
/// <td align=right><code>409</code></td>
/// </tr>
/// </tbody>
/// </table>
///
/// **Notes:**
/// - The performance for canceling an order (single cancel or as part of a cancel-replace) is always better when only `orderId` is sent. Sending `origClientOrderId` or both `orderId` + `origClientOrderId` will be slower.
///
/// # Arguments
///
/// - `params`: [`OrderCancelReplaceParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::OrderCancelReplaceResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#order-cancel-replace).
///
pub async fn order_cancel_replace(
&self,
params: OrderCancelReplaceParams,
) -> anyhow::Result<RestApiResponse<models::OrderCancelReplaceResponse>> {
self.trade_api_client.order_cancel_replace(params).await
}
/// New Order list - OCO (TRADE)
///
/// Send in an one-cancels-the-other (OCO) pair, where activation of one
/// order immediately cancels the other.
///
/// - An OCO has 2 orders called the **above order** and **below order**.
/// - One of the orders must be a `LIMIT_MAKER/TAKE_PROFIT/TAKE_PROFIT_LIMIT` order and the other must be `STOP_LOSS` or `STOP_LOSS_LIMIT` order.
/// - Price restrictions
/// - If the OCO is on the `SELL` side:
/// - `LIMIT_MAKER/TAKE_PROFIT_LIMIT` `price` > Last Traded Price > `STOP_LOSS/STOP_LOSS_LIMIT` `stopPrice`
/// - `TAKE_PROFIT stopPrice` > Last Traded Price > `STOP_LOSS/STOP_LOSS_LIMIT stopPrice`
/// - If the OCO is on the `BUY` side:
/// - `LIMIT_MAKER/TAKE_PROFIT_LIMIT price` < Last Traded Price < `stopPrice`
/// - `TAKE_PROFIT stopPrice` < Last Traded Price < `STOP_LOSS/STOP_LOSS_LIMIT stopPrice` * OCOs add **2 orders** to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
/// - OCOs add 2 orders to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
///
/// Weight(IP): 1
///
/// Unfilled Order Count: 2
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// # Arguments
///
/// - `params`: [`OrderListOcoParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::OrderListOcoResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#order-list-oco).
///
pub async fn order_list_oco(
&self,
params: OrderListOcoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOcoResponse>> {
self.trade_api_client.order_list_oco(params).await
}
/// New Order List - OPO (TRADE)
///
/// Place an [OPO](/products/spot/faqs/opo).
///
/// - OPOs add 2 orders to the `EXCHANGE_MAX_NUM_ORDERS`` filter and `MAX_NUM_ORDERS`` filter.
///
/// Weight(IP): 1
///
/// Unfilled Order Count: 2
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// # Arguments
///
/// - `params`: [`OrderListOpoParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::OrderListOpoResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#order-list-opo).
///
pub async fn order_list_opo(
&self,
params: OrderListOpoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOpoResponse>> {
self.trade_api_client.order_list_opo(params).await
}
/// New Order List - OPOCO (TRADE)
///
/// Place an [OPOCO](/products/spot/faqs/opo).
///
/// Weight(IP): 1
///
/// Unfilled Order Count: 3
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// # Arguments
///
/// - `params`: [`OrderListOpocoParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::OrderListOpocoResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#order-list-opoco).
///
pub async fn order_list_opoco(
&self,
params: OrderListOpocoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOpocoResponse>> {
self.trade_api_client.order_list_opoco(params).await
}
/// New Order list - OTO (TRADE)
///
/// Place an OTO.
///
/// - An OTO (One-Triggers-the-Other) is an order list comprised of 2 orders.
/// - The first order is called the **working order** and must be `LIMIT` or `LIMIT_MAKER`. Initially, only the working order goes on the order book.
/// - The second order is called the **pending order**. It can be any order type except for `MARKET` orders using parameter `quoteOrderQty`. The pending order is only placed on the order book when the working order gets **fully filled**.
/// - If either the working order or the pending order is cancelled individually, the other order in the order list will also be canceled or expired.
/// - When the order list is placed, if the working order gets **immediately fully filled**, the placement response will show the working order as `FILLED` but the pending order will still appear as `PENDING_NEW`. You need to query the status of the pending order again to see its updated status.
/// - OTOs add **2 orders** to the `EXCHANGE_MAX_NUM_ORDERS` filter and `MAX_NUM_ORDERS` filter.
///
/// Weight(IP): 1
///
/// Unfilled Order Count: 2
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// **Mandatory parameters based on `pendingType` or `workingType`**
///
/// Depending on the `pendingType` or `workingType`, some optional parameters will become mandatory.
///
/// |Type |Additional mandatory parameters|Additional information|
/// |---- |---- |------
/// |`workingType` = `LIMIT` |`workingTimeInForce` |
/// |`pendingType` = `LIMIT` |`pendingPrice`, `pendingTimeInForce` |
/// |`pendingType` = `STOP_LOSS` or `TAKE_PROFIT` |`pendingStopPrice` and/or `pendingTrailingDelta`|
/// |`pendingType` = `STOP_LOSS_LIMIT` or `TAKE_PROFIT_LIMIT`|`pendingPrice`, `pendingStopPrice` and/or `pendingTrailingDelta`, `pendingTimeInForce`|
///
/// # Arguments
///
/// - `params`: [`OrderListOtoParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::OrderListOtoResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#order-list-oto).
///
pub async fn order_list_oto(
&self,
params: OrderListOtoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOtoResponse>> {
self.trade_api_client.order_list_oto(params).await
}
/// New Order list - OTOCO (TRADE)
///
/// Place an OTOCO.
///
/// - An OTOCO (One-Triggers-One-Cancels-the-Other) is an order list comprised of 3 orders.
/// - The first order is called the **working order** and must be `LIMIT` or `LIMIT_MAKER`. Initially, only the working order goes on the order book.
/// - The behavior of the working order is the same as the [OTO](#order-list-oto).
/// - OTOCO has 2 pending orders (pending above and pending below), forming an OCO pair. The pending orders are only placed on the order book when the working order gets **fully filled**.
/// - The rules of the pending above and pending below follow the same rules as the [Order list OCO](#order-list-oco).
/// - OTOCOs add **3 orders** to the `EXCHANGE_MAX_NUM_ORDERS` filter and `MAX_NUM_ORDERS` filter.
///
/// Weight(IP): 1
///
/// Unfilled Order Count: 3
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// **Mandatory parameters based on `pendingAboveType`, `pendingBelowType` or `workingType`**
///
/// Depending on the `pendingAboveType`/`pendingBelowType` or `workingType`, some optional parameters will become mandatory.
///
/// |Type |Additional mandatory parameters|Additional information|
/// |---- |---- |------
/// |`workingType` = `LIMIT` |`workingTimeInForce` |
/// |`pendingAboveType`= `LIMIT_MAKER` |`pendingAbovePrice` |
/// |`pendingAboveType` = `STOP_LOSS/TAKE_PROFIT` |`pendingAboveStopPrice` and/or `pendingAboveTrailingDelta`|
/// |`pendingAboveType=STOP_LOSS_LIMIT/TAKE_PROFIT_LIMIT` |`pendingAbovePrice`, `pendingAboveStopPrice` and/or `pendingAboveTrailingDelta`, `pendingAboveTimeInForce`|
/// |`pendingBelowType`= `LIMIT_MAKER` |`pendingBelowPrice` |
/// |`pendingBelowType= STOP_LOSS/TAKE_PROFIT` |`pendingBelowStopPrice` and/or `pendingBelowTrailingDelta`|
/// |`pendingBelowType=STOP_LOSS_LIMIT/TAKE_PROFIT_LIMIT` |`pendingBelowPrice`, `pendingBelowStopPrice` and/or `pendingBelowTrailingDelta`, `pendingBelowTimeInForce`|
///
/// # Arguments
///
/// - `params`: [`OrderListOtocoParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::OrderListOtocoResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#order-list-otoco).
///
pub async fn order_list_otoco(
&self,
params: OrderListOtocoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOtocoResponse>> {
self.trade_api_client.order_list_otoco(params).await
}
/// New OCO - Deprecated (TRADE)
///
/// Send in a new OCO.
///
/// - Price Restrictions:
/// - `SELL`: Limit Price > Last Price > Stop Price
/// - `BUY`: Limit Price < Last Price < Stop Price
/// - Quantity Restrictions:
/// - Both legs must have the same quantity.
/// - `ICEBERG` quantities however do not have to be the same
/// - `OCO` adds **2 orders** to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
///
/// Weight(IP): 1
///
/// Unfilled Order Count: 2
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// # Arguments
///
/// - `params`: [`OrderOcoParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::OrderOcoResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#order-oco).
///
/// # Deprecation
///
/// **Deprecated:** This method may be removed in a future version.
#[deprecated]
pub async fn order_oco(
&self,
params: OrderOcoParams,
) -> anyhow::Result<RestApiResponse<models::OrderOcoResponse>> {
self.trade_api_client.order_oco(params).await
}
/// Test new order (TRADE)
///
/// Test new order creation and signature/recvWindow long.
///
/// Creates and validates a new order but does not send it into the matching
/// engine.
///
/// Weight: |Condition|Weight|
/// |---|---|
/// |Without `computeCommissionRates`|1|
/// |With `computeCommissionRates`|20|
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Memory
///
/// # Arguments
///
/// - `params`: [`OrderTestParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::OrderTestResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#order-test).
///
pub async fn order_test(
&self,
params: OrderTestParams,
) -> anyhow::Result<RestApiResponse<models::OrderTestResponse>> {
self.trade_api_client.order_test(params).await
}
/// New order using SOR (TRADE)
///
/// Places an order using smart order routing (SOR).
///
/// This adds 1 order to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
///
/// Read [SOR FAQ](/products/spot/faqs/sor_faq) to learn more.
///
/// Weight(IP): 1
///
/// Unfilled Order Count: 1
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Matching Engine
///
/// **Note:** `POST /api/v3/sor/order` only supports `LIMIT` and `MARKET` orders. `quoteOrderQty` is not supported.
///
/// # Arguments
///
/// - `params`: [`SorOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::SorOrderResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#sor-order).
///
pub async fn sor_order(
&self,
params: SorOrderParams,
) -> anyhow::Result<RestApiResponse<models::SorOrderResponse>> {
self.trade_api_client.sor_order(params).await
}
/// Test new order using SOR (TRADE)
///
/// Test new order creation and signature/recvWindow using smart order routing (SOR).
/// Creates and validates a new order but does not send it into the matching engine.
///
/// Weight: |Condition|Weight|
/// |---|---|
/// |Without `computeCommissionRates`|1|
/// |With `computeCommissionRates`|20|
///
/// Security Type: TRADE
///
/// Notes:
/// **Data Source:** Memory
///
/// # Arguments
///
/// - `params`: [`SorOrderTestParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::SorOrderTestResponse>`] 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/core-trading-spot-trading/api/rest-api/trade#sor-order-test).
///
pub async fn sor_order_test(
&self,
params: SorOrderTestParams,
) -> anyhow::Result<RestApiResponse<models::SorOrderTestResponse>> {
self.trade_api_client.sor_order_test(params).await
}
}