use serde::Serialize;
use crate::model::TradeMode;
#[derive(Debug, Clone, Serialize)]
pub struct MaxLoanRequest {
#[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
inst_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<String>,
#[serde(rename = "mgnMode")]
mgn_mode: TradeMode,
#[serde(rename = "mgnCcy", skip_serializing_if = "Option::is_none")]
mgn_ccy: Option<String>,
#[serde(rename = "tradeQuoteCcy", skip_serializing_if = "Option::is_none")]
trade_quote_ccy: Option<String>,
}
impl MaxLoanRequest {
pub fn new(inst_id: impl Into<String>, mgn_mode: TradeMode) -> Self {
Self::by_instrument(inst_id, mgn_mode)
}
pub fn by_instrument(inst_id: impl Into<String>, mgn_mode: TradeMode) -> Self {
Self {
mgn_mode,
inst_id: Some(inst_id.into()),
ccy: None,
mgn_ccy: None,
trade_quote_ccy: None,
}
}
pub fn by_currency(ccy: impl Into<String>) -> Self {
Self {
mgn_mode: TradeMode::Cross,
inst_id: None,
ccy: Some(ccy.into()),
mgn_ccy: None,
trade_quote_ccy: None,
}
}
pub fn currency(mut self, ccy: impl Into<String>) -> Self {
self.inst_id = None;
self.ccy = Some(ccy.into());
self
}
pub fn margin_currency(mut self, mgn_ccy: impl Into<String>) -> Self {
self.mgn_ccy = Some(mgn_ccy.into());
self
}
pub fn trade_quote_currency(mut self, trade_quote_ccy: impl Into<String>) -> Self {
self.trade_quote_ccy = Some(trade_quote_ccy.into());
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct InterestAccruedRequest {
#[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
inst_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<String>,
#[serde(rename = "mgnMode", skip_serializing_if = "Option::is_none")]
mgn_mode: Option<TradeMode>,
#[serde(skip_serializing_if = "Option::is_none")]
after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<u32>,
}
impl InterestAccruedRequest {
pub fn new() -> Self {
Self::default()
}
pub fn inst_id(mut self, inst_id: impl Into<String>) -> Self {
self.inst_id = Some(inst_id.into());
self
}
pub fn currency(mut self, ccy: impl Into<String>) -> Self {
self.ccy = Some(ccy.into());
self
}
pub fn margin_mode(mut self, mgn_mode: TradeMode) -> Self {
self.mgn_mode = Some(mgn_mode);
self
}
pub fn after(mut self, after: impl Into<String>) -> Self {
self.after = Some(after.into());
self
}
pub fn before(mut self, before: impl Into<String>) -> Self {
self.before = Some(before.into());
self
}
pub fn limit(mut self, limit: u32) -> Self {
self.limit = Some(limit);
self
}
}
#[derive(Debug, Clone, Serialize)]
pub struct BorrowRepayRequest {
ccy: String,
side: String,
amt: String,
#[serde(rename = "ordId", skip_serializing_if = "Option::is_none")]
ord_id: Option<String>,
}
impl BorrowRepayRequest {
pub fn new(ccy: impl Into<String>, side: impl Into<String>, amt: impl Into<String>) -> Self {
Self {
ccy: ccy.into(),
side: side.into(),
amt: amt.into(),
ord_id: None,
}
}
pub fn order_id(mut self, ord_id: impl Into<String>) -> Self {
self.ord_id = Some(ord_id.into());
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct BorrowRepayHistoryRequest {
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<u32>,
}
impl BorrowRepayHistoryRequest {
pub fn new() -> Self {
Self::default()
}
pub fn currency(mut self, ccy: impl Into<String>) -> Self {
self.ccy = Some(ccy.into());
self
}
pub fn after(mut self, after: impl Into<String>) -> Self {
self.after = Some(after.into());
self
}
pub fn before(mut self, before: impl Into<String>) -> Self {
self.before = Some(before.into());
self
}
pub fn limit(mut self, limit: u32) -> Self {
self.limit = Some(limit);
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct InterestLimitsRequest {
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
limit_type: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<String>,
}
impl InterestLimitsRequest {
pub fn new() -> Self {
Self::default()
}
pub fn limit_type(mut self, limit_type: impl Into<String>) -> Self {
self.limit_type = Some(limit_type.into());
self
}
pub fn currency(mut self, ccy: impl Into<String>) -> Self {
self.ccy = Some(ccy.into());
self
}
}