nautilus_model/events/account/
stubs.rs1use nautilus_core::UUID4;
17use rstest::fixture;
18
19use crate::{
20 enums::AccountType,
21 events::AccountState,
22 identifiers::stubs::{account_id, uuid4},
23 types::{
24 stubs::{stub_account_balance, stub_margin_balance},
25 AccountBalance, Currency, Money,
26 },
27};
28
29#[fixture]
30pub fn cash_account_state() -> AccountState {
31 AccountState::new(
32 account_id(),
33 AccountType::Cash,
34 vec![stub_account_balance()],
35 vec![],
36 true,
37 uuid4(),
38 0.into(),
39 0.into(),
40 Some(Currency::USD()),
41 )
42}
43
44#[fixture]
45pub fn cash_account_state_million_usd(
46 #[default("1000000 USD")] total: &str,
47 #[default("0 USD")] locked: &str,
48 #[default("1000000 USD")] free: &str,
49) -> AccountState {
50 AccountState::new(
51 account_id(),
52 AccountType::Cash,
53 vec![AccountBalance::new(
54 Money::from(total),
55 Money::from(locked),
56 Money::from(free),
57 )],
58 vec![],
59 true,
60 UUID4::new(),
61 0.into(),
62 0.into(),
63 Some(Currency::USD()),
64 )
65}
66
67#[fixture]
68pub fn cash_account_state_million_usdt() -> AccountState {
69 AccountState::new(
70 account_id(),
71 AccountType::Cash,
72 vec![AccountBalance::new(
73 Money::from("1000000 USD"),
74 Money::from("0 USD"),
75 Money::from("1000000 USD"),
76 )],
77 vec![],
78 true,
79 uuid4(),
80 0.into(),
81 0.into(),
82 Some(Currency::USD()),
83 )
84}
85
86#[fixture]
87pub fn cash_account_state_multi() -> AccountState {
88 let btc_account_balance = AccountBalance::new(
89 Money::from("10 BTC"),
90 Money::from("0 BTC"),
91 Money::from("10 BTC"),
92 );
93 let eth_account_balance = AccountBalance::new(
94 Money::from("20 ETH"),
95 Money::from("0 ETH"),
96 Money::from("20 ETH"),
97 );
98 AccountState::new(
99 account_id(),
100 AccountType::Cash,
101 vec![btc_account_balance, eth_account_balance],
102 vec![],
103 true,
104 uuid4(),
105 0.into(),
106 0.into(),
107 None, )
109}
110
111#[fixture]
112pub fn cash_account_state_multi_changed_btc() -> AccountState {
113 let btc_account_balance = AccountBalance::new(
114 Money::from("9 BTC"),
115 Money::from("0.5 BTC"),
116 Money::from("8.5 BTC"),
117 );
118 let eth_account_balance = AccountBalance::new(
119 Money::from("20 ETH"),
120 Money::from("0 ETH"),
121 Money::from("20 ETH"),
122 );
123 AccountState::new(
124 account_id(),
125 AccountType::Cash,
126 vec![btc_account_balance, eth_account_balance],
127 vec![],
128 true,
129 uuid4(),
130 0.into(),
131 0.into(),
132 None, )
134}
135
136#[fixture]
137pub fn margin_account_state() -> AccountState {
138 AccountState::new(
139 account_id(),
140 AccountType::Margin,
141 vec![stub_account_balance()],
142 vec![stub_margin_balance()],
143 true,
144 uuid4(),
145 0.into(),
146 0.into(),
147 Some(Currency::USD()),
148 )
149}