tedchou12 / webull

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

get_history_orders returns [] #218

Closed MHassanNajafi closed 3 years ago

MHassanNajafi commented 3 years ago

Hi,

I'm working on two different accounts. I was using one of them for a few months now with many orders. The other account is new with a few orders.

get_history_orders(status='Filled',count=5) on the first account works fine but on the second account returns [ ]. Any idea what the problem might be?

Thanks

MHassanNajafi commented 3 years ago

Has anyone here have difficulty using the get_history_orders function? I have a new and an old Webull account. get_history_orders works with the old account but not with the new one. Is there any chance they changed something in the new accounts?

tedchou12 commented 3 years ago

@MHassanNajafi I have no issues. With the new account, did you ensure you logged in successfully? Are you able to do get_account() on the new account?

MHassanNajafi commented 3 years ago

@tedchou12 Yes. I have logged in successfully and get_account() returns account information. It's so weird. Is your account new? I opened my new account two weeks ago.

@MHassanNajafi I have no issues. With the new account, did you ensure you logged in successfully? Are you able to do get_account() on the new account?

tedchou12 commented 3 years ago

@MHassanNajafi Are you sure you have historical orders? they do show up on your webull app?

tedchou12 commented 3 years ago

If you do get_history_orders(status='All',count=5) do you get anything?

MHassanNajafi commented 3 years ago

@tedchou12 For my old account, I get the details of the five last orders and for the new account I get [ ].

If you do get_history_orders(status='All',count=5) do you get anything?

MHassanNajafi commented 3 years ago

@tedchou12

1) how old is your account?

2) Any chance this caused by some changes from Webull in new accounts? I see get_history_orders function request for orders in the following format:

https://tradeapi.webullbroker.com/api/trade/v2/option/list?secAccountId={account_id}&startTime=1970-0-1&dateType=ORDER&pageSize={page_size}&status='

Any chance "v2" is for old accounts and for recently opened accounts the format for requesting orders has changed?

tedchou12 commented 3 years ago

@MHassanNajafi

  1. Mine account is old, 3-4 years already.
  2. That might be the case. You can try changing v2 to v3...or something, but I recommend try to do inspect, is faster. https://www.youtube.com/watch?v=2dz8PTMa8p0&t=327s
MHassanNajafi commented 3 years ago

@tedchou12 My old account that is two years old works fine too. But my new account seems to have a problem with get_history_orders function. I tried inspect but had no success in finding the new format of requesting detail of order history. Anyone here you suggest I contact for this? Today I even tried another 2-weeks old account and same issue exists for that account. So this might be an issue for any new user.

@MHassanNajafi

  1. Mine account is old, 3-4 years already.
  2. That might be the case. You can try changing v2 to v3...or something, but I recommend try to do inspect, is faster. https://www.youtube.com/watch?v=2dz8PTMa8p0&t=327s
tedchou12 commented 3 years ago

@MHassanNajafi If you really want to get the new account to work. Please send a email to me. ted.chou12@gmail . com. I have to take a look to see what's happening.

MHassanNajafi commented 3 years ago

@tedchou12

I was able to finally solve the issue by replacing the current order request URL:

f'https://tradeapi.webullbroker.com/api/trade/v2/option/list?secAccountId={account_id}&startTime=1970-0-1&dateType=ORDER&pageSize={page_size}&status='

with this one:

f'https://ustrade.webullbroker.com/api/trade/v2/option/list?secAccountId={account_id}&startTime=1970-0-1&dateType=ORDER&pageSize={page_size}&status='

It seems that for my new account the order history should now be fetched from ustrade.webullbroker.com rather than tradeapi.webullbroker.com. The tradeapi address only works with my 2 years old account. But ustrade address works for both my accounts.

Many thanks for helping me with this.

@MHassanNajafi If you really want to get the new account to work. Please send a email to me. ted.chou12@gmail . com. I have to take a look to see what's happening.