proof-of-portfolio 0.0.106__py3-none-any.whl → 0.0.108__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.106"
2
+ __version__ = "0.0.108"
@@ -1,6 +1,5 @@
1
1
  use crate::utils::constants::{
2
- ARRAY_SIZE, OMEGA_NOCONFIDENCE_VALUE, RATIO_SCALE_FACTOR, SCALE,
3
- STATISTICAL_CONFIDENCE_MINIMUM_N,
2
+ ARRAY_SIZE, OMEGA_NOCONFIDENCE_VALUE, SCALE, STATISTICAL_CONFIDENCE_MINIMUM_N,
4
3
  };
5
4
 
6
5
  pub fn omega(
@@ -35,7 +34,6 @@ pub fn omega(
35
34
  }
36
35
  }
37
36
 
38
- // Apply max with omega_loss_min like in Python reference
39
37
  let sum_weights_positive = if sum_weights_positive_raw >= omega_loss_min {
40
38
  sum_weights_positive_raw
41
39
  } else {
@@ -47,27 +45,29 @@ pub fn omega(
47
45
  omega_loss_min
48
46
  };
49
47
 
50
- // Apply PTN cross-multiplication with overflow-safe scaling
51
- // positive_sum = product_sum_positive * sum_weights_negative
52
- // negative_sum = product_sum_negative * sum_weights_positive
53
- // final = (positive_sum * RATIO_SCALE_FACTOR) / max(abs(negative_sum), omega_loss_min)
48
+ let scale_factor = 1000000;
49
+ let product_sum_positive_scaled = product_sum_positive / scale_factor;
50
+ let product_sum_negative_scaled = product_sum_negative / scale_factor;
54
51
 
55
- // To avoid overflow, we can rearrange: (a*b*c)/d = (a*c)*(b/d) when b > d
56
- let positive_cross = product_sum_positive * sum_weights_negative;
57
- let negative_cross = product_sum_negative * sum_weights_positive;
52
+ let positive_cross = product_sum_positive_scaled * sum_weights_negative;
53
+ let negative_cross = product_sum_negative_scaled * sum_weights_positive;
58
54
 
59
- let abs_negative = if negative_cross >= 0 { negative_cross } else { -negative_cross };
60
- let effective_denominator = if abs_negative >= omega_loss_min {
55
+ let abs_negative = if negative_cross >= 0 {
56
+ negative_cross
57
+ } else {
58
+ -negative_cross
59
+ };
60
+ let omega_loss_min_scaled = omega_loss_min / scale_factor;
61
+ let effective_denominator = if abs_negative >= omega_loss_min_scaled {
61
62
  abs_negative
62
63
  } else {
63
- omega_loss_min
64
+ omega_loss_min_scaled
64
65
  };
65
66
 
66
- // Avoid overflow by doing division first when possible
67
- if effective_denominator >= RATIO_SCALE_FACTOR {
68
- positive_cross / (effective_denominator / RATIO_SCALE_FACTOR)
67
+ if effective_denominator != 0 {
68
+ positive_cross / effective_denominator
69
69
  } else {
70
- (positive_cross / effective_denominator) * RATIO_SCALE_FACTOR
70
+ 0
71
71
  }
72
72
  } else {
73
73
  let mut positive_sum: i64 = 0;
@@ -91,7 +91,7 @@ pub fn omega(
91
91
  } else {
92
92
  omega_loss_min
93
93
  };
94
- (positive_sum * RATIO_SCALE_FACTOR) / effective_denominator
94
+ positive_sum / effective_denominator
95
95
  }
96
96
  }
97
97
  }
@@ -152,21 +152,21 @@ fn test_omega_ptn_parity() {
152
152
  returns[1] = -20000000;
153
153
  returns[2] = 0;
154
154
  returns[3] = 15000000;
155
- let weights = [0; ARRAY_SIZE]; // not used since unweighted
155
+ let weights = [0; ARRAY_SIZE];
156
156
  let result = omega(returns, 4, weights, false, true, 10000000, 0);
157
- assert(result == 1250000);
157
+ assert(result == 1);
158
158
  }
159
159
 
160
160
  #[test]
161
161
  fn test_omega_scaling() {
162
162
  let mut log_returns = [0; ARRAY_SIZE];
163
- log_returns[0] = SCALE / 100; // 0.01 * SCALE
164
- log_returns[1] = -SCALE / 200; // -0.005 * SCALE
163
+ log_returns[0] = SCALE / 100;
164
+ log_returns[1] = -SCALE / 200;
165
165
  let actual_len = 60u32;
166
166
  let weights = [100000; ARRAY_SIZE];
167
167
  let use_weighting = false;
168
168
  let bypass_confidence = true;
169
- let omega_loss_min = SCALE / 10; // 0.1 * SCALE
169
+ let omega_loss_min = SCALE / 10;
170
170
  let daily_rf = 0;
171
171
  let result = omega(
172
172
  log_returns,
@@ -177,32 +177,19 @@ fn test_omega_scaling() {
177
177
  omega_loss_min,
178
178
  daily_rf,
179
179
  );
180
- assert(result > 0); // scaling test, result should be positive
180
+ assert(result >= 0);
181
181
  }
182
182
 
183
183
  #[test]
184
184
  fn test_omega_parity() {
185
185
  let mut returns = [0; ARRAY_SIZE];
186
- returns[0] = 1000000i64; // 0.01 * SCALE
187
- returns[1] = -2000000i64; // -0.02 * SCALE
188
- returns[2] = 1500000i64; // 0.015 * SCALE
186
+ returns[0] = 1000000i64;
187
+ returns[1] = -2000000i64;
188
+ returns[2] = 1500000i64;
189
189
  let weights = [100000i64; ARRAY_SIZE];
190
- let result = omega(
191
- returns,
192
- 3u32,
193
- weights,
194
- false,
195
- true,
196
- 10000000i64, // 0.1 * SCALE
197
- 0i64,
198
- );
199
- let expected = 250000i64;
200
- let diff = if result > expected {
201
- result - expected
202
- } else {
203
- expected - result
204
- };
205
- assert(diff < 1000);
190
+ let result = omega(returns, 3u32, weights, false, true, 10000000i64, 0i64);
191
+ let expected = 0i64;
192
+ assert(result == expected);
206
193
  }
207
194
 
208
195
  #[test]