For a stock broker on a trading floor or an independent investor buying and selling shares of companies, it is essential to keep an eye on the news about specific companies so they can make informed decisions about their trades. Imagine if an application could watch the news for you and record the clips that are most relevant to your work. This code pattern showcases an application that does just that, by monitoring multiple live news streams in real time for news that’s potentially important to the user based on their investment portfolio.
If you’ve ever set foot on a trading floor, you know that there are almost always several TVs tuned to business news stations. The trading floor is anything but a quiet place, making it all but impossible for traders to hear any of the content coming from those channels other than catastrophic breaking news. Breaking news also tends to be about larger, more visible companies; news about smaller companies may have a greater impact on individual fund managers or equity researchers than these big news stories, but may go undetected as these news segments tend to be shorter and can get buried beneath the larger stories.
This code pattern shows you how to create a web application that takes the user’s investment portfolio as input and monitors multiple live news streams in real time to identify what tickers in the portfolio are covered in the media. If the app comes across a relevant event in the news, it records the content of the stream until the news source moves on to another subject. It then sends these clips back to the user so they can watch these clips at their convenience, and prepare for potential market changes that could affect their portfolio.
This code pattern is for developers who want to integrate with the investment portfolio services and use them to monitor live video feeds. When you have completed it, you will understand how to:
- Create a Flask web app that is integrated with the Investment Portfolio service.
- Monitor live video feeds in real time using Python.
- Use OpenCV and Tesseract-OCR to perform character recognition on the frames in a video feed.
- Use Web Sockets for real-time streaming of data between the server and the client application.
- User sends the investment portfolio to the Investment Portfolio service.
- User selects multiple news feeds for the application to monitor.
- Application sends the portfolio name and selected news feeds to the server.
- Server pulls the user’s portfolio from the investment portfolio service.
- Server then spawns a process for each feed to monitor them in parallel.
- Each process spawns two threads:
- One that starts and stops recording the clip once the process identifies an appropriate clip for the user based on the portfolio
- The other sends the clip extracted through an error detect sequence to fix any encoding issues with the clip
- Processes continuously send the clips to be stored in a repository.
- User gets the clips on the client side through a socket connection to the server.
Find the detailed steps for this pattern in the README. Those steps will show you how to manually deploy your app to a local machine:
- Set up your machine.
- Clone the repository.
- Create the Investment Portfolio service.
- Configure the .env file.
- Run the application in a Docker container.
- Upload the holdings.
- Watch the news.