Skip to content

Commit 8b8f7b7

Browse files
committed
push version 0.2.9
1 parent bf434ac commit 8b8f7b7

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
## Overview
1717

18+
Current Version: **0.2.9**
19+
1820
The unofficial Python API client library for TD Ameritrade allows individuals with TD Ameritrade accounts to manage trades, pull historical and real-time data, manage their accounts, create and modify orders all using the Python programming language.
1921

2022
To learn more about the TD Ameritrade API, please refer to the [official documentation](https://developer.tdameritrade.com/apis).
@@ -60,6 +62,12 @@ The project can be found at PyPI, if you'd like to view the project please use t
6062
pip install td-ameritrade-python-api
6163
```
6264

65+
To upgrade the library run the following command:
66+
67+
```bash
68+
pip install --upgrade td-ameritrade-python-api
69+
```
70+
6371
## Usage
6472

6573
This example demonstrates how to login to the API and demonstrates sending a request using the `get_quotes` endpoint, using your API key.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# I'm in alpha development still, so a compliant version number is a1.
1818
# read this as MAJOR VERSION 0, MINOR VERSION 1, MAINTENANCE VERSION 0
19-
version='0.2.8',
19+
version='0.2.9',
2020

2121
# here is a simple description of the library, this will appear when
2222
# someone searches for the library on https://pypi.org/search

td/stream.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io
44
import json
55
import os
6+
import textwrap
67
import unicodedata
78
import urllib
89

@@ -562,26 +563,34 @@ def close_logic(self, logic_type: str) -> bool:
562563

563564
async def close_stream(self) -> None:
564565
"""Closes the connection to the streaming service."""
565-
566-
print('Connection with server closed, beginning close process...')
567566

568567
# close the connection.
569568
await self.connection.close()
570569

570+
# Define the Message.
571+
message = textwrap.dedent("""
572+
{lin_brk}
573+
CLOSING PROCESS INITIATED:
574+
{lin_brk}
575+
WebSocket Closed: True
576+
Event Loop Closed: True
577+
{lin_brk}
578+
""").format(lin_brk="="*80)
579+
571580
# Shutdown all asynchronus generators.
572581
await self.loop.shutdown_asyncgens()
573582

574583
# Stop the loop.
575584
if self.loop.is_running():
576585
self.loop.call_soon_threadsafe(self.loop.stop())
577-
578-
self.loop.close()
586+
print(message)
587+
await asyncio.sleep(3)
579588

580-
# Once closed, verify it's closed.
581-
if self.loop.is_closed():
582-
print('Event loop was closed.')
583-
else:
584-
print('Event loop was not closed.')
589+
# # Once closed, verify it's closed.
590+
# if self.loop.is_closed():
591+
# print('Event loop was closed.')
592+
# else:
593+
# print('Event loop was not closed.')
585594

586595
# # cancel all the task.
587596
# for index, task in enumerate(asyncio.Task.all_tasks()):
@@ -706,7 +715,7 @@ async def _receive_message(self, return_value: bool = False) -> dict:
706715
elif self.print_to_console:
707716
print('='*20)
708717
print('Message Received:')
709-
print('')
718+
print('-'*20)
710719
print(message_decoded)
711720
print('-'*20)
712721
print('')
@@ -715,7 +724,7 @@ async def _receive_message(self, return_value: bool = False) -> dict:
715724

716725
# stop the connection if there is an error.
717726
await self.close_stream()
718-
break
727+
break
719728

720729
async def _parse_json_message(self, message: str) -> dict:
721730
"""Parses incoming messages from the stream

0 commit comments

Comments
 (0)