alexgolec / tda-api

A TD Ameritrade API client for Python. Includes historical data for equities and ETFs, options chains, streaming order book data, complex order construction, and more.
https://tda-api.readthedocs.io
MIT License
1.27k stars 338 forks source link

Add documentation about generating news links from headline stream contents #58

Open alexgolec opened 4 years ago

alexgolec commented 4 years ago

https://research.tdameritrade.com/grid/public/markets/news/story.asp?docKey=XXXXX

httran13 commented 3 years ago

Neat!

According to : https://developer.tdameritrade.com/content/streaming-data#_Toc504640622 image

We can relate the Headline ID to the key we need.

If we run a subscribe to a symbol, for example, below I have ADBE

{'COUNT_FOR_KEYWORD': 5,
              'ERROR_CODE': 0,
              'HEADLINE': 'MW Adobe Systems stock price target raised to $730 '
                          'from $630 at BMO Capital',
              'HEADLINE_ID': 'SN20210916008147',
              'IS_HOT': False,
              'KEYWORD_ARRAY': 'I/XISL,N/DJMW,P/SGN,P/OAC,I/XRUS,M/NND,I/XSTX,R/PRM,N/SN,I/XGDW,N/WEI,P/EWR,I/XDJLC,R/US,*ALL*,R/CA,P/RTRS,P/AEQI,M/TEC,R/USW,P/BFX,I/XDJGI,N/DJWI,N/CNW,P/HDL,I/XNQ1,I/XSLI,P/HLO,P/ABO,P/MWHL,I/XSP1,R/NME,I/XFCS,I/XSP5,ADBE,N/RUBL,I/SOF',
              'STATUS': 'U',
              'STORY_DATETIME': 1631800840000,
              'STORY_ID': 'SN20210916008147',
              'STORY_SOURCE': 'DJCNEWS',
              'key': 'ADBE',
              'seq': 8}

The HEADLINE_ID = SN20210916008147

all we need to do is take this link : https://research.tdameritrade.com/grid/public/markets/news/story.asp?docKey=

and set param docKey=1-, Why prefixed with "1-"? I dont know, i was viewing some headlines at the link above and see that it was prefixed with 1-

So we can go to

https://research.tdameritrade.com/grid/public/markets/news/story.asp?docKey=1-SN20210916008147

and get the story from td website

mm0 commented 2 years ago

It appears as though most headlines come from DJCNEWS/BENZINGA, which are not publicly available from the URL provided. I believe the "1-" prefix corresponds to "CBSMW" (MarketWatch), in which might be accessible publicly. You would have to store a mapping from STORY_SOURCE to prefix based on the values found via the "Filter by News Source" dropdown on the right of the page: image

There doesn't seem to be any documentation for the NEWS_STORY API Service, so perhaps this is unimplemented on their end, but that would likely be the way to retrieve news content. image