Fundamental financial calculations
There are a number of analyses and data conversions commonly used to analyze the performance of historical stock quotes. These calculations generally relate to either analyzing the rate of return from an investment in a stock over a daily or monthly basis or how multiple stocks perform relative to each other or a market index. The calculations could also relate to determining the riskiness of an investment in a stock relative to others. We will now look at all of these operations using our previously collected stock data.
Calculating simple daily percentage change
The simple daily percentage change (without dividends and other factors) is the amount of percentage change in the value of a stock over a single day of trading. It is defined by the following formula:
Using this formula, the following command calculates the percentage change for AA between 2014-01-04
and 2014-01-05
:
In [18]: AA_p_t0 = daily_close_px.iloc[0]['AA'] #Pt-1 AA_p_t1 = daily_close_px...