tedchou12 / webull

Unofficial APIs for Webull.
MIT License
597 stars 183 forks source link

Issue with get_bars(self, stock=None, tId = None, interval='m1', count=1, extendTrading=0, timeStamp=None) Function #238

Closed scally88 closed 3 years ago

scally88 commented 3 years ago

I am trying to use the timeStamp input variable of the function. Whenever I try to provide an epoc timestamp I get an error with the received data. The error log I get is as follows:


KeyError Traceback (most recent call last)

in 12 acode = input('Enter your name:') 13 login_data = wb.login(username, pw, devname, acode) ---> 14 data=wb.get_bars(stock='AAPL', interval='m1', extendTrading=0, timeStamp=datetime.datetime.today().astimezone(pytz.timezone('America/New_York')).now().timestamp()) 15 print(data.index[0]) c:\users\ericd\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages\webull\webull.py in get_bars(self, stock, tId, interval, count, extendTrading, timeStamp) 823 response = requests.get(self._urls.bars(tId), params=params, headers=headers) 824 result = response.json() --> 825 time_zone = timezone(result[0]['timeZone']) 826 for row in result[0]['data']: 827 row = row.split(',') KeyError: 0 Also, I have tried providing the following different epoc time variables but still get the same error. The declarations are as follows: datetime.datetime.now().timestamp() time.time() Anyone have any ideas?
boonyeow commented 3 years ago

Hey buddy, can you try rounding off your timestamp to the nearest whole number and see if it works?

image

I don't think their API takes in decimal as parameter for timeStamp.

scally88 commented 3 years ago

I tried it out and that seems to be what the problem was. The API didn't like the decimal value. Applied a floor function to the timestamp everything seems to work out.

Thanks!