use crate::{
v1::api::GmoApi,
request::AccessLevel,
utils,
};
use anyhow::Result;
use serde::{Deserialize, Serialize};
const PATH: &str = "/v1/closeBulkOrder";
impl GmoApi {
pub async fn post_close_bulk_order(&self, parameters: PostCloseBulkOrderParameters) -> Result<PostCloseBulkOrderResponse> {
self.post(PATH, Some(parameters), AccessLevel::Private).await
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PostCloseBulkOrderParameters {
symbol: String,
side: String,
execution_type: String,
time_in_force: Option<String>,
#[serde(serialize_with = "utils::serialize_option_as_string")]
price: Option<f64>,
#[serde(serialize_with = "utils::serialize_as_string")]
size: f64,
}
impl PostCloseBulkOrderParameters {
pub fn new(
symbol: &str,
side: &str,
execution_type: &str,
size: f64,
) -> Self {
Self {
symbol: symbol.to_string(),
side: side.to_string(),
execution_type: execution_type.to_string(),
size,
price: None,
time_in_force: None,
}
}
pub fn with_time_in_force(mut self, time_in_force: &str) -> Self {
self.time_in_force = Some(time_in_force.to_string());
self
}
pub fn with_price(mut self, price: f64) -> Self {
self.price = Some(price);
self
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct PostCloseBulkOrderResponse {
status: i32,
data: String,
responsetime: String,
}
impl PostCloseBulkOrderResponse {
pub fn status(&self) -> i32 {
self.status
}
pub fn data(&self) -> &str {
&self.data
}
pub fn responsetime(&self) -> &str {
&self.responsetime
}
}