Closed shalli2 closed 7 months ago
It seems like I can get both of the endpoints working...
It seems like I can get both of the endpoints working...
can you post the code for get_activities or get_history_orders, get_account() works for me but not the other two? My code is below: wb = webull() f = None credential_data = None try:
f = open("wb_token.txt", "r") credential_data = json.load(f) except: print("First time login to webull.") pass if credential_data is None:
print(wb.get_mfa(wb_user)) print(wb.get_security(wb_user)) mfa_code = input("MFA Code: ") credential_data = wb.login(...) f = open("wb_token.txt", "w") f.write(json.dumps(credential_data)) f.close() data = wb.get_account() else: wb._refresh_token = credential_data['refreshToken'] wb._access_token = credential_data['accessToken'] wb._token_expire = credential_data['tokenExpireTime'] wb._uuid = credential_data['uuid'] n_data = wb.refresh_login() credential_data['refreshToken'] = n_data['refreshToken'] credential_data['accessToken'] = n_data['accessToken'] credential_data['tokenExpireTime'] = n_data['tokenExpireTime'] if credential_data is not None: file = open('wb_token.txt', 'w') json.dump(credential_data, file) file.close() data_h = wb.get_history_orders() data_a = wb.get_account()
can you format your code?
can you format your code?
Here it is.. sample-webull.py.txt
you can get a output on line 36?
you dont seem to have line 32 to 36 indented...
you dont seem to have line 32 to 36 indented...
Hi, I missed indentation there when I was sending it to you. That is not the problem, it works for get_account but not for other two.
your code works for me.
What is the output for get_account()
?
your code works for me. What is the output for
get_account()
?
Output is the account details and positions. Can you post your code that is working for you? I am using Ubuntu 20.04 version
The code:
import json
from webull_package.webull import webull
wb = webull()
f = None
credential_data = None
try:
# if this fails, delete wb_token.txt and run again, enter MFA code sent to email. this will create new wb_token.txt
f = open("webull_credentials.json", "r")
credential_data = json.load(f)
except:
print("First time login to webull.")
pass
if credential_data is None:
# If first time save login as token
print(wb.get_mfa(wb_user))
print(wb.get_security(wb_user))
mfa_code = input("MFA Code: ")
credential_data = wb.login(...)
f = open("webull_credentials.json", "w")
f.write(json.dumps(credential_data))
f.close()
data = wb.get_account()
else:
wb._refresh_token = credential_data['refreshToken']
wb._access_token = credential_data['accessToken']
wb._token_expire = credential_data['tokenExpireTime']
wb._uuid = credential_data['uuid']
n_data = wb.refresh_login()
credential_data['refreshToken'] = n_data['refreshToken']
credential_data['accessToken'] = n_data['accessToken']
credential_data['tokenExpireTime'] = n_data['tokenExpireTime']
if credential_data is not None:
file = open('webull_credentials.json', 'w')
json.dump(credential_data, file)
file.close()
data_h = wb.get_history_orders()
data_a = wb.get_account()
print(data_h)
output:
mac@TeddeMBP webull_demo % python3 sample-webull.py
[{'comboTickerType': 'stock', 'outsideRegularTradingHour': False, 'orders': [{'orderId': 5232419828886612120, 'tickerType': 'EQUITY', 'ticker': {'tickerId': 913256135, 'symbol': 'AAPL', 'name': 'Apple Inc', 'tinyName': 'Apple Inc', 'listStatus': 1, 'exchangeCode': 'NSQ', 'exchangeId': 96, 'type': 2, 'regionId': 6, 'currencyId': 247, 'currencyCode': 'USD', 'secType': [61], 'disExchangeCode': 'NASDAQ', 'disSymbol': 'AAPL'}, 'action': 'BUY', 'orderType': 'MKT', 'totalQuantity': '0.01', 'tickerId': 913256135, 'timeInForce': 'DAY', 'optionExercisePrice': '0.00', 'filledQuantity': '0', 'entrustType': 'QTY', 'placeAmount': '0', 'filledAmount': '0', 'remainAmount': '0', 'statusCode': 'Failed', 'statusStr': 'Failed', 'symbol': 'AAPL', 'optionContractMultiplier': '0', 'optionContractDeli...}
which looked fine
output:
mac@TeddeMBP webull_demo % python3 sample-webull.py [{'comboTickerType': 'stock', 'outsideRegularTradingHour': False, 'orders': [{'orderId': 5232419828886612120, 'tickerType': 'EQUITY', 'ticker': {'tickerId': 913256135, 'symbol': 'AAPL', 'name': 'Apple Inc', 'tinyName': 'Apple Inc', 'listStatus': 1, 'exchangeCode': 'NSQ', 'exchangeId': 96, 'type': 2, 'regionId': 6, 'currencyId': 247, 'currencyCode': 'USD', 'secType': [61], 'disExchangeCode': 'NASDAQ', 'disSymbol': 'AAPL'}, 'action': 'BUY', 'orderType': 'MKT', 'totalQuantity': '0.01', 'tickerId': 913256135, 'timeInForce': 'DAY', 'optionExercisePrice': '0.00', 'filledQuantity': '0', 'entrustType': 'QTY', 'placeAmount': '0', 'filledAmount': '0', 'remainAmount': '0', 'statusCode': 'Failed', 'statusStr': 'Failed', 'symbol': 'AAPL', 'optionContractMultiplier': '0', 'optionContractDeli...}
which looked fine
What is your setup? OS and versions?
output:
mac@TeddeMBP webull_demo % python3 sample-webull.py [{'comboTickerType': 'stock', 'outsideRegularTradingHour': False, 'orders': [{'orderId': 5232419828886612120, 'tickerType': 'EQUITY', 'ticker': {'tickerId': 913256135, 'symbol': 'AAPL', 'name': 'Apple Inc', 'tinyName': 'Apple Inc', 'listStatus': 1, 'exchangeCode': 'NSQ', 'exchangeId': 96, 'type': 2, 'regionId': 6, 'currencyId': 247, 'currencyCode': 'USD', 'secType': [61], 'disExchangeCode': 'NASDAQ', 'disSymbol': 'AAPL'}, 'action': 'BUY', 'orderType': 'MKT', 'totalQuantity': '0.01', 'tickerId': 913256135, 'timeInForce': 'DAY', 'optionExercisePrice': '0.00', 'filledQuantity': '0', 'entrustType': 'QTY', 'placeAmount': '0', 'filledAmount': '0', 'remainAmount': '0', 'statusCode': 'Failed', 'statusStr': 'Failed', 'symbol': 'AAPL', 'optionContractMultiplier': '0', 'optionContractDeli...}
which looked fine
What is your setup? OS and versions?
Can you also send your webull.py and endpoints.py files?
I don't think OS makes a difference.
The files I have used are the latest files in the package, just update it is fine.
Getting "405 response" for get_activities. get_history_orders() is also not working. get_account works with the same setup/tokens.