Order Submission

View as MarkdownOpen in Claude

Submission of orders for Event Contracts via the Web API functions like orders for any other instrument.

However, it is important to note the differing mechanics between CME Group products and ForecastEx instruments:

  • CME Group instruments can be bought and sold and function as normal futures options.
  • ForecastEx instruments cannot be sold, only bought. To exit or reduce a position, one must buy the opposing Event Contract, and IB will net the opposing positions together automatically.

In both cases, no short selling is permitted.

ForecastEx

In the context of ForecastEx trading, the other right must be bought to open and close the position. In this scenario, we are entering the position by buying the YES side of the January contract. This is demonstrated in the first payload.

However, if we wanted to close the position after buying the YES, we would use the second payload to buy the NO side.

1import requests
2
3url = f"{baseUrl}/iserver/account/{accountId}/orders"
4
5// Opening Order (BUY to open 1 YES contract)
6payload = {
7 "orders": [
8 {
9 "side": "BUY",
10 "quantity": 1,
11 "conid": 773659700, //YES contract expiring JAN 04 '27
12 "orderType": "MKT",
13 "listingExchange": "FORECASTEX",
14 "tif": "DAY"
15 }
16 ]
17}
18
19// Closing Order (BUY to close 1 NO contract)
20payload = {
21 "orders": [
22 {
23 "side": "BUY",
24 "quantity": 1,
25 "conid": 773659707, //NO contract expiring JAN 04 '27
26 "orderType": "MKT",
27 "listingExchange": "FORECASTEX",
28 "tif": "DAY"
29 }
30 ]
31}
32
33response = requests.post(url=url, data=payload)
34print(response.text)

CME Group

In the case of CME listed contracts, we can simply change our side value from BUY to SELL to close our position.

1import requests
2
3url = f"{baseUrl}/iserver/account/{accountId}/orders"
4
5// Closing Order (BUY to close 1 NO contract)
6payload = {
7 "orders": [
8 {
9 "side": "BUY",
10 "quantity": 1,
11 "conid": 861917649, // US Payroll Employment
12 "orderType": "MKT",
13 "listingExchange": "CME",
14 "tif": "DAY"
15 }
16 ]
17}
18
19response = requests.post(url=url, data=payload)
20print(response.text)