Skip to content

Commit a73df22

Browse files
authored
docs: Update async migration guide and references to use canonical names, removing Async* prefix.
Co-authored-by: Genie <[email protected]> Update Documentation for Async Migration
2 parents 9dce464 + 88caa51 commit a73df22

File tree

2 files changed

+45
-40
lines changed

2 files changed

+45
-40
lines changed

docs/_reference_docs/ASYNC_MIGRATION_GUIDE.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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)
6970
1. **All API methods are now async** - Must use `await`
7071
2. **Context managers are async** - Use `async with`
7172
3. **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
8081
from 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()
9192
client.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)
116117
order_manager = create_order_manager(client)
117118
position_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)
121122
await order_manager.initialize()
122123

123-
position_manager = create_async_position_manager(client)
124+
position_manager = create_position_manager(client)
124125
await 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
143144
import asyncio
144-
from project_x_py import AsyncProjectX
145+
from project_x_py import ProjectX
145146

146147
async 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)
160161
orders = 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)
166167
await order_manager.initialize()
167168

168169
response = await order_manager.place_market_order("MGC", 0, 1)
@@ -181,10 +182,10 @@ data_manager.initialize()
181182
data_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

189190
await realtime_client.connect()
190191
await data_manager.initialize()
@@ -204,9 +205,9 @@ suite["realtime_client"].connect()
204205
suite["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

300303
1. **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
404407
import asyncio
405-
from project_x_py import AsyncProjectX, create_async_trading_suite
408+
from project_x_py import ProjectX, create_trading_suite
406409

407410
async 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
)

docs/_reference_docs/async_refactoring_issue.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ The current synchronous architecture has several limitations:
6161
- Converted all managers to async: OrderManager, PositionManager, RealtimeDataManager, OrderBook
6262
- Implemented proper async locking and thread safety
6363
- Created comprehensive test suites for all managers (62 tests total)
64-
- Ensured all managers can share AsyncProjectXRealtimeClient instance
64+
- Ensured all managers can share ProjectXRealtimeClient instance
6565

6666
**Phase 4 (SignalR/WebSocket Integration) - COMPLETED on 2025-07-31**
67-
- Created AsyncProjectXRealtimeClient with async wrapper around SignalR
67+
- Created ProjectXRealtimeClient with async wrapper around SignalR
6868
- Implemented async event handling and callback system
6969
- Added JWT token refresh and reconnection support
7070
- Created async factory functions for all components
@@ -153,14 +153,14 @@ The current synchronous architecture has several limitations:
153153
- Thread-safe operations using asyncio.Lock
154154
- Runs synchronous SignalR operations in executor for compatibility
155155

156-
**Async Factory Functions Created:**
157-
- `create_async_client()` - Create AsyncProjectX client
158-
- `create_async_realtime_client()` - Create async real-time WebSocket client
159-
- `create_async_order_manager()` - Create async order manager
160-
- `create_async_position_manager()` - Create async position manager
161-
- `create_async_data_manager()` - Create async OHLCV data manager
162-
- `create_async_orderbook()` - Create async market depth orderbook
163-
- `create_async_trading_suite()` - Create complete async trading toolkit
156+
**Async Factory Functions Created (now canonical, async-ready by default):**
157+
- `create_client()` - Create ProjectX client
158+
- `create_realtime_client()` - Create real-time WebSocket client
159+
- `create_order_manager()` - Create order manager
160+
- `create_position_manager()` - Create position manager
161+
- `create_data_manager()` - Create OHLCV data manager
162+
- `create_orderbook()` - Create market depth orderbook
163+
- `create_trading_suite()` - Create complete async trading toolkit
164164

165165
**Integration Features:**
166166
- All async managers share single AsyncProjectXRealtimeClient instance
@@ -205,16 +205,16 @@ This refactoring will introduce breaking changes:
205205
3. Event handlers must be async functions
206206
4. Example code and integrations need updates
207207

208-
## Migration Guide (Draft)
208+
## Migration Guide
209209

210210
```python
211211
# Old (Sync)
212212
client = ProjectX(api_key, username)
213213
client.authenticate()
214214
positions = client.get_positions()
215215

216-
# New (Async)
217-
async with AsyncProjectX(api_key, username) as client:
216+
# New (Async-ready, canonical names)
217+
async with ProjectX(api_key, username) as client:
218218
await client.authenticate()
219219
positions = await client.get_positions()
220220
```
@@ -257,14 +257,14 @@ aioresponses = ">=0.7.6" # For mocking async HTTP
257257

258258
```python
259259
import asyncio
260-
from project_x_py import AsyncProjectX, create_async_trading_suite
260+
from project_x_py import ProjectX, create_trading_suite
261261

262262
async def trading_bot():
263-
async with AsyncProjectX(api_key, username) as client:
263+
async with ProjectX(api_key, username) as client:
264264
await client.authenticate()
265265

266-
# Create async trading suite
267-
suite = await create_async_trading_suite(
266+
# Create trading suite (now async-ready by default)
267+
suite = await create_trading_suite(
268268
instrument="MGC",
269269
project_x=client,
270270
jwt_token=client.session_token,
@@ -325,4 +325,6 @@ if __name__ == "__main__":
325325

326326
---
327327

328+
**Note:** All public classes and factory functions are now async-ready by default. The Async* prefix is no longer used—simply use the canonical names shown in the latest examples above.
329+
328330
**Note**: This refactoring aligns with the CLAUDE.md directive for "No Backward Compatibility" and "Clean Code Priority" during active development.

0 commit comments

Comments
 (0)