From e10e3062ff93ca268604cf0a8df60c2c214e06f7 Mon Sep 17 00:00:00 2001 From: DiTus Date: Sun, 21 Dec 2025 11:36:13 +0100 Subject: [PATCH] feat(kpi): include initial hedge capital in HODL benchmark calculation --- tools/kpi_tracker.py | 11 ++++++----- uniswap_manager.py | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/kpi_tracker.py b/tools/kpi_tracker.py index 4447aba..dda3f3e 100644 --- a/tools/kpi_tracker.py +++ b/tools/kpi_tracker.py @@ -41,9 +41,9 @@ def initialize_kpi_csv(): "Fee_Coverage_Ratio" ]) -def calculate_hodl_benchmark(initial_eth: Decimal, initial_usdc: Decimal, current_eth_price: Decimal) -> Decimal: - """Calculates value if assets were just held.""" - return (initial_eth * current_eth_price) + initial_usdc +def calculate_hodl_benchmark(initial_eth: Decimal, initial_usdc: Decimal, initial_hedge_usdc: Decimal, current_eth_price: Decimal) -> Decimal: + """Calculates value if assets were just held (Wallet Assets + Hedge Account Cash).""" + return (initial_eth * current_eth_price) + initial_usdc + initial_hedge_usdc def log_kpi_snapshot( snapshot_data: Dict[str, float] @@ -51,7 +51,7 @@ def log_kpi_snapshot( """ Logs a KPI snapshot to CSV. Expected keys in snapshot_data: - - initial_eth, initial_usdc + - initial_eth, initial_usdc, initial_hedge_usdc - current_eth_price - uniswap_pos_value_usd - uniswap_fees_claimed_usd @@ -70,7 +70,8 @@ def log_kpi_snapshot( # 1. Benchmark (HODL) init_eth = Decimal(str(snapshot_data.get('initial_eth', 0))) init_usdc = Decimal(str(snapshot_data.get('initial_usdc', 0))) - benchmark_val = calculate_hodl_benchmark(init_eth, init_usdc, price) + init_hedge = Decimal(str(snapshot_data.get('initial_hedge_usdc', 0))) + benchmark_val = calculate_hodl_benchmark(init_eth, init_usdc, init_hedge, price) # 2. Strategy NAV (Net Asset Value) # NAV = Uni Pos + Uni Fees (Claimed+Unclaimed) + Hedge Equity + (Wallet Surplus - Initial Wallet Surplus?) diff --git a/uniswap_manager.py b/uniswap_manager.py index 345b695..7a9ed9b 100644 --- a/uniswap_manager.py +++ b/uniswap_manager.py @@ -128,6 +128,7 @@ CLOSE_POSITION_ENABLED = True OPEN_POSITION_ENABLED = True REBALANCE_ON_CLOSE_BELOW_RANGE = True TARGET_INVESTMENT_VALUE_USDC = 2000 +INITIAL_HEDGE_CAPITAL_USDC = 2000 # Your starting Hyperliquid balance for Benchmark calc RANGE_WIDTH_PCT = Decimal("0.01") # +/- 1% (2% total width) SLIPPAGE_TOLERANCE = Decimal("0.02") # do not change, or at least remember it ( 0.02 = 2.0% slippage tolerance) TRANSACTION_TIMEOUT_SECONDS = 30 @@ -773,6 +774,7 @@ def main(): snapshot = { 'initial_eth': active_auto_pos.get('amount0_initial', 0), 'initial_usdc': active_auto_pos.get('amount1_initial', 0), + 'initial_hedge_usdc': INITIAL_HEDGE_CAPITAL_USDC, 'current_eth_price': float(current_price), 'uniswap_pos_value_usd': float(current_pos_value_usd), 'uniswap_fees_claimed_usd': 0.0, # Not tracked accumulated yet in JSON, using Unclaimed mainly