tedchou12 / webull

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

placed order with "Failed" status #203

Closed munkeycigar closed 3 years ago

munkeycigar commented 3 years ago

I've been able to place orders correctly, but recently I've started getting orders that end up with a "Failed" status. Would anyone know reasons for an order failing? There are definitely enough funds in the account to cover the trade and I can see that the order was placed with the correct quantity and price. These are options orders if that makes any difference.

I've been using some SPY calls that are $0.01 to test that my logic for placing the order, but when I leave my bot running and it places an order, the status on that order ends up as "Failed".

I've contacted WeBull support and they haven't been very helpful. They say they don't see failed orders, but I can clearly see from the desktop app when I look at my account details.

I'm wondering if there are headers missing or something different about the requests being made from this client vs the requests that are sent from the web app? But that wouldn't make much sense, because like I said, I've been able to place those SPY calls successfully.

Any help/insight would be appreciated.

zenhorace commented 3 years ago

check to ensure you your trade token (which is different from your login/access token) isn't expired when you're trying to place the options order. The trade token is only live for 30 mins

munkeycigar commented 3 years ago

I do call get_trade_token() before every place_order(). The weird thing is that there have been orders that have gone through with the same code/logic I have in place. But I've had a few orders here and there end up with the "Failed" status. I was just curious if anyone else has run into this issue.

tedchou12 commented 3 years ago

I recall if you do result = place_order() print(result) should give you the reason why the place order falied?

zenhorace commented 3 years ago

You said these are options orders? If some go through and others don't then this might be the issue: For "some" options limit orders the price has to be in increments of $0.05 if the price is under $3.00, otherwise exchange will reject the order. But this doesn't apply to all options and I'm not sure how webull determines which options the rule applies to. But print the result and see what's up

munkeycigar commented 3 years ago

sorry to also clarify, i'm placing options orders (using place_option_order()). WeBull returns a 500 error, but no helpful message. But the weird thing is that the order that failed still shows up on the WeBull app, but with a "Failed" status, and it has all of the correct order details as far as strike price, expire date, direction, quantity, and price.

So I've been able to place orders correctly, so it makes me think that it should be working fine. It happens intermittently.

@hfacey ah ok yea i think you are right there for the options limit. That clears up what's going on. Thanks for the help.