Skip to content

Commit 5a68b16

Browse files
authored
Streaming changes according to Schwab_Trader_API_-_Streamer_Guide.pdf (#127)
* Field names changed according documentation * Documentation changed to reflect function name changes for NYSE_BOOK service * Changes as requested in the second round of comments from @alexgolec * TIMESALE_EQUITY, TIMESALE_FUTURES, TIMESALE_OPTIONS and NEWS_HEADLINE services removed because aren't supported by Schwab * Added support for SCREENER_EQUITY and SCREENER_OPTION services. * Added LOGOUT and ADD functions on level one and book services. * Minor fixes requested by @alexgolec
1 parent 2e7ff09 commit 5a68b16

File tree

3 files changed

+2765
-1843
lines changed

3 files changed

+2765
-1843
lines changed

docs/streaming.rst

+93-62
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ exception.
7676
.. automethod:: schwab.streaming.StreamClient.login
7777

7878

79+
-----------
80+
Logging Out
81+
-----------
82+
83+
For a clean exit, it's recommended to log out of the stream when you're done.
84+
85+
.. automethod:: schwab.streaming.StreamClient.logout
86+
87+
7988
----------------------
8089
Subscribing to Streams
8190
----------------------
@@ -96,14 +105,24 @@ subscription methods again seems to clear the old subscription and create a new
96105
one. Note this behavior is not officially documented, so this interpretation may
97106
be incorrect.
98107

108+
109+
----------------------
110+
Add symbols to Streams
111+
----------------------
112+
113+
These functions have names that follow the pattern ``SERVICE_NAME_add``.
114+
These functions send a request to add to the list of subscribed symbols for a
115+
particular data stream.
116+
117+
99118
-------------------------
100119
Un-Subscribing to Streams
101120
-------------------------
102121

103-
These functions have names that follow the pattern ``SERVICE_NAME_unsubs``.
104-
These functions send a request to disable the symbols of a streaming data for a
105-
particular data stream. They are *not* thread safe, so they should only be
106-
called in series. When unsubscribing to services with symbols, symbols which
122+
These functions have names that follow the pattern ``SERVICE_NAME_unsubs``.
123+
These functions send a request to disable the symbols of a streaming data for a
124+
particular data stream. They are *not* thread safe, so they should only be
125+
called in series. When unsubscribing to services with symbols, symbols which
107126
were not explicitly unsubscribed remain subscribed.
108127

109128

@@ -224,12 +243,15 @@ to our `Discord server <https://discord.gg/BEr6y6Xqyv>`__. We'll be updating
224243
this page as we discover new things.
225244

226245
The following streams are confirmed working:
227-
* :ref:`equity_charts`
228-
* :ref:`level_one_quotes_stream`
229-
* :ref:`level_one_option_stream`
246+
* :ref:`charts`
247+
* :ref:`level_one`
230248
* :ref:`level_two`
249+
* :ref:`screener`
250+
* :ref:`account_activity`
231251

232252

253+
.. _charts:
254+
233255
++++++++++++
234256
OHLCV Charts
235257
++++++++++++
@@ -293,6 +315,7 @@ Level one quotes for equities traded on NYSE, AMEX, and PACIFIC.
293315

294316
.. automethod:: schwab.streaming::StreamClient.level_one_equity_subs
295317
.. automethod:: schwab.streaming::StreamClient.level_one_equity_unsubs
318+
.. automethod:: schwab.streaming::StreamClient.level_one_equity_add
296319
.. automethod:: schwab.streaming::StreamClient.add_level_one_equity_handler
297320
.. autoclass:: schwab.streaming::StreamClient.LevelOneEquityFields
298321
:members:
@@ -311,12 +334,15 @@ available option symbols.
311334

312335
.. automethod:: schwab.streaming::StreamClient.level_one_option_subs
313336
.. automethod:: schwab.streaming::StreamClient.level_one_option_unsubs
337+
.. automethod:: schwab.streaming::StreamClient.level_one_option_add
314338
.. automethod:: schwab.streaming::StreamClient.add_level_one_option_handler
315339
.. autoclass:: schwab.streaming::StreamClient.LevelOneOptionFields
316340
:members:
317341
:undoc-members:
318342

319343

344+
.. _level_one_futures_stream:
345+
320346
--------------
321347
Futures Quotes
322348
--------------
@@ -325,25 +351,14 @@ Level one quotes for futures.
325351

326352
.. automethod:: schwab.streaming::StreamClient.level_one_futures_subs
327353
.. automethod:: schwab.streaming::StreamClient.level_one_futures_unsubs
354+
.. automethod:: schwab.streaming::StreamClient.level_one_futures_add
328355
.. automethod:: schwab.streaming::StreamClient.add_level_one_futures_handler
329356
.. autoclass:: schwab.streaming::StreamClient.LevelOneFuturesFields
330357
:members:
331358
:undoc-members:
332359

333360

334-
------------
335-
Forex Quotes
336-
------------
337-
338-
Level one quotes for foreign exchange pairs.
339-
340-
.. automethod:: schwab.streaming::StreamClient.level_one_forex_subs
341-
.. automethod:: schwab.streaming::StreamClient.level_one_forex_unsubs
342-
.. automethod:: schwab.streaming::StreamClient.add_level_one_forex_handler
343-
.. autoclass:: schwab.streaming::StreamClient.LevelOneForexFields
344-
:members:
345-
:undoc-members:
346-
361+
.. _level_one_futures_options_stream:
347362

348363
----------------------
349364
Futures Options Quotes
@@ -353,12 +368,30 @@ Level one quotes for futures options.
353368

354369
.. automethod:: schwab.streaming::StreamClient.level_one_futures_options_subs
355370
.. automethod:: schwab.streaming::StreamClient.level_one_futures_options_unsubs
371+
.. automethod:: schwab.streaming::StreamClient.level_one_futures_options_add
356372
.. automethod:: schwab.streaming::StreamClient.add_level_one_futures_options_handler
357373
.. autoclass:: schwab.streaming::StreamClient.LevelOneFuturesOptionsFields
358374
:members:
359375
:undoc-members:
360376

361377

378+
.. _level_one_forex_stream:
379+
380+
------------
381+
Forex Quotes
382+
------------
383+
384+
Level one quotes for foreign exchange pairs.
385+
386+
.. automethod:: schwab.streaming::StreamClient.level_one_forex_subs
387+
.. automethod:: schwab.streaming::StreamClient.level_one_forex_unsubs
388+
.. automethod:: schwab.streaming::StreamClient.level_one_forex_add
389+
.. automethod:: schwab.streaming::StreamClient.add_level_one_forex_handler
390+
.. autoclass:: schwab.streaming::StreamClient.LevelOneForexFields
391+
:members:
392+
:undoc-members:
393+
394+
362395
.. _level_two:
363396

364397
++++++++++++++++++++
@@ -419,12 +452,14 @@ book is called "listed." Testing indicates this stream corresponds to the NYSE
419452
book, but if you find any behavior that suggests otherwise please
420453
`let us know <https://github.com/alexgolec/schwab-api/issues>`__.
421454

422-
.. automethod:: schwab.streaming::StreamClient.listed_book_subs
423-
.. automethod:: schwab.streaming::StreamClient.listed_book_unsubs
424-
.. automethod:: schwab.streaming::StreamClient.add_listed_book_handler
455+
.. automethod:: schwab.streaming::StreamClient.nyse_book_subs
456+
.. automethod:: schwab.streaming::StreamClient.nyse_book_unsubs
457+
.. automethod:: schwab.streaming::StreamClient.nyse_book_add
458+
.. automethod:: schwab.streaming::StreamClient.add_nyse_book_handler
425459

426460
.. automethod:: schwab.streaming::StreamClient.nasdaq_book_subs
427461
.. automethod:: schwab.streaming::StreamClient.nasdaq_book_unsubs
462+
.. automethod:: schwab.streaming::StreamClient.nasdaq_book_add
428463
.. automethod:: schwab.streaming::StreamClient.add_nasdaq_book_handler
429464

430465

@@ -440,64 +475,60 @@ exchanges, although this is an admittedly an uneducated guess.
440475

441476
.. automethod:: schwab.streaming::StreamClient.options_book_subs
442477
.. automethod:: schwab.streaming::StreamClient.options_book_unsubs
478+
.. automethod:: schwab.streaming::StreamClient.options_book_add
443479
.. automethod:: schwab.streaming::StreamClient.add_options_book_handler
444480

445481

446-
++++++++++++
447-
Time of Sale
448-
++++++++++++
482+
.. _screener:
449483

450-
The data in :ref:`level_two` describes the bids and asks for various
451-
instruments, but by itself is insufficient to determine when trades actually
452-
take place. The time of sale streams notify on trades as they happen. Together
453-
with the level two data, they provide a fairly complete picture of what is
454-
happening on an exchange.
484+
++++++++
485+
Screener
486+
++++++++
455487

456-
All time of sale streams uss a common set of fields:
488+
Top 10 advances and decliners by volume, trades, percent change and average percent
489+
volume.
457490

458-
.. autoclass:: schwab.streaming::StreamClient.TimesaleFields
459-
:members:
460-
:undoc-members:
491+
Symbols in upper case and separated by commas.
461492

493+
(PREFIX)_(SORTFIELD)_(FREQUENCY) where PREFIX is:
494+
* Indices: $COMPX $DJI, $SPX.X, INDEX_ALL
495+
* Exchanges: NYSE, NASDAQ, OTCBB, EQUITY_ALL
496+
* Option: OPTION_PUT, OPTION_CALL, OPTION_ALL
462497

463-
-------------
464-
Equity Trades
465-
-------------
498+
and sortField is:
499+
* VOLUME, TRADES, PERCENT_CHANGE_UP, PERCENT_CHANGE_DOWN, AVERAGE_PERCENT_VOLUME
466500

467-
.. automethod:: schwab.streaming::StreamClient.timesale_equity_subs
468-
.. automethod:: schwab.streaming::StreamClient.timesale_equity_unsubs
469-
.. automethod:: schwab.streaming::StreamClient.add_timesale_equity_handler
501+
and frequency is:
502+
* 0, 1, 5, 10, 30 60 minutes (0 is for all day)
470503

504+
Both the equity and option screener streams use a common set of fields:
471505

472-
--------------
473-
Futures Trades
474-
--------------
506+
.. autoclass:: schwab.streaming::StreamClient.ScreenerFields
507+
:members:
508+
:undoc-members:
475509

476-
.. automethod:: schwab.streaming::StreamClient.timesale_futures_subs
477-
.. automethod:: schwab.streaming::StreamClient.timesale_futures_unsubs
478-
.. automethod:: schwab.streaming::StreamClient.add_timesale_futures_handler
479510

511+
---------------
512+
Screener Equity
513+
---------------
480514

481-
--------------
482-
Options Trades
483-
--------------
515+
.. automethod:: schwab.streaming::StreamClient.screener_equity_subs
516+
.. automethod:: schwab.streaming::StreamClient.screener_equity_unsubs
517+
.. automethod:: schwab.streaming::StreamClient.screener_equity_add
518+
.. automethod:: schwab.streaming::StreamClient.add_screener_equity_handler
484519

485-
.. automethod:: schwab.streaming::StreamClient.timesale_options_subs
486-
.. automethod:: schwab.streaming::StreamClient.timesale_options_unsubs
487-
.. automethod:: schwab.streaming::StreamClient.add_timesale_options_handler
488520

521+
---------------
522+
Screener Option
523+
---------------
489524

490-
++++++++++++++
491-
News Headlines
492-
++++++++++++++
525+
.. automethod:: schwab.streaming::StreamClient.screener_option_subs
526+
.. automethod:: schwab.streaming::StreamClient.screener_option_unsubs
527+
.. automethod:: schwab.streaming::StreamClient.screener_option_add
528+
.. automethod:: schwab.streaming::StreamClient.add_screener_option_handler
493529

494-
.. automethod:: schwab.streaming::StreamClient.news_headline_subs
495-
.. automethod:: schwab.streaming::StreamClient.news_headline_unsubs
496-
.. automethod:: schwab.streaming::StreamClient.add_news_headline_handler
497-
.. autoclass:: schwab.streaming::StreamClient.NewsHeadlineFields
498-
:members:
499-
:undoc-members:
500530

531+
.. _account_activity:
501532

502533
++++++++++++++++
503534
Account Activity

0 commit comments

Comments
 (0)