News Data Stream Issue - Doesn't give any output

Hi,

Am able to use NewsClient

from rich.pretty import pprint
from alpaca.data.historical import NewsClient
from alpaca.data.requests import NewsRequest
import os

symbols = ["NVDA"]

client = NewsClient(os.environ.get("ALPACA_KEY"), os.environ.get("ALPACA_SECRET"), raw_data=True)

news_data = client.get_news(NewsRequest(symbols=symbols[0], limit=100,include_content=True, exclude_contentless=True))

pprint(news_data["news"])

However, am facing issues with NewsDataStream

from rich.pretty import pprint
from alpaca.data.live import NewsDataStream
import os

symbols = ["NVDA"]

news_stream_client = NewsDataStream(os.environ.get("ALPACA_KEY"), os.environ.get("ALPACA_SECRET"))

async def news_data_stream_handler(data):
    print(data)


news_stream_client.subscribe_news(news_data_stream_handler, *symbols)
news_stream_client.run()

I have a algoplus plan. Am using paper-live endpoints for this. Can you please help with the same.

@learn2178 Your code works fine. I believe the issue is there isn’t a lot of news for NVDA and you didn’t wait long enough to get any. The websocket only streams current news so you won’t get any previous articles as when you use the APIs.

I added SPY which has more news, ran for about 20 minutes, and got these two results with your code.

Could that be the issue?

Thanks for the response.