Skip to main content

nautilus_analysis/python/statistics/
mod.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 Nautech 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
16//! Python bindings for trading performance statistics.
17
18pub mod alpha;
19pub mod beta_ratio;
20pub mod cagr;
21pub mod calmar_ratio;
22pub mod down_capture_ratio;
23pub mod expectancy;
24pub mod expected_shortfall;
25pub mod information_ratio;
26pub mod long_ratio;
27pub mod loser_avg;
28pub mod loser_max;
29pub mod loser_min;
30pub mod max_drawdown;
31pub mod omega_ratio;
32pub mod profit_factor;
33pub mod returns_avg;
34pub mod returns_avg_loss;
35pub mod returns_avg_win;
36pub mod returns_kurtosis;
37pub mod returns_skewness;
38pub mod returns_volatility;
39pub mod risk_return_ratio;
40pub mod sharpe_ratio;
41pub mod sortino_ratio;
42pub mod tail_ratio;
43pub mod tracking_error;
44pub mod treynor_ratio;
45pub mod ulcer_index;
46pub mod up_capture_ratio;
47pub mod value_at_risk;
48pub mod win_rate;
49pub mod winner_avg;
50pub mod winner_max;
51pub mod winner_min;
52
53use std::collections::BTreeMap;
54
55use nautilus_core::UnixNanos;
56
57fn transform_returns(raw_returns: &BTreeMap<u64, f64>) -> BTreeMap<UnixNanos, f64> {
58    raw_returns
59        .keys()
60        .map(|&k| (UnixNanos::from(k), raw_returns[&k]))
61        .collect()
62}