Skip to content

Commit

Permalink
Remove redundant polymorphic traits
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Jun 1, 2024
1 parent 6d01698 commit bd12777
Show file tree
Hide file tree
Showing 18 changed files with 181 additions and 359 deletions.
6 changes: 0 additions & 6 deletions nautilus_core/common/src/cache/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ use nautilus_model::{
instruments::{any::InstrumentAny, synthetic::SyntheticInstrument},
orderbook::book::OrderBook,
orders::{any::OrderAny, list::OrderList},
polymorphism::{
GetClientOrderId, GetEmulationTrigger, GetExecAlgorithmId, GetExecSpawnId, GetInstrumentId,
GetOrderFilledQty, GetOrderLeavesQty, GetOrderQuantity, GetOrderSide, GetPositionId,
GetStrategyId, GetVenueOrderId, IsClosed, IsInflight, IsOpen,
},
position::Position,
types::{currency::Currency, price::Price, quantity::Quantity},
};
Expand Down Expand Up @@ -2526,7 +2521,6 @@ mod tests {
synthetic::SyntheticInstrument,
},
orders::stubs::{TestOrderEventStubs, TestOrderStubs},
polymorphism::{GetClientOrderId, GetOrderStatus, GetVenueOrderId, IsClosed, IsOpen},
types::{price::Price, quantity::Quantity},
};
use rstest::*;
Expand Down
3 changes: 0 additions & 3 deletions nautilus_core/common/src/factories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ pub mod tests {
identifiers::{
client_order_id::ClientOrderId, instrument_id::InstrumentId, order_list_id::OrderListId,
},
polymorphism::{
GetClientOrderId, GetExecAlgorithmId, GetInstrumentId, GetOrderQuantity, GetOrderSide,
},
};
use rstest::rstest;

Expand Down
1 change: 0 additions & 1 deletion nautilus_core/execution/src/matching_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use nautilus_model::{
base::OrderError,
market::MarketOrder,
},
polymorphism::{GetClientOrderId, GetLimitPrice, GetOrderSideSpecified, GetStopPrice},
types::price::Price,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ mod tests {
Instrument,
},
orders::stubs::{TestOrderEventStubs, TestOrderStubs},
polymorphism::GetClientOrderId,
types::{currency::Currency, price::Price, quantity::Quantity},
};
use serial_test::serial;
Expand Down
2 changes: 1 addition & 1 deletion nautilus_core/model/src/data/bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ use indexmap::IndexMap;
use nautilus_core::{nanos::UnixNanos, serialization::Serializable};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

use super::GetTsInit;
use crate::{
enums::{AggregationSource, BarAggregation, PriceType},
identifiers::instrument_id::InstrumentId,
polymorphism::GetTsInit,
types::{price::Price, quantity::Quantity},
};

Expand Down
6 changes: 4 additions & 2 deletions nautilus_core/model/src/data/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ use indexmap::IndexMap;
use nautilus_core::{nanos::UnixNanos, serialization::Serializable};
use serde::{Deserialize, Serialize};

use super::order::{BookOrder, NULL_ORDER};
use super::{
order::{BookOrder, NULL_ORDER},
GetTsInit,
};
use crate::{
enums::{BookAction, RecordFlag},
identifiers::instrument_id::InstrumentId,
polymorphism::GetTsInit,
};

/// Represents a single change/delta in an order book.
Expand Down
4 changes: 2 additions & 2 deletions nautilus_core/model/src/data/deltas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use std::{

use nautilus_core::nanos::UnixNanos;

use super::delta::OrderBookDelta;
use crate::{identifiers::instrument_id::InstrumentId, polymorphism::GetTsInit};
use super::{delta::OrderBookDelta, GetTsInit};
use crate::identifiers::instrument_id::InstrumentId;

/// Represents a grouped batch of `OrderBookDelta` updates for an `OrderBook`.
///
Expand Down
4 changes: 2 additions & 2 deletions nautilus_core/model/src/data/depth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use indexmap::IndexMap;
use nautilus_core::{nanos::UnixNanos, serialization::Serializable};
use serde::{Deserialize, Serialize};

use super::order::BookOrder;
use crate::{identifiers::instrument_id::InstrumentId, polymorphism::GetTsInit};
use super::{order::BookOrder, GetTsInit};
use crate::identifiers::instrument_id::InstrumentId;

pub const DEPTH10_LEN: usize = 10;

Expand Down
5 changes: 4 additions & 1 deletion nautilus_core/model/src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use self::{
bar::Bar, delta::OrderBookDelta, deltas::OrderBookDeltas_API, depth::OrderBookDepth10,
quote::QuoteTick, trade::TradeTick,
};
use crate::polymorphism::GetTsInit;

/// A built-in Nautilus data type.
///
Expand All @@ -49,6 +48,10 @@ pub enum Data {
Bar(Bar),
}

pub trait GetTsInit {
fn ts_init(&self) -> UnixNanos;
}

impl GetTsInit for Data {
fn ts_init(&self) -> UnixNanos {
match self {
Expand Down
2 changes: 1 addition & 1 deletion nautilus_core/model/src/data/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ use indexmap::IndexMap;
use nautilus_core::{correctness::check_equal_u8, nanos::UnixNanos, serialization::Serializable};
use serde::{Deserialize, Serialize};

use super::GetTsInit;
use crate::{
enums::PriceType,
identifiers::instrument_id::InstrumentId,
polymorphism::GetTsInit,
types::{fixed::FIXED_PRECISION, price::Price, quantity::Quantity},
};

Expand Down
2 changes: 1 addition & 1 deletion nautilus_core/model/src/data/trade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ use indexmap::IndexMap;
use nautilus_core::{nanos::UnixNanos, serialization::Serializable};
use serde::{Deserialize, Serialize};

use super::GetTsInit;
use crate::{
enums::AggressorSide,
identifiers::{instrument_id::InstrumentId, trade_id::TradeId},
polymorphism::GetTsInit,
types::{price::Price, quantity::Quantity},
};

Expand Down
1 change: 0 additions & 1 deletion nautilus_core/model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub mod instruments;
pub mod macros;
pub mod orderbook;
pub mod orders;
pub mod polymorphism;
pub mod position;
pub mod types;
pub mod venues;
Expand Down
Loading

0 comments on commit bd12777

Please sign in to comment.