Pulling External Factors for Trading Analytics

Oleg Kazanskyi
4 min readJun 14, 2022

--

Photo by Josep Castells on Unsplash

FOREWORD

In the previous article, we collected stock’s financial KPIs data. In the end, we got a script that pulls 15 well-defined variables tha5 describe a company’s health.

But in trading, examining the financial results only is not the best predictor of future value. Before we move on to the data analysis and ML learning stage we need to gather more parameters that might be helpful in building something useful.

External market conditions may affect the company’s performance and valuation a lot, and we need to include these in our model.

SECTION 1. EXTERNAL FACTORS

We will take several of the most general parameters that knowingly affect enterprise value in the short and long term: Market Volatility, Borrowing Costs and Crises.

We would need:

  • VIX daily data for market Volatility;
  • U.S. 10-Year Bond data to follow the general trend of the borrowing costs;
  • Periods of big market crashes

- VIX (VOLATILITY INDEX)

The volatility index is a good indicator of the level of fear in the market on a scale from 1 to 100. The lower this variable is, the more predictable the market movements are, and when it is high it’s usually a piece of bad news for the stocks.

I couldn’t find one place where I could load the required data, and I will scrap VIX from “https://cdn.cboe.com/api/global/us_indices/daily_prices/VIX_History.csv

Here is a simple script for this:

- 10 YEAR U.S. BOND

US treasury notes are traded on daily basis and can be a good indicator of monetary value. If the yield from the notes is low the investors might prefer stocks to keep earning, and when the yield goes high it can wipe some value from the stock market.

10-year bonds daily data we can get from ‘https://finance.yahoo.com/’. Here is the script to pull it with Selenium library:

- LATEST CRISES

The idea here is to manually set calendar days when the drop of the S&P index was below 15% of the recent top value. After that, we can count the number of days for each trade after the latest crisis. This way we may try capturing the macrocycles of the economy.

This information may duplicate VIX values as every crisis, in general, happens in periods of high volatility. But we could give it a try.

Photo by Isaac Smith on Unsplash

SECTION 2. MARKET PLAYERS PREDICTION

This is the last aspect of data that we need to gather before the analysis stage. As of now, we have 15 financial KPIs and 3 parameters that describe outer market weather. But the price of the stock is affected not only by previous performance or current market conditions but the future expectations of the company’s results and its over- or underperformance.

If stock players expect that the company will earn a dollar per stock, but it ends up with 1.3$ in earnings it will be a big boost for the stock price. We do capture earnings per stock in the financial KPIs part, but the utilization here is a little different. The aim is not to get a historical analysis but to gain a market’s future expectation of the performance.

In other words, knowing the company’s previous performance only might be not enough to understand why the stock is overpriced or underpriced, but knowing what is the market's vision about the stock’s future will be helpful.

The most powerful indicators that can explain the price fluctuations in this case are:

  1. Expected vs real earnings. Or we can call it the level of surprise that a company conveys on the report date.
  2. Dividends announcements. When dividends grow it makes a stock more attractive.
  3. Expected Earnings. This is related to the latest period when we can’t compare market expectations with the real performance as the company’s report is not published yet.

All of this data we can pull from https://www.zacks.com, here is a script to do this

SECTION 3. COMBINING ALL THE DATA

In the previous articles, we collected:

  • a company’s financial historical data of 15 KPIs;
  • external factors that may impact a stock’s value, like market volatility, 10 year Bond yield;
  • prospective expectations that affect forecasted returns and, therefore market value: dividends announcements, expected earnings vs factual earnings.

Now it is time to combine all the data into one dataset, which we will use in our ML model later.

We will use a loop to collect DOW 30 stocks data as mentioned in the script below.

WHAT’S NEXT?

After we have all the required financial KPIs and combined them with market conditions, we can use the final dataset for further data analysis and ML learning.

We may need to add and twist several things in the process but in general, I think we are ready to move on to the next stage of data analysis.

I will use DOW 30 companies’ data as it is provided for free by tiingo.com, and I will cover all the insights in the following article. We might need to increase the number of stocks in our analysis if we don’t find any trends, but let’s see where the process leads us.

Please follow up!

--

--

Oleg Kazanskyi

Master of Finance with a high passion for BI and Data Analysis