tedchou12 / webull

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

issue fetching orders using get_history_orders() #403

Closed hadenponish1 closed 1 year ago

hadenponish1 commented 1 year ago

I had previously been able to retrieve orders using the get_history_orders() function but as of this morning seems to be raising errors I'm unable to troubleshoot or seen solutions for.

My code is pretty simple,

from webull import webull # for paper trading, import 'paper_webull'

webull_email = **email**
webull_pass = **password**

wb = webull()

did = **did from response headers**
wb._did = did

at_ = **at from response headers** 
wb.get_trade_token(at_)

wb.login(webull_email, webull_pass)

I previously used this line to get order history no problem but today am recieving the following response

orders = wb.get_history_orders(status = 'All', count = 20)

{'msg': "org.springframework.validation.BeanPropertyBindingResult: 1 errors\nField error in object 'orderPageQueryParam' on field 'startTime': rejected value [1970-0-1]; codes [typeMismatch.orderPageQueryParam.startTime,typeMismatch.startTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [orderPageQueryParam.startTime,startTime]; arguments []; default message [startTime]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'startTime'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.util.Date] for value '1970-0-1'; nested exception is java.lang.IllegalArgumentException]",
 'code': '400',
 'success': False}

I've tried uninstalling webull, reinstalling, and upgrading package thinking there may have been an update I missed but no luck. Given the error, I also tried including startTime parameters with no luck. Adding these return a different error which is somewhat expected of "unexpected keyword argument 'startTime'.

I've tested other functions to confirm I'm logged in properly testing wb.is_logged_in() and wb.get_watchlists() which both work as expected.

Any help would be greatly appreciated.

*** also tried following solutions here https://github.com/tedchou12/webull/issues/394 with no luck.

BobLiu20 commented 1 year ago

me too. seems webull change api

BobLiu20 commented 1 year ago

I fix it. just change '1970-0-1' to '1970-1-1' in entpoints.py file

hadenponish1 commented 1 year ago

hmm. Doesn't seem to work for me @BobLiu20 Did you happen to change anything else? I replaced in these lines

    def orders(self, account_id, page_size):
        return f'{self.base_ustradebroker_url}/trade/v2/option/list?secAccountId={account_id}&startTime=1970-1-1&dateType=ORDER&pageSize={page_size}&status='

    def history(self, account_id):
        return f'{self.base_ustrade_url}/trading/v1/webull/order/list?secAccountId={account_id}'

    def paper_orders(self, paper_account_id, page_size):
        return f'{self.base_paper_url}/paper/1/acc/{paper_account_id}/order?&startTime=1970-1-1&dateType=ORDER&pageSize={page_size}&status='
hadenponish1 commented 1 year ago

@BobLiu20 wanted to bump this. Did you happen to change anything else in the endpoints.py file? I provided the code where I changed the 1970-0-1 to 1970-1-1 like you suggested with no luck. I had also tried variations like 1970-01-01 and others.

hadenponish1 commented 1 year ago

Just removed the startTime parameter in request URL and does is the trick. I know it's not the ideal way but does the job for now. Closing and will continue to debug for a more correct solution.

    return f'{self.base_ustradebroker_url}/trade/v2/option/list?secAccountId={account_id}&dateType=ORDER&pageSize={page_size}&status=' ##work around for now, removed the date parameter and works correctly.