diff --git a/clp_hedger.py b/clp_hedger.py index 0f2b570..65428fb 100644 --- a/clp_hedger.py +++ b/clp_hedger.py @@ -438,16 +438,14 @@ class ScalperHedger: self.strategy_start_time = int(time.time() * 1000) self.trade_history_seen = set() - self.accumulated_pnl = Decimal("0.0") - self.accumulated_fees = Decimal("0.0") + + # Resume PnL from file if available, otherwise 0.0 + self.accumulated_pnl = to_decimal(position_data.get('hedge_pnl_realized', 0.0)) + self.accumulated_fees = to_decimal(position_data.get('hedge_fees_paid', 0.0)) + self.active_position_id = position_data['token_id'] - update_position_stats(self.active_position_id, { - "hedge_pnl_realized": 0.0, - "hedge_fees_paid": 0.0 - }) - - logger.info(f"[DELTA] Strat Init: Pos {self.active_position_id} | Range: {lower}-{upper} | Entry: {entry_price} | Start Px: {start_price:.2f}") + 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: logger.error(f"Failed to init strategy: {e}")