/*
* Stocks Trading REST API
*
* REST APIs for Binance Stocks Trading. All endpoints under `/sapi/v1/equity/_*`.
*
* 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,
market_data_api_client: MarketDataApiClient,
tokenized_api_client: TokenizedApiClient,
trade_api_client: TradeApiClient,
user_data_streams_api_client: UserDataStreamsApiClient,
}
impl RestApi {
pub fn new(configuration: ConfigurationRestApi) -> Self {
let account_api_client = AccountApiClient::new(configuration.clone());
let market_data_api_client = MarketDataApiClient::new(configuration.clone());
let tokenized_api_client = TokenizedApiClient::new(configuration.clone());
let trade_api_client = TradeApiClient::new(configuration.clone());
let user_data_streams_api_client = UserDataStreamsApiClient::new(configuration.clone());
Self {
configuration,
account_api_client,
market_data_api_client,
tokenized_api_client,
trade_api_client,
user_data_streams_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
}
/// Sign US Equity Disclaimer (TRADE)
///
/// Records the user's acknowledgement and acceptance of the US equity disclaimer. This must be completed before the account can access certain US equity trading features. The acceptance is tied to the account associated with the API key.
///
/// Weight: 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`SignUsEquityDisclaimerParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::SignUsEquityDisclaimerResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/account#sign-us-equity-disclaimer).
///
pub async fn sign_us_equity_disclaimer(
&self,
params: SignUsEquityDisclaimerParams,
) -> anyhow::Result<RestApiResponse<models::SignUsEquityDisclaimerResponse>> {
self.account_api_client
.sign_us_equity_disclaimer(params)
.await
}
/// Exchange Info (`MARKET_DATA`)
///
/// Returns current exchange trading rules and the list of tradable US-equity symbols. `MARKET_DATA` endpoint — requires an API key (`X-MBX-APIKEY`) but no signature. Response is served from a server-side cache.
///
/// Weight: 1
///
/// Security Type: `MARKET_DATA`
///
/// # 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/advanced-trading-stocks-trading/api/rest-api/market-data#exchange-info).
///
pub async fn exchange_info(
&self,
params: ExchangeInfoParams,
) -> anyhow::Result<RestApiResponse<models::ExchangeInfoResponse>> {
self.market_data_api_client.exchange_info(params).await
}
/// Latest Quote (`MARKET_DATA`)
///
/// Returns the latest best bid / best ask for a single US-equity ticker. The returned value is at most ~5 seconds stale. Returns an **empty response body** (not the literal `null`) when no quote is available for the supplied ticker (e.g. the ticker is unknown, halted, or de-listed).
///
/// Weight: 1
///
/// Security Type: `MARKET_DATA`
///
/// # Arguments
///
/// - `params`: [`LatestQuoteParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::LatestQuoteResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/market-data#latest-quote).
///
pub async fn latest_quote(
&self,
params: LatestQuoteParams,
) -> anyhow::Result<RestApiResponse<models::LatestQuoteResponse>> {
self.market_data_api_client.latest_quote(params).await
}
/// Tokenized Assets (`MARKET_DATA`)
///
/// Returns the list of all tokenized assets currently available for mint / redeem, together with each asset's underlying equity symbol and conversion multiplier. `MARKET_DATA` endpoint — requires an API key (`X-MBX-APIKEY`) but no signature. Response is served from a server-side cache.
///
/// Weight: 1
///
/// Security Type: `MARKET_DATA`
///
/// # Arguments
///
/// - `params`: [`TokenizedAssetsParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::TokenizedAssetsResponseInner>>`] 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/advanced-trading-stocks-trading/api/rest-api/market-data#tokenized-assets).
///
pub async fn tokenized_assets(
&self,
) -> anyhow::Result<RestApiResponse<Vec<models::TokenizedAssetsResponseInner>>> {
self.market_data_api_client.tokenized_assets().await
}
/// Tokenized Convert History (`USER_DATA`)
///
/// Paged history of mint / redeem conversions for the caller. Cursor-style pagination — supply the `nextLastId` from the previous page's response to fetch the next page.
///
/// Weight: 1
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`TokenizedConvertHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::TokenizedConvertHistoryResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/tokenized#tokenized-convert-history).
///
pub async fn tokenized_convert_history(
&self,
params: TokenizedConvertHistoryParams,
) -> anyhow::Result<RestApiResponse<models::TokenizedConvertHistoryResponse>> {
self.tokenized_api_client
.tokenized_convert_history(params)
.await
}
/// Tokenized Convert Status (`USER_DATA`)
///
/// Query the current status of a single mint / redeem request by its `issuerRequestId`. Returns an empty object when no record matches (caller's ID scope only).
///
/// Weight: 1
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`TokenizedConvertStatusParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::TokenizedConvertStatusResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/tokenized#tokenized-convert-status).
///
pub async fn tokenized_convert_status(
&self,
params: TokenizedConvertStatusParams,
) -> anyhow::Result<RestApiResponse<models::TokenizedConvertStatusResponse>> {
self.tokenized_api_client
.tokenized_convert_status(params)
.await
}
/// Tokenized Mint (TRADE)
///
/// Mint a tokenized asset from an underlying equity holding. The caller's underlying equity (e.g. `AAPL`) is burned (or locked), and the corresponding tokenized asset (e.g. `AAPLB`) is credited. The tokenized asset is resolved server-side from `underlyingAsset`; callers only provide the underlying ticker and quantity. Mint is asynchronous: the endpoint returns an `issuerRequestId` immediately with a transient status; poll `/tokenized/convert-status` to observe the terminal state, or inspect `/tokenized/history` for the full record. Rate limit: 50 requests / min (UID).
///
/// Weight: 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`TokenizedMintParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::TokenizedMintResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/tokenized#tokenized-mint).
///
pub async fn tokenized_mint(
&self,
params: TokenizedMintParams,
) -> anyhow::Result<RestApiResponse<models::TokenizedMintResponse>> {
self.tokenized_api_client.tokenized_mint(params).await
}
/// Tokenized Redeem (TRADE)
///
/// Redeem a tokenized asset back into the underlying equity. The caller's tokenized asset (e.g. `AAPLB`) is burned, and the corresponding underlying equity (e.g. `AAPL`) is released. The underlying asset is resolved server-side from `tokenizedAsset`; callers only provide the tokenized asset and quantity. Redeem is asynchronous: the endpoint returns an `issuerRequestId` immediately with a transient status; poll `/tokenized/convert-status` to observe the terminal state, or inspect `/tokenized/history` for the full record. Rate limit: 200 requests / min (UID).
///
/// Weight: 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`TokenizedRedeemParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::TokenizedRedeemResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/tokenized#tokenized-redeem).
///
pub async fn tokenized_redeem(
&self,
params: TokenizedRedeemParams,
) -> anyhow::Result<RestApiResponse<models::TokenizedRedeemResponse>> {
self.tokenized_api_client.tokenized_redeem(params).await
}
/// Cancel All Equity Orders (TRADE)
///
/// Cancel all open orders for the caller. No request body is required — the scope is all of the caller's open orders. The downstream service handles idempotency; to inspect per-order outcomes, query `/order/history` after the call.
///
/// Weight: 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`CancelAllEquityOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelAllEquityOrdersResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/trade#cancel-all-equity-orders).
///
pub async fn cancel_all_equity_orders(
&self,
params: CancelAllEquityOrdersParams,
) -> anyhow::Result<RestApiResponse<models::CancelAllEquityOrdersResponse>> {
self.trade_api_client.cancel_all_equity_orders(params).await
}
/// Cancel Equity Order (TRADE)
///
/// Cancel a single open order by its `orderId`.
///
/// Weight: 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`CancelEquityOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelEquityOrderResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/trade#cancel-equity-order).
///
pub async fn cancel_equity_order(
&self,
params: CancelEquityOrderParams,
) -> anyhow::Result<RestApiResponse<models::CancelEquityOrderResponse>> {
self.trade_api_client.cancel_equity_order(params).await
}
/// Current Open Orders (`USER_DATA`)
///
/// Query all unfinished (open) orders for the caller. No business parameters are needed — user identity is derived from the signature.
///
/// Weight: 1
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`CurrentOpenOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::CurrentOpenOrdersResponseInner>>`] 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/advanced-trading-stocks-trading/api/rest-api/trade#current-open-orders).
///
pub async fn current_open_orders(
&self,
params: CurrentOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::CurrentOpenOrdersResponseInner>>> {
self.trade_api_client.current_open_orders(params).await
}
/// Equity Order Detail (`USER_DATA`)
///
/// Returns a single order along with its trade execution list. Callers can only read their own orders — the user identity is derived from the signed request.
///
/// Weight: 1
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`EquityOrderDetailParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::EquityOrderDetailResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/trade#equity-order-detail).
///
pub async fn equity_order_detail(
&self,
params: EquityOrderDetailParams,
) -> anyhow::Result<RestApiResponse<models::EquityOrderDetailResponse>> {
self.trade_api_client.equity_order_detail(params).await
}
/// Equity Order History (`USER_DATA`)
///
/// Paged order history for the caller. Filters by symbol, order type, side, status, and time range.
///
/// Weight: 1
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`EquityOrderHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::EquityOrderHistoryResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/trade#equity-order-history).
///
pub async fn equity_order_history(
&self,
params: EquityOrderHistoryParams,
) -> anyhow::Result<RestApiResponse<models::EquityOrderHistoryResponse>> {
self.trade_api_client.equity_order_history(params).await
}
/// Equity Trade History (`USER_DATA`)
///
/// Paged equity trade (per-fill) history for the caller. Each row is one execution, not one order — a partially filled order produces multiple rows. Filters by symbol, side, specific `orderId`, and time range.
///
/// Weight: 1
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`EquityTradeHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::EquityTradeHistoryResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/trade#equity-trade-history).
///
pub async fn equity_trade_history(
&self,
params: EquityTradeHistoryParams,
) -> anyhow::Result<RestApiResponse<models::EquityTradeHistoryResponse>> {
self.trade_api_client.equity_trade_history(params).await
}
/// Place Equity Order (TRADE)
///
/// Place a new equity order. Supports all combinations of `LIMIT` / `MARKET` × `BUY` / `SELL`. For `LIMIT BUY` orders the commission fee is automatically computed and reserved by the server at placement time — callers submit `price` and `quantity` only, no `fee` field is required.
///
/// **Field combination matrix**
///
/// | Side | `OrderType` | Required | Forbidden | | ---- | --------- | -------- | --------- | | BUY | LIMIT | `price`, `quantity`, `tradingSession` | `notional` | | BUY | MARKET | `notional` | `price`, `quantity`, `tradingSession` | | SELL | LIMIT | `price`, `quantity`, `tradingSession` | `notional` | | SELL | MARKET | `quantity` | `price`, `notional`, `tradingSession` |
///
/// **Fractional shares**: when `quantity` has a decimal component, or an order is placed by `notional`, it is treated as a fractional-share order. A fractional-share `GTC` order must be paired with `tradingSession = EXTENDED` or `24H`.
///
/// Rate limit: 200 requests / min (UID).
///
/// Weight: 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`PlaceEquityOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::PlaceEquityOrderResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/trade#place-equity-order).
///
pub async fn place_equity_order(
&self,
params: PlaceEquityOrderParams,
) -> anyhow::Result<RestApiResponse<models::PlaceEquityOrderResponse>> {
self.trade_api_client.place_equity_order(params).await
}
/// Create / Renew Listen Key (`USER_STREAM`)
///
/// Create a new stock user-data-stream `listenKey`, or renew an existing one. Calling this endpoint for the same user with an active `listenKey` extends its validity; if there is no active key, a new one is issued. Use the returned `listenKey` to subscribe to the stock user data stream.
///
/// Weight: 1
///
/// Security Type: `USER_STREAM`
///
/// # Arguments
///
/// - `params`: [`CreateRenewListenKeyParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CreateRenewListenKeyResponse>`] 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/advanced-trading-stocks-trading/api/rest-api/user-data-streams#create-renew-listen-key).
///
pub async fn create_renew_listen_key(
&self,
params: CreateRenewListenKeyParams,
) -> anyhow::Result<RestApiResponse<models::CreateRenewListenKeyResponse>> {
self.user_data_streams_api_client
.create_renew_listen_key(params)
.await
}
}