/*
* Binance Options API
*
* OpenAPI specification for Binance exchange - Options API
*
* The version of the OpenAPI document: 0.3.0
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::options::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for passing parameters to the method [`create_batch_orders_v1`]
#[derive(Clone, Debug, Default)]
pub struct CreateBatchOrdersV1Params {
pub orders: Vec<models::OptionsCreateBatchOrdersV1ReqOrdersItem>,
pub timestamp: i64,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`create_block_order_execute_v1`]
#[derive(Clone, Debug, Default)]
pub struct CreateBlockOrderExecuteV1Params {
pub block_order_matching_key: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`create_countdown_cancel_all_heart_beat_v1`]
#[derive(Clone, Debug, Default)]
pub struct CreateCountdownCancelAllHeartBeatV1Params {
pub timestamp: i64,
pub underlyings: String,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`create_countdown_cancel_all_v1`]
#[derive(Clone, Debug, Default)]
pub struct CreateCountdownCancelAllV1Params {
pub countdown_time: i64,
pub timestamp: i64,
pub underlying: String,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`create_mmp_reset_v1`]
#[derive(Clone, Debug, Default)]
pub struct CreateMmpResetV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>,
pub underlying: Option<String>
}
/// struct for passing parameters to the method [`create_mmp_set_v1`]
#[derive(Clone, Debug, Default)]
pub struct CreateMmpSetV1Params {
pub timestamp: i64,
pub delta_limit: Option<String>,
pub frozen_time_in_milliseconds: Option<i64>,
pub qty_limit: Option<String>,
pub recv_window: Option<i64>,
pub underlying: Option<String>,
pub window_time_in_milliseconds: Option<i64>
}
/// struct for passing parameters to the method [`create_order_v1`]
#[derive(Clone, Debug, Default)]
pub struct CreateOrderV1Params {
pub quantity: String,
pub side: String,
pub symbol: String,
pub timestamp: i64,
pub r#type: String,
pub client_order_id: Option<String>,
pub is_mmp: Option<bool>,
pub new_order_resp_type: Option<String>,
pub post_only: Option<bool>,
pub price: Option<String>,
pub recv_window: Option<i64>,
pub reduce_only: Option<bool>,
pub time_in_force: Option<String>
}
/// struct for passing parameters to the method [`delete_all_open_orders_by_underlying_v1`]
#[derive(Clone, Debug, Default)]
pub struct DeleteAllOpenOrdersByUnderlyingV1Params {
/// Option underlying, e.g BTCUSDT
pub underlying: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`delete_all_open_orders_v1`]
#[derive(Clone, Debug, Default)]
pub struct DeleteAllOpenOrdersV1Params {
/// Option trading pair, e.g BTC-200730-9000-C
pub symbol: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`delete_batch_orders_v1`]
#[derive(Clone, Debug, Default)]
pub struct DeleteBatchOrdersV1Params {
/// Option trading pair, e.g BTC-200730-9000-C
pub symbol: String,
pub timestamp: i64,
/// Order ID, e.g [4611875134427365377,4611875134427365378]
pub order_ids: Option<Vec<i64>>,
/// User-defined order ID, e.g ["my_id_1","my_id_2"]
pub client_order_ids: Option<Vec<String>>,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`delete_order_v1`]
#[derive(Clone, Debug, Default)]
pub struct DeleteOrderV1Params {
/// Option trading pair, e.g BTC-200730-9000-C
pub symbol: String,
pub timestamp: i64,
/// Order ID, e.g 4611875134427365377
pub order_id: Option<i64>,
/// User-defined order ID, e.g 10000
pub client_order_id: Option<String>,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_account_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetAccountV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_bill_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetBillV1Params {
/// Asset type, only support USDT as of now
pub currency: String,
pub timestamp: i64,
/// Return the recordId and subsequent data, the latest data is returned by default, e.g 100000
pub record_id: Option<i64>,
/// Start Time, e.g 1593511200000
pub start_time: Option<i64>,
/// End Time, e.g 1593512200000
pub end_time: Option<i64>,
/// Number of result sets returned Default:100 Max:1000
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_block_order_execute_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetBlockOrderExecuteV1Params {
pub block_order_matching_key: String,
pub timestamp: i64,
/// The value cannot be greater than 60000
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_block_order_orders_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetBlockOrderOrdersV1Params {
pub timestamp: i64,
/// If specified, returns the specific block trade associated with the blockOrderMatchingKey
pub block_order_matching_key: Option<String>,
pub end_time: Option<i64>,
pub start_time: Option<i64>,
pub underlying: Option<String>,
/// The value cannot be greater than 60000
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_block_trades_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetBlockTradesV1Params {
/// Option trading pair, e.g. BTC-200730-9000-C
pub symbol: Option<String>,
/// Number of records; Default: 100 and Max: 500
pub limit: Option<i32>
}
/// struct for passing parameters to the method [`get_block_user_trades_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetBlockUserTradesV1Params {
pub timestamp: i64,
pub end_time: Option<i64>,
pub start_time: Option<i64>,
pub underlying: Option<String>,
/// The value cannot be greater than 60000
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_countdown_cancel_all_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetCountdownCancelAllV1Params {
pub timestamp: i64,
/// Option underlying, e.g BTCUSDT
pub underlying: Option<String>,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_depth_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetDepthV1Params {
/// Option trading pair, e.g BTC-200730-9000-C
pub symbol: String,
/// Default:100 Max:1000.Optional value:[10, 20, 50, 100, 500, 1000]
pub limit: Option<i32>
}
/// struct for passing parameters to the method [`get_exercise_history_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetExerciseHistoryV1Params {
/// Underlying index like BTCUSDT
pub underlying: Option<String>,
/// Start Time
pub start_time: Option<i64>,
/// End Time
pub end_time: Option<i64>,
/// Number of records Default:100 Max:100
pub limit: Option<i32>
}
/// struct for passing parameters to the method [`get_exercise_record_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetExerciseRecordV1Params {
pub timestamp: i64,
/// Option trading pair, e.g BTC-200730-9000-C
pub symbol: Option<String>,
/// startTime
pub start_time: Option<i64>,
/// endTime
pub end_time: Option<i64>,
/// default 1000, max 1000
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_historical_trades_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetHistoricalTradesV1Params {
/// Option trading pair, e.g BTC-200730-9000-C
pub symbol: String,
/// The UniqueId ID from which to return. The latest deal record is returned by default
pub from_id: Option<i64>,
/// Number of records Default:100 Max:500
pub limit: Option<i32>
}
/// struct for passing parameters to the method [`get_history_orders_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetHistoryOrdersV1Params {
/// Option trading pair
pub symbol: String,
pub timestamp: i64,
/// Returns the orderId and subsequent orders, the most recent order is returned by default
pub order_id: Option<i64>,
/// Start Time, e.g 1593511200000
pub start_time: Option<i64>,
/// End Time, e.g 1593512200000
pub end_time: Option<i64>,
/// Number of result sets returned Default:100 Max:1000
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_income_asyn_id_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetIncomeAsynIdV1Params {
/// get by download id api
pub download_id: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_index_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetIndexV1Params {
/// Spot pair(Option contract underlying asset, e.g BTCUSDT)
pub underlying: String
}
/// struct for passing parameters to the method [`get_klines_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetKlinesV1Params {
/// Option trading pair, e.g BTC-200730-9000-C
pub symbol: String,
/// Time interval
pub interval: String,
/// Start Time 1592317127349
pub start_time: Option<i64>,
/// End Time
pub end_time: Option<i64>,
/// Number of records Default:500 Max:1500
pub limit: Option<i32>
}
/// struct for passing parameters to the method [`get_margin_account_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetMarginAccountV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_mark_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetMarkV1Params {
/// Option trading pair, e.g BTC-200730-9000-C
pub symbol: Option<String>
}
/// struct for passing parameters to the method [`get_mmp_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetMmpV1Params {
pub timestamp: i64,
/// underlying, e.g BTCUSDT
pub underlying: Option<String>,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_open_interest_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetOpenInterestV1Params {
/// underlying asset, e.g ETH/BTC
pub underlying_asset: String,
/// expiration date, e.g 221225
pub expiration: String
}
/// struct for passing parameters to the method [`get_open_orders_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetOpenOrdersV1Params {
pub timestamp: i64,
/// return all orders if don't pass, Option trading pair, e.g BTC-200730-9000-C,
pub symbol: Option<String>,
/// Returns the orderId and subsequent orders, the most recent order is returned by default
pub order_id: Option<i64>,
/// Start Time
pub start_time: Option<i64>,
/// End Time
pub end_time: Option<i64>,
/// Number of result sets returned Default:100 Max:1000
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_order_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetOrderV1Params {
/// Option trading pair, e.g BTC-200730-9000-C
pub symbol: String,
pub timestamp: i64,
/// Order id
pub order_id: Option<i64>,
/// User-defined order ID cannot be repeated in pending orders
pub client_order_id: Option<String>,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_position_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetPositionV1Params {
pub timestamp: i64,
/// Option trading pair, e.g BTC-200730-9000-C
pub symbol: Option<String>,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`get_ticker_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetTickerV1Params {
/// Option trading pair, e.g BTC-200730-9000-C
pub symbol: Option<String>
}
/// struct for passing parameters to the method [`get_trades_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetTradesV1Params {
/// Option trading pair, e.g BTC-200730-9000-C
pub symbol: String,
/// Number of records Default:100 Max:500
pub limit: Option<i32>
}
/// struct for passing parameters to the method [`get_user_trades_v1`]
#[derive(Clone, Debug, Default)]
pub struct GetUserTradesV1Params {
pub timestamp: i64,
/// Option symbol, e.g BTC-200730-9000-C
pub symbol: Option<String>,
/// Trade id to fetch from. Default gets most recent trades, e.g 4611875134427365376
pub from_id: Option<i64>,
/// Start time, e.g 1593511200000
pub start_time: Option<i64>,
/// End time, e.g 1593512200000
pub end_time: Option<i64>,
/// Default 100; max 1000
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
/// struct for passing parameters to the method [`update_block_order_create_v1`]
#[derive(Clone, Debug, Default)]
pub struct UpdateBlockOrderCreateV1Params {
pub block_order_matching_key: String,
pub timestamp: i32,
pub recv_window: Option<i32>
}
/// struct for typed errors of method [`create_batch_orders_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateBatchOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_block_order_execute_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateBlockOrderExecuteV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_countdown_cancel_all_heart_beat_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCountdownCancelAllHeartBeatV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_countdown_cancel_all_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCountdownCancelAllV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_listen_key_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateListenKeyV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_mmp_reset_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateMmpResetV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_mmp_set_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateMmpSetV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_order_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_all_open_orders_by_underlying_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAllOpenOrdersByUnderlyingV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_all_open_orders_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAllOpenOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_batch_orders_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteBatchOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_listen_key_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteListenKeyV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_order_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_account_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAccountV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_bill_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBillV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_block_order_execute_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBlockOrderExecuteV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_block_order_orders_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBlockOrderOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_block_trades_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBlockTradesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_block_user_trades_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBlockUserTradesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_countdown_cancel_all_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCountdownCancelAllV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_depth_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetDepthV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_exchange_info_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetExchangeInfoV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_exercise_history_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetExerciseHistoryV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_exercise_record_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetExerciseRecordV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_historical_trades_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetHistoricalTradesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_history_orders_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetHistoryOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_income_asyn_id_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIncomeAsynIdV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_income_asyn_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIncomeAsynV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_index_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIndexV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_klines_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetKlinesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_margin_account_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginAccountV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_mark_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarkV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_mmp_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMmpV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_open_interest_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetOpenInterestV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_open_orders_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetOpenOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_order_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_ping_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPingV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_position_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPositionV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_ticker_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetTickerV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_time_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetTimeV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_trades_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetTradesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_trades_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserTradesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_block_order_create_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateBlockOrderCreateV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_listen_key_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateListenKeyV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
/// Send multiple option orders.
pub async fn create_batch_orders_v1(configuration: &configuration::Configuration, params: CreateBatchOrdersV1Params) -> Result<Vec<models::OptionsCreateBatchOrdersV1RespInner>, Error<CreateBatchOrdersV1Error>> {
let uri_str = format!("{}/eapi/v1/batchOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("orders", params.orders.into_iter().map(|p| serde_json::to_string(&p).unwrap_or_default()).collect::<Vec<String>>().join(",").to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
req_builder = req_builder.form(&multipart_form_params);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OptionsCreateBatchOrdersV1RespInner>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::OptionsCreateBatchOrdersV1RespInner>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateBatchOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Accept a block trade order
pub async fn create_block_order_execute_v1(configuration: &configuration::Configuration, params: CreateBlockOrderExecuteV1Params) -> Result<models::CreateBlockOrderExecuteV1Resp, Error<CreateBlockOrderExecuteV1Error>> {
let uri_str = format!("{}/eapi/v1/block/order/execute", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("blockOrderMatchingKey", params.block_order_matching_key.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
req_builder = req_builder.form(&multipart_form_params);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateBlockOrderExecuteV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateBlockOrderExecuteV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateBlockOrderExecuteV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint resets the time from which the countdown will begin to the time this messaged is received. It should be called repeatedly as heartbeats. Multiple heartbeats can be updated at once by specifying the underlying symbols as a list (ex. BTCUSDT,ETHUSDT) in the underlyings parameter.
pub async fn create_countdown_cancel_all_heart_beat_v1(configuration: &configuration::Configuration, params: CreateCountdownCancelAllHeartBeatV1Params) -> Result<models::CreateCountdownCancelAllHeartBeatV1Resp, Error<CreateCountdownCancelAllHeartBeatV1Error>> {
let uri_str = format!("{}/eapi/v1/countdownCancelAllHeartBeat", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let mut multipart_form_params = std::collections::HashMap::new();
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
multipart_form_params.insert("underlyings", params.underlyings.to_string());
req_builder = req_builder.form(&multipart_form_params);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCountdownCancelAllHeartBeatV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateCountdownCancelAllHeartBeatV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCountdownCancelAllHeartBeatV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint sets the parameters of the auto-cancel feature which cancels all open orders (both market maker protection and non market maker protection order types) of the underlying symbol at the end of the specified countdown time period if no heartbeat message is sent. After the countdown time period, all open orders will be cancelled and new orders will be rejected with error code -2010 until either a heartbeat message is sent or the auto-cancel feature is turned off by setting countdownTime to 0.
pub async fn create_countdown_cancel_all_v1(configuration: &configuration::Configuration, params: CreateCountdownCancelAllV1Params) -> Result<models::CreateCountdownCancelAllV1Resp, Error<CreateCountdownCancelAllV1Error>> {
let uri_str = format!("{}/eapi/v1/countdownCancelAll", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("countdownTime", params.countdown_time.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
multipart_form_params.insert("underlying", params.underlying.to_string());
req_builder = req_builder.form(&multipart_form_params);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateCountdownCancelAllV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateCountdownCancelAllV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCountdownCancelAllV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent. If the account has an active listenKey, that listenKey will be returned and its validity will be extended for 60 minutes.
pub async fn create_listen_key_v1(configuration: &configuration::Configuration) -> Result<models::CreateListenKeyV1Resp, Error<CreateListenKeyV1Error>> {
let uri_str = format!("{}/eapi/v1/listenKey", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateListenKeyV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateListenKeyV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateListenKeyV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Reset MMP, start MMP order again.
pub async fn create_mmp_reset_v1(configuration: &configuration::Configuration, params: CreateMmpResetV1Params) -> Result<models::CreateMmpResetV1Resp, Error<CreateMmpResetV1Error>> {
let uri_str = format!("{}/eapi/v1/mmpReset", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let mut multipart_form_params = std::collections::HashMap::new();
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
if let Some(param_value) = params.underlying {
multipart_form_params.insert("underlying", param_value.to_string());
}
req_builder = req_builder.form(&multipart_form_params);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMmpResetV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateMmpResetV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateMmpResetV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Set config for MMP. Market Maker Protection(MMP) is a set of protection mechanism for option market maker, this mechanism is able to prevent mass trading in short period time. Once market maker's account branches the threshold, the Market Maker Protection will be triggered. When Market Maker Protection triggers, all the current MMP orders will be canceled, new MMP orders will be rejected. Market maker can use this time to reevaluate market and modify order price.
pub async fn create_mmp_set_v1(configuration: &configuration::Configuration, params: CreateMmpSetV1Params) -> Result<models::CreateMmpSetV1Resp, Error<CreateMmpSetV1Error>> {
let uri_str = format!("{}/eapi/v1/mmpSet", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let mut multipart_form_params = std::collections::HashMap::new();
if let Some(param_value) = params.delta_limit {
multipart_form_params.insert("deltaLimit", param_value.to_string());
}
if let Some(param_value) = params.frozen_time_in_milliseconds {
multipart_form_params.insert("frozenTimeInMilliseconds", param_value.to_string());
}
if let Some(param_value) = params.qty_limit {
multipart_form_params.insert("qtyLimit", param_value.to_string());
}
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
if let Some(param_value) = params.underlying {
multipart_form_params.insert("underlying", param_value.to_string());
}
if let Some(param_value) = params.window_time_in_milliseconds {
multipart_form_params.insert("windowTimeInMilliseconds", param_value.to_string());
}
req_builder = req_builder.form(&multipart_form_params);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateMmpSetV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateMmpSetV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateMmpSetV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Send a new order.
pub async fn create_order_v1(configuration: &configuration::Configuration, params: CreateOrderV1Params) -> Result<models::OptionsCreateOrderV1Resp, Error<CreateOrderV1Error>> {
let uri_str = format!("{}/eapi/v1/order", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let mut multipart_form_params = std::collections::HashMap::new();
if let Some(param_value) = params.client_order_id {
multipart_form_params.insert("clientOrderId", param_value.to_string());
}
if let Some(param_value) = params.is_mmp {
multipart_form_params.insert("isMmp", param_value.to_string());
}
if let Some(param_value) = params.new_order_resp_type {
multipart_form_params.insert("newOrderRespType", param_value.to_string());
}
if let Some(param_value) = params.post_only {
multipart_form_params.insert("postOnly", param_value.to_string());
}
if let Some(param_value) = params.price {
multipart_form_params.insert("price", param_value.to_string());
}
multipart_form_params.insert("quantity", params.quantity.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
if let Some(param_value) = params.reduce_only {
multipart_form_params.insert("reduceOnly", param_value.to_string());
}
multipart_form_params.insert("side", params.side.to_string());
multipart_form_params.insert("symbol", params.symbol.to_string());
if let Some(param_value) = params.time_in_force {
multipart_form_params.insert("timeInForce", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
multipart_form_params.insert("type", params.r#type.to_string());
req_builder = req_builder.form(&multipart_form_params);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionsCreateOrderV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OptionsCreateOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Cancel all active orders on specified underlying.
pub async fn delete_all_open_orders_by_underlying_v1(configuration: &configuration::Configuration, params: DeleteAllOpenOrdersByUnderlyingV1Params) -> Result<models::DeleteAllOpenOrdersByUnderlyingV1Resp, Error<DeleteAllOpenOrdersByUnderlyingV1Error>> {
let uri_str = format!("{}/eapi/v1/allOpenOrdersByUnderlying", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("underlying".to_string(), params.underlying.to_string()));
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAllOpenOrdersByUnderlyingV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteAllOpenOrdersByUnderlyingV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAllOpenOrdersByUnderlyingV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Cancel all active order on a symbol.
pub async fn delete_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteAllOpenOrdersV1Params) -> Result<models::DeleteAllOpenOrdersV1Resp, Error<DeleteAllOpenOrdersV1Error>> {
let uri_str = format!("{}/eapi/v1/allOpenOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAllOpenOrdersV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteAllOpenOrdersV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Cancel multiple orders.
pub async fn delete_batch_orders_v1(configuration: &configuration::Configuration, params: DeleteBatchOrdersV1Params) -> Result<Vec<models::OptionsDeleteBatchOrdersV1RespInner>, Error<DeleteBatchOrdersV1Error>> {
let uri_str = format!("{}/eapi/v1/batchOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.order_ids {
match "multi" {
"multi" => {
for p in param_value {
query_params.push(("orderIds".to_string(), p.to_string()));
}
},
_ => {
let joined = param_value.iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",");
query_params.push(("orderIds".to_string(), joined));
}
};
}
if let Some(ref param_value) = params.client_order_ids {
match "multi" {
"multi" => {
for p in param_value {
query_params.push(("clientOrderIds".to_string(), p.to_string()));
}
},
_ => {
let joined = param_value.iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",");
query_params.push(("clientOrderIds".to_string(), joined));
}
};
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::OptionsDeleteBatchOrdersV1RespInner>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::OptionsDeleteBatchOrdersV1RespInner>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteBatchOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Close out a user data stream.
pub async fn delete_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<DeleteListenKeyV1Error>> {
let uri_str = format!("{}/eapi/v1/listenKey", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteListenKeyV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Cancel an active order.
pub async fn delete_order_v1(configuration: &configuration::Configuration, params: DeleteOrderV1Params) -> Result<models::DeleteOrderV1Resp, Error<DeleteOrderV1Error>> {
let uri_str = format!("{}/eapi/v1/order", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.client_order_id {
query_params.push(("clientOrderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteOrderV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get current account information.
pub async fn get_account_v1(configuration: &configuration::Configuration, params: GetAccountV1Params) -> Result<models::GetAccountV1Resp, Error<GetAccountV1Error>> {
let uri_str = format!("{}/eapi/v1/account", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAccountV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetAccountV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAccountV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Query account funding flows.
pub async fn get_bill_v1(configuration: &configuration::Configuration, params: GetBillV1Params) -> Result<Vec<models::GetBillV1RespItem>, Error<GetBillV1Error>> {
let uri_str = format!("{}/eapi/v1/bill", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("currency".to_string(), params.currency.to_string()));
if let Some(ref param_value) = params.record_id {
query_params.push(("recordId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetBillV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetBillV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBillV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Query block trade details; returns block trade details from counterparty's perspective.
pub async fn get_block_order_execute_v1(configuration: &configuration::Configuration, params: GetBlockOrderExecuteV1Params) -> Result<models::GetBlockOrderExecuteV1Resp, Error<GetBlockOrderExecuteV1Error>> {
let uri_str = format!("{}/eapi/v1/block/order/execute", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("blockOrderMatchingKey".to_string(), params.block_order_matching_key.to_string()));
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetBlockOrderExecuteV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetBlockOrderExecuteV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBlockOrderExecuteV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Check block trade order status.
pub async fn get_block_order_orders_v1(configuration: &configuration::Configuration, params: GetBlockOrderOrdersV1Params) -> Result<Vec<models::GetBlockOrderOrdersV1RespItem>, Error<GetBlockOrderOrdersV1Error>> {
let uri_str = format!("{}/eapi/v1/block/order/orders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.block_order_matching_key {
query_params.push(("blockOrderMatchingKey".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.underlying {
query_params.push(("underlying".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetBlockOrderOrdersV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetBlockOrderOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBlockOrderOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get recent block trades
pub async fn get_block_trades_v1(configuration: &configuration::Configuration, params: GetBlockTradesV1Params) -> Result<Vec<models::GetBlockTradesV1RespItem>, Error<GetBlockTradesV1Error>> {
let uri_str = format!("{}/eapi/v1/blockTrades", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetBlockTradesV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetBlockTradesV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBlockTradesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Gets block trades for a specific account.
pub async fn get_block_user_trades_v1(configuration: &configuration::Configuration, params: GetBlockUserTradesV1Params) -> Result<Vec<models::GetBlockUserTradesV1RespItem>, Error<GetBlockUserTradesV1Error>> {
let uri_str = format!("{}/eapi/v1/block/user-trades", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.underlying {
query_params.push(("underlying".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetBlockUserTradesV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetBlockUserTradesV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBlockUserTradesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// This endpoint returns the auto-cancel parameters for each underlying symbol. Note only active auto-cancel parameters will be returned, if countdownTime is set to 0 (ie. countdownTime has been turned off), the underlying symbol and corresponding countdownTime parameter will not be returned in the response.
pub async fn get_countdown_cancel_all_v1(configuration: &configuration::Configuration, params: GetCountdownCancelAllV1Params) -> Result<models::GetCountdownCancelAllV1Resp, Error<GetCountdownCancelAllV1Error>> {
let uri_str = format!("{}/eapi/v1/countdownCancelAll", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.underlying {
query_params.push(("underlying".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCountdownCancelAllV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetCountdownCancelAllV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCountdownCancelAllV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Check orderbook depth on specific symbol
pub async fn get_depth_v1(configuration: &configuration::Configuration, params: GetDepthV1Params) -> Result<models::GetDepthV1Resp, Error<GetDepthV1Error>> {
let uri_str = format!("{}/eapi/v1/depth", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetDepthV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetDepthV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetDepthV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Current exchange trading rules and symbol information
pub async fn get_exchange_info_v1(configuration: &configuration::Configuration) -> Result<models::OptionsGetExchangeInfoV1Resp, Error<GetExchangeInfoV1Error>> {
let uri_str = format!("{}/eapi/v1/exchangeInfo", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OptionsGetExchangeInfoV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OptionsGetExchangeInfoV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetExchangeInfoV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get historical exercise records.
pub async fn get_exercise_history_v1(configuration: &configuration::Configuration, params: GetExerciseHistoryV1Params) -> Result<Vec<models::GetExerciseHistoryV1RespItem>, Error<GetExerciseHistoryV1Error>> {
let uri_str = format!("{}/eapi/v1/exerciseHistory", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.underlying {
query_params.push(("underlying".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetExerciseHistoryV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetExerciseHistoryV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetExerciseHistoryV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get account exercise records.
pub async fn get_exercise_record_v1(configuration: &configuration::Configuration, params: GetExerciseRecordV1Params) -> Result<Vec<models::GetExerciseRecordV1RespItem>, Error<GetExerciseRecordV1Error>> {
let uri_str = format!("{}/eapi/v1/exerciseRecord", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetExerciseRecordV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetExerciseRecordV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetExerciseRecordV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get older market historical trades.
pub async fn get_historical_trades_v1(configuration: &configuration::Configuration, params: GetHistoricalTradesV1Params) -> Result<Vec<models::GetHistoricalTradesV1RespItem>, Error<GetHistoricalTradesV1Error>> {
let uri_str = format!("{}/eapi/v1/historicalTrades", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.from_id {
query_params.push(("fromId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetHistoricalTradesV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetHistoricalTradesV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetHistoricalTradesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Query all finished orders within 5 days, finished status: CANCELLED FILLED REJECTED.
pub async fn get_history_orders_v1(configuration: &configuration::Configuration, params: GetHistoryOrdersV1Params) -> Result<Vec<models::GetHistoryOrdersV1RespItem>, Error<GetHistoryOrdersV1Error>> {
let uri_str = format!("{}/eapi/v1/historyOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetHistoryOrdersV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetHistoryOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetHistoryOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get option transaction history download Link by Id
pub async fn get_income_asyn_id_v1(configuration: &configuration::Configuration, params: GetIncomeAsynIdV1Params) -> Result<models::GetIncomeAsynIdV1Resp, Error<GetIncomeAsynIdV1Error>> {
let uri_str = format!("{}/eapi/v1/income/asyn/id", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("downloadId".to_string(), params.download_id.to_string()));
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetIncomeAsynIdV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetIncomeAsynIdV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetIncomeAsynIdV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get download id for option transaction history
pub async fn get_income_asyn_v1(configuration: &configuration::Configuration) -> Result<models::GetIncomeAsynV1Resp, Error<GetIncomeAsynV1Error>> {
let uri_str = format!("{}/eapi/v1/income/asyn", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetIncomeAsynV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetIncomeAsynV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetIncomeAsynV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get spot index price for option underlying.
pub async fn get_index_v1(configuration: &configuration::Configuration, params: GetIndexV1Params) -> Result<models::GetIndexV1Resp, Error<GetIndexV1Error>> {
let uri_str = format!("{}/eapi/v1/index", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("underlying".to_string(), params.underlying.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetIndexV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetIndexV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetIndexV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Kline/candlestick bars for an option symbol. Klines are uniquely identified by their open time.
pub async fn get_klines_v1(configuration: &configuration::Configuration, params: GetKlinesV1Params) -> Result<Vec<models::GetKlinesV1RespItem>, Error<GetKlinesV1Error>> {
let uri_str = format!("{}/eapi/v1/klines", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
query_params.push(("interval".to_string(), params.interval.to_string()));
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetKlinesV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetKlinesV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetKlinesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get current account information.
pub async fn get_margin_account_v1(configuration: &configuration::Configuration, params: GetMarginAccountV1Params) -> Result<models::GetMarginAccountV1Resp, Error<GetMarginAccountV1Error>> {
let uri_str = format!("{}/eapi/v1/marginAccount", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMarginAccountV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetMarginAccountV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginAccountV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Option mark price and greek info.
pub async fn get_mark_v1(configuration: &configuration::Configuration, params: GetMarkV1Params) -> Result<Vec<models::GetMarkV1RespItem>, Error<GetMarkV1Error>> {
let uri_str = format!("{}/eapi/v1/mark", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetMarkV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetMarkV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarkV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get config for MMP.
pub async fn get_mmp_v1(configuration: &configuration::Configuration, params: GetMmpV1Params) -> Result<models::GetMmpV1Resp, Error<GetMmpV1Error>> {
let uri_str = format!("{}/eapi/v1/mmp", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.underlying {
query_params.push(("underlying".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMmpV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetMmpV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMmpV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get open interest for specific underlying asset on specific expiration date.
pub async fn get_open_interest_v1(configuration: &configuration::Configuration, params: GetOpenInterestV1Params) -> Result<Vec<models::GetOpenInterestV1RespItem>, Error<GetOpenInterestV1Error>> {
let uri_str = format!("{}/eapi/v1/openInterest", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("underlyingAsset".to_string(), params.underlying_asset.to_string()));
query_params.push(("expiration".to_string(), params.expiration.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetOpenInterestV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetOpenInterestV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetOpenInterestV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Query current all open orders, status: ACCEPTED PARTIALLY_FILLED
pub async fn get_open_orders_v1(configuration: &configuration::Configuration, params: GetOpenOrdersV1Params) -> Result<Vec<models::GetOpenOrdersV1RespItem>, Error<GetOpenOrdersV1Error>> {
let uri_str = format!("{}/eapi/v1/openOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetOpenOrdersV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetOpenOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetOpenOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Check an order status.
pub async fn get_order_v1(configuration: &configuration::Configuration, params: GetOrderV1Params) -> Result<models::GetOrderV1Resp, Error<GetOrderV1Error>> {
let uri_str = format!("{}/eapi/v1/order", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.client_order_id {
query_params.push(("clientOrderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetOrderV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Test connectivity to the Rest API.
pub async fn get_ping_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<GetPingV1Error>> {
let uri_str = format!("{}/eapi/v1/ping", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetPingV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get current position information.
pub async fn get_position_v1(configuration: &configuration::Configuration, params: GetPositionV1Params) -> Result<Vec<models::GetPositionV1RespItem>, Error<GetPositionV1Error>> {
let uri_str = format!("{}/eapi/v1/position", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetPositionV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetPositionV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetPositionV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// 24 hour rolling window price change statistics.
pub async fn get_ticker_v1(configuration: &configuration::Configuration, params: GetTickerV1Params) -> Result<Vec<models::GetTickerV1RespItem>, Error<GetTickerV1Error>> {
let uri_str = format!("{}/eapi/v1/ticker", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetTickerV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetTickerV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetTickerV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Test connectivity to the Rest API and get the current server time.
pub async fn get_time_v1(configuration: &configuration::Configuration) -> Result<models::GetTimeV1Resp, Error<GetTimeV1Error>> {
let uri_str = format!("{}/eapi/v1/time", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTimeV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetTimeV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetTimeV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get recent market trades
pub async fn get_trades_v1(configuration: &configuration::Configuration, params: GetTradesV1Params) -> Result<Vec<models::GetTradesV1RespItem>, Error<GetTradesV1Error>> {
let uri_str = format!("{}/eapi/v1/trades", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetTradesV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetTradesV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetTradesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get trades for a specific account and symbol.
pub async fn get_user_trades_v1(configuration: &configuration::Configuration, params: GetUserTradesV1Params) -> Result<Vec<models::GetUserTradesV1RespItem>, Error<GetUserTradesV1Error>> {
let uri_str = format!("{}/eapi/v1/userTrades", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.from_id {
query_params.push(("fromId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetUserTradesV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GetUserTradesV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUserTradesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Extends a block trade expire time by 30 mins from the current time.
pub async fn update_block_order_create_v1(configuration: &configuration::Configuration, params: UpdateBlockOrderCreateV1Params) -> Result<models::UpdateBlockOrderCreateV1Resp, Error<UpdateBlockOrderCreateV1Error>> {
let uri_str = format!("{}/eapi/v1/block/order/create", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("blockOrderMatchingKey", params.block_order_matching_key.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
req_builder = req_builder.form(&multipart_form_params);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateBlockOrderCreateV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateBlockOrderCreateV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateBlockOrderCreateV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. It's recommended to send a ping about every 60 minutes.
pub async fn update_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<UpdateListenKeyV1Error>> {
let uri_str = format!("{}/eapi/v1/listenKey", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
// Create a mutable vector for query parameters
let mut query_params: Vec<(String, String)> = Vec::new();
// Create header parameters collection
let mut header_params = std::collections::HashMap::new();
// Handle Binance Auth first if configured
if let Some(ref binance_auth) = configuration.binance_auth {
// Add API key to headers
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
// Generate request body for signing (if any)
let body_string: Option<Vec<u8>> = None;
// Sign the request
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
// Add signature to query params
query_params.push(("signature".to_string(), signature));
}
// Apply all query parameters
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
// Add user agent if configured
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
// Apply all header parameters
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateListenKeyV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}