tedchou12 / webull

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

getting issue fetching orders using wb.get_history_orders() #418

Closed hadenponish1 closed 11 months ago

hadenponish1 commented 11 months ago

This seems to be an issue that's occurred in the last 48 hrs or so as I was previsouly able to extract orders no problem.

my code looks like this

from webull import webull # for paper trading, import 'paper_webull'
from dotenv import load_dotenv
import os

# Load environment variables from .env file
load_dotenv()
webull_email = os.environ['webull_email']
webull_pass = os.environ['webull_pass']

wb = webull()
wb._did = os.environ['did']
access_token = os.environ['access_token']
wb.get_trade_token(access_token)

if wb.login(webull_email, webull_pass):
    print("Success Login")

###get all orders from account history 
orders = wb.get_history_orders(status = 'All', count = 10000)
print(orders)

now my error message returned is

{'msg': 'secAccountId=null', 'code': '400', 'success': False}

adding an secAccountId parameter to the function returns an error as an unexpected keyword argument. I also tried updating webull module with no luck.

hadenponish1 commented 11 months ago

resolved with a workaround/hybrid of the suggestions left in this thread -> https://github.com/tedchou12/webull/issues/410

I noticed my access_token and did had changed from the previously stored creds I had. Manually pulled by opening network tab after logging in an incognito browser (v2 query for those looking) and replaced these as well as the UUID which I didn't use before. Adjusted the code to

from webull import webull # for paper trading, import 'paper_webull'
from dotenv import load_dotenv
import os

# Load environment variables from .env file
load_dotenv()
webull_email = os.environ['webull_email']
webull_pass = os.environ['webull_pass']
webull_access_token = os.environ['access_token']
webull_uuid = os.environ['webull_uuid']

wb = webull()

creds = wb.login(webull_email, webull_pass)
wb.api_login(access_token= webull_access_token, uuid = webull_uuid)
orders = wb.get_history_orders(status = 'All', count = 10000)
print(len(orders))

and works like a charm. Closing issue.

hadenponish1 commented 11 months ago

closing