tedchou12 / webull

Unofficial APIs for Webull.
MIT License
597 stars 181 forks source link

wb.place_order_otoco returns 'forward' and doesn't place orders #297

Closed cnoffsin closed 2 years ago

cnoffsin commented 2 years ago

I have tried to run:

 wb.place_order_otoco(stock=ticker, price=fixed_bid_price, stop_loss_price=fixed_stop_loss_price, limit_profit_price=fixed_limit_profit_price, time_in_force='DAY', quant=1)

And it doesn't place the orders, just seems to output:

'forward'

I made sure I wasn't in paper mode and I am able to place orders with wb_place_order OK.

I tried to dig a bit into the response headers but haven't been able to find a reason why it doesn't work yet since I can't seem to figure out how to get it to output more of the response json for some more info.

xzs11x commented 2 years ago

I am also having this problem. I am going to guess it is an endpoint implementation issue

cnoffsin commented 2 years ago

Added some print statements here

https://github.com/tedchou12/webull/blob/0125e51d6fe097cb66e18f9ee05eb917d8782e9c/webull/webull.py#L565

            response2 = requests.post(self._urls.place_otoco_orders(self._account_id), json=data2, headers=headers, timeout=self.timeout)

            # print('Resp 2: {}'.format(response1))
            result2=response2.json
            print(result2)
            return response2.json()

And got:

{'msg': 'Inner server error', 'traceId': 'REDACTED', 'code': 'trade.secAcct.mismatch.with.user', 'data': {}, 'success': False}
cnoffsin commented 2 years ago

Really sorry I had paper_webull() imported at a lower spot in my script.

Per issue 275 you cannot do otoco orders with paper_webull.

Thanks for looking!

xzs11x commented 2 years ago

Yeah, paper_webull() won't allow otoco orders. I should've thought to mention. Did fixing your print statement allow the order to now go through?

cnoffsin commented 2 years ago

The print statement gave me this message:

{'msg': 'Inner server error', 'traceId': 'REDACTED', 'code': 'trade.secAcct.mismatch.with.user', 'data': {}, 'success': False}

Which helped me search the github issues on the project and find the other issue.

Otherwise I was just getting 'forward' as a response which didn't make it so I could troubleshoot it.

I have gotten it to give some other output:

{'forward': False, 'checkResultList': [{'code': 'trade.webull.DAY_ORDER_NOT_ALLOWED_AFT_CORE_TIME_LIMIT', 'msg': "Regular trading hours has ended. If you would like to place this order, please select the Exten

Which shows this without the print statement I think:

Regular trading hours has ended. If you would like to place this order, please select the Extended Hours Tab; or you can change the Time-in-Force to Good 'Til Canceled.

Same for this:

{'forward': False, 'checkResultList': [{'code': 'trade.order.param.error', 'msg': 'Invalid request parameter'}]}
trade.order.param.error
Invalid request parameter

So I think the json output for that trade.secAcct.mismatch.with.user just isn't caught.