ChatGPT Provides Help with API

I just used ChatGPT to help me structure an OSO JSON. I am passing this along to others here that may find it useful. It is not correct all the time. It depends on how detailed your question is.

Here is what I asked:

I wrote the following JSON to place a Tradovate OSO order. It should place a Buy Stop order at 4151, a take profit limit order at 4152, and a stop loss limit order at 4150, but it is not doing that.
{
“accountSpec”: [USERNAME],
“accountId”: [“ACCOUNTID”],
“action”: Buy,
“symbol”: MESM3,
“orderQty”: 1,
“orderType”: “StopLimit”,
“price”: 4151,
“stopPrice”: 4151,
“isAutomated”: True
“bracket1”: {
“action”: Sell,
“orderType”: “Limit”,
“price”: 4152
},
“bracket2”: {
action": Sell,
“orderType”: “Stop”,
“stopPrice”: 4150
}
}

Can you fix it?

Here is ChatGPT’s response:

There are a few syntax errors and missing key-value pairs in the JSON code you provided that need to be addressed to place the OSO order correctly. Here is the corrected JSON code:

{
“accountSpec”: “[USERNAME]”,
“accountId”: “[ACCOUNTID]”,
“action”: “Buy”,
“symbol”: “MESM3”,
“orderQty”: 1,
“orderType”: “StopLimit”,
“price”: 4151,
“stopPrice”: 4151,
“isAutomated”: true,
“bracket”: {
“bracket1”: {
“action”: “Sell”,
“orderType”: “Limit”,
“price”: 4152
},
“bracket2”: {
“action”: “Sell”,
“orderType”: “StopLimit”,
“price”: 4150,
“stopPrice”: 4150
}
}
}

The changes include:

  • Adding quotes around the accountSpec and accountId values.
  • Adding quotes around the action values for both the main order and the bracket orders.
  • Adding a missing comma after the isAutomated key-value pair.
  • Combining the bracket1 and bracket2 keys into a single bracket object.
  • Changing the orderType of the stop loss order from Stop to StopLimit to match the requirements for an OSO order.

With these changes, the JSON code should correctly place the Buy Stop order at 4151, the take profit limit order at 4152, and the stop loss limit order at 4150.

I think this is cool! :slight_smile:

Thanks for sharing!

I was playing with ChatGPT 4 this weekend, and whenever the answer is wrong or could be more correct to the topic I am asking about, I will include the link to the documentation or the sample code from Github, etc. It still misses a couple things, but definitely saves me a lot of time.

I don’t think it will replace me any time soon, but I have been using it almost every day to help me remember things I have forgotten or give me the TL;DR; of new things.