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 #[serde(skip_serializing_if = "Option::is_none")]
18 pos_id: Option<Cow<'a, str>>,
19}
20
21impl<'a> PositionsRequest<'a> {
22 pub fn new() -> Self {
24 Self::default()
25 }
26
27 pub fn inst_type(mut self, inst_type: InstType) -> Self {
29 self.inst_type = Some(inst_type);
30 self
31 }
32
33 pub fn inst_id(mut self, inst_id: impl Into<Cow<'a, str>>) -> Self {
35 self.inst_id = Some(inst_id.into());
36 self
37 }
38
39 pub fn position_id(mut self, pos_id: impl Into<Cow<'a, str>>) -> Self {
41 self.pos_id = Some(pos_id.into());
42 self
43 }
44}
45
46#[derive(Debug, Clone, Default, Serialize)]
48#[serde(rename_all = "camelCase")]
49pub struct PositionRiskRequest {
50 #[serde(skip_serializing_if = "Option::is_none")]
51 inst_type: Option<InstType>,
52}
53
54impl PositionRiskRequest {
55 pub fn new() -> Self {
57 Self::default()
58 }
59
60 pub fn inst_type(mut self, inst_type: InstType) -> Self {
62 self.inst_type = Some(inst_type);
63 self
64 }
65}