proof-of-portfolio 0.0.94__py3-none-any.whl → 0.0.96__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- proof_of_portfolio/__init__.py +59 -11
- proof_of_portfolio/_version.py +1 -1
- proof_of_portfolio/circuits/components/src/core/calmar.nr +16 -6
- proof_of_portfolio/circuits/components/src/core/omega.nr +10 -10
- proof_of_portfolio/circuits/components/src/utils/ann_excess_return.nr +8 -7
- proof_of_portfolio/circuits/components/src/utils/risk_normalization.nr +7 -9
- proof_of_portfolio/circuits/components/src/utils/weighting_distribution.nr +12 -7
- proof_of_portfolio/circuits/src/main.nr +16 -29
- proof_of_portfolio/circuits/target/circuits.json +1 -1
- proof_of_portfolio/circuits/vk/vk +0 -0
- proof_of_portfolio/proof_generator.py +38 -5
- {proof_of_portfolio-0.0.94.dist-info → proof_of_portfolio-0.0.96.dist-info}/METADATA +1 -1
- {proof_of_portfolio-0.0.94.dist-info → proof_of_portfolio-0.0.96.dist-info}/RECORD +16 -16
- {proof_of_portfolio-0.0.94.dist-info → proof_of_portfolio-0.0.96.dist-info}/WHEEL +0 -0
- {proof_of_portfolio-0.0.94.dist-info → proof_of_portfolio-0.0.96.dist-info}/entry_points.txt +0 -0
- {proof_of_portfolio-0.0.94.dist-info → proof_of_portfolio-0.0.96.dist-info}/top_level.txt +0 -0
proof_of_portfolio/__init__.py
CHANGED
@@ -54,9 +54,21 @@ def requires_dependencies(func):
|
|
54
54
|
|
55
55
|
def _prove_worker(
|
56
56
|
miner_data,
|
57
|
-
|
57
|
+
daily_pnl=None,
|
58
|
+
hotkey=None,
|
58
59
|
verbose=False,
|
59
60
|
annual_risk_free_percentage=4.19,
|
61
|
+
calmar_ratio_cap=10,
|
62
|
+
days_in_year_crypto=365,
|
63
|
+
weighted_average_decay_max=1.0,
|
64
|
+
weighted_average_decay_min=0.15,
|
65
|
+
weighted_average_decay_rate=0.075,
|
66
|
+
omega_loss_minimum=0.01,
|
67
|
+
sharpe_stddev_minimum=0.01,
|
68
|
+
sortino_downside_minimum=0.01,
|
69
|
+
statistical_confidence_minimum_n_ceil=60,
|
70
|
+
annual_risk_free_decimal=0.0419,
|
71
|
+
drawdown_maxvalue_percentage=10,
|
60
72
|
use_weighting=False,
|
61
73
|
bypass_confidence=False,
|
62
74
|
daily_checkpoints=2,
|
@@ -69,10 +81,22 @@ def _prove_worker(
|
|
69
81
|
from .proof_generator import generate_proof
|
70
82
|
|
71
83
|
result = generate_proof(
|
72
|
-
miner_data,
|
73
|
-
|
84
|
+
data=miner_data,
|
85
|
+
daily_pnl=daily_pnl,
|
86
|
+
miner_hotkey=hotkey,
|
74
87
|
verbose=verbose,
|
75
88
|
annual_risk_free_percentage=annual_risk_free_percentage,
|
89
|
+
calmar_ratio_cap=calmar_ratio_cap,
|
90
|
+
days_in_year_crypto=days_in_year_crypto,
|
91
|
+
weighted_average_decay_max=weighted_average_decay_max,
|
92
|
+
weighted_average_decay_min=weighted_average_decay_min,
|
93
|
+
weighted_average_decay_rate=weighted_average_decay_rate,
|
94
|
+
omega_loss_minimum=omega_loss_minimum,
|
95
|
+
sharpe_stddev_minimum=sharpe_stddev_minimum,
|
96
|
+
sortino_downside_minimum=sortino_downside_minimum,
|
97
|
+
statistical_confidence_minimum_n_ceil=statistical_confidence_minimum_n_ceil,
|
98
|
+
annual_risk_free_decimal=annual_risk_free_decimal,
|
99
|
+
drawdown_maxvalue_percentage=drawdown_maxvalue_percentage,
|
76
100
|
use_weighting=use_weighting,
|
77
101
|
bypass_confidence=bypass_confidence,
|
78
102
|
daily_checkpoints=daily_checkpoints,
|
@@ -151,9 +175,21 @@ async def prove(
|
|
151
175
|
|
152
176
|
def prove_sync(
|
153
177
|
miner_data,
|
154
|
-
|
178
|
+
daily_pnl=None,
|
179
|
+
hotkey=None,
|
155
180
|
verbose=False,
|
156
181
|
annual_risk_free_percentage=4.19,
|
182
|
+
calmar_ratio_cap=10,
|
183
|
+
days_in_year_crypto=365,
|
184
|
+
weighted_average_decay_max=1.0,
|
185
|
+
weighted_average_decay_min=0.15,
|
186
|
+
weighted_average_decay_rate=0.075,
|
187
|
+
omega_loss_minimum=0.01,
|
188
|
+
sharpe_stddev_minimum=0.01,
|
189
|
+
sortino_downside_minimum=0.01,
|
190
|
+
statistical_confidence_minimum_n_ceil=60,
|
191
|
+
annual_risk_free_decimal=0.0419,
|
192
|
+
drawdown_maxvalue_percentage=10,
|
157
193
|
use_weighting=False,
|
158
194
|
bypass_confidence=False,
|
159
195
|
daily_checkpoints=2,
|
@@ -172,11 +208,23 @@ def prove_sync(
|
|
172
208
|
"""
|
173
209
|
return _prove_worker(
|
174
210
|
miner_data,
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
211
|
+
daily_pnl=daily_pnl,
|
212
|
+
hotkey=hotkey,
|
213
|
+
verbose=verbose,
|
214
|
+
annual_risk_free_percentage=annual_risk_free_percentage,
|
215
|
+
calmar_ratio_cap=calmar_ratio_cap,
|
216
|
+
days_in_year_crypto=days_in_year_crypto,
|
217
|
+
weighted_average_decay_max=weighted_average_decay_max,
|
218
|
+
weighted_average_decay_min=weighted_average_decay_min,
|
219
|
+
weighted_average_decay_rate=weighted_average_decay_rate,
|
220
|
+
omega_loss_minimum=omega_loss_minimum,
|
221
|
+
sharpe_stddev_minimum=sharpe_stddev_minimum,
|
222
|
+
sortino_downside_minimum=sortino_downside_minimum,
|
223
|
+
statistical_confidence_minimum_n_ceil=statistical_confidence_minimum_n_ceil,
|
224
|
+
annual_risk_free_decimal=annual_risk_free_decimal,
|
225
|
+
drawdown_maxvalue_percentage=drawdown_maxvalue_percentage,
|
226
|
+
use_weighting=use_weighting,
|
227
|
+
bypass_confidence=bypass_confidence,
|
228
|
+
daily_checkpoints=daily_checkpoints,
|
229
|
+
account_size=account_size,
|
182
230
|
)
|
proof_of_portfolio/_version.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# This file is auto-generated during build
|
2
|
-
__version__ = "0.0.
|
2
|
+
__version__ = "0.0.96"
|
@@ -1,7 +1,6 @@
|
|
1
1
|
use crate::utils::{
|
2
|
-
ann_excess_return::ann_excess_return,
|
3
2
|
constants::{
|
4
|
-
ARRAY_SIZE, CALMAR_NOCONFIDENCE_VALUE,
|
3
|
+
ARRAY_SIZE, CALMAR_NOCONFIDENCE_VALUE, RATIO_SCALE_FACTOR, SCALE,
|
5
4
|
STATISTICAL_CONFIDENCE_MINIMUM_N,
|
6
5
|
},
|
7
6
|
risk_normalization::risk_normalization,
|
@@ -11,7 +10,7 @@ use super::drawdown::daily_max_drawdown;
|
|
11
10
|
pub fn calmar(
|
12
11
|
log_returns: [i64; ARRAY_SIZE],
|
13
12
|
actual_len: u32,
|
14
|
-
|
13
|
+
annual_risk_free: i64,
|
15
14
|
weights: [i64; ARRAY_SIZE],
|
16
15
|
use_weighting: bool,
|
17
16
|
bypass_confidence: bool,
|
@@ -19,18 +18,21 @@ pub fn calmar(
|
|
19
18
|
variance_val: i64,
|
20
19
|
ann_excess_return_val: i64,
|
21
20
|
calmar_cap: i64,
|
21
|
+
days_in_year: i64,
|
22
|
+
drawdown_max_percent: i64,
|
22
23
|
) -> i64 {
|
23
24
|
if !bypass_confidence & actual_len < STATISTICAL_CONFIDENCE_MINIMUM_N {
|
24
25
|
CALMAR_NOCONFIDENCE_VALUE
|
25
26
|
} else {
|
26
|
-
let base_return_percentage = (avg_daily_return *
|
27
|
+
let base_return_percentage = (avg_daily_return * days_in_year * 100) / SCALE;
|
27
28
|
let max_drawdown_decimal = daily_max_drawdown(log_returns, actual_len);
|
28
|
-
let drawdown_normalization_factor =
|
29
|
+
let drawdown_normalization_factor =
|
30
|
+
risk_normalization(max_drawdown_decimal, drawdown_max_percent);
|
29
31
|
|
30
32
|
if drawdown_normalization_factor == 0 {
|
31
33
|
0
|
32
34
|
} else {
|
33
|
-
let raw_calmar =
|
35
|
+
let raw_calmar = base_return_percentage * drawdown_normalization_factor;
|
34
36
|
if raw_calmar > calmar_cap {
|
35
37
|
calmar_cap * RATIO_SCALE_FACTOR
|
36
38
|
} else {
|
@@ -67,6 +69,8 @@ fn test_calmar_normal_case() {
|
|
67
69
|
variance_val,
|
68
70
|
ann_excess,
|
69
71
|
1,
|
72
|
+
365,
|
73
|
+
10,
|
70
74
|
);
|
71
75
|
assert(result != 0);
|
72
76
|
}
|
@@ -92,6 +96,8 @@ fn test_calmar_insufficient_data() {
|
|
92
96
|
variance_val,
|
93
97
|
ann_excess,
|
94
98
|
1,
|
99
|
+
365,
|
100
|
+
10,
|
95
101
|
);
|
96
102
|
assert(result == 0);
|
97
103
|
}
|
@@ -118,6 +124,8 @@ fn test_calmar_exactly_30_days() {
|
|
118
124
|
variance_val,
|
119
125
|
ann_excess,
|
120
126
|
1,
|
127
|
+
365,
|
128
|
+
10,
|
121
129
|
);
|
122
130
|
assert(result != 0);
|
123
131
|
}
|
@@ -144,6 +152,8 @@ fn test_calmar_negative_returns() {
|
|
144
152
|
variance_val,
|
145
153
|
ann_excess,
|
146
154
|
1,
|
155
|
+
365,
|
156
|
+
10,
|
147
157
|
);
|
148
158
|
assert(result != 0);
|
149
159
|
}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
use crate::utils::constants::{
|
2
|
-
ARRAY_SIZE,
|
3
|
-
OMEGA_SCALE_FACTOR, RATIO_SCALE_FACTOR, STATISTICAL_CONFIDENCE_MINIMUM_N,
|
2
|
+
ARRAY_SIZE, OMEGA_NOCONFIDENCE_VALUE, RATIO_SCALE_FACTOR, STATISTICAL_CONFIDENCE_MINIMUM_N,
|
4
3
|
};
|
5
4
|
|
6
5
|
pub fn omega(
|
@@ -9,6 +8,7 @@ pub fn omega(
|
|
9
8
|
weights: [i64; ARRAY_SIZE],
|
10
9
|
use_weighting: bool,
|
11
10
|
bypass_confidence: bool,
|
11
|
+
omega_loss_min: i64,
|
12
12
|
) -> i64 {
|
13
13
|
if !bypass_confidence & actual_len < STATISTICAL_CONFIDENCE_MINIMUM_N {
|
14
14
|
OMEGA_NOCONFIDENCE_VALUE
|
@@ -44,10 +44,10 @@ pub fn omega(
|
|
44
44
|
0
|
45
45
|
};
|
46
46
|
|
47
|
-
let effective_denominator = if mean_neg >=
|
47
|
+
let effective_denominator = if mean_neg >= omega_loss_min {
|
48
48
|
mean_neg
|
49
49
|
} else {
|
50
|
-
|
50
|
+
omega_loss_min
|
51
51
|
};
|
52
52
|
(mean_pos * RATIO_SCALE_FACTOR) / effective_denominator
|
53
53
|
} else {
|
@@ -79,10 +79,10 @@ pub fn omega(
|
|
79
79
|
0
|
80
80
|
};
|
81
81
|
|
82
|
-
let effective_denominator = if mean_neg >=
|
82
|
+
let effective_denominator = if mean_neg >= omega_loss_min {
|
83
83
|
mean_neg
|
84
84
|
} else {
|
85
|
-
|
85
|
+
omega_loss_min
|
86
86
|
};
|
87
87
|
(mean_pos * RATIO_SCALE_FACTOR) / effective_denominator
|
88
88
|
}
|
@@ -97,7 +97,7 @@ fn test_omega_all_positive() {
|
|
97
97
|
}
|
98
98
|
|
99
99
|
let weights = [100000; ARRAY_SIZE];
|
100
|
-
let result = omega(returns, 5, weights, false, false);
|
100
|
+
let result = omega(returns, 5, weights, false, false, 10000000);
|
101
101
|
assert(result == 10000000);
|
102
102
|
}
|
103
103
|
|
@@ -109,7 +109,7 @@ fn test_omega_all_negative() {
|
|
109
109
|
}
|
110
110
|
|
111
111
|
let weights = [100000; ARRAY_SIZE];
|
112
|
-
let result = omega(returns, 5, weights, false, false);
|
112
|
+
let result = omega(returns, 5, weights, false, false, 10000000);
|
113
113
|
assert(result == 0);
|
114
114
|
}
|
115
115
|
|
@@ -122,7 +122,7 @@ fn test_omega_mixed_returns() {
|
|
122
122
|
returns[3] = -300;
|
123
123
|
|
124
124
|
let weights = [100000; ARRAY_SIZE];
|
125
|
-
let result = omega(returns, 4, weights, false, false);
|
125
|
+
let result = omega(returns, 4, weights, false, false, 10000000);
|
126
126
|
assert(result == 22500000);
|
127
127
|
}
|
128
128
|
|
@@ -134,6 +134,6 @@ fn test_omega_zero_returns() {
|
|
134
134
|
}
|
135
135
|
|
136
136
|
let weights = [100000; ARRAY_SIZE];
|
137
|
-
let result = omega(returns, 5, weights, false, false);
|
137
|
+
let result = omega(returns, 5, weights, false, false, 10000000);
|
138
138
|
assert(result == 10000000);
|
139
139
|
}
|
@@ -3,9 +3,10 @@ use crate::utils::{average::average, constants::{ARRAY_SIZE, DAYS_IN_YEAR}};
|
|
3
3
|
pub fn ann_excess_return(
|
4
4
|
log_returns: [i64; ARRAY_SIZE],
|
5
5
|
actual_len: u32,
|
6
|
-
|
6
|
+
annual_risk_free: i64,
|
7
7
|
weights: [i64; ARRAY_SIZE],
|
8
8
|
use_weighting: bool,
|
9
|
+
days_in_year: i64,
|
9
10
|
) -> i64 {
|
10
11
|
let sum_of_weights = if use_weighting {
|
11
12
|
let mut sum: i64 = 0;
|
@@ -25,8 +26,8 @@ pub fn ann_excess_return(
|
|
25
26
|
use_weighting,
|
26
27
|
sum_of_weights,
|
27
28
|
);
|
28
|
-
let annualized = avg *
|
29
|
-
annualized -
|
29
|
+
let annualized = avg * days_in_year;
|
30
|
+
annualized - annual_risk_free
|
30
31
|
}
|
31
32
|
|
32
33
|
#[test]
|
@@ -37,7 +38,7 @@ fn test_ann_excess_return_positive() {
|
|
37
38
|
returns[2] = 150;
|
38
39
|
|
39
40
|
let weights = [100000; ARRAY_SIZE];
|
40
|
-
let result = ann_excess_return(returns, 3, 10000, weights, false);
|
41
|
+
let result = ann_excess_return(returns, 3, 10000, weights, false, 365);
|
41
42
|
assert(result > 0);
|
42
43
|
}
|
43
44
|
|
@@ -49,7 +50,7 @@ fn test_ann_excess_return_negative() {
|
|
49
50
|
returns[2] = -150;
|
50
51
|
|
51
52
|
let weights = [100000; ARRAY_SIZE];
|
52
|
-
let result = ann_excess_return(returns, 3, 10000, weights, false);
|
53
|
+
let result = ann_excess_return(returns, 3, 10000, weights, false, 365);
|
53
54
|
assert(result < 0);
|
54
55
|
}
|
55
56
|
|
@@ -61,7 +62,7 @@ fn test_ann_excess_return_equal_to_risk_free() {
|
|
61
62
|
returns[2] = 100;
|
62
63
|
|
63
64
|
let weights = [100000; ARRAY_SIZE];
|
64
|
-
let result = ann_excess_return(returns, 3, 36500, weights, false);
|
65
|
+
let result = ann_excess_return(returns, 3, 36500, weights, false, 365);
|
65
66
|
assert(result == 0);
|
66
67
|
}
|
67
68
|
|
@@ -72,6 +73,6 @@ fn test_ann_excess_return_zero_risk_free() {
|
|
72
73
|
returns[1] = 200;
|
73
74
|
|
74
75
|
let weights = [100000; ARRAY_SIZE];
|
75
|
-
let result = ann_excess_return(returns, 2, 0, weights, false);
|
76
|
+
let result = ann_excess_return(returns, 2, 0, weights, false, 365);
|
76
77
|
assert(result == 54750);
|
77
78
|
}
|
@@ -1,8 +1,6 @@
|
|
1
1
|
use crate::utils::constants::SCALE;
|
2
2
|
|
3
|
-
pub fn mdd_augmentation(drawdown_decimal: i64) -> i64 {
|
4
|
-
let max_drawdown_percentage = 10;
|
5
|
-
|
3
|
+
pub fn mdd_augmentation(drawdown_decimal: i64, max_drawdown_percentage: i64) -> i64 {
|
6
4
|
if (drawdown_decimal <= 0) | (drawdown_decimal >= SCALE) {
|
7
5
|
0
|
8
6
|
} else {
|
@@ -16,27 +14,27 @@ pub fn mdd_augmentation(drawdown_decimal: i64) -> i64 {
|
|
16
14
|
}
|
17
15
|
}
|
18
16
|
|
19
|
-
pub fn risk_normalization(drawdown_decimal: i64) -> i64 {
|
20
|
-
mdd_augmentation(drawdown_decimal)
|
17
|
+
pub fn risk_normalization(drawdown_decimal: i64, max_drawdown_percentage: i64) -> i64 {
|
18
|
+
mdd_augmentation(drawdown_decimal, max_drawdown_percentage)
|
21
19
|
}
|
22
20
|
|
23
21
|
#[test]
|
24
22
|
fn test_risk_normalization_zero_drawdown() {
|
25
|
-
let result = risk_normalization(0);
|
23
|
+
let result = risk_normalization(0, 10);
|
26
24
|
assert(result == 0);
|
27
25
|
}
|
28
26
|
|
29
27
|
#[test]
|
30
28
|
fn test_risk_normalization_high_drawdown() {
|
31
29
|
let drawdown_15_percent = (15 * SCALE) / 100;
|
32
|
-
let result = risk_normalization(drawdown_15_percent);
|
30
|
+
let result = risk_normalization(drawdown_15_percent, 10);
|
33
31
|
assert(result == 0);
|
34
32
|
}
|
35
33
|
|
36
34
|
#[test]
|
37
35
|
fn test_risk_normalization_low_drawdown() {
|
38
36
|
let drawdown_2_percent = (2 * SCALE) / 100;
|
39
|
-
let result = risk_normalization(drawdown_2_percent);
|
37
|
+
let result = risk_normalization(drawdown_2_percent, 10);
|
40
38
|
let expected = SCALE / 2;
|
41
39
|
assert(result == expected);
|
42
40
|
}
|
@@ -44,6 +42,6 @@ fn test_risk_normalization_low_drawdown() {
|
|
44
42
|
#[test]
|
45
43
|
fn test_risk_normalization_max_threshold() {
|
46
44
|
let drawdown_10_percent = (10 * SCALE) / 100;
|
47
|
-
let result = risk_normalization(drawdown_10_percent);
|
45
|
+
let result = risk_normalization(drawdown_10_percent, 10);
|
48
46
|
assert(result == 0);
|
49
47
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
use crate::utils::constants::ARRAY_SIZE;
|
1
|
+
use crate::utils::constants::{ARRAY_SIZE, SCALE};
|
2
2
|
|
3
3
|
fn exp_decay_scaled(neg_x_scaled: i64) -> i64 {
|
4
4
|
let scale: i64 = 100000;
|
@@ -17,18 +17,23 @@ fn exp_decay_scaled(neg_x_scaled: i64) -> i64 {
|
|
17
17
|
}
|
18
18
|
}
|
19
19
|
|
20
|
-
pub fn weighting_distribution(
|
20
|
+
pub fn weighting_distribution(
|
21
|
+
actual_len: u32,
|
22
|
+
weighted_decay_max: i64,
|
23
|
+
weighted_decay_min: i64,
|
24
|
+
weighted_decay_rate: i64,
|
25
|
+
) -> [i64; ARRAY_SIZE] {
|
21
26
|
let mut weights = [0; ARRAY_SIZE];
|
22
|
-
let max_weight
|
23
|
-
let min_weight
|
24
|
-
let decay_rate
|
27
|
+
let max_weight = weighted_decay_max;
|
28
|
+
let min_weight = weighted_decay_min;
|
29
|
+
let decay_rate = weighted_decay_rate;
|
25
30
|
let weight_range = max_weight - min_weight;
|
26
|
-
let scale
|
31
|
+
let scale = SCALE;
|
27
32
|
|
28
33
|
for i in 0..ARRAY_SIZE {
|
29
34
|
if (i as u32) < actual_len {
|
30
35
|
let position_from_newest = (actual_len - 1) - (i as u32);
|
31
|
-
let neg_x_scaled = -(decay_rate * (position_from_newest as i64))
|
36
|
+
let neg_x_scaled = -(decay_rate * (position_from_newest as i64));
|
32
37
|
let exp_val_scaled = exp_decay_scaled(neg_x_scaled);
|
33
38
|
|
34
39
|
let weighted_val = (weight_range * exp_val_scaled) / scale;
|
@@ -8,25 +8,28 @@ use components::core::merkle::{
|
|
8
8
|
use components::utils::{
|
9
9
|
ann_excess_return::ann_excess_return,
|
10
10
|
average::average,
|
11
|
-
constants::{ARRAY_SIZE, MAX_DAYS, MAX_RETURNS, MAX_SIGNALS, MERKLE_DEPTH
|
11
|
+
constants::{ARRAY_SIZE, MAX_DAYS, MAX_RETURNS, MAX_SIGNALS, MERKLE_DEPTH},
|
12
12
|
variance::variance,
|
13
|
-
weighting_distribution::weighting_distribution,
|
14
13
|
};
|
15
14
|
|
16
15
|
fn main(
|
17
16
|
log_returns: [i64; MAX_DAYS],
|
18
17
|
n_returns: u32,
|
18
|
+
daily_pnl: [i64; ARRAY_SIZE],
|
19
|
+
n_pnl: u32,
|
19
20
|
signals: [TradingSignal; MAX_SIGNALS],
|
20
21
|
signals_count: u32,
|
21
22
|
path_elements: [[Field; MERKLE_DEPTH]; MAX_SIGNALS],
|
22
23
|
path_indices: [[Field; MERKLE_DEPTH]; MAX_SIGNALS],
|
23
24
|
signals_merkle_root: pub Field,
|
24
|
-
risk_free_rate: pub i64,
|
25
25
|
use_weighting: bool,
|
26
26
|
bypass_confidence: pub bool,
|
27
|
-
account_size: i64,
|
28
27
|
weights: [i64; ARRAY_SIZE],
|
29
28
|
calmar_cap: i64,
|
29
|
+
days_in_year: i64,
|
30
|
+
omega_loss_min: i64,
|
31
|
+
annual_risk_free: i64,
|
32
|
+
drawdown_max_percent: i64,
|
30
33
|
) -> pub [Field; 9] {
|
31
34
|
// Verify all trading signals are included in the merkle tree
|
32
35
|
let mut all_verified = true;
|
@@ -93,37 +96,18 @@ fn main(
|
|
93
96
|
let ann_excess_return_val = ann_excess_return(
|
94
97
|
returns_array,
|
95
98
|
n_returns,
|
96
|
-
|
99
|
+
annual_risk_free,
|
97
100
|
weights,
|
98
101
|
use_weighting,
|
102
|
+
days_in_year,
|
99
103
|
);
|
100
104
|
|
101
|
-
let
|
102
|
-
for i in 0..MAX_DAYS {
|
103
|
-
if (i as u32) < n_returns {
|
104
|
-
let log_return = returns_array[i];
|
105
|
-
let x_squared = (log_return * log_return) / SCALE;
|
106
|
-
let x_cubed = (x_squared * log_return) / SCALE;
|
107
|
-
let x_fourth = (x_cubed * log_return) / SCALE;
|
108
|
-
let x_fifth = (x_fourth * log_return) / SCALE;
|
109
|
-
let exp_minus_one =
|
110
|
-
log_return + (x_squared / 2) + (x_cubed / 6) + (x_fourth / 24) + (x_fifth / 120);
|
111
|
-
daily_pnl_array[i] = (exp_minus_one * account_size) / SCALE;
|
112
|
-
}
|
113
|
-
}
|
114
|
-
|
115
|
-
let avg_daily_pnl = average(
|
116
|
-
daily_pnl_array,
|
117
|
-
n_returns,
|
118
|
-
weights,
|
119
|
-
use_weighting,
|
120
|
-
sum_of_weights,
|
121
|
-
);
|
105
|
+
let avg_daily_pnl = average(daily_pnl, n_pnl, weights, use_weighting, sum_of_weights);
|
122
106
|
|
123
107
|
let sharpe_ratio = sharpe(
|
124
108
|
returns_array,
|
125
109
|
n_returns,
|
126
|
-
|
110
|
+
annual_risk_free,
|
127
111
|
weights,
|
128
112
|
use_weighting,
|
129
113
|
bypass_confidence,
|
@@ -135,7 +119,7 @@ fn main(
|
|
135
119
|
let calmar_ratio = calmar(
|
136
120
|
returns_array,
|
137
121
|
n_returns,
|
138
|
-
|
122
|
+
annual_risk_free,
|
139
123
|
weights,
|
140
124
|
use_weighting,
|
141
125
|
bypass_confidence,
|
@@ -143,6 +127,8 @@ fn main(
|
|
143
127
|
variance_val,
|
144
128
|
ann_excess_return_val,
|
145
129
|
calmar_cap,
|
130
|
+
days_in_year,
|
131
|
+
drawdown_max_percent,
|
146
132
|
);
|
147
133
|
let omega_ratio = omega(
|
148
134
|
returns_array,
|
@@ -150,11 +136,12 @@ fn main(
|
|
150
136
|
weights,
|
151
137
|
use_weighting,
|
152
138
|
bypass_confidence,
|
139
|
+
omega_loss_min,
|
153
140
|
);
|
154
141
|
let sortino_ratio = sortino(
|
155
142
|
returns_array,
|
156
143
|
n_returns,
|
157
|
-
|
144
|
+
annual_risk_free,
|
158
145
|
weights,
|
159
146
|
use_weighting,
|
160
147
|
bypass_confidence,
|