# ChatGPT Provides Help with API

**URL:** <https://community.tradovate.com/t/chatgpt-provides-help-with-api/6956>\
**Category:** Traders Helping Traders\
**Created:** [March 19, 2023, 5:34am UTC](https://community.tradovate.com/t/chatgpt-provides-help-with-api/6956 "2023-03-19T05:34:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_Mangaroo](https://avatars.discourse-cdn.com/v4/letter/w/c0e974/32.png) [@William\_Mangaroo](https://community.tradovate.com/u/William_Mangaroo)\
**Post date:** [March 19, 2023, 5:34am UTC](https://community.tradovate.com/t/chatgpt-provides-help-with-api/6956/1 "2023-03-19T05:34:38Z")

</div>

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! 🙂

---

<div class="post-metadata">

**Author:** ![latter-day-trader](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@latter-day-trader](https://community.tradovate.com/u/latter-day-trader)\
**Post date:** [March 20, 2023, 11:19pm UTC](https://community.tradovate.com/t/chatgpt-provides-help-with-api/6956/2 "2023-03-20T23:19:44Z")

</div>

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.
