Placing Orders

View as MarkdownOpen in Claude

First, ensure you have an active brokerage session, as shown in Initializing Brokerage Session. Then, send a POST request to the /iserver/account/{accountId}/orders endpoint.

1import requests
2
3account_id = "DU123456"
4url = f"https://localhost:5000/v1/api/iserver/account/{account_id}/orders"
5
6payload = {
7 "orders": [
8 {
9 "conid": 265598,
10 "orderType": "LMT",
11 "price": 165,
12 "quantity": 100,
13 "side": "BUY",
14 "tif": "DAY"
15 }
16 ]
17}
18
19headers = {"Content-Type": "application/json"}
20
21response = requests.post(url, json=payload, headers=headers)
22
23print(response.status_code)
24print(response.json())