detailed info about wallets
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Hyperliquid Wallet Data Fetcher - Perfect Table Alignment
|
||||
Hyperliquid Wallet Data Fetcher - FINAL Perfect Alignment
|
||||
==========================================================
|
||||
Complete Python script to pull all available data for a Hyperliquid wallet via API.
|
||||
|
||||
@ -189,18 +189,19 @@ class HyperliquidWalletAnalyzer:
|
||||
|
||||
def print_positions_summary_table(self, positions: list):
|
||||
"""
|
||||
Print a summary table of all positions with properly aligned vertical separators.
|
||||
Print a summary table of all positions with perfectly aligned columns.
|
||||
NO emojis in data cells - keeps them simple text only for perfect alignment.
|
||||
|
||||
Args:
|
||||
positions: List of position dictionaries
|
||||
"""
|
||||
print(f"\n{'='*130}")
|
||||
print(f"POSITIONS SUMMARY TABLE")
|
||||
print(f"{'='*130}")
|
||||
print("POSITIONS SUMMARY TABLE")
|
||||
print('='*130)
|
||||
|
||||
# Header with vertical separators
|
||||
print("| Asset | Side | Size | Entry Price | Position Value | Unrealized PnL | ROE | Leverage |")
|
||||
print("|----------|-----------|------------------|------------------|--------------------|--------------------|------------|------------|")
|
||||
# Print header
|
||||
print("| Asset | Side | Size | Entry Price | Position Value | Unrealized PnL | ROE | Leverage |")
|
||||
print("|----------|-------|-------------------|-------------------|-------------------|-------------------|------------|------------|")
|
||||
|
||||
total_position_value = 0
|
||||
total_pnl = 0
|
||||
@ -220,53 +221,40 @@ class HyperliquidWalletAnalyzer:
|
||||
leverage_value = leverage.get('value', 0) if isinstance(leverage, dict) else 0
|
||||
leverage_type = leverage.get('type', 'cross') if isinstance(leverage, dict) else 'cross'
|
||||
|
||||
# Determine side - NO EMOJIS in data
|
||||
side_text = "LONG" if size > 0 else "SHORT"
|
||||
side_emoji = "📈" if size > 0 else "📉"
|
||||
|
||||
# Add color indicators (using text instead of emojis for alignment)
|
||||
# Format PnL and ROE with signs
|
||||
pnl_sign = "+" if unrealized_pnl >= 0 else ""
|
||||
roe_sign = "+" if return_on_equity >= 0 else ""
|
||||
|
||||
# Accumulate totals
|
||||
total_position_value += abs(position_value)
|
||||
total_pnl += unrealized_pnl
|
||||
|
||||
# Format numbers with proper width - no emojis in the data
|
||||
size_str = f"{abs(size):,.4f}"
|
||||
entry_str = f"${entry_px:,.2f}"
|
||||
value_str = f"${abs(position_value):,.2f}"
|
||||
pnl_str = f"{pnl_sign}${unrealized_pnl:,.2f}"
|
||||
roe_str = f"{return_on_equity:+.2%}"
|
||||
# Format all values as strings with proper width
|
||||
asset_str = f"{coin[:8]:<8}"
|
||||
side_str = f"{side_text:<5}"
|
||||
size_str = f"{abs(size):>17,.4f}"
|
||||
entry_str = f"${entry_px:>16,.2f}"
|
||||
value_str = f"${abs(position_value):>16,.2f}"
|
||||
pnl_str = f"{pnl_sign}${unrealized_pnl:>15,.2f}"
|
||||
roe_str = f"{roe_sign}{return_on_equity:>9.2%}"
|
||||
lev_str = f"{leverage_value}x {leverage_type[:4]}"
|
||||
|
||||
# Use fixed width with ljust/rjust for proper alignment
|
||||
row = (f"| {coin[:8]:<8} "
|
||||
f"| {side_text:<5} {side_emoji} "
|
||||
f"| {size_str:>16} "
|
||||
f"| {entry_str:>16} "
|
||||
f"| {value_str:>18} "
|
||||
f"| {pnl_str:>18} "
|
||||
f"| {roe_str:>10} "
|
||||
f"| {lev_str:<10} |")
|
||||
print(row)
|
||||
# Print row with exact spacing
|
||||
print(f"| {asset_str} | {side_str} | {size_str} | {entry_str} | {value_str} | {pnl_str} | {roe_str} | {lev_str:<10} |")
|
||||
|
||||
# Separator before totals
|
||||
print("|==========|===========|==================|==================|====================|====================|============|============|")
|
||||
print("|==========|=======|===================|===================|===================|===================|============|============|")
|
||||
|
||||
# Total row
|
||||
total_value_str = f"${total_position_value:,.2f}"
|
||||
total_value_str = f"${total_position_value:>16,.2f}"
|
||||
total_pnl_sign = "+" if total_pnl >= 0 else ""
|
||||
total_pnl_str = f"{total_pnl_sign}${total_pnl:,.2f}"
|
||||
total_pnl_str = f"{total_pnl_sign}${total_pnl:>15,.2f}"
|
||||
|
||||
total_row = (f"| {'TOTAL':<8} "
|
||||
f"| {'':<9} "
|
||||
f"| {'':<16} "
|
||||
f"| {'':<16} "
|
||||
f"| {total_value_str:>18} "
|
||||
f"| {total_pnl_str:>18} "
|
||||
f"| {'':<10} "
|
||||
f"| {'':<10} |")
|
||||
print(total_row)
|
||||
print(f"{'='*130}\n")
|
||||
print(f"| TOTAL | | | | {total_value_str} | {total_pnl_str} | | |")
|
||||
print('='*130 + '\n')
|
||||
|
||||
def get_spot_state(self) -> Dict[str, Any]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user