Skip to main content

nautilus_model/events/account/
stubs.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16use nautilus_core::UUID4;
17use rstest::fixture;
18
19use crate::{
20    enums::AccountType,
21    events::AccountState,
22    identifiers::stubs::{account_id, uuid4},
23    types::{
24        AccountBalance, Currency, Money,
25        stubs::{stub_account_balance, stub_margin_balance},
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, // multi cash account
108    )
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, // multi cash account
133    )
134}
135
136#[fixture]
137pub fn betting_account_state() -> AccountState {
138    AccountState::new(
139        account_id(),
140        AccountType::Betting,
141        vec![AccountBalance::new(
142            Money::from("1000 GBP"),
143            Money::from("0 GBP"),
144            Money::from("1000 GBP"),
145        )],
146        vec![],
147        true,
148        uuid4(),
149        0.into(),
150        0.into(),
151        Some(Currency::GBP()),
152    )
153}
154
155#[fixture]
156pub fn betting_account_state_changed() -> AccountState {
157    AccountState::new(
158        account_id(),
159        AccountType::Betting,
160        vec![AccountBalance::new(
161            Money::from("900 GBP"),
162            Money::from("50 GBP"),
163            Money::from("850 GBP"),
164        )],
165        vec![],
166        true,
167        uuid4(),
168        0.into(),
169        0.into(),
170        Some(Currency::GBP()),
171    )
172}
173
174#[fixture]
175pub fn margin_account_state() -> AccountState {
176    AccountState::new(
177        account_id(),
178        AccountType::Margin,
179        vec![stub_account_balance()],
180        vec![stub_margin_balance()],
181        true,
182        uuid4(),
183        0.into(),
184        0.into(),
185        Some(Currency::USD()),
186    )
187}
188
189#[fixture]
190pub fn wallet_account_state() -> AccountState {
191    let eth_account_balance = AccountBalance::new(
192        Money::from("10 ETH"),
193        Money::from("0 ETH"),
194        Money::from("10 ETH"),
195    );
196    let usdc_account_balance = AccountBalance::new(
197        Money::from("25000 USDC"),
198        Money::from("0 USDC"),
199        Money::from("25000 USDC"),
200    );
201    AccountState::new(
202        account_id(),
203        AccountType::Wallet,
204        vec![eth_account_balance, usdc_account_balance],
205        vec![],
206        true,
207        uuid4(),
208        0.into(),
209        0.into(),
210        None, // multi-currency wallet account
211    )
212}
213
214#[fixture]
215pub fn wallet_account_state_changed() -> AccountState {
216    let eth_account_balance = AccountBalance::new(
217        Money::from("9.5 ETH"),
218        Money::from("0 ETH"),
219        Money::from("9.5 ETH"),
220    );
221    let usdc_account_balance = AccountBalance::new(
222        Money::from("30000 USDC"),
223        Money::from("0 USDC"),
224        Money::from("30000 USDC"),
225    );
226    AccountState::new(
227        account_id(),
228        AccountType::Wallet,
229        vec![eth_account_balance, usdc_account_balance],
230        vec![],
231        true,
232        UUID4::new(),
233        0.into(),
234        0.into(),
235        None, // multi-currency wallet account
236    )
237}