Skip to content

Commit 3a67bd3

Browse files
committed
accountsmanager almost done
Signed-off-by: Pushkar Mishra <[email protected]>
1 parent 4fb5e70 commit 3a67bd3

File tree

3 files changed

+581
-25
lines changed

3 files changed

+581
-25
lines changed

nautilus_core/model/src/accounts/any.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ use serde::{Deserialize, Serialize};
2020
use crate::{
2121
accounts::{base::Account, cash::CashAccount, margin::MarginAccount},
2222
enums::AccountType,
23-
events::account::state::AccountState,
23+
events::{account::state::AccountState, order::OrderFilled},
2424
identifiers::AccountId,
25+
instruments::any::InstrumentAny,
26+
position::Position,
2527
types::{currency::Currency, money::Money},
2628
};
2729

@@ -87,6 +89,18 @@ impl AccountAny {
8789
}
8890
Ok(account)
8991
}
92+
93+
pub fn calculate_pnls(
94+
&self,
95+
instrument: InstrumentAny, // TODO: Make this a reference
96+
fill: OrderFilled, // TODO: Make this a reference
97+
position: Option<Position>,
98+
) -> anyhow::Result<Vec<Money>> {
99+
match self {
100+
AccountAny::Margin(margin) => margin.calculate_pnls(instrument, fill, position),
101+
AccountAny::Cash(cash) => cash.calculate_pnls(instrument, fill, position),
102+
}
103+
}
90104
}
91105

92106
impl From<AccountState> for AccountAny {

nautilus_core/model/src/accounts/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct BaseAccount {
4141
pub calculate_account_state: bool,
4242
pub events: Vec<AccountState>,
4343
pub commissions: HashMap<Currency, f64>,
44-
pub balances: HashMap<Currency, AccountBalance>,
44+
pub balances: HashMap<Currency, AccountBalance>, // want this
4545
pub balances_starting: HashMap<Currency, Money>,
4646
}
4747

0 commit comments

Comments
 (0)