nautilus_model/accounts/
stubs.rsuse rstest::fixture;
use crate::{
accounts::{base::Account, cash::CashAccount, margin::MarginAccount},
enums::LiquiditySide,
events::account::{state::AccountState, stubs::*},
instruments::any::InstrumentAny,
types::{currency::Currency, money::Money, price::Price, quantity::Quantity},
};
#[fixture]
pub fn margin_account(margin_account_state: AccountState) -> MarginAccount {
MarginAccount::new(margin_account_state, true)
}
#[fixture]
pub fn cash_account(cash_account_state: AccountState) -> CashAccount {
CashAccount::new(cash_account_state, true)
}
#[fixture]
pub fn cash_account_million_usd(cash_account_state_million_usd: AccountState) -> CashAccount {
CashAccount::new(cash_account_state_million_usd, true)
}
#[fixture]
pub fn cash_account_multi(cash_account_state_multi: AccountState) -> CashAccount {
CashAccount::new(cash_account_state_multi, true)
}
#[must_use]
pub fn calculate_commission(
instrument: InstrumentAny,
quantity: Quantity,
price: Price,
currency: Option<Currency>,
) -> Money {
let account_state = if Some(Currency::USDT()) == currency {
cash_account_state_million_usdt()
} else {
cash_account_state_million_usd("1000000 USD", "0 USD", "1000000 USD")
};
let account = cash_account_million_usd(account_state);
account
.calculate_commission(instrument, quantity, price, LiquiditySide::Taker, None)
.unwrap()
}