Skip to content

Commit

Permalink
Cleanup Rust imports
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Feb 23, 2024
1 parent a29c8f7 commit 06dc861
Show file tree
Hide file tree
Showing 25 changed files with 235 additions and 277 deletions.
21 changes: 10 additions & 11 deletions nautilus_core/accounting/src/account/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@
use std::collections::HashMap;

use anyhow::Result;
use nautilus_model::enums::{AccountType, LiquiditySide, OrderSide};
use nautilus_model::events::account::state::AccountState;
use nautilus_model::events::order::filled::OrderFilled;
use nautilus_model::identifiers::account_id::AccountId;
use nautilus_model::instruments::Instrument;
use nautilus_model::position::Position;
use nautilus_model::types::balance::AccountBalance;
use nautilus_model::types::currency::Currency;
use nautilus_model::types::money::Money;
use nautilus_model::types::price::Price;
use nautilus_model::types::quantity::Quantity;
use nautilus_model::{
enums::{AccountType, LiquiditySide, OrderSide},
events::{account::state::AccountState, order::filled::OrderFilled},
identifiers::account_id::AccountId,
instruments::Instrument,
position::Position,
types::{
balance::AccountBalance, currency::Currency, money::Money, price::Price, quantity::Quantity,
},
};
use pyo3::prelude::*;
use rust_decimal::prelude::ToPrimitive;

Expand Down
71 changes: 32 additions & 39 deletions nautilus_core/accounting/src/account/cash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@
// limitations under the License.
// -------------------------------------------------------------------------------------------------

use std::collections::HashMap;
use std::fmt::Display;
use std::ops::{Deref, DerefMut};
use std::{
collections::HashMap,
fmt::Display,
ops::{Deref, DerefMut},
};

use anyhow::Result;
use nautilus_model::enums::{AccountType, LiquiditySide, OrderSide};
use nautilus_model::events::account::state::AccountState;
use nautilus_model::events::order::filled::OrderFilled;
use nautilus_model::instruments::Instrument;
use nautilus_model::position::Position;
use nautilus_model::types::balance::AccountBalance;
use nautilus_model::types::currency::Currency;
use nautilus_model::types::money::Money;
use nautilus_model::types::price::Price;
use nautilus_model::types::quantity::Quantity;
use nautilus_model::{
enums::{AccountType, LiquiditySide, OrderSide},
events::{account::state::AccountState, order::filled::OrderFilled},
instruments::Instrument,
position::Position,
types::{
balance::AccountBalance, currency::Currency, money::Money, price::Price, quantity::Quantity,
},
};
use pyo3::prelude::*;

use crate::account::base::BaseAccount;
use crate::account::Account;
use crate::account::{base::BaseAccount, Account};

#[derive(Debug)]
#[cfg_attr(
Expand Down Expand Up @@ -185,31 +185,24 @@ impl Display for CashAccount {
////////////////////////////////////////////////////////////////////////////////
#[cfg(test)]
mod tests {
use crate::account::cash::CashAccount;
use crate::account::stubs::*;
use crate::account::Account;
use nautilus_common::factories::OrderFactory;
use nautilus_common::stubs::*;
use nautilus_model::enums::{AccountType, LiquiditySide, OrderSide};
use nautilus_model::events::account::state::AccountState;
use nautilus_model::events::account::stubs::*;
use nautilus_model::identifiers::account_id::AccountId;
use nautilus_model::identifiers::position_id::PositionId;
use nautilus_model::identifiers::strategy_id::StrategyId;
use nautilus_model::instruments::crypto_perpetual::CryptoPerpetual;
use nautilus_model::instruments::currency_pair::CurrencyPair;
use nautilus_model::instruments::equity::Equity;
use nautilus_model::instruments::stubs::*;
use nautilus_model::orders::market::MarketOrder;
use nautilus_model::orders::stubs::TestOrderEventStubs;
use nautilus_model::position::Position;
use nautilus_model::types::currency::Currency;
use nautilus_model::types::money::Money;
use nautilus_model::types::price::Price;
use nautilus_model::types::quantity::Quantity;
use std::collections::{HashMap, HashSet};

use nautilus_common::{factories::OrderFactory, stubs::*};
use nautilus_model::{
enums::{AccountType, LiquiditySide, OrderSide},
events::account::{state::AccountState, stubs::*},
identifiers::{account_id::AccountId, position_id::PositionId, strategy_id::StrategyId},
instruments::{
crypto_perpetual::CryptoPerpetual, currency_pair::CurrencyPair, equity::Equity,
stubs::*,
},
orders::{market::MarketOrder, stubs::TestOrderEventStubs},
position::Position,
types::{currency::Currency, money::Money, price::Price, quantity::Quantity},
};
use rstest::rstest;
use std::collections::HashMap;
use std::collections::HashSet;

use crate::account::{cash::CashAccount, stubs::*, Account};

#[rstest]
fn test_display(cash_account: CashAccount) {
Expand Down
55 changes: 26 additions & 29 deletions nautilus_core/accounting/src/account/margin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,32 @@

#![allow(dead_code)]

use std::ops::{Deref, DerefMut};
use std::{
collections::HashMap,
fmt::Display,
hash::{Hash, Hasher},
ops::{Deref, DerefMut},
};

use anyhow::Result;
use nautilus_model::enums::{AccountType, LiquiditySide, OrderSide};
use nautilus_model::events::account::state::AccountState;
use nautilus_model::events::order::filled::OrderFilled;
use nautilus_model::identifiers::instrument_id::InstrumentId;
use nautilus_model::instruments::Instrument;
use nautilus_model::position::Position;
use nautilus_model::types::balance::{AccountBalance, MarginBalance};
use nautilus_model::types::currency::Currency;
use nautilus_model::types::money::Money;
use nautilus_model::types::price::Price;
use nautilus_model::types::quantity::Quantity;
use nautilus_model::{
enums::{AccountType, LiquiditySide, OrderSide},
events::{account::state::AccountState, order::filled::OrderFilled},
identifiers::instrument_id::InstrumentId,
instruments::Instrument,
position::Position,
types::{
balance::{AccountBalance, MarginBalance},
currency::Currency,
money::Money,
price::Price,
quantity::Quantity,
},
};
use pyo3::prelude::*;
use rust_decimal::prelude::ToPrimitive;

use crate::account::base::BaseAccount;
use crate::account::Account;
use crate::account::{base::BaseAccount, Account};

#[derive(Debug)]
#[cfg_attr(
Expand Down Expand Up @@ -384,23 +386,18 @@ impl Hash for MarginAccount {
////////////////////////////////////////////////////////////////////////////////
#[cfg(test)]
mod tests {
use crate::account::margin::MarginAccount;
use crate::account::stubs::*;
use crate::account::Account;
use nautilus_model::events::account::state::AccountState;
use nautilus_model::events::account::stubs::*;
use nautilus_model::identifiers::instrument_id::InstrumentId;
use nautilus_model::identifiers::stubs::*;
use nautilus_model::instruments::crypto_perpetual::CryptoPerpetual;
use nautilus_model::instruments::currency_pair::CurrencyPair;
use nautilus_model::instruments::stubs::*;
use nautilus_model::types::currency::Currency;
use nautilus_model::types::money::Money;
use nautilus_model::types::price::Price;
use nautilus_model::types::quantity::Quantity;
use rstest::rstest;
use std::collections::HashMap;

use nautilus_model::{
events::account::{state::AccountState, stubs::*},
identifiers::{instrument_id::InstrumentId, stubs::*},
instruments::{crypto_perpetual::CryptoPerpetual, currency_pair::CurrencyPair, stubs::*},
types::{currency::Currency, money::Money, price::Price, quantity::Quantity},
};
use rstest::rstest;

use crate::account::{margin::MarginAccount, stubs::*, Account};

#[rstest]
fn test_display(margin_account: MarginAccount) {
assert_eq!(
Expand Down
22 changes: 11 additions & 11 deletions nautilus_core/accounting/src/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
// limitations under the License.
// -------------------------------------------------------------------------------------------------

use anyhow::Result;
use nautilus_model::enums::{LiquiditySide, OrderSide};
use nautilus_model::events::account::state::AccountState;
use nautilus_model::events::order::filled::OrderFilled;
use nautilus_model::instruments::Instrument;
use nautilus_model::position::Position;
use nautilus_model::types::balance::AccountBalance;
use nautilus_model::types::currency::Currency;
use nautilus_model::types::money::Money;
use nautilus_model::types::price::Price;
use nautilus_model::types::quantity::Quantity;
use std::collections::HashMap;

use anyhow::Result;
use nautilus_model::{
enums::{LiquiditySide, OrderSide},
events::{account::state::AccountState, order::filled::OrderFilled},
instruments::Instrument,
position::Position,
types::{
balance::AccountBalance, currency::Currency, money::Money, price::Price, quantity::Quantity,
},
};

pub trait Account {
fn balance_total(&self, currency: Option<Currency>) -> Option<Money>;
fn balances_total(&self) -> HashMap<Currency, Money>;
Expand Down
18 changes: 7 additions & 11 deletions nautilus_core/accounting/src/account/stubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@
// limitations under the License.
// -------------------------------------------------------------------------------------------------

use nautilus_model::enums::LiquiditySide;
use nautilus_model::events::account::state::AccountState;
use nautilus_model::events::account::stubs::*;
use nautilus_model::instruments::Instrument;
use nautilus_model::types::currency::Currency;
use nautilus_model::types::money::Money;
use nautilus_model::types::price::Price;
use nautilus_model::types::quantity::Quantity;
use nautilus_model::{
enums::LiquiditySide,
events::account::{state::AccountState, stubs::*},
instruments::Instrument,
types::{currency::Currency, money::Money, price::Price, quantity::Quantity},
};
use rstest::fixture;

use crate::account::cash::CashAccount;
use crate::account::margin::MarginAccount;
use crate::account::Account;
use crate::account::{cash::CashAccount, margin::MarginAccount, Account};

#[fixture]
pub fn margin_account(margin_account_state: AccountState) -> MarginAccount {
Expand Down
33 changes: 14 additions & 19 deletions nautilus_core/accounting/src/python/cash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,21 @@
use std::collections::HashMap;

use nautilus_core::python::to_pyvalue_err;
use nautilus_model::enums::{LiquiditySide, OrderSide};
use nautilus_model::events::account::state::AccountState;
use nautilus_model::events::order::filled::OrderFilled;
use nautilus_model::identifiers::account_id::AccountId;
use nautilus_model::instruments::crypto_future::CryptoFuture;
use nautilus_model::instruments::crypto_perpetual::CryptoPerpetual;
use nautilus_model::instruments::currency_pair::CurrencyPair;
use nautilus_model::instruments::equity::Equity;
use nautilus_model::instruments::futures_contract::FuturesContract;
use nautilus_model::instruments::options_contract::OptionsContract;
use nautilus_model::position::Position;
use nautilus_model::types::currency::Currency;
use nautilus_model::types::money::Money;
use nautilus_model::types::price::Price;
use nautilus_model::types::quantity::Quantity;
use pyo3::basic::CompareOp;
use pyo3::prelude::*;
use nautilus_model::{
enums::{LiquiditySide, OrderSide},
events::{account::state::AccountState, order::filled::OrderFilled},
identifiers::account_id::AccountId,
instruments::{
crypto_future::CryptoFuture, crypto_perpetual::CryptoPerpetual,
currency_pair::CurrencyPair, equity::Equity, futures_contract::FuturesContract,
options_contract::OptionsContract,
},
position::Position,
types::{currency::Currency, money::Money, price::Price, quantity::Quantity},
};
use pyo3::{basic::CompareOp, prelude::*};

use crate::account::cash::CashAccount;
use crate::account::Account;
use crate::account::{cash::CashAccount, Account};

#[pymethods]
impl CashAccount {
Expand Down
22 changes: 10 additions & 12 deletions nautilus_core/accounting/src/python/margin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@
// -------------------------------------------------------------------------------------------------

use nautilus_core::python::to_pyvalue_err;
use nautilus_model::events::account::state::AccountState;
use nautilus_model::identifiers::account_id::AccountId;
use nautilus_model::identifiers::instrument_id::InstrumentId;
use nautilus_model::instruments::crypto_future::CryptoFuture;
use nautilus_model::instruments::crypto_perpetual::CryptoPerpetual;
use nautilus_model::instruments::currency_pair::CurrencyPair;
use nautilus_model::instruments::equity::Equity;
use nautilus_model::instruments::futures_contract::FuturesContract;
use nautilus_model::instruments::options_contract::OptionsContract;
use nautilus_model::types::money::Money;
use nautilus_model::types::price::Price;
use nautilus_model::types::quantity::Quantity;
use nautilus_model::{
events::account::state::AccountState,
identifiers::{account_id::AccountId, instrument_id::InstrumentId},
instruments::{
crypto_future::CryptoFuture, crypto_perpetual::CryptoPerpetual,
currency_pair::CurrencyPair, equity::Equity, futures_contract::FuturesContract,
options_contract::OptionsContract,
},
types::{money::Money, price::Price, quantity::Quantity},
};
use pyo3::{basic::CompareOp, prelude::*, types::PyDict};

use crate::account::margin::MarginAccount;
Expand Down
20 changes: 9 additions & 11 deletions nautilus_core/accounting/src/stubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@
// limitations under the License.
// -------------------------------------------------------------------------------------------------

use nautilus_common::factories::OrderFactory;
use nautilus_common::stubs::*;
use nautilus_model::enums::OrderSide;
use nautilus_model::identifiers::instrument_id::InstrumentId;
use nautilus_model::instruments::currency_pair::CurrencyPair;
use nautilus_model::instruments::stubs::audusd_sim;
use nautilus_model::orders::market::MarketOrder;
use nautilus_model::orders::stubs::TestOrderEventStubs;
use nautilus_model::position::Position;
use nautilus_model::types::price::Price;
use nautilus_model::types::quantity::Quantity;
use nautilus_common::{factories::OrderFactory, stubs::*};
use nautilus_model::{
enums::OrderSide,
identifiers::instrument_id::InstrumentId,
instruments::{currency_pair::CurrencyPair, stubs::audusd_sim},
orders::{market::MarketOrder, stubs::TestOrderEventStubs},
position::Position,
types::{price::Price, quantity::Quantity},
};
use rstest::fixture;

#[fixture]
Expand Down
3 changes: 1 addition & 2 deletions nautilus_core/adapters/src/databento/python/historical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ use pyo3::{
};
use tokio::sync::Mutex;

use super::loader::convert_instrument_to_pyobject;
use crate::databento::{
common::get_date_time_range,
decode::{decode_instrument_def_msg, decode_record, raw_ptr_to_ustr},
symbology::decode_nautilus_instrument_id,
types::{DatabentoPublisher, PublisherId},
};

use super::loader::convert_instrument_to_pyobject;

#[cfg_attr(
feature = "python",
pyclass(module = "nautilus_trader.core.nautilus_pyo3.databento")
Expand Down
Loading

0 comments on commit 06dc861

Please sign in to comment.