proof-of-portfolio 0.0.92__py3-none-any.whl → 0.0.94__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.
@@ -1,2 +1,2 @@
1
1
  # This file is auto-generated during build
2
- __version__ = "0.0.92"
2
+ __version__ = "0.0.94"
@@ -18,6 +18,7 @@ pub fn calmar(
18
18
  avg_daily_return: i64,
19
19
  variance_val: i64,
20
20
  ann_excess_return_val: i64,
21
+ calmar_cap: i64,
21
22
  ) -> i64 {
22
23
  if !bypass_confidence & actual_len < STATISTICAL_CONFIDENCE_MINIMUM_N {
23
24
  CALMAR_NOCONFIDENCE_VALUE
@@ -30,11 +31,10 @@ pub fn calmar(
30
31
  0
31
32
  } else {
32
33
  let raw_calmar = (base_return_percentage * drawdown_normalization_factor) / SCALE;
33
- let calmar_cap = 10 * RATIO_SCALE_FACTOR;
34
34
  if raw_calmar > calmar_cap {
35
- calmar_cap
35
+ calmar_cap * RATIO_SCALE_FACTOR
36
36
  } else {
37
- raw_calmar
37
+ raw_calmar * RATIO_SCALE_FACTOR
38
38
  }
39
39
  }
40
40
  }
@@ -66,6 +66,7 @@ fn test_calmar_normal_case() {
66
66
  avg,
67
67
  variance_val,
68
68
  ann_excess,
69
+ 1,
69
70
  );
70
71
  assert(result != 0);
71
72
  }
@@ -90,6 +91,7 @@ fn test_calmar_insufficient_data() {
90
91
  avg,
91
92
  variance_val,
92
93
  ann_excess,
94
+ 1,
93
95
  );
94
96
  assert(result == 0);
95
97
  }
@@ -115,6 +117,7 @@ fn test_calmar_exactly_30_days() {
115
117
  avg,
116
118
  variance_val,
117
119
  ann_excess,
120
+ 1,
118
121
  );
119
122
  assert(result != 0);
120
123
  }
@@ -140,6 +143,7 @@ fn test_calmar_negative_returns() {
140
143
  avg,
141
144
  variance_val,
142
145
  ann_excess,
146
+ 1,
143
147
  );
144
148
  assert(result != 0);
145
149
  }
@@ -33,46 +33,58 @@ pub fn omega(
33
33
  }
34
34
  }
35
35
 
36
- if sum_weights_positive == 0 {
37
- sum_weights_positive = OMEGA_LOSS_MINIMUM;
38
- }
39
- if sum_weights_negative == 0 {
40
- sum_weights_negative = OMEGA_LOSS_MINIMUM;
41
- }
42
-
43
- let positive_sum_u128 = (product_sum_positive as u128) * (sum_weights_negative as u128);
44
- let negative_sum_u128 = ((-product_sum_negative) as u128) * (sum_weights_positive as u128);
45
-
46
- let positive_sum = (positive_sum_u128 / 1000000) as i64;
47
- let negative_sum = (negative_sum_u128 / 1000000) as i64;
36
+ let mean_pos = if sum_weights_positive != 0 {
37
+ product_sum_positive / sum_weights_positive
38
+ } else {
39
+ 0
40
+ };
41
+ let mean_neg = if sum_weights_negative != 0 {
42
+ (-product_sum_negative) / sum_weights_negative
43
+ } else {
44
+ 0
45
+ };
48
46
 
49
- let effective_denominator = if negative_sum >= OMEGA_LOSS_MINIMUM {
50
- negative_sum
47
+ let effective_denominator = if mean_neg >= OMEGA_LOSS_MINIMUM {
48
+ mean_neg
51
49
  } else {
52
50
  OMEGA_LOSS_MINIMUM
53
51
  };
54
- let final_calc = ((positive_sum as u128) * (RATIO_SCALE_FACTOR as u128)) / (effective_denominator as u128);
55
- final_calc as i64
52
+ (mean_pos * RATIO_SCALE_FACTOR) / effective_denominator
56
53
  } else {
57
- let mut positive_sum: u64 = 0;
58
- let mut negative_sum: u64 = 0;
54
+ let mut positive_sum: i64 = 0;
55
+ let mut negative_sum: i64 = 0;
56
+ let mut count_pos: u32 = 0;
57
+ let mut count_neg: u32 = 0;
59
58
 
60
59
  for i in 0..ARRAY_SIZE {
61
60
  if (i as u32) < actual_len {
62
61
  if log_returns[i] > 0 {
63
- positive_sum = positive_sum + (log_returns[i] as u64);
62
+ positive_sum += log_returns[i];
63
+ count_pos += 1;
64
64
  } else if log_returns[i] < 0 {
65
- negative_sum = negative_sum + ((-log_returns[i]) as u64);
65
+ negative_sum += (-log_returns[i]);
66
+ count_neg += 1;
66
67
  }
67
68
  }
68
69
  }
69
70
 
70
- let effective_denominator = if negative_sum >= OMEGA_LOSS_MINIMUM as u64 {
71
- negative_sum
71
+ let mean_pos = if count_pos > 0 {
72
+ positive_sum / (count_pos as i64)
73
+ } else {
74
+ 0
75
+ };
76
+ let mean_neg = if count_neg > 0 {
77
+ negative_sum / (count_neg as i64)
72
78
  } else {
73
- OMEGA_LOSS_MINIMUM as u64
79
+ 0
80
+ };
81
+
82
+ let effective_denominator = if mean_neg >= OMEGA_LOSS_MINIMUM {
83
+ mean_neg
84
+ } else {
85
+ OMEGA_LOSS_MINIMUM
74
86
  };
75
- ((positive_sum * RATIO_SCALE_FACTOR as u64) / effective_denominator) as i64
87
+ (mean_pos * RATIO_SCALE_FACTOR) / effective_denominator
76
88
  }
77
89
  }
78
90
  }
@@ -25,6 +25,8 @@ fn main(
25
25
  use_weighting: bool,
26
26
  bypass_confidence: pub bool,
27
27
  account_size: i64,
28
+ weights: [i64; ARRAY_SIZE],
29
+ calmar_cap: i64,
28
30
  ) -> pub [Field; 9] {
29
31
  // Verify all trading signals are included in the merkle tree
30
32
  let mut all_verified = true;
@@ -51,7 +53,7 @@ fn main(
51
53
  }
52
54
 
53
55
  let weights = if use_weighting {
54
- weighting_distribution(n_returns)
56
+ weights
55
57
  } else {
56
58
  // Equal weights when weighting is disabled
57
59
  let mut equal_weights = [0; ARRAY_SIZE];
@@ -140,6 +142,7 @@ fn main(
140
142
  avg_daily_return,
141
143
  variance_val,
142
144
  ann_excess_return_val,
145
+ calmar_cap,
143
146
  );
144
147
  let omega_ratio = omega(
145
148
  returns_array,