diff --git a/clp_config.py b/clp_config.py index 42f9c55..6677320 100644 --- a/clp_config.py +++ b/clp_config.py @@ -24,6 +24,7 @@ DEFAULT_STRATEGY = { "TRANSACTION_TIMEOUT_SECONDS": 30, # Timeout for blockchain transactions # Hedging Settings + "HEDGE_STRATEGY": "ASYMMETRIC", # Options: "STANDARD" (Full Range Hedge), "ASYMMETRIC" (Edge-Only Reduction) "MIN_HEDGE_THRESHOLD": Decimal("0.012"), # Minimum delta change (in coins) required to trigger a trade # Unified Hedger Settings diff --git a/clp_hedger.py b/clp_hedger.py index fd6aca1..10892ed 100644 --- a/clp_hedger.py +++ b/clp_hedger.py @@ -213,7 +213,7 @@ class HyperliquidStrategy: else: # >=5% range return Decimal("0.075") # Standard for wide ranges - def calculate_rebalance(self, current_price: Decimal, current_short_size: Decimal) -> Dict: + def calculate_rebalance(self, current_price: Decimal, current_short_size: Decimal, strategy_type: str = "ASYMMETRIC") -> Dict: # Note: current_short_size here is virtual (just for this specific strategy), # but the unified hedger will use the 'target_short' output primarily. @@ -221,15 +221,17 @@ class HyperliquidStrategy: # --- ASYMMETRIC COMPENSATION --- adj_pct = Decimal("0.0") - range_width = self.high_range - self.low_range - if range_width > 0: - dist = current_price - self.entry_price - half_width = range_width / Decimal("2") - norm_dist = dist / half_width - max_boost = self.get_compensation_boost() - adj_pct = -norm_dist * max_boost - adj_pct = max(-max_boost, min(max_boost, adj_pct)) + if strategy_type == "ASYMMETRIC": + range_width = self.high_range - self.low_range + + if range_width > 0: + dist = current_price - self.entry_price + half_width = range_width / Decimal("2") + norm_dist = dist / half_width + max_boost = self.get_compensation_boost() + adj_pct = -norm_dist * max_boost + adj_pct = max(-max_boost, min(max_boost, adj_pct)) raw_target_short = pool_delta adjusted_target_short = raw_target_short * (Decimal("1.0") + adj_pct) @@ -664,8 +666,12 @@ class UnifiedHedger: if coin not in self.last_prices: continue price = self.last_prices[coin] + # Get Config & Strategy Type + config = self.coin_configs.get(coin, {}) + strategy_type = config.get("HEDGE_STRATEGY", "ASYMMETRIC") + # Calc Logic - calc = strat.calculate_rebalance(price, Decimal("0")) + calc = strat.calculate_rebalance(price, Decimal("0"), strategy_type) if coin not in aggregates: aggregates[coin] = {'target_short': Decimal("0"), 'contributors': 0, 'is_at_edge': False, 'is_at_bottom_edge': False, 'adj_pct': Decimal("0"), 'is_closing': False} @@ -788,7 +794,9 @@ class UnifiedHedger: # --- ASYMMETRIC HEDGE CHECK --- is_asymmetric_blocked = False p_mid_asym = Decimal("0") - if is_buy_bool and not bypass_cooldown: + strategy_type = config.get("HEDGE_STRATEGY", "ASYMMETRIC") + + if strategy_type == "ASYMMETRIC" and is_buy_bool and not bypass_cooldown: total_L_asym = Decimal("0") for k_strat, strat_inst in self.strategies.items(): if self.strategy_states[k_strat]['coin'] == coin: