<p>I agree with Dan it is likely a typo.</p>
<hr>
<p>Some definitions <em>(using your notations)</em></p>
<blockquote>
<p>Investment : <span class="math-container">$f_0$</span></p>
<p>Investment one year later : <span class="math-container">$f_1$</span></p>
<p>Net income : <span class="math-container">$f_1 - f_0$</span></p>
<p>ROI: <span class="math-container">$-1 + \frac{f_1}{f_0}$</span></p>
</blockquote>
<p>It follows that the correct code should be</p>
<pre><code>ROI = (goog/goog.tshift(-365) -1)*100
</code></pre>

CC BY-SA 4.0
2019-11-10T10:55:36.587Z
*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.
keepAlive
CC BY-SA 4.0
2019-11-09T14:59:53.317Z
2019-11-09T15:11:39.740Z
2020-06-17T09:40:54.643Z
keepAlive
<p>This article discusses ROI:</p>
<p><a href="https://www.investopedia.com/articles/basics/10/guide-to-calculating-roi.asp" rel="nofollow noreferrer">https://www.investopedia.com/articles/basics/10/guide-to-calculating-roi.asp</a></p>
<p>This article covers adjustments to stock price and volume data:</p>
<p><a href="https://blog.quandl.com/guide-to-stock-price-calculation" rel="nofollow noreferrer">https://blog.quandl.com/guide-to-stock-price-calculation</a></p>
<p>Some observations about efforts to maximize ROI from stock investing:</p>
<ol>
<li><p>When one enters a market position, such as in the stock market, this is a random experiment where the investment tends to produce a percent gain or loss over time.</p>
</li>
<li><p>The invested capital may be taking a loss in the position while some other position in a different stock is typically making a large gain at the same time. Or the position is making a small gain while a large gain is made in an alternative position.</p>
</li>
<li><p>If one makes a loss of -50% on the position then one must make a gain of 100%, either in the same position or a different position, just to break even. The total cost of entrance to the position, price paid plus commissions, is the denominator in the calculations.</p>
</li>
<li><p>Surfing price waves is an effort to cut losses short when one gets into a random experiment that produces a loss and to let winners run when one gets into a random experiment that produces large gains.</p>
</li>
<li><p>Those who hold to the efficient market hypothesis or random walk theory argue that one cannot anticipate the random price movements of the stock market so it is best to invest in an index of stocks.</p>
</li>
<li><p>Some stock pickers seem to be able to beat the market but other sources say perhaps 80% or more of active money managers do not beat the S&amp;P 500 index for significant periods of time.</p>
</li>
</ol>

CC BY-SA 4.0
2020-09-05T23:29:17.210Z
2020-09-05T23:29:17.210Z
SystemTheory
<p>To understand the return formula, think of it this way: ROI is the <code>effect/effort - 1</code>. If you invest 100 dollars today, which is your <code>effort</code>, and one year later you have 105 dollars (<code>effect</code>), you get a 5% payoff. </p>

CC BY-SA 4.0
2020-09-05T03:02:10.577Z
It might be more intuitive if it's written as (effect-effort)/effort
Acccumulation
CC BY-SA 4.0
2019-12-09T17:20:51.577Z
2019-12-09T17:26:09.557Z
2019-12-09T17:26:09.557Z
AlexB
<p>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 ...</p>

<p>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.</p>

<p>In one example he calculates the ROI out of a series of stock rates:</p>

<pre><code>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');
</code></pre>

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

<p>For my understanding, the central formular is (with <span class="math-container">$f_0$</span> for the data from one year ago and <span class="math-container">$f_1$</span> for the current data): </p>

<p><span class="math-container">$\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} $</span> </p>

<p>What I found when googling for ROI are especically the definitions from Wikipedia:</p>

<p><em>return on investment = Net income / Investment</em></p>

<p>or</p>

<p><em>return on investment = (gain from investment – cost of investment) / cost of investment</em></p>

<p>or</p>

<p><em>return on investment = (revenue − cost of goods sold) / cost of goods sold</em></p>

<p>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.</p>

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

<p>Thanks and cheers
Wolfgang</p>

CC BY-SA 4.0
2019-11-08T16:50:13.070Z
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?
Dan
<stock-market><capital-returns><python>
ROI and stock rates
wollud1969
# ROI and stock rates

(Asked by: username_0 on 2019-11-08)

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

**Tags:** stock-market, capital-returns, python
> **Comments:**
> **username_1**: 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?  

---

## 3 answers

### Answer by username_2 on 2019-11-09. Score: 2

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

> **Comments:**
> **username_2**: *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.  

---

### Answer by username_3 on 2020-09-05. Score: 0

This article discusses ROI:

<https://www.investopedia.com/articles/basics/10/guide-to-calculating-roi.asp>

This article covers adjustments to stock price and volume data:

<https://blog.quandl.com/guide-to-stock-price-calculation>

Some observations about efforts to maximize ROI from stock investing:

1. When one enters a market position, such as in the stock market, this is a random experiment where the investment tends to produce a percent gain or loss over time.
2. The invested capital may be taking a loss in the position while some other position in a different stock is typically making a large gain at the same time. Or the position is making a small gain while a large gain is made in an alternative position.
3. If one makes a loss of -50% on the position then one must make a gain of 100%, either in the same position or a different position, just to break even. The total cost of entrance to the position, price paid plus commissions, is the denominator in the calculations.
4. Surfing price waves is an effort to cut losses short when one gets into a random experiment that produces a loss and to let winners run when one gets into a random experiment that produces large gains.
5. Those who hold to the efficient market hypothesis or random walk theory argue that one cannot anticipate the random price movements of the stock market so it is best to invest in an index of stocks.
6. Some stock pickers seem to be able to beat the market but other sources say perhaps 80% or more of active money managers do not beat the S&P 500 index for significant periods of time.


---

### Answer by username_4 on 2019-12-09. Score: 0

To understand the return formula, think of it this way: ROI is the `effect/effort - 1`. If you invest 100 dollars today, which is your `effort`, and one year later you have 105 dollars (`effect`), you get a 5% payoff.

> **Comments:**
> **username_5**: It might be more intuitive if it's written as (effect-effort)/effort  

---

