tedchou12 / webull

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

Issue with get_history_orders() #410

Open MHassanNajafi opened 1 year ago

MHassanNajafi commented 1 year ago

Hi All,

get_history_orders() function has stopped working for me. Anyone else has the same issue?

M1NL1TE commented 1 year ago

Sorry that it's unrelated, but people are having issues logging in now. Are you still able to login with the API?

MHassanNajafi commented 1 year ago

Sorry that it's unrelated, but people are having issues logging in now. Are you still able to login with the API?

Yes. I use the following command to log in: wb.login(MYUSER, MYPASS)

What error does it show when you enter wb.login?

M1NL1TE commented 1 year ago

Sorry that it's unrelated, but people are having issues logging in now. Are you still able to login with the API?

Yes. I use the following command to log in: wb.login(MYUSER, MYPASS)

What error does it show when you enter wb.login?

So the code doesn't abruptly stop with an error just from trying to login but just as a way of checking if the login worked, I always output my account info to the terminal after logging in. So when I do

account_Info = wb.get_account() print(account_info)

I get this

{'timestamp': 36-16 20:00:00-04:00 36-26 05:00:00-04:00 '2023-06-26T13:58:14.355+0000*. 'status': 404, 'error': 'Not Found' I message': 'No message available', 'path': '/webull-paper-center/api/paper/1/acc/'

Are you able to print out your account info without any errors? I also submitted an issue about the image verification failing which is why my login doesn't work

MHassanNajafi commented 1 year ago

Dear M1NL1TE,

I just tried these again, and it worked for me: wb.login(USER, PASS) account_Info = wb.get_account() print(account_Info)

One question. Are you working with live trading or paper trading? In the message you receive, I can see the "paper" term. Maybe that's the reason. Do you import Webull or paper_Webull?

M1NL1TE commented 1 year ago

Dear M1NL1TE,

I just tried these again, and it worked for me:

wb.login(USER, PASS)

account_Info = wb.get_account()

print(account_Info)

One question. Are you working with live trading or paper trading? In the message you receive, I can see the "paper" term. Maybe that's the reason. Do you import Webull or paper_Webull?

I am working with paper trading. I have tried to switch to live trading and the error becomes this: {'msg': 'AccessToken is expire, 'code': 'auth.token.expire', 'data': (), 'success": False}

I tried doing the mfa again but it doesn't work. And now any subsequent attempts at using wb.get_mfa(email) doesn't send any new mfa emails

MHassanNajafi commented 1 year ago

Dear M1NL1TE:

Try these with your live trading:

creds = wb.login(USER, PASS) ACCESS_TOKEN=creds['accessToken'] REFRESH_TOKEN=creds['refreshToken'] TOKEN_EXPIRE=creds['tokenExpireTime'] UUID=creds['uuid'] wb.api_login(access_token=ACCESS_TOKEN, refresh_token=REFRESH_TOKEN,token_expire=TOKEN_EXPIRE, uuid=UUID)

Jakezheng commented 1 year ago

Dear M1NL1TE:

Try these with your live trading:

creds = wb.login(USER, PASS) ACCESS_TOKEN=creds['accessToken'] REFRESH_TOKEN=creds['refreshToken'] TOKEN_EXPIRE=creds['tokenExpireTime'] UUID=creds['uuid'] wb.api_login(access_token=ACCESS_TOKEN, refresh_token=REFRESH_TOKEN,token_expire=TOKEN_EXPIRE, uuid=UUID)

How to get the new "creds " when the old one expire?

M1NL1TE commented 1 year ago

Dear M1NL1TE:

Try these with your live trading:

creds = wb.login(USER, PASS)

ACCESS_TOKEN=creds['accessToken']

REFRESH_TOKEN=creds['refreshToken']

TOKEN_EXPIRE=creds['tokenExpireTime']

UUID=creds['uuid']

wb.api_login(access_token=ACCESS_TOKEN, refresh_token=REFRESH_TOKEN,token_expire=TOKEN_EXPIRE, uuid=UUID)

Those keys don't exist for me. I get a "KeyError: 'accessToken'"

I checked the keys in the creds dictionary/data object and there are no keys for any of those (accessToken,token_expire,uuid) Only noticeable thing I can see in creds is the "failed to verify image verification"

mrazum commented 1 year ago

Hi All,

get_history_orders() function has stopped working for me. Anyone else has the same issue?

I'm experiencing the same issue as well

joecat808 commented 1 year ago

I figured out a workaround for wb.get_history_orders() not working for me.

Currently, wb.get_history_orders() is returning the following error: {'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}

Looks like the issue is the startTime format, "1970-0-1", is no longer working. I tried several different formats to no avail. Instead, I simply removed this parameter from the source file and it's working fine.

Open endpoints.py (site-packages > webull > endpoints.py)

Change line 144 ("orders" function within urls class) so that startDate is removed: def orders(self, account_id, page_size):

return f'{self.base_ustradebroker_url}/trade/v2/option/list?secAccountId={account_id}&startTime=1970-0-1&dateType=ORDER&pageSize={page_size}&status='

return f'{self.base_ustradebroker_url}/trade/v2/option/list?secAccountId={account_id}&dateType=ORDER&pageSize={page_size}&status='

Save and rerun. This worked for me.

Jakezheng commented 1 year ago

I figured out a workaround for wb.get_history_orders() not working for me.

Currently, wb.get_history_orders() is returning the following error: {'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}

Looks like the issue is the startTime format, "1970-0-1", is no longer working. I tried several different formats to no avail. Instead, I simply removed this parameter from the source file and it's working fine.

Open endpoints.py (site-packages > webull > endpoints.py)

Change line 144 ("orders" function within urls class) so that startDate is removed: def orders(self, account_id, page_size): #return f'{self.base_ustradebroker_url}/trade/v2/option/list?secAccountId={account_id}&startTime=1970-0-1&dateType=ORDER&pageSize={page_size}&status=' return f'{self.base_ustradebroker_url}/trade/v2/option/list?secAccountId={account_id}&dateType=ORDER&pageSize={page_size}&status='

Save and rerun. This worked for me.

Any idea how to stay login and refresh tokens?

MHassanNajafi commented 1 year ago

I figured out a workaround for wb.get_history_orders() not working for me.

Currently, wb.get_history_orders() is returning the following error: {'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}

Looks like the issue is the startTime format, "1970-0-1", is no longer working. I tried several different formats to no avail. Instead, I simply removed this parameter from the source file and it's working fine.

Open endpoints.py (site-packages > webull > endpoints.py)

Change line 144 ("orders" function within urls class) so that startDate is removed: def orders(self, account_id, page_size): #return f'{self.base_ustradebroker_url}/trade/v2/option/list?secAccountId={account_id}&startTime=1970-0-1&dateType=ORDER&pageSize={page_size}&status=' return f'{self.base_ustradebroker_url}/trade/v2/option/list?secAccountId={account_id}&dateType=ORDER&pageSize={page_size}&status='

Save and rerun. This worked for me.

This was exactly the same solution I found and worked for me.

sitrucb286 commented 1 year ago

to open endpoint, I did from webull import endpoints and right-click endpoints and open definitions to get to line 144 and then changed the >> return basically deleting '&startTime=1970-0-1'. Thanks "Hassan"

rakesh433jntu commented 12 months ago

@MHassanNajafi @sitrucb286 you are amazing. it is working for me. Thank you,..!!