Skip to content

Commit 60d83cf

Browse files
committed
Fix clippy lints
1 parent b7db3ff commit 60d83cf

File tree

6 files changed

+42
-11
lines changed

6 files changed

+42
-11
lines changed

RELEASES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ None
4646
- Improved Cython-Rust indicator parity for `ExponentialMovingAverage` (EMA) (#2642), thanks @nicolad
4747
- Improved Cython-Rust indicator parity for `HullMovingAverage` (HMA) (#2648), thanks @nicolad
4848
- Improved Cython-Rust indicator parity for `LinearRegression` (#2651), thanks @nicolad
49+
- Improved Cython-Rust indicator parity for `WilderMovingAverage` (RMA) (#2653), thanks @nicolad
4950
- Improved zero size trade logging for Binance Futures (#2588), thanks @bartolootrit
5051
- Improved error handling on API key authentication errors for Polymarket
5152
- Improved exception on deserializing order from cache database
@@ -71,6 +72,7 @@ None
7172
- Fixed position snapshot cache access for `ExecutionEngine`
7273
- Fixed authentication for Redis when password provided with no username
7374
- Fixed various numpy and pandas FutureWarning(s)
75+
- Fixed message bus subscription matching logic in Rust (#2646), thanks @twitu
7476
- Fixed trailing stop market fill behavior when top-level exhausted to align with market orders (#2540), thanks for reporting @stastnypremysl
7577
- Fixed stop limit fill behavior on initial trigger where the limit order was continuing to fill as a taker beyond available liquidity, thanks for reporting @hope2see
7678
- Fixed modifying and updating trailing stop orders (#2619), thanks @hope2see

crates/backtest/src/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl BacktestEngine {
8181
///
8282
/// # Errors
8383
///
84-
/// Returns an error if the core NautilusKernel fails to initialize.
84+
/// Returns an error if the core `NautilusKernel` fails to initialize.
8585
pub fn new(config: BacktestEngineConfig) -> anyhow::Result<Self> {
8686
let kernel = NautilusKernel::new(Ustr::from("BacktestEngine"), config.kernel.clone())?;
8787

crates/common/src/msgbus/core.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
// -------------------------------------------------------------------------------------------------
2+
// Copyright (C) 2015-2025 2Nautech Systems Pty Ltd. All rights reserved.
3+
// https://nautechsystems.io
4+
//
5+
// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6+
// You may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
// -------------------------------------------------------------------------------------------------
15+
116
use std::{
217
cell::RefCell,
318
collections::HashMap,
@@ -90,7 +105,6 @@ impl Display for Topic {
90105
/// This is an internal class intended to be used by the message bus to organize
91106
/// topics and their subscribers.
92107
///
93-
94108
#[derive(Clone, Debug)]
95109
pub struct Subscription {
96110
/// The shareable message handler for the subscription.

crates/common/src/msgbus/matching.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
// -------------------------------------------------------------------------------------------------
2+
// Copyright (C) 2015-2025 2Nautech Systems Pty Ltd. All rights reserved.
3+
// https://nautechsystems.io
4+
//
5+
// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6+
// You may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
// -------------------------------------------------------------------------------------------------
15+
116
use ustr::Ustr;
217

318
use super::core::{Pattern, Topic};

crates/indicators/src/average/lr.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl LinearRegression {
9393

9494
let n = period as f64;
9595
let x_sum = 0.5 * n * (n + 1.0);
96-
let x_mul_sum = x_sum * (2.0 * n + 1.0) / 3.0;
96+
let x_mul_sum = x_sum * 2.0f64.mul_add(n, 1.0) / 3.0;
9797
let divisor = n.mul_add(x_mul_sum, -(x_sum * x_sum));
9898

9999
Self {
@@ -266,7 +266,7 @@ mod tests {
266266
fn test_inputs_len_never_exceeds_period() {
267267
let mut lr = LinearRegression::new(3);
268268
for i in 0..10 {
269-
lr.update_raw(i as f64);
269+
lr.update_raw(f64::from(i));
270270
}
271271
assert_eq!(lr.inputs.len(), lr.period);
272272
}
@@ -275,7 +275,7 @@ mod tests {
275275
fn test_oldest_element_evicted() {
276276
let mut lr = LinearRegression::new(4);
277277
for v in 1..=5 {
278-
lr.update_raw(v as f64);
278+
lr.update_raw(f64::from(v));
279279
}
280280
assert!(!lr.inputs.contains(&1.0));
281281
assert_eq!(lr.inputs.front(), Some(&2.0));
@@ -285,7 +285,7 @@ mod tests {
285285
fn test_recent_elements_preserved() {
286286
let mut lr = LinearRegression::new(5);
287287
for v in 0..5 {
288-
lr.update_raw(v as f64);
288+
lr.update_raw(f64::from(v));
289289
}
290290
lr.update_raw(99.0);
291291
let expected = vec![1.0, 2.0, 3.0, 4.0, 99.0];
@@ -420,7 +420,7 @@ mod tests {
420420

421421
let n = period as f64;
422422
let expected_x_sum = 0.5 * n * (n + 1.0);
423-
let expected_x_mul_sum = expected_x_sum * (2.0 * n + 1.0) / 3.0;
423+
let expected_x_mul_sum = expected_x_sum * 2.0f64.mul_add(n, 1.0) / 3.0;
424424
let expected_divisor = n.mul_add(expected_x_mul_sum, -(expected_x_sum * expected_x_sum));
425425

426426
assert!((lr.x_sum - expected_x_sum).abs() < 1e-12, "x_sum mismatch");
@@ -441,7 +441,7 @@ mod tests {
441441
let (x_sum, x_mul_sum, divisor) = (lr.x_sum, lr.x_mul_sum, lr.divisor);
442442

443443
for v in 0..20 {
444-
lr.update_raw(v as f64);
444+
lr.update_raw(f64::from(v));
445445
}
446446

447447
assert_eq!(lr.x_sum, x_sum, "x_sum must remain unchanged after updates");
@@ -462,7 +462,7 @@ mod tests {
462462
let (x_sum, x_mul_sum, divisor) = (lr.x_sum, lr.x_mul_sum, lr.divisor);
463463

464464
for v in 0..8 {
465-
lr.update_raw(v as f64);
465+
lr.update_raw(f64::from(v));
466466
}
467467
lr.reset();
468468

crates/indicators/src/average/rma.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ mod tests {
259259
let mut rma = WilderMovingAverage::new(10, None);
260260

261261
for price in 1_u32..=10 {
262-
rma.update_raw(price as f64);
262+
rma.update_raw(f64::from(price));
263263
}
264264

265265
assert!(rma.initialized());
@@ -291,7 +291,7 @@ mod tests {
291291
let mut rma = WilderMovingAverage::new(1_000, None);
292292

293293
for p in 1_u32..=999 {
294-
rma.update_raw(p as f64);
294+
rma.update_raw(f64::from(p));
295295
}
296296

297297
assert_eq!(rma.count(), 999);

0 commit comments

Comments
 (0)