Skip to content

Commit 273b2be

Browse files
committed
work on examples
1 parent 9f7f66a commit 273b2be

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

examples/07_technical_indicators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ async def main():
312312
await realtime_client.subscribe_user_updates()
313313

314314
# Initialize data manager
315-
await data_manager.initialize(initial_days=1)
315+
await data_manager.initialize(initial_days=4)
316316

317317
# Subscribe to market data
318318
instruments = await client.search_instruments("MNQ")

examples/basic_usage.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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}")

examples/factory_functions_demo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ async def complete_suite_creation():
108108
print(f" ✅ OrderBook: {suite['orderbook'].__class__.__name__}")
109109
print(f" ✅ Order Manager: {suite['order_manager'].__class__.__name__}")
110110
print(f" ✅ Position Manager: {suite['position_manager'].__class__.__name__}")
111-
print(f" ✅ Config: {suite['config'].__class__.__name__}")
112111

113112
# Connect and initialize
114113
print("\n🔌 Connecting to real-time services...")

0 commit comments

Comments
 (0)