refactor: Standardize CLP Manager and Hedger modules & cleanup
- **clp_manager.py**: Renamed from 'uniswap_manager.py'. Standardized logic for Uniswap V3 liquidity provision. - **clp_hedger.py**: Renamed from 'unified_hedger.py'. Consolidated hedging logic including Delta Calculation fixes, EAC (Edge Avoidance), and Fishing order implementation. - **Cleanup**: Removed legacy 'aerodrome' folder and tools. - **Monitoring**: Added Telegram monitoring scripts. - **Config**: Updated gitignore to exclude market data CSVs.
This commit is contained in:
74
florida/tools/debug_pnl_check.py
Normal file
74
florida/tools/debug_pnl_check.py
Normal file
@ -0,0 +1,74 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
from decimal import Decimal
|
||||
from dotenv import load_dotenv
|
||||
from hyperliquid.info import Info
|
||||
from hyperliquid.utils import constants
|
||||
|
||||
# Load env
|
||||
current_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.append(current_dir)
|
||||
load_dotenv(os.path.join(current_dir, '.env'))
|
||||
|
||||
address = os.environ.get("MAIN_WALLET_ADDRESS")
|
||||
if not address:
|
||||
print("No address found")
|
||||
sys.exit(1)
|
||||
|
||||
info = Info(constants.MAINNET_API_URL, skip_ws=True)
|
||||
|
||||
# Target Start Time: 2025-12-30 21:32:52 (From user JSON)
|
||||
START_TIME_MS = 1767126772 * 1000
|
||||
COIN = "BNB"
|
||||
|
||||
print(f"--- DEBUG PnL CHECK ---")
|
||||
print(f"Address: {address}")
|
||||
print(f"Coin: {COIN}")
|
||||
print(f"Start Time: {START_TIME_MS}")
|
||||
|
||||
try:
|
||||
fills = info.user_fills(address)
|
||||
|
||||
valid_fills = []
|
||||
total_closed_pnl = Decimal("0")
|
||||
total_fees = Decimal("0")
|
||||
|
||||
print(f"\n--- FILLS FOUND ---")
|
||||
print(f"{'Time':<20} | {'Side':<5} | {'Sz':<8} | {'Px':<8} | {'Fee':<8} | {'ClosedPnL':<10}")
|
||||
print("-" * 80)
|
||||
|
||||
for fill in fills:
|
||||
if fill['coin'] == COIN and fill['time'] >= START_TIME_MS:
|
||||
valid_fills.append(fill)
|
||||
|
||||
fee = Decimal(str(fill['fee']))
|
||||
pnl = Decimal(str(fill['closedPnl']))
|
||||
|
||||
total_closed_pnl += pnl
|
||||
total_fees += fee
|
||||
|
||||
ts_str = time.strftime('%H:%M:%S', time.localtime(fill['time']/1000))
|
||||
print(f"{ts_str:<20} | {fill['side']:<5} | {fill['sz']:<8} | {fill['px']:<8} | {fee:<8.4f} | {pnl:<10.4f}")
|
||||
|
||||
print("-" * 80)
|
||||
print(f"Count: {len(valid_fills)}")
|
||||
print(f"Sum Closed PnL (Gross): {total_closed_pnl:.4f}")
|
||||
print(f"Sum Fees: {total_fees:.4f}")
|
||||
|
||||
net_realized = total_closed_pnl - total_fees
|
||||
print(f"NET REALIZED (Gross - Fees): {net_realized:.4f}")
|
||||
|
||||
# Check JSON
|
||||
json_path = os.path.join(current_dir, "PANCAKESWAP_BNB_status.json")
|
||||
if os.path.exists(json_path):
|
||||
with open(json_path, 'r') as f:
|
||||
data = json.load(f)
|
||||
last_pos = data[-1]
|
||||
print(f"\n--- JSON STATE ---")
|
||||
print(f"hedge_TotPnL: {last_pos.get('hedge_TotPnL')}")
|
||||
print(f"hedge_fees_paid: {last_pos.get('hedge_fees_paid')}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
Reference in New Issue
Block a user