Skip to content

Commit

Permalink
accountsmanager almost done
Browse files Browse the repository at this point in the history
Signed-off-by: Pushkar Mishra <[email protected]>
  • Loading branch information
Pushkarm029 committed Nov 18, 2024
1 parent 4fb5e70 commit 3a67bd3
Show file tree
Hide file tree
Showing 3 changed files with 581 additions and 25 deletions.
16 changes: 15 additions & 1 deletion nautilus_core/model/src/accounts/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ use serde::{Deserialize, Serialize};
use crate::{
accounts::{base::Account, cash::CashAccount, margin::MarginAccount},
enums::AccountType,
events::account::state::AccountState,
events::{account::state::AccountState, order::OrderFilled},
identifiers::AccountId,
instruments::any::InstrumentAny,
position::Position,
types::{currency::Currency, money::Money},
};

Expand Down Expand Up @@ -87,6 +89,18 @@ impl AccountAny {
}
Ok(account)
}

pub fn calculate_pnls(
&self,
instrument: InstrumentAny, // TODO: Make this a reference
fill: OrderFilled, // TODO: Make this a reference
position: Option<Position>,
) -> anyhow::Result<Vec<Money>> {
match self {
AccountAny::Margin(margin) => margin.calculate_pnls(instrument, fill, position),
AccountAny::Cash(cash) => cash.calculate_pnls(instrument, fill, position),
}
}
}

impl From<AccountState> for AccountAny {
Expand Down
2 changes: 1 addition & 1 deletion nautilus_core/model/src/accounts/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct BaseAccount {
pub calculate_account_state: bool,
pub events: Vec<AccountState>,
pub commissions: HashMap<Currency, f64>,
pub balances: HashMap<Currency, AccountBalance>,
pub balances: HashMap<Currency, AccountBalance>, // want this
pub balances_starting: HashMap<Currency, Money>,
}

Expand Down
Loading

0 comments on commit 3a67bd3

Please sign in to comment.