tedchou12 / webull

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

Problems with options #375

Open erbri007 opened 1 year ago

erbri007 commented 1 year ago

500 issues with options.

I have been having issues with place_option_orders. I'm not sure what the issue is. I can get it to work by matching the API I see with the browser, but not with the current setup.

Working:

{ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36", "Accept": "/", "Accept-Encoding": "gzip, deflate", "Accept-Language": "en-US,en;q=0.5", "Content-Type": "application/json", "platform": "web", "origin": "https://app.webull.com", "sec-ch-ua": "\"Chromium\";v=\"106\", \"Not;A=Brand\";v=\"99\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "cross-site", "hl": "en", "os": "web", "osv": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36", "app": "global", "app-group": "broker", "appid": "wb_web_app", "ver": "3.39.27", "lzone": "dc_core1", "ph": "MacOS Firefox", "tz": "xxx", "locale": "eng", "device-type": "Web", "did": "xxx", "reqid": "xxx", "access_token": "dc_us_tech1.xxx", "t_token": "xxxxx", "t_time": "1673474483817" } https://ustrade.webullfinance.com/api/trading/v1/webull/order/optionPlace?secAccountId=xxxxx { "lmtPrice": "3.78", "auxPrice": null, "orderType": "LMT", "timeInForce": "GTC", "orders": [ { "quantity": 1, "action": "BUY", "tickerId": 1036819607, "tickerType": "OPTION" } ], "serialId": "xxxx" }

Not working:

{ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36", "Accept": "/", "Accept-Encoding": "gzip, deflate", "Accept-Language": "en-US,en;q=0.5", "Content-Type": "application/json", "platform": "web", "origin": "https://app.webull.com", "sec-ch-ua": "\"Chromium\";v=\"106\", \"Not;A=Brand\";v=\"99\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "cross-site", "hl": "en", "os": "web", "osv": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36", "app": "global", "app-group": "broker", "appid": "wb_web_app", "ver": "3.39.27", "lzone": "dc_core_r001", "ph": "MacOS Firefox", "tz": "xxx", "locale": "eng", "device-type": "Web", "did": "xxxx", "reqid": "xxxx", "access_token": "dc_us_tech1.xxxx", "t_token": "xxxx", "t_time": "1673475875214", "zone_var": "dc_core1" } https://ustrade.webullfinance.com/api/trading/v1/webull/order/optionPlace?secAccountId=xxxxx { "orderType": "LMT", "serialId": "xxxx", "lmtPrice": 3.62, "timeInForce": "GTC", "orders": [ { "quantity": 1, "action": "BUY", "tickerId": 1036819607, "tickerType": "OPTION" } ] }

Any Ideas?

tedchou12 commented 1 year ago

Thanks, looks like the URL and the lzone are different.

Could you give the two a try and let me know which it is?

截圖 2023-01-12 上午10 50 38
erbri007 commented 1 year ago

Looks like changing dc_core_r001 to dc_core1 in webull.py was all that was needed. Thank you for the help!

Does on_order_message work for you?

tedchou12 commented 1 year ago

I haven't used it lately, but the last time I used it was arond mid last year? I remembered it worked okay.

erbri007 commented 1 year ago

You're right that mid last year it did work, but not since then for me. It's fairly important, because I try to keep my hits to the servers as few as possible. Because I'm not able to see when an order fills, I have to check periodically, which is more hits to the server than I'd regularly carry out. It's still not a lot, but it's also slower using that method. I tried to find where that's being carried out through chrome developer tools, but have yet to find anything other than it's possibly using a different mechanism these days.

erbri007 commented 1 year ago

I fixed on_order_message, needs an update to streamconn.py. Do you support active developers contributing directly, or do is it better to just open an issue and put the updates there?

zenhorace commented 1 year ago

There are a couple of contributors. If you have a bugfix, feel free to send a PR and one of us will look at it