ibkr_cp_api_client/models/
positions.rs1use super::contract::unpack_exchanges;
2use super::definitions::AssetClass;
3use super::definitions::OptionRight;
4use rust_decimal::Decimal;
5use serde::Deserialize;
6use serde::Serialize;
7use serde_json::Value;
8
9#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
10#[serde(rename_all = "camelCase")]
11#[serde(default)]
12pub struct Position {
13 pub acct_id: String,
14 #[serde(with = "unpack_exchanges")]
15 pub all_exchanges: Vec<String>,
16 pub asset_class: AssetClass,
17 pub avg_cost: Decimal,
18 pub avg_price: Decimal,
19 pub base_avg_cost: Option<Decimal>,
20 pub base_avg_price: Option<Decimal>,
21 pub base_mkt_price: Option<Decimal>,
22 pub base_mkt_value: Option<Decimal>,
23 pub base_realized_pnl: Option<Decimal>,
24 pub base_unrealized_pnl: Option<Decimal>,
25 #[serde(skip)]
26 pub chinese_name: String,
27 pub con_exch_map: Vec<Value>,
28 pub conid: i64,
29 pub contract_desc: String,
30 pub country_code: String,
31 pub cross_currency: Option<bool>,
32 pub currency: String,
33 #[serde(skip)]
34 pub display_rule: DisplayRule,
35 pub exchs: Value,
36 pub exercise_style: Value,
37 pub expiry: Option<String>,
38 pub full_name: String,
39 pub group: String,
40 pub has_options: bool,
41 #[serde(skip)]
42 pub increment_rules: Vec<IncrementRule>,
43 pub is_event_contract: bool,
44 #[serde(rename = "isUS")]
45 pub is_us: bool,
46 pub last_trading_day: Option<String>,
47 pub listing_exchange: Option<String>,
48 pub mkt_price: Decimal,
49 pub mkt_value: Decimal,
50 pub model: String,
51 pub multiplier: Option<Decimal>,
52 pub name: Option<String>,
53 pub page_size: i64,
54 pub position: Decimal,
55 pub put_or_call: Option<OptionRight>,
56 pub realized_pnl: Decimal,
57 pub sector: String,
58 pub sector_group: Option<String>,
59 pub strike: Value,
60 pub ticker: String,
61 pub time: i64,
62 #[serde(rename = "type")]
63 pub type_field: String,
64 pub und_comp: Option<Value>,
65 pub und_conid: i64,
66 pub und_sym: Option<String>,
67 pub unrealized_pnl: Decimal,
68}
69#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
71#[serde(rename_all = "camelCase")]
72pub struct DisplayRule {
73 pub display_rule_step: Vec<DisplayRuleStep>,
74 pub magnification: i64,
75}
76
77#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
78#[serde(rename_all = "camelCase")]
79pub struct DisplayRuleStep {
80 pub decimal_digits: i64,
81 pub lower_edge: Decimal,
82 pub whole_digits: i64,
83}
84
85#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
86#[serde(rename_all = "camelCase")]
87pub struct IncrementRule {
88 pub increment: Decimal,
89 pub lower_edge: Decimal,
90}