Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

barchart data #5

Open
Oriono opened this issue Apr 10, 2021 · 0 comments
Open

barchart data #5

Oriono opened this issue Apr 10, 2021 · 0 comments

Comments

@Oriono
Copy link

Oriono commented Apr 10, 2021

Hi Alex,

Awesome work! similar to your TD api, this saved me a lot of time from building it from scratch.

Everything seems to work fine besides the barchart data part.

I tried to use small time window to avoid data overload, even tho I couldn't get any of those barchart historical data functions working:

ts_client.stream_bars_start_date('TSLA',5,'Minute','2021-4-5','USEQPreAndPost')

and it gave me the following error:

ValueError                                Traceback (most recent call last)
/usr/local/lib/python3.9/site-packages/urllib3/response.py in _update_chunk_length(self)
    696         try:
--> 697             self.chunk_left = int(line, 16)
    698         except ValueError:

ValueError: invalid literal for int() with base 16: b''

During handling of the above exception, another exception occurred:

InvalidChunkLength                        Traceback (most recent call last)
/usr/local/lib/python3.9/site-packages/urllib3/response.py in _error_catcher(self)
    437             try:
--> 438                 yield
    439 

/usr/local/lib/python3.9/site-packages/urllib3/response.py in read_chunked(self, amt, decode_content)
    763             while True:
--> 764                 self._update_chunk_length()
    765                 if self.chunk_left == 0:

/usr/local/lib/python3.9/site-packages/urllib3/response.py in _update_chunk_length(self)
    700             self.close()
--> 701             raise InvalidChunkLength(self, line)
    702 

InvalidChunkLength: InvalidChunkLength(got length b'', 0 bytes read)

During handling of the above exception, another exception occurred:

ProtocolError                             Traceback (most recent call last)
/usr/local/lib/python3.9/site-packages/requests/models.py in generate()
    752                 try:
--> 753                     for chunk in self.raw.stream(chunk_size, decode_content=True):
    754                         yield chunk

/usr/local/lib/python3.9/site-packages/urllib3/response.py in stream(self, amt, decode_content)
    571         if self.chunked and self.supports_chunked_reads():
--> 572             for line in self.read_chunked(amt, decode_content=decode_content):
    573                 yield line

/usr/local/lib/python3.9/site-packages/urllib3/response.py in read_chunked(self, amt, decode_content)
    792             if self._original_response:
--> 793                 self._original_response.close()
    794 

/usr/local/Cellar/[email protected]/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py in __exit__(self, type, value, traceback)
    134             try:
--> 135                 self.gen.throw(type, value, traceback)
    136             except StopIteration as exc:

/usr/local/lib/python3.9/site-packages/urllib3/response.py in _error_catcher(self)
    454                 # This includes IncompleteRead.
--> 455                 raise ProtocolError("Connection broken: %r" % e, e)
    456 

ProtocolError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

During handling of the above exception, another exception occurred:

ChunkedEncodingError                      Traceback (most recent call last)
~/Documents/Fun/trading/apis/ts.py in 
----> 43 ts_client.stream_bars_start_date('TSLA',5,'Minute','2021-4-5','USEQPreAndPost')

~/Documents/Fun/trading/apis/client.py in stream_bars_start_date(self, symbol, interval, unit, start_date, session)
   1024 
   1025         # grab the response.
-> 1026         response = self._handle_requests(
   1027             url=url_endpoint,
   1028             method='get',

~/Documents/Fun/trading/apis/client.py in _handle_requests(self, url, method, headers, args, stream, payload)
    523                 response = requests.get(
    524                     url=url, headers=headers, params=args, verify=True, stream=True)
--> 525                 for line in response.iter_lines(chunk_size=300):
    526 
    527                     if 'END' not in line.decode() and line.decode() != '':

/usr/local/lib/python3.9/site-packages/requests/models.py in iter_lines(self, chunk_size, decode_unicode, delimiter)
    795         pending = None
    796 
--> 797         for chunk in self.iter_content(chunk_size=chunk_size, decode_unicode=decode_unicode):
    798 
    799             if pending is not None:

/usr/local/lib/python3.9/site-packages/requests/models.py in generate()
    754                         yield chunk
    755                 except ProtocolError as e:
--> 756                     raise ChunkedEncodingError(e)
    757                 except DecodeError as e:
    758                     raise ContentDecodingError(e)

ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

I thought it might be Tradestation API issue, then I checked in Postman and it worked fine.
image

Could you take a look when you have time and see if it could be an easy fix?

Thanks,
Orion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant