Skip to content

Commit

Permalink
add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dancost committed Jul 23, 2024
1 parent 606d844 commit 35c2160
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/ws_tests/performance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def test_performance(forex_api_session):
order_data = {"stocks": "EURUSD", "quantity": 10}

async with aiohttp.ClientSession() as client:
# Open WebSocket connection
# open ws connection
async with connect(uri, ping_interval=None) as websocket:
# Place 100 orders simultaneously
tasks = [place_order(client, base_url, order_data) for _ in range(100)]
Expand All @@ -31,20 +31,20 @@ async def test_performance(forex_api_session):
end_time = time.time()
print(f"Time to place 100 orders: {end_time - start_time:.2f} seconds")

# Check response and collect order IDs
# check response and collect order IDs
order_ids = []
for response in responses:
assert 'id' in response, f"Response missing 'id': {response}"
order_ids.append(response['id'])

print(f"Placed 100 orders successfully.")

# Subscribe to specific order IDs
# subscribe to specific order IDs
for order_id in order_ids:
subscribe_message = json.dumps({"action": "subscribe", "order_id": order_id})
await websocket.send(subscribe_message)

# Read WebSocket messages
# read ws messages
executed_timestamps = {}
for _ in range(100): # Expect only the EXECUTED messages
message = await asyncio.wait_for(websocket.recv(), timeout=20)
Expand All @@ -54,7 +54,7 @@ async def test_performance(forex_api_session):
executed_timestamps[order_id] = time.time()
print(f"Executed message for order {order_id}: {message_data}")

# Compute delays
# compute delays
execution_delays = []
for order_id in order_ids:
if order_id in executed_timestamps:
Expand Down

0 comments on commit 35c2160

Please sign in to comment.