Skip to content

Commit

Permalink
Fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Apr 15, 2024
1 parent 4896771 commit 3ca1d11
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 18 deletions.
1 change: 1 addition & 0 deletions nautilus_core/accounting/src/account/stubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub fn cash_account_multi(cash_account_state_multi: AccountState) -> CashAccount
CashAccount::new(cash_account_state_multi, true).unwrap()
}

#[must_use]
pub fn calculate_commission(
instrument: InstrumentAny,
quantity: Quantity,
Expand Down
6 changes: 3 additions & 3 deletions nautilus_core/core/src/nanos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ impl PartialOrd<Option<u64>> for UnixNanos {

impl From<u64> for UnixNanos {
fn from(value: u64) -> Self {
UnixNanos(value)
Self(value)
}
}

impl From<&str> for UnixNanos {
fn from(value: &str) -> Self {
UnixNanos(value.parse().unwrap())
Self(value.parse().unwrap())
}
}

Expand Down Expand Up @@ -208,6 +208,6 @@ mod tests {
#[rstest]
fn test_display() {
let nanos = UnixNanos::from(123);
assert_eq!(format!("{}", nanos), "123");
assert_eq!(format!("{nanos}"), "123");
}
}
6 changes: 6 additions & 0 deletions nautilus_core/execution/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,32 @@ pub struct ExecutionEngine {
}

impl ExecutionEngine {
#[must_use]
pub fn position_id_count(&self, strategy_id: StrategyId) -> u64 {
todo!();
}

#[must_use]
pub fn check_integrity(&self) -> bool {
todo!();
}

#[must_use]
pub fn check_connected(&self) -> bool {
todo!();
}

#[must_use]
pub fn check_disconnected(&self) -> bool {
todo!();
}

#[must_use]
pub fn check_residuals(&self) -> bool {
todo!();
}

#[must_use]
pub fn get_external_order_claims_instruments(&self) -> HashSet<InstrumentId> {
todo!();
}
Expand Down
2 changes: 2 additions & 0 deletions nautilus_core/execution/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub enum TradingCommand {
}

impl TradingCommand {
#[must_use]
pub fn client_id(&self) -> ClientId {
match self {
Self::SubmitOrder(command) => command.client_id,
Expand All @@ -53,6 +54,7 @@ impl TradingCommand {
}
}

#[must_use]
pub fn instrument_id(&self) -> InstrumentId {
match self {
Self::SubmitOrder(command) => command.instrument_id,
Expand Down
2 changes: 1 addition & 1 deletion nautilus_core/execution/src/messages/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use nautilus_model::identifiers::{
};
use serde::{Deserialize, Serialize};

#[derive(Clone, PartialEq, Debug, Default, Serialize, Deserialize, Builder)]
#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, Builder)]
#[builder(default)]
#[serde(tag = "type")]
pub struct SubmitOrder {
Expand Down
3 changes: 1 addition & 2 deletions nautilus_core/model/src/instruments/crypto_perpetual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ use nautilus_core::{
use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};

use super::InstrumentAny;
use crate::{
enums::{AssetClass, InstrumentClass},
identifiers::{instrument_id::InstrumentId, symbol::Symbol},
instruments::Instrument,
types::{currency::Currency, money::Money, price::Price, quantity::Quantity},
};

use super::InstrumentAny;

#[repr(C)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(
Expand Down
8 changes: 8 additions & 0 deletions nautilus_core/model/src/instruments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub enum InstrumentAny {
}

impl InstrumentAny {
#[must_use]
pub fn id(&self) -> InstrumentId {
match self {
Self::CryptoFuture(inst) => inst.id,
Expand All @@ -67,6 +68,7 @@ impl InstrumentAny {
}
}

#[must_use]
pub fn base_currency(&self) -> Option<Currency> {
match self {
Self::CryptoFuture(inst) => inst.base_currency(),
Expand All @@ -80,6 +82,7 @@ impl InstrumentAny {
}
}

#[must_use]
pub fn quote_currency(&self) -> Currency {
match self {
Self::CryptoFuture(inst) => inst.quote_currency(),
Expand All @@ -93,6 +96,7 @@ impl InstrumentAny {
}
}

#[must_use]
pub fn settlement_currency(&self) -> Currency {
match self {
Self::CryptoFuture(inst) => inst.settlement_currency(),
Expand All @@ -106,6 +110,7 @@ impl InstrumentAny {
}
}

#[must_use]
pub fn is_inverse(&self) -> bool {
match self {
Self::CryptoFuture(inst) => inst.is_inverse(),
Expand All @@ -119,6 +124,7 @@ impl InstrumentAny {
}
}

#[must_use]
pub fn calculate_notional_value(
&self,
quantity: Quantity,
Expand Down Expand Up @@ -154,6 +160,7 @@ impl InstrumentAny {
}

// #[deprecated(since = "0.21.0", note = "Will be removed in a future version")]
#[must_use]
pub fn maker_fee(&self) -> Decimal {
match self {
Self::CryptoFuture(inst) => inst.maker_fee(),
Expand All @@ -168,6 +175,7 @@ impl InstrumentAny {
}

// #[deprecated(since = "0.21.0", note = "Will be removed in a future version")]
#[must_use]
pub fn taker_fee(&self) -> Decimal {
match self {
Self::CryptoFuture(inst) => inst.taker_fee(),
Expand Down
2 changes: 1 addition & 1 deletion nautilus_core/model/src/orders/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ pub struct OrderCore {
impl OrderCore {
pub fn new(init: OrderInitialized) -> anyhow::Result<Self> {
let events: Vec<OrderEvent> = vec![OrderEvent::OrderInitialized(init.clone())];
Ok(OrderCore {
Ok(Self {
events,
commissions: HashMap::new(),
venue_order_ids: Vec::new(),
Expand Down
4 changes: 2 additions & 2 deletions nautilus_core/model/src/python/orders/limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl LimitOrder {
#[getter]
#[pyo3(name = "expire_time")]
fn py_expire_time(&self) -> Option<u64> {
self.expire_time.map(|e| e.into())
self.expire_time.map(std::convert::Into::into)
}

#[getter]
Expand Down Expand Up @@ -335,7 +335,7 @@ impl LimitOrder {
#[getter]
#[pyo3(name = "expire_time_ns")]
fn py_expire_time_ns(&self) -> Option<u64> {
self.expire_time.map(|e| e.into())
self.expire_time.map(std::convert::Into::into)
}

#[getter]
Expand Down
2 changes: 1 addition & 1 deletion nautilus_core/model/src/python/orders/limit_if_touched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl LimitIfTouchedOrder {
trigger_price,
trigger_type,
time_in_force,
expire_time.map(|x| x.into()),
expire_time.map(std::convert::Into::into),
post_only,
reduce_only,
quote_quantity,
Expand Down
2 changes: 1 addition & 1 deletion nautilus_core/model/src/python/orders/market_if_touched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl MarketIfTouchedOrder {
trigger_price,
trigger_type,
time_in_force,
expire_time.map(|x| x.into()),
expire_time.map(std::convert::Into::into),
reduce_only,
quote_quantity,
display_qty,
Expand Down
2 changes: 1 addition & 1 deletion nautilus_core/model/src/python/orders/market_to_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl MarketToLimitOrder {
order_side,
quantity,
time_in_force,
expire_time.map(|x| x.into()),
expire_time.map(std::convert::Into::into),
post_only,
reduce_only,
quote_quantity,
Expand Down
4 changes: 2 additions & 2 deletions nautilus_core/model/src/python/orders/stop_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl StopLimitOrder {
trigger_price,
trigger_type,
time_in_force,
expire_time.map(|x| x.into()),
expire_time.map(std::convert::Into::into),
post_only,
reduce_only,
quote_quantity,
Expand Down Expand Up @@ -184,7 +184,7 @@ impl StopLimitOrder {
#[getter]
#[pyo3(name = "expire_time")]
fn py_expire_time(&self) -> Option<u64> {
self.expire_time.map(|e| e.into())
self.expire_time.map(std::convert::Into::into)
}

#[getter]
Expand Down
2 changes: 1 addition & 1 deletion nautilus_core/model/src/python/orders/stop_market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl StopMarketOrder {
trigger_price,
trigger_type,
time_in_force,
expire_time.map(|x| x.into()),
expire_time.map(std::convert::Into::into),
reduce_only,
quote_quantity,
display_qty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl TrailingStopLimitOrder {
trailing_offset,
trailing_offset_type,
time_in_force,
expire_time.map(|x| x.into()),
expire_time.map(std::convert::Into::into),
post_only,
reduce_only,
quote_quantity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl TrailingStopMarketOrder {
trailing_offset,
trailing_offset_type,
time_in_force,
expire_time.map(|x| x.into()),
expire_time.map(std::convert::Into::into),
reduce_only,
quote_quantity,
display_qty,
Expand Down
2 changes: 1 addition & 1 deletion nautilus_core/model/src/python/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl Position {
#[getter]
#[pyo3(name = "ts_closed")]
fn py_ts_closed(&self) -> Option<u64> {
self.ts_closed.map(|ts_closed| ts_closed.into())
self.ts_closed.map(std::convert::Into::into)
}

#[getter]
Expand Down

0 comments on commit 3ca1d11

Please sign in to comment.