0
$\begingroup$

I'm an engineer with minimal to zero knowledge about economical topics, please be patient with me if the following question makes no sense or is too basic ...

Currently I'm working through the "Python Data Science Handbook" of Jake van der Plas. In the chapter about time series data there are several examples with financial numbers, in particular stock rates.

In one example he calculates the ROI out of a series of stock rates:

from pandas_datareader import data

# data_source google won't work anymore, use yahoo
goog = data.DataReader('GOOG', start='2004', end='2016',
                       data_source='google')
goog = goog.asfreq('D', method='pad')
ROI = 100 * (goog.tshift(-365) / goog - 1)
ROI.plot()
plt.ylabel('% Return on Investment');

So, he divides data from one year ago with the current data, plus 1, times 100 (to get it into percent values).

For my understanding, the central formular is (with $f_0$ for the data from one year ago and $f_1$ for the current data):

$\frac{f_0}{f_1} - 1 \equiv \frac{f_0}{f_1} - \frac{f_1}{f_1} \equiv \frac{f_0 - f_1}{f_1} $

What I found when googling for ROI are especically the definitions from Wikipedia:

return on investment = Net income / Investment

or

return on investment = (gain from investment – cost of investment) / cost of investment

or

return on investment = (revenue − cost of goods sold) / cost of goods sold

Although the latter both definitions come quite close to the formular above, I'm unable to see the relationship between stock rates used in the data of the code example and the words used in the definitons from Wikipedia.

Can anyone help me to understand this a bit better, with a brief explanation or a hint where to continue reading on this topic?

Thanks and cheers Wolfgang

New contributor
wollud1969 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
  • $\begingroup$ I'm not certain his maths is exactly right, but I assume that he is working out the return on buying a stock and keeping it for a year, i.e. $f_0$ = "cost of investment" and $f_1$ = "gain from investment" in the second WP definition you give. I would have thought $\frac{f_1 - f_0}{f_0}$ made more sense -- could it be a typo? $\endgroup$ – Dan Nov 8 at 16:50
0
$\begingroup$

I agree with Dan it is likely a typo.


Some definitions (using your notations)

Investment : $f_0$

Investment one year later : $f_1$

Net income : $f_1 - f_0$

ROI: $-1 + \frac{f_1}{f_0}$

It follows that the correct code should be

ROI = (goog/goog.tshift(-365) -1)*100
$\endgroup$
  • $\begingroup$ Putting aside that multiplying by $100$ boils down to considering that a percentage is a unit/constant, which is not to me. I mean: $0.01=1\%=10^{-2}$. But he does so probably only for the plot. $\endgroup$ – keepAlive yesterday

Your Answer

wollud1969 is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.