
    jc	                     *   d dl Z d dlmZ d dlmZ d dlmZ d dlmZm	Z	  e              ej
                    Z e	j        e          Ze                                  e j        d          Zes e j        d          Zd Zed	k    r e             dS dS )
    N)load_dotenv)Info)	constants)	BotConfigRuntimePathsHL_MAIN_ADDRESSHL_API_WALLET_ADDRESSc                     t           st          d           d S t          t          j        d          } 	 |                     t                     }|                    dg           }d |D             }t          |          }t          d |D                       }| 	                    t                     }|                    dg           }d}d}	|D ]:}
|
d	         d
k    r,t          |
d                   }t          |
d                   }	 n;||	z
  }||z   }|dk    r|	|z  dz  nd}d|dd|dd|	dd|dd|dd| }t          |           t          t          j        dd          5 }|                    |           d d d            d S # 1 swxY w Y   d S # t          $ r}t          d|            Y d }~d S d }~ww xY w)Nu/   ❌ Fehler: Keine Adresse in der .env gefunden.T)skip_wsassetPositionsc                 P    g | ]#}t          |d          d                   dk    !|$S )positionszir   )float.0ps     
balance.py
<listcomp>z check_health.<locals>.<listcomp>   s4    RRRqq}U7K1L1LPQ1Q1Q1Q1Q1Q    c              3   h   K   | ]-}t          |d                              dd                    V  .dS )r   unrealizedPnlr   N)r   getr   s     r   	<genexpr>zcheck_health.<locals>.<genexpr>   s>      aaaU1Z=#4#4_a#H#HIIaaaaaar   balancesg        coinUSDCtotalholdr   d   uB   📊 Portfolio-Status (Unified Margin):
Nettovermögen (Equity): $z.2fz
Freies USDC: $z
Gebundene Margin: $z
Offener PnL: $z
Risiko-Auslastung: z.1fz%
Offene Trades: wzutf-8)encodingu+   ❌ Fehler beim Abrufen der Börsen-Daten: )WALLET_ADDRESSprintr   r   MAINNET_API_URL
user_stater   lensumspot_user_stater   openPATHSaccount_healthwrite	Exception)infor&   	positionsactive_tradestrade_countunrealized_pnl
spot_statespot_balances
usdc_total	usdc_holdb	free_usdcaccount_valuemargin_usage_pctreportfes                    r   check_healthr?      s    ?@@@	)4888D+A__^44
NN#3R88	RRIRRR-((aaS`aaaaa )).99
"z266
	 	 	AyF"""1W:..
!!F),,	 #
 *	"^3@MPQ@Q@QI5;;WX,)6>, ,&., , #,3, , ,3	, ,
 #3;, , *, , 	 	f%&g>>> 	!GGFOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  A A A?A??@@@@@@@@@As<   D3F (F>F FF FF 
F?"F::F?__main__)osdotenvr   hyperliquid.infor   hyperliquid.utilsr   configr   r   	from_fileCONFIGfrom_configr+   ensure_dirsgetenvr#   r?   __name__ r   r   <module>rM      s    				       ! ! ! ! ! ! ' ' ' ' ' ' * * * * * * * * 				  ((      ,-- 8RY677N2A 2A 2Ah zLNNNNN r   