Today I decided to develop a deeper understanding of stocks. I find finance in general and stocks in particular kind of boring; I like math, computer science, that kind of stuff. So, instead of forcing myself to learn about stocks the usual way by reading finance books or articles, I decided to use coding to organically learn specific stock related topics. I only assume you have Python 3 installed, then you just need to pip install yfinance. Now, you're ready to start exploring.
import yfinance as stock_data
import json
hcp = stock_data.Ticker('HCP')
stock_info = hcp.get_info()
print(stock_info.keys())
After I got the list of all keys I could explore, I decided to check the stock volume.
volume = stock_info['volume']
print(volume)
> 2031364
I remember hearing about stock volume, but obviously it didn't stick. When I had a concrete number I got curious. After brief research I learned the stock volume is just the number of shares traded during some time period. However, I was unable to find what this specific value means. So, I tried something more specific, namely the stock volume during the last 10 days.
avg_volume = stock_info['averageDailyVolume10Day']
print(avg_volume)
> 1803570
Next I thought it'd be interesting to figure out how was that average formed. Specifically, how did the volume change, say during the last five days.
hcp.history(period="5d")
> ... Volume
> ... 2489700
> ... 1172200
> ... 1905800
> ... 1433100
> ... 2031500
Now, I was curious about the significance of the stock volume. It turns out that stock volume is one of the fundamental indicators. Specifically, the volume patterns over time point toward trends. For example, increasing price and decreasing volume might indicate lack of interest. Inversely, decreasing price and increasing volume indicate that something about the stock has fundamentally changed. I'll likely continue to deepen my understanding now that dry financial concepts got concrete embodiment in data via code.