feat(hedger): capture and save initial hedge capital for KPI benchmarking
This commit is contained in:
@ -445,6 +445,26 @@ class ScalperHedger:
|
||||
|
||||
self.active_position_id = position_data['token_id']
|
||||
|
||||
# --- Capture Initial Capital ---
|
||||
if 'initial_hedge_usdc' not in position_data:
|
||||
try:
|
||||
# Priority: Env Var (Manual Override) -> Account Equity (Automatic)
|
||||
env_initial = os.environ.get("INITIAL_HEDGE_CAPITAL_USDC")
|
||||
if env_initial:
|
||||
start_equity = to_decimal(env_initial)
|
||||
logger.info(f"Using Configured Initial Hedge Capital: ${start_equity:.2f}")
|
||||
else:
|
||||
current_pos = self.get_current_position(COIN_SYMBOL)
|
||||
start_equity = current_pos['equity']
|
||||
logger.info(f"Recorded Initial Hedge Capital (Equity): ${start_equity:.2f}")
|
||||
|
||||
if start_equity > 0:
|
||||
update_position_stats(self.active_position_id, {
|
||||
"initial_hedge_usdc": float(start_equity)
|
||||
})
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to record initial capital: {e}")
|
||||
|
||||
logger.info(f"[DELTA] Strat Init: Pos {self.active_position_id} | Range: {lower}-{upper} | Entry: {entry_price} | Start Px: {start_price:.2f} | Resumed PnL: {self.accumulated_pnl:.2f}")
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user