All news

How I wrote a script to search for analyst recommendations on Russian companies

Four years ago, I wrote a search engine to find undervalued US stocks using data from Yahoo Finance. That's because there are more than 10,000 stocks traded in the US, of which about 4,000 have analyst price recommendations. Those are big numbers, and hard to work with. What about Russia?

I've been slowly trying to find a system that would provide analyst recommendations for Russian companies until I recently discovered such an API. For example, here are some recommendations for the electric scooter rental operator WUSH:

In fact, there is one nuance in the quantity. There are 170 securities listed on the Moscow Exchange, of which only 89 have received recommendations.

While the number of articles is much smaller, the API provides specific names of recommended companies, as well as forecast dates and forecast prices. In theory, you could collect prices over time and compare them to forecast prices to create a list of the most accurate analysts.

But I was more interested in creating a summary table of all 89 available stocks.

We wrote the code in Node.js and accessed the T-Bank Invest API to retrieve the data. Features include: • Initialization and setup: • The script starts by importing the required modules: Configuration ( ), Logging Utility ( ), and Tinkoff Client ( ). This simplifies interaction with the Tinkoff Invest API. • Step 1: Get stock data: • This function queries Tinkoff’s InstrumentsService for a list of available stocks. Filter this data to select stocks listed on the MOEX exchange ( ). • The filtered and full inventory lists are logged and returned. Key stock data such as , , and , are retrieved for further processing. • Step 2: Get analyst forecasts: • This function loops through the filtered list of stocks and retrieves analyst forecasts using the endpoint. • Check if forecasts are available for each stock. If present, the forecast data (current price, consensus price, price change, and number of recommendations) is stored in an array. If no forecasts are found, the count of articles without recommendations is incremented by +1. • The system enforces a 600ms delay between API calls to comply with the rate limit (100 requests per minute). • Step 3: Create an HTML Table • Use Google Charts to render a table containing the stock logo, price, consensus price, and number of analyst recommendations. • The table is saved as an HTML file so users can easily view it in their browser. • Final Execution: • The code puts everything together in an asynchronous function that first fetches the stock data, then the forecasts, and finally generates an HTML table summarizing the analyst recommendations. • The output is an HTML file containing real-time stock data from the T-Bank: T-Investments API, sorted by potential price moves, with stock logos and at-risk countries included.

To summarize, this script is an analysis tool that extracts current stock data from T-Bank - T-Investments API, processes analyst recommendations and generates clear and visual reports for decision making.

The transaction logs can be found on GitHub. The completed spreadsheet can be downloaded here. • For numeric columns such as Current Price, Agreed Price, Potential Price Move, etc., sorting in ascending or descending order is straightforward. • For text columns such as Name and Ticker, sorting is alphabetical.

The script allows you to find companies based on analyst recommendations. However, these options are not individual investment recommendations and may not match your investment goals. This is because the script is just a tool, and the decision to buy a particular security is made by you independently after studying the issuer.

Once a new module is written and tested, it is loaded.


Source: sMart-lab.ru - Блоги Инвесторов, Форумы по акциям, КотировкиsMart-lab.ru - Блоги Инвесторов, Форумы по акциям, Котировки

Loading...
follow the news
Stay up to date with the latest news and updates! Subscribe to our browser updates and be the first to receive the latest notifications.
© АС РАЗВОРОТ.