rust_okx/api/account/requests/
positions.rs1use std::borrow::Cow;
2
3use serde::Serialize;
4
5use crate::model::InstType;
6
7#[derive(Debug, Clone, Default, Serialize)]
11#[serde(rename_all = "camelCase")]
12pub struct PositionsRequest<'a> {
13 #[serde(skip_serializing_if = "Option::is_none")]
14 inst_type: Option<InstType>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 inst_id: Option<Cow<'a, str>>,
17}
18
19impl<'a> PositionsRequest<'a> {
20 pub fn new() -> Self {
22 Self::default()
23 }
24
25 pub fn inst_type(mut self, inst_type: InstType) -> Self {
27 self.inst_type = Some(inst_type);
28 self
29 }
30
31 pub fn inst_id(mut self, inst_id: impl Into<Cow<'a, str>>) -> Self {
33 self.inst_id = Some(inst_id.into());
34 self
35 }
36}
37
38#[derive(Debug, Clone, Default, Serialize)]
40#[serde(rename_all = "camelCase")]
41pub struct PositionRiskRequest {
42 #[serde(skip_serializing_if = "Option::is_none")]
43 inst_type: Option<InstType>,
44}
45
46impl PositionRiskRequest {
47 pub fn new() -> Self {
49 Self::default()
50 }
51
52 pub fn inst_type(mut self, inst_type: InstType) -> Self {
54 self.inst_type = Some(inst_type);
55 self
56 }
57}