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

Added actives functions to StreamClient. #324

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions tda/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -1929,3 +1929,126 @@ def add_news_headline_handler(self, handler):
'''
self._handlers['NEWS_HEADLINE'].append(
self._BookHandler(handler, self.NewsHeadlineFields))

##########################################################################
# ACTIVES

class ActivesFields(_BaseFieldEnum):
'''
`Official documentation <https://developer.tdameritrade.com/content/
streaming-data#_Toc504640583>`__
'''
SYMBOL = 0
ACTIVES_DATA = 1

async def actives_options_subs(self, keys):
'''
`Official documentation <https://developer.tdameritrade.com/content/
streaming-data#_Toc504640583>`__

Subscribe to the day's top traded option symbols.
'''
await self._service_op(keys, 'ACTIVES_OPTIONS', 'SUBS',
self.ActivesFields,
fields=self.ActivesFields.all_fields())

async def actives_options_unsubs(self, keys):
'''
`Official documentation <https://developer.tdameritrade.com/content/
streaming-data#_Toc504640583>`__

Un-Subscribe from active option symbols.
'''
await self._service_op(keys, 'ACTIVES_OPTIONS', 'UNSUBS')

def add_actives_options_handler(self, handler):
'''
Register a function to handle active options as they are provided. See
:ref:`registering_handlers` for details.
'''
self._handlers['ACTIVES_OPTIONS'].append(_Handler(handler,
self.ActivesFields))

async def actives_otcbb_subs(self, keys):
'''
`Official documentation <https://developer.tdameritrade.com/content/
streaming-data#_Toc504640583>`__

Subscribe to the most active OTCBB symbols.
'''
await self._service_op(keys, 'ACTIVES_OTCBB', 'SUBS',
self.ActivesFields,
fields=self.ActivesFields.all_fields())

async def actives_otcbb_unsubs(self, keys):
'''
`Official documentation <https://developer.tdameritrade.com/content/
streaming-data#_Toc504640583>`__

Un-Subscribe from the most active OTCBB symbols.
'''
await self._service_op(keys, 'ACTIVES_OTCBB', 'UNSUBS')

def add_actives_otcbb_handler(self, handler):
'''
Register a function to handle actives as they are provided. See
:ref:`registering_handlers` for details.
'''
self._handlers['ACTIVES_OTCBB'].append(_Handler(handler,
self.ActivesFields))

async def actives_nyse_subs(self, keys):
'''
`Official documentation <https://developer.tdameritrade.com/content/
streaming-data#_Toc504640583>`__

Subscribe to the NYSE's most active symbols.
'''
await self._service_op(keys, 'ACTIVES_NYSE', 'SUBS',
self.ActivesFields,
fields=self.ActivesFields.all_fields())

async def actives_nyse_unsubs(self, keys):
'''
`Official documentation <https://developer.tdameritrade.com/content/
streaming-data#_Toc504640583>`__

Un-Subscribe from NYSE actives.
'''
await self._service_op(keys, 'ACTIVES_NYSE', 'UNSUBS')

def add_actives_nyse_handler(self, handler):
'''
Register a function to handle actives as they are provided. See
:ref:`registering_handlers` for details.
'''
self._handlers['ACTIVES_NYSE'].append(_Handler(handler,
self.ActivesFields))

async def actives_nasdaq_subs(self, keys):
'''
`Official documentation <https://developer.tdameritrade.com/content/
streaming-data#_Toc504640583>`__

Subscribe to the NASDAQ's most active symbols.
'''
await self._service_op(keys, 'ACTIVES_NASDAQ', 'SUBS',
self.ActivesFields,
fields=self.ActivesFields.all_fields())

async def actives_nasdaq_unsubs(self, keys):
'''
`Official documentation <https://developer.tdameritrade.com/content/
streaming-data#_Toc504640583>`__

Un-Subscribe from NASDAQ actives.
'''
await self._service_op(keys, 'ACTIVES_NASDAQ', 'UNSUBS')

def add_actives_nasdaq_handler(self, handler):
'''
Register a function to handle actives as they are provided. See
:ref:`registering_handlers` for details.
'''
self._handlers['ACTIVES_NASDAQ'].append(_Handler(handler,
self.ActivesFields))