Skip to main content

longport/trade/requests/
get_stock_positions.rs

1use serde::Serialize;
2
3use crate::types::normalize_symbol_owned;
4
5/// Options for get stock positions request
6#[derive(Debug, Serialize, Default)]
7pub struct GetStockPositionsOptions {
8    #[serde(skip_serializing_if = "<[_]>::is_empty", rename = "symbol")]
9    symbols: Vec<String>,
10}
11
12impl GetStockPositionsOptions {
13    /// Create a new `GetStockPositionsOptions`
14    #[inline]
15    pub fn new() -> Self {
16        Default::default()
17    }
18
19    /// Set the stock symbols
20    #[inline]
21    #[must_use]
22    pub fn symbols<I, T>(self, symbols: I) -> Self
23    where
24        I: IntoIterator<Item = T>,
25        T: Into<String>,
26    {
27        Self {
28            symbols: symbols.into_iter().map(normalize_symbol_owned).collect(),
29        }
30    }
31}