Closed manojjenago closed 3 years ago
interesting... Can you post the entire code? but delete the password and pin.
I am using the below code
from webull import webull, endpoints # for real money trading, just import 'webull' instead
from webull.streamconn import StreamConn
import paho.mqtt.client as mqtt
import json
import trendln
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
matplotlib.interactive(True)
import numpy as np
import pandas as pd
from datetime import datetime
import sched
import time
import config
print("Logging in to WeBull...")
#login to Webull
wb = webull()
f = None
s = sched.scheduler(time.time, time.sleep)
fh = open('webull_credentials.json', 'r')
credential_data = json.load(fh)
fh.close()
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']
file = open('webull_credentials.json', 'w')
json.dump(credential_data, file)
file.close()
# important to get the account_id
accountid= wb.get_account_id()
getpositions = wb.get_positions()
print(accountid)
wb.get_trade_token(config.PASSWORD)
print(getpositions)
order = wb.place_order( stock='AAPL', action='BUY', orderType='MKT', enforce='DAY', quant=1)
I am getting the account id and the positions , but not able to place the order . However when I change to paper then I am able to see in webull paper account
I am using the below code
from webull import webull, endpoints # for real money trading, just import 'webull' instead from webull.streamconn import StreamConn import paho.mqtt.client as mqtt import json import trendln import matplotlib import matplotlib.pyplot as plt import matplotlib.dates as mdates matplotlib.interactive(True) import numpy as np import pandas as pd from datetime import datetime import sched import time import config print("Logging in to WeBull...") #login to Webull wb = webull() f = None s = sched.scheduler(time.time, time.sleep) fh = open('webull_credentials.json', 'r') credential_data = json.load(fh) fh.close() 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'] file = open('webull_credentials.json', 'w') json.dump(credential_data, file) file.close() # important to get the account_id accountid= wb.get_account_id() getpositions = wb.get_positions() print(accountid) wb.get_trade_token(config.PASSWORD) print(getpositions) order = wb.place_order( stock='AAPL', action='BUY', orderType='MKT', enforce='DAY', quant=1)
I am getting the account id and the positions , but not able to place the order . However when I change to paper then I am able to see in webull paper account
Never mind figured out, somehow my trading was blocked by webull for sometime, Now I can able to place orders. Sorry for inconvience caused.
And I must admid that you are the only person I have seen who responds to queries immidiately.
Thanks for that and hope you all good wishes , Learned a lot from this post ...
Hi, I am getting a weird error , where I can able to place orders in paper trading , but when I change to webull (to palce actual Orders), it did no work. Do I need to change anything else here ??
I am getting the account id and then able to place the paper trading ordres successfully though.
`accountid= wb.get_account_id()'
But when I change to webull from paper trading , I am not able to place any orders with same code that works in paper trading I changed the below
from webull import paper_webull, endpoints
tofrom webull import webull, endpoints. It did not work
and from
wb = paper_webull()
towb = webull()
Please let me know if anything need to be changed ..
Thanks, Manoj