proof-of-portfolio 0.0.52__py3-none-any.whl → 0.0.54__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.52"
2
+ __version__ = "0.0.54"
@@ -3,7 +3,6 @@ import toml
3
3
  import re
4
4
  import os
5
5
  import time
6
- from .min_metrics import MinMetrics
7
6
  import math
8
7
  import bittensor as bt
9
8
 
@@ -19,12 +18,6 @@ MAX_DAYS = 120
19
18
  def run_command(command, cwd, verbose=True):
20
19
  """Executes a command in a given directory and returns the output."""
21
20
  result = subprocess.run(command, capture_output=True, text=True, cwd=cwd)
22
- if verbose:
23
- bt.logging.info("--- nargo stdout ---")
24
- bt.logging.info(result.stdout)
25
- bt.logging.info("--- nargo stderr ---")
26
- bt.logging.info(result.stderr)
27
- bt.logging.info("--------------------")
28
21
  if result.returncode != 0:
29
22
  if verbose:
30
23
  bt.logging.error("Error:")
@@ -364,27 +357,60 @@ def generate_proof(
364
357
  bt.logging.info("Preparing circuit inputs...")
365
358
 
366
359
  cps = perf_ledger["cps"]
367
- checkpoint_count = len(cps)
368
- if checkpoint_count > MAX_CHECKPOINTS:
360
+ if len(cps) > MAX_CHECKPOINTS:
369
361
  if verbose:
370
362
  bt.logging.warning(
371
- f"Warning: Miner has {checkpoint_count} checkpoints, but circuit only supports {MAX_CHECKPOINTS}. Truncating."
363
+ f"Warning: Miner has {len(cps)} checkpoints, but circuit only supports {MAX_CHECKPOINTS}. Truncating."
372
364
  )
373
365
  cps = cps[:MAX_CHECKPOINTS]
374
- checkpoint_count = MAX_CHECKPOINTS
366
+
367
+ target_duration = perf_ledger["target_cp_duration_ms"]
375
368
 
376
369
  gains = [int(c["gain"] * SCALING_FACTOR) for c in cps]
377
370
  losses = [int(c["loss"] * SCALING_FACTOR) for c in cps]
378
371
  last_update_times = [c["last_update_ms"] for c in cps]
379
372
  accum_times = [c["accum_ms"] for c in cps]
380
- target_duration = perf_ledger["target_cp_duration_ms"]
373
+ checkpoint_count = len(cps)
381
374
 
382
- # Pad
383
375
  gains += [0] * (MAX_CHECKPOINTS - len(gains))
384
376
  losses += [0] * (MAX_CHECKPOINTS - len(losses))
385
377
  last_update_times += [0] * (MAX_CHECKPOINTS - len(last_update_times))
386
378
  accum_times += [0] * (MAX_CHECKPOINTS - len(accum_times))
387
379
 
380
+ daily_log_returns = aggregate_daily_returns(cps, target_duration, daily_checkpoints)
381
+ aggregated_gains = []
382
+ aggregated_losses = []
383
+ aggregated_last_update_times = []
384
+ aggregated_accum_times = []
385
+
386
+ for i, daily_return in enumerate(daily_log_returns):
387
+ if daily_return >= 0:
388
+ aggregated_gains.append(int(daily_return * SCALING_FACTOR))
389
+ aggregated_losses.append(0)
390
+ else:
391
+ aggregated_gains.append(0)
392
+ aggregated_losses.append(int(daily_return * SCALING_FACTOR))
393
+
394
+ aggregated_last_update_times.append(1000000 + i)
395
+ aggregated_accum_times.append(target_duration)
396
+
397
+ aggregated_checkpoint_count = len(daily_log_returns)
398
+
399
+ aggregated_gains += [0] * (MAX_CHECKPOINTS - len(aggregated_gains))
400
+ aggregated_losses += [0] * (MAX_CHECKPOINTS - len(aggregated_losses))
401
+ aggregated_last_update_times += [0] * (
402
+ MAX_CHECKPOINTS - len(aggregated_last_update_times)
403
+ )
404
+ aggregated_accum_times += [0] * (MAX_CHECKPOINTS - len(aggregated_accum_times))
405
+
406
+ if verbose:
407
+ bt.logging.info(
408
+ f"Processing {checkpoint_count} raw checkpoints for merkle roots"
409
+ )
410
+ bt.logging.info(
411
+ f"Using {aggregated_checkpoint_count} aggregated daily returns for metrics"
412
+ )
413
+
388
414
  all_orders = []
389
415
  for pos in positions:
390
416
  all_orders.extend(pos["orders"])
@@ -445,7 +471,7 @@ def generate_proof(
445
471
 
446
472
  if verbose:
447
473
  bt.logging.info(
448
- f"Prepared {checkpoint_count} checkpoints and {signals_count} signals."
474
+ f"Prepared {aggregated_checkpoint_count} aggregated daily returns and {signals_count} signals for circuit."
449
475
  )
450
476
 
451
477
  if verbose:
@@ -544,11 +570,11 @@ def generate_proof(
544
570
 
545
571
  # Finally, LFG
546
572
  main_prover_input = {
547
- "gains": [str(g) for g in gains],
548
- "losses": [str(l) for l in losses],
549
- "last_update_times": [str(t) for t in last_update_times],
550
- "accum_times": [str(a) for a in accum_times],
551
- "checkpoint_count": str(checkpoint_count),
573
+ "gains": [str(g) for g in aggregated_gains],
574
+ "losses": [str(l) for l in aggregated_losses],
575
+ "last_update_times": [str(t) for t in aggregated_last_update_times],
576
+ "accum_times": [str(a) for a in aggregated_accum_times],
577
+ "checkpoint_count": str(aggregated_checkpoint_count),
552
578
  "target_duration": str(target_duration),
553
579
  "signals": signals,
554
580
  "signals_count": str(signals_count),
@@ -650,39 +676,6 @@ def generate_proof(
650
676
 
651
677
  prove_time, verification_success = run_bb_prove(main_circuit_dir)
652
678
 
653
- # Calculate MinMetrics (Python) for comparison with ZK circuit
654
- try:
655
- daily_log_returns = aggregate_daily_returns(
656
- cps, target_duration, daily_checkpoints
657
- )
658
-
659
- if len(daily_log_returns) > 0:
660
- python_avg_daily_pnl = MinMetrics.average(daily_log_returns)
661
- python_sharpe = MinMetrics.sharpe(daily_log_returns, bypass_confidence=True)
662
- python_max_drawdown = MinMetrics.daily_max_drawdown(daily_log_returns)
663
- python_calmar = MinMetrics.calmar(daily_log_returns, bypass_confidence=True)
664
- python_omega = MinMetrics.omega(daily_log_returns, bypass_confidence=True)
665
- python_sortino = MinMetrics.sortino(
666
- daily_log_returns, bypass_confidence=True
667
- )
668
- python_stat_confidence = MinMetrics.statistical_confidence(
669
- daily_log_returns, bypass_confidence=True
670
- )
671
- else:
672
- python_avg_daily_pnl = python_sharpe = python_max_drawdown = (
673
- python_calmar
674
- ) = python_omega = python_sortino = python_stat_confidence = 0.0
675
-
676
- except Exception as e:
677
- if verbose:
678
- print(f"Warning: Could not calculate Python MinMetrics: {e}")
679
- import traceback
680
-
681
- print(f"Traceback: {traceback.format_exc()}")
682
- python_avg_daily_pnl = python_sharpe = python_max_drawdown = python_calmar = (
683
- python_omega
684
- ) = python_sortino = python_stat_confidence = "N/A"
685
-
686
679
  # Always print key production info: hotkey and verification status
687
680
  print(f"Hotkey: {miner_hotkey}")
688
681
  print(f"Orders processed: {signals_count}")
@@ -696,38 +689,6 @@ def generate_proof(
696
689
  print(f"Sortino Ratio: {sortino_ratio_scaled:.9f}")
697
690
  print(f"Statistical Confidence: {stat_confidence_scaled:.9f}")
698
691
 
699
- # Print Python MinMetrics for comparison
700
- print("\n--- PYTHON MINMETRICS ---")
701
- if isinstance(python_avg_daily_pnl, (int, float)):
702
- print(f"Average Daily PnL: {python_avg_daily_pnl:.9f}")
703
- else:
704
- print(f"Average Daily PnL: {python_avg_daily_pnl}")
705
- if isinstance(python_sharpe, (int, float)):
706
- print(f"Sharpe Ratio: {python_sharpe:.9f}")
707
- else:
708
- print(f"Sharpe Ratio: {python_sharpe}")
709
- if isinstance(python_max_drawdown, (int, float)):
710
- print(
711
- f"Max Drawdown: {python_max_drawdown:.9f} ({python_max_drawdown * 100:.6f}%)"
712
- )
713
- else:
714
- print(f"Max Drawdown: {python_max_drawdown}")
715
- if isinstance(python_calmar, (int, float)):
716
- print(f"Calmar Ratio: {python_calmar:.9f}")
717
- else:
718
- print(f"Calmar Ratio: {python_calmar}")
719
- if isinstance(python_omega, (int, float)):
720
- print(f"Omega Ratio: {python_omega:.9f}")
721
- else:
722
- print(f"Omega Ratio: {python_omega}")
723
- if isinstance(python_sortino, (int, float)):
724
- print(f"Sortino Ratio: {python_sortino:.9f}")
725
- else:
726
- print(f"Sortino Ratio: {python_sortino}")
727
- if isinstance(python_stat_confidence, (int, float)):
728
- print(f"Statistical Confidence: {python_stat_confidence:.9f}")
729
- else:
730
- print(f"Statistical Confidence: {python_stat_confidence}")
731
692
  if prove_time is not None:
732
693
  print(f"Proof generated in {prove_time}s")
733
694
  else:
@@ -739,26 +700,8 @@ def generate_proof(
739
700
  print(f"Signals Merkle Root: {signals_merkle_root}")
740
701
  print(f"Returns Merkle Root: {returns_merkle_root}")
741
702
 
742
- print("\n=== PORTFOLIO METRICS ===")
743
- print(f"Average Daily PnL (raw): {avg_daily_pnl_value}")
744
- print(f"Average Daily PnL (scaled): {avg_daily_pnl_scaled:.9f}")
745
- print(f"Sharpe Ratio (raw): {sharpe_ratio_raw}")
746
- print(f"Sharpe Ratio (scaled): {sharpe_ratio_scaled:.9f}")
747
- print(f"Max Drawdown (raw): {max_drawdown_raw}")
748
- print(
749
- f"Max Drawdown (scaled): {max_drawdown_scaled:.9f} ({max_drawdown_scaled * 100:.6f}%)"
750
- )
751
- print(f"Calmar Ratio (raw): {calmar_ratio_raw}")
752
- print(f"Calmar Ratio (scaled): {calmar_ratio_scaled:.9f}")
753
- print(f"Omega Ratio (raw): {omega_ratio_raw}")
754
- print(f"Omega Ratio (scaled): {omega_ratio_scaled:.9f}")
755
- print(f"Sortino Ratio (raw): {sortino_ratio_raw}")
756
- print(f"Sortino Ratio (scaled): {sortino_ratio_scaled:.9f}")
757
- print(f"Statistical Confidence (raw): {stat_confidence_raw}")
758
- print(f"Statistical Confidence (scaled): {stat_confidence_scaled:.9f}")
759
-
760
703
  print("\n=== DATA SUMMARY ===")
761
- print(f"Checkpoints processed: {checkpoint_count}")
704
+ print(f"Daily returns processed: {aggregated_checkpoint_count}")
762
705
  print(f"Trading signals processed: {signals_count}")
763
706
  print(f"Valid daily returns: {valid_days}")
764
707
 
@@ -796,7 +739,7 @@ def generate_proof(
796
739
  "stat_confidence_scaled": stat_confidence_scaled,
797
740
  },
798
741
  "data_summary": {
799
- "checkpoints_processed": checkpoint_count,
742
+ "daily_returns_processed": aggregated_checkpoint_count,
800
743
  "signals_processed": signals_count,
801
744
  "valid_daily_returns": int(valid_days),
802
745
  },
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proof-of-portfolio
3
- Version: 0.0.52
3
+ Version: 0.0.54
4
4
  Summary: Zero-Knowledge Proof framework for verifiable, private portfolio performance metrics
5
5
  Author-email: "Inference Labs, Inc." <info@inferencelabs.com>
6
6
  Requires-Python: >=3.10
@@ -1,12 +1,12 @@
1
1
  proof_of_portfolio/__init__.py,sha256=YTYX7P0aBNCoRyG_wEX5fTQBMIjF1S4-1VpFqNRWsfQ,4587
2
- proof_of_portfolio/_version.py,sha256=nbfRvwjdZE1U_FHiBunVBSCMbjmHZB6Wla5okiWNEbk,66
2
+ proof_of_portfolio/_version.py,sha256=OmWe3MV4SRhF5pTgUH8YeBjPHoNIPVkI9IhscKrKwgY,66
3
3
  proof_of_portfolio/analyze_data.py,sha256=t80ueFtBUzcWTrPiamiC1HXvw5Em-151zXJx0cCk8sQ,3709
4
4
  proof_of_portfolio/main.py,sha256=JbvdAK7B6hw2sQdjT0EVCiglCQZgN3urKphdeWcW43w,30994
5
5
  proof_of_portfolio/min_metrics.py,sha256=U16B7YRl0UbCterdJ1ksqFOxR5DiQeslUzMVGEWNyog,13211
6
6
  proof_of_portfolio/miner.py,sha256=eGXcPMRQVAepzXJj1ePbbDAf-72E9Yj9n-yfP7GohLw,17177
7
7
  proof_of_portfolio/parsing_utils.py,sha256=Hx61Sby5mEbC6uzhG9G69K7YPCLbjU6vK8fazpNBeLc,6463
8
8
  proof_of_portfolio/post_install.py,sha256=e-57Z_h-svQdjA8ibsM985MXmdV6-KLyymQm3Cgu8YM,5654
9
- proof_of_portfolio/proof_generator.py,sha256=8mNNbp0tILCLMI1wjs-8IYR7wxb7YzKv6f_sShvv69I,29976
9
+ proof_of_portfolio/proof_generator.py,sha256=2_inInKWTVAW-G1_dP1VT0DNXyHD0IcP8TEeWPN541c,27203
10
10
  proof_of_portfolio/signal_processor.py,sha256=JQjnkMJEbv_MWIgKNrjKjrBIcIT5pAkAlCneEOGsqT0,6702
11
11
  proof_of_portfolio/validator.py,sha256=kt3BeaXOffv-h52PZBKV1YHUWtiGsnPte16m3EJpITY,3839
12
12
  proof_of_portfolio/circuits/Nargo.toml,sha256=D6ycN7H3xiTcWHH5wz4qXYTXn7Ht0WgPr9w4B7d8ZGw,141
@@ -81,8 +81,8 @@ proof_of_portfolio/tree_generator/Nargo.toml,sha256=O6iSvb-EpV0XcETiDxNgSp7XKNiY
81
81
  proof_of_portfolio/tree_generator/target.gz,sha256=7LPzAb8JvKWSDOzyW5vI_6NKQ0aB9cb31q4CWbchFSw,308614
82
82
  proof_of_portfolio/tree_generator/src/main.nr,sha256=zHG_0OphqSROyeVc7yTSEULg4bYS8B-LsmvTzTl8aW4,2393
83
83
  proof_of_portfolio/tree_generator/target/tree_generator.json,sha256=M_bI5et5ncgILJ_Czen4ZsGfWHwComEVxMLQpIWmN1k,1540889
84
- proof_of_portfolio-0.0.52.dist-info/METADATA,sha256=SbYK8mDKeyA5fNUOQzCXdDIejhgF-p-Z2IUoV0FnsQc,7076
85
- proof_of_portfolio-0.0.52.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
86
- proof_of_portfolio-0.0.52.dist-info/entry_points.txt,sha256=KeLSJT_UJtr1WiLTkhlGqWQuPKbO_ylgj6OXOC2gJV4,53
87
- proof_of_portfolio-0.0.52.dist-info/top_level.txt,sha256=sY5xZnE6YuiISK1IuRHPfl71NV0vXO3N3YA2li_SPXU,19
88
- proof_of_portfolio-0.0.52.dist-info/RECORD,,
84
+ proof_of_portfolio-0.0.54.dist-info/METADATA,sha256=kYsa8aO0eUharsOK0_dtKORNhZ9kRP9RuQN5wBhKVz0,7076
85
+ proof_of_portfolio-0.0.54.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
86
+ proof_of_portfolio-0.0.54.dist-info/entry_points.txt,sha256=KeLSJT_UJtr1WiLTkhlGqWQuPKbO_ylgj6OXOC2gJV4,53
87
+ proof_of_portfolio-0.0.54.dist-info/top_level.txt,sha256=sY5xZnE6YuiISK1IuRHPfl71NV0vXO3N3YA2li_SPXU,19
88
+ proof_of_portfolio-0.0.54.dist-info/RECORD,,