@@ -26,20 +26,21 @@ async def main():
2626 # Create client using environment variables
2727 async with ProjectX .from_env () as client :
2828 print ("✅ Client created successfully" )
29- if client .account_info is None :
30- print ("❌ No account info found" )
31- return
3229
3330 # Authenticate
3431 print ("\n 🔐 Authenticating..." )
3532 await client .authenticate ()
33+ if client .account_info is None :
34+ print ("❌ No account info found" )
35+ raise ValueError ("No account info found" )
36+
3637 print (f"✅ Authenticated as: { client .account_info .name } " )
3738 print (f"📊 Using account: { client .account_info .name } " )
3839 print (f"💰 Balance: ${ client .account_info .balance :,.2f} " )
3940
4041 # Get positions
4142 print ("\n 📈 Fetching positions..." )
42- positions : list [Position ] = await client .get_positions ()
43+ positions : list [Position ] = await client .search_open_positions ()
4344
4445 if positions :
4546 print (f"Found { len (positions )} position(s):" )
@@ -71,10 +72,13 @@ async def main():
7172 # Show performance stats
7273 print ("\n 📊 Performance Statistics:" )
7374 health = await client .get_health_status ()
74- print (f" - API calls made: { health ['api_calls' ]} " )
75- print (f" - Cache hits: { health ['cache_hits' ]} " )
76- print (f" - Cache hit rate: { health ['cache_hit_rate' ]:.1%} " )
77- print (f" - Token expires in: { health ['token_expires_in' ]:.0f} seconds" )
75+ print (f" - API Status: { health ['api_status' ]} " )
76+ print (f" - API Version: { health ['api_version' ]} " )
77+
78+ client_stats = health ["client_stats" ]
79+ print (f" - API calls made: { client_stats ['api_calls' ]} " )
80+ print (f" - Cache hits: { client_stats ['cache_hits' ]} " )
81+ print (f" - Cache hit rate: { client_stats ['cache_hit_rate' ]:.1%} " )
7882
7983 except Exception as e :
8084 print (f"\n ❌ Error: { type (e ).__name__ } : { e } " )
0 commit comments