use std::borrow::Cow;
use serde::Serialize;
use crate::model::InstType;
#[derive(Debug, Clone, Serialize)]
pub struct InstrumentsRequest<'a> {
#[serde(rename = "instType")]
inst_type: InstType,
#[serde(rename = "seriesId", skip_serializing_if = "Option::is_none")]
series_id: Option<Cow<'a, str>>,
#[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
inst_family: Option<Cow<'a, str>>,
#[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
inst_id: Option<Cow<'a, str>>,
}
impl<'a> InstrumentsRequest<'a> {
pub fn new(inst_type: InstType) -> Self {
Self {
inst_type,
series_id: None,
inst_family: None,
inst_id: None,
}
}
pub fn series_id(mut self, series_id: impl Into<Cow<'a, str>>) -> Self {
self.series_id = Some(series_id.into());
self
}
pub fn inst_family(mut self, inst_family: impl Into<Cow<'a, str>>) -> Self {
self.inst_family = Some(inst_family.into());
self
}
pub fn inst_id(mut self, inst_id: impl Into<Cow<'a, str>>) -> Self {
self.inst_id = Some(inst_id.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
pub struct InstIdRequest<'a> {
#[serde(rename = "instId")]
inst_id: Cow<'a, str>,
}
impl<'a> InstIdRequest<'a> {
pub fn new(inst_id: impl Into<Cow<'a, str>>) -> Self {
Self {
inst_id: inst_id.into(),
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct CurrencyRequest<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
}
impl<'a> CurrencyRequest<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(ccy.into());
self
}
}
mod edge;
pub use edge::*;
#[derive(Debug, Clone, Serialize)]
pub struct InstrumentFamilyRequest<'a> {
#[serde(rename = "instType")]
inst_type: InstType,
#[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
underlying: Option<Cow<'a, str>>,
#[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
inst_id: Option<Cow<'a, str>>,
#[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
inst_family: Option<Cow<'a, str>>,
}
impl<'a> InstrumentFamilyRequest<'a> {
pub fn new(inst_type: InstType) -> Self {
Self {
inst_type,
underlying: None,
inst_id: None,
inst_family: None,
}
}
pub fn underlying(mut self, underlying: impl Into<Cow<'a, str>>) -> Self {
self.underlying = Some(underlying.into());
self
}
pub fn inst_id(mut self, inst_id: impl Into<Cow<'a, str>>) -> Self {
self.inst_id = Some(inst_id.into());
self
}
pub fn inst_family(mut self, inst_family: impl Into<Cow<'a, str>>) -> Self {
self.inst_family = Some(inst_family.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
pub struct FundingRateHistoryRequest<'a> {
#[serde(rename = "instId")]
inst_id: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
after: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
before: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<u32>,
}
impl<'a> FundingRateHistoryRequest<'a> {
pub fn new(inst_id: impl Into<Cow<'a, str>>) -> Self {
Self {
inst_id: inst_id.into(),
after: None,
before: None,
limit: None,
}
}
pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
self.after = Some(after.into());
self
}
pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> 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 DeliveryExerciseHistoryRequest<'a> {
#[serde(rename = "instType")]
inst_type: InstType,
#[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
underlying: Option<Cow<'a, str>>,
#[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
inst_family: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
after: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
before: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<u32>,
}
impl<'a> DeliveryExerciseHistoryRequest<'a> {
pub fn new(inst_type: InstType) -> Self {
Self {
inst_type,
underlying: None,
inst_family: None,
after: None,
before: None,
limit: None,
}
}
pub fn underlying(mut self, underlying: impl Into<Cow<'a, str>>) -> Self {
self.underlying = Some(underlying.into());
self
}
pub fn inst_family(mut self, inst_family: impl Into<Cow<'a, str>>) -> Self {
self.inst_family = Some(inst_family.into());
self
}
pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
self.after = Some(after.into());
self
}
pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> 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 PositionTiersRequest<'a> {
#[serde(rename = "instType")]
inst_type: InstType,
#[serde(rename = "tdMode")]
td_mode: Cow<'a, str>,
#[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
underlying: Option<Cow<'a, str>>,
#[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
inst_id: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
tier: Option<Cow<'a, str>>,
#[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
inst_family: Option<Cow<'a, str>>,
}
impl<'a> PositionTiersRequest<'a> {
pub fn new(inst_type: InstType, td_mode: impl Into<Cow<'a, str>>) -> Self {
Self {
inst_type,
td_mode: td_mode.into(),
underlying: None,
inst_id: None,
ccy: None,
tier: None,
inst_family: None,
}
}
pub fn underlying(mut self, underlying: impl Into<Cow<'a, str>>) -> Self {
self.underlying = Some(underlying.into());
self
}
pub fn inst_id(mut self, inst_id: impl Into<Cow<'a, str>>) -> Self {
self.inst_id = Some(inst_id.into());
self
}
pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(ccy.into());
self
}
pub fn tier(mut self, tier: impl Into<Cow<'a, str>>) -> Self {
self.tier = Some(tier.into());
self
}
pub fn inst_family(mut self, inst_family: impl Into<Cow<'a, str>>) -> Self {
self.inst_family = Some(inst_family.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
pub struct InsuranceFundRequest<'a> {
#[serde(rename = "instType")]
inst_type: InstType,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
fund_type: Option<Cow<'a, str>>,
#[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
underlying: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
before: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
after: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<u32>,
#[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
inst_family: Option<Cow<'a, str>>,
}
impl<'a> InsuranceFundRequest<'a> {
pub fn new(inst_type: InstType) -> Self {
Self {
inst_type,
fund_type: None,
underlying: None,
ccy: None,
before: None,
after: None,
limit: None,
inst_family: None,
}
}
pub fn fund_type(mut self, fund_type: impl Into<Cow<'a, str>>) -> Self {
self.fund_type = Some(fund_type.into());
self
}
pub fn underlying(mut self, underlying: impl Into<Cow<'a, str>>) -> Self {
self.underlying = Some(underlying.into());
self
}
pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(ccy.into());
self
}
pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> Self {
self.before = Some(before.into());
self
}
pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
self.after = Some(after.into());
self
}
pub fn limit(mut self, limit: u32) -> Self {
self.limit = Some(limit);
self
}
pub fn inst_family(mut self, inst_family: impl Into<Cow<'a, str>>) -> Self {
self.inst_family = Some(inst_family.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ConvertContractCoinRequest<'a> {
#[serde(rename = "type")]
conversion_type: Cow<'a, str>,
#[serde(rename = "instId")]
inst_id: Cow<'a, str>,
sz: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
px: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
unit: Option<Cow<'a, str>>,
}
impl<'a> ConvertContractCoinRequest<'a> {
pub fn new(
conversion_type: impl Into<Cow<'a, str>>,
inst_id: impl Into<Cow<'a, str>>,
sz: impl Into<Cow<'a, str>>,
) -> Self {
Self {
conversion_type: conversion_type.into(),
inst_id: inst_id.into(),
sz: sz.into(),
px: None,
unit: None,
}
}
pub fn price(mut self, px: impl Into<Cow<'a, str>>) -> Self {
self.px = Some(px.into());
self
}
pub fn unit(mut self, unit: impl Into<Cow<'a, str>>) -> Self {
self.unit = Some(unit.into());
self
}
}