11# Async Migration Guide for project-x-py
22
3- This guide helps you migrate from the synchronous ProjectX SDK to the new async/await architecture.
3+ This guide helps you migrate from the synchronous ProjectX SDK to the new async/await architecture.
4+ ** Note:** All public classes and factory functions are now async-ready by default—no Async* prefix is required.
45
56## Table of Contents
67
@@ -69,7 +70,7 @@ await realtime_client.add_callback("position_update", on_position_update)
69701 . ** All API methods are now async** - Must use ` await `
70712 . ** Context managers are async** - Use ` async with `
71723 . ** Callbacks can be async** - Better event handling
72- 4 . ** Import changes ** - New async classes available
73+ 4 . ** Imports updated ** - All classes and factory functions are async-ready and use the canonical names (no Async * prefix).
7374
7475## Migration Steps
7576
@@ -79,8 +80,8 @@ await realtime_client.add_callback("position_update", on_position_update)
7980# Old imports
8081from project_x_py import ProjectX, create_trading_suite
8182
82- # New imports for async
83- from project_x_py import AsyncProjectX, create_async_trading_suite
83+ # New imports (all classes/factories are async-ready by default)
84+ from project_x_py import ProjectX, create_trading_suite
8485```
8586
8687### Step 2: Update Client Creation
@@ -91,7 +92,7 @@ client = ProjectX.from_env()
9192client.authenticate()
9293
9394# New async client
94- async with AsyncProjectX .from_env() as client:
95+ async with ProjectX .from_env() as client:
9596 await client.authenticate()
9697```
9798
@@ -116,11 +117,11 @@ data = await client.get_data("MGC", days=5)
116117order_manager = create_order_manager(client)
117118position_manager = create_position_manager(client)
118119
119- # New async managers
120- order_manager = create_async_order_manager (client)
120+ # New async managers (all managers are now async-ready by default)
121+ order_manager = create_order_manager (client)
121122await order_manager.initialize()
122123
123- position_manager = create_async_position_manager (client)
124+ position_manager = create_position_manager (client)
124125await position_manager.initialize()
125126```
126127
@@ -138,13 +139,13 @@ def main():
138139 print (f " Connected as: { account.name} " )
139140```
140141
141- ** Async:**
142+ ** Async (now using canonical names) :**
142143``` python
143144import asyncio
144- from project_x_py import AsyncProjectX
145+ from project_x_py import ProjectX
145146
146147async def main ():
147- async with AsyncProjectX .from_env() as client:
148+ async with ProjectX .from_env() as client:
148149 await client.authenticate()
149150 print (f " Connected as: { client.account_info.name} " )
150151
@@ -160,9 +161,9 @@ response = order_manager.place_market_order("MGC", 0, 1)
160161orders = order_manager.search_open_orders()
161162```
162163
163- ** Async:**
164+ ** Async (now using canonical names) :**
164165``` python
165- order_manager = create_async_order_manager (client)
166+ order_manager = create_order_manager (client)
166167await order_manager.initialize()
167168
168169response = await order_manager.place_market_order(" MGC" , 0 , 1 )
@@ -181,10 +182,10 @@ data_manager.initialize()
181182data_manager.start_realtime_feed()
182183```
183184
184- ** Async:**
185+ ** Async (now using canonical names) :**
185186``` python
186- realtime_client = create_async_realtime_client (jwt_token, account_id)
187- data_manager = create_async_data_manager (" MGC" , client, realtime_client)
187+ realtime_client = create_realtime_client (jwt_token, account_id)
188+ data_manager = create_data_manager (" MGC" , client, realtime_client)
188189
189190await realtime_client.connect()
190191await data_manager.initialize()
@@ -204,9 +205,9 @@ suite["realtime_client"].connect()
204205suite[" data_manager" ].initialize()
205206```
206207
207- ** Async:**
208+ ** Async (now using canonical names) :**
208209``` python
209- suite = await create_async_trading_suite (
210+ suite = await create_trading_suite (
210211 " MGC" , client, jwt_token, account_id,
211212 timeframes = [" 5min" , " 15min" ]
212213)
@@ -217,6 +218,8 @@ await suite["data_manager"].initialize()
217218
218219## Common Patterns
219220
221+ All public classes and factory functions are async-ready—use canonical names (no Async* prefix).
222+
220223### 1. Concurrent Operations
221224
222225``` python
@@ -299,7 +302,7 @@ monitor_task = asyncio.create_task(monitor_positions(position_manager))
299302
3003031 . ** Always use async context managers:**
301304 ``` python
302- async with AsyncProjectX .from_env() as client:
305+ async with ProjectX .from_env() as client:
303306 # Client is properly cleaned up
304307 ```
305308
@@ -399,16 +402,16 @@ def trading_bot():
399402 time.sleep(60 )
400403```
401404
402- ** New Async Bot:**
405+ ** New Async Bot (now using canonical names) :**
403406``` python
404407import asyncio
405- from project_x_py import AsyncProjectX, create_async_trading_suite
408+ from project_x_py import ProjectX, create_trading_suite
406409
407410async def trading_bot ():
408- async with AsyncProjectX .from_env() as client:
411+ async with ProjectX .from_env() as client:
409412 await client.authenticate()
410413
411- suite = await create_async_trading_suite (
414+ suite = await create_trading_suite (
412415 " MGC" , client, client.jwt_token,
413416 client.account_info.id
414417 )
0 commit comments