Skip to main content

rust_okx/api/account/requests/
balances.rs

1use std::borrow::Cow;
2
3use serde::Serialize;
4
5/// Request for [`get_balance`](crate::api::account::Account::get_balance),
6/// [`get_interest_rate`](crate::api::account::Account::get_interest_rate),
7/// [`get_max_withdrawal`](crate::api::account::Account::get_max_withdrawal), and
8/// [`get_greeks`](crate::api::account::Account::get_greeks).
9///
10/// All fields are optional; omit to return data for all currencies.
11#[derive(Debug, Clone, Default, Serialize)]
12pub struct BalanceRequest<'a> {
13    #[serde(skip_serializing_if = "Option::is_none")]
14    ccy: Option<Cow<'a, str>>,
15}
16
17impl<'a> BalanceRequest<'a> {
18    /// Create an unfiltered balance query.
19    pub fn new() -> Self {
20        Self::default()
21    }
22
23    /// Set the currency filter.
24    pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
25        self.ccy = Some(ccy.into());
26        self
27    }
28}