nautilus_analysis/python/statistics/mod.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 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
16pub mod expectancy;
17pub mod long_ratio;
18pub mod loser_avg;
19pub mod loser_max;
20pub mod loser_min;
21pub mod profit_factor;
22pub mod returns_avg;
23pub mod returns_avg_loss;
24pub mod returns_avg_win;
25pub mod returns_volatlity;
26pub mod risk_return_ratio;
27pub mod sharpe_ratio;
28pub mod sortino_ratio;
29pub mod win_rate;
30pub mod winner_avg;
31pub mod winner_max;
32pub mod winner_min;
33
34use std::collections::BTreeMap;
35
36use nautilus_core::UnixNanos;
37
38fn transform_returns(raw_returns: BTreeMap<u64, f64>) -> BTreeMap<UnixNanos, f64> {
39 raw_returns
40 .keys()
41 .map(|&k| (UnixNanos::from(k), raw_returns[&k]))
42 .collect()
43}