Sum of a Geometric Series

What is the sum of the following geometric series?
\[
\sum_{i=0}^{k}a^i=1+a+a^2+…+a^k
\]
We will frequently need a simple formula for this finite series. It is called a geometric series because each term is related by a multiple to the previous one. If each term was related by a fixed difference, it would be called an arithmetic series; but that’s for another day.
Let us define the sum as \(S\). Then writing the equation for \(S\) and \(aS\) with some clever alignment:

\begin{array}{rrrccc}
S=&1&+a&+a^2&+…&+a^k \\
aS=&&a&+a^2&+…&+a^k&+a^{k+1}
\end{array}
Subtract the equations
\[
S(1-a)=1-a^{k+1}
\]
or
\begin{align}
S=
\begin{cases}
\frac{1-a^{k+1}}{1-a} &a \neq 1 \\
k+1 &\text{otherwise}
\end{cases}
\end{align}
where we have to be careful to divide by \(1-a\) only if \(a\neq 1\), and the answer for \(a=1\) is determined by inspection.
Q.E.D.

Trading Bitcoins

This is part 2 of our Bitcoin analysis.  Following part 1 Do Bitcoin Prices Walk Randomly? we can apply some simple analysis on bitcoin trading profitability.

Recall that in the previous post, we learned that Bitcoin prices are slightly negatively correlated over various time periods. Thus we might ask the question, what if we followed a very simple strategy: Sell when prices rose in the prior period, and Buy when they fell. Our percentage profits would be roughly proportional to \(\sigma r / p\) where \(\sigma\) is the standard deviation of the price change, \(r\) is the correlation coefficient, and \(p\) is the current price. We analyzed the Bitcoin prices from the BTC-e exchange for 2015-2016. Here is the variation data (legend 2015 indicates aggregated data 2015-2016):

Bitcoin data for different time periods over 20167
Note that for short time periods (1 minute), there is more correlation in prices, but since the variance (standard deviation) is smaller, the profit on each trade will be smaller. This is where transaction costs come into play.

We now add two more things:

  1. A threshold that a price change must exceed in order to make the trade
  2. A transaction fee of 0.20%.  This is typical on Bitcoin exchanges.  Some might be less, depending on trading volume, and also Maker fees can be lower (where you place a limit order rather than execute against a current order)
profit for different periods and thresholds

profit for different periods and thresholds

You can see that we cannot quite get a positive profit on this admittedly simple trading strategy.  The correlation between prices changes is just not big enough to overcome the transaction fees.  You can see that as we raise the threshold, the profit per trade increases, but does not quite rise to the level of 0.20%, our transaction costs.

 

Do Bitcoin Prices Walk Randomly?

Or, A Random Walk Down Bitcoin Avenue

A process follows a random walk if it has changes that are independent from one time interval to the next.  A common question is “Does the price of X follow a random walk?”  In particular, people are curious about the prices of stocks because they want to make money. Without getting too technical yet, if a price follows a random walk, you can’t make money trying to predict future prices.  If you can show that it does not follow such a random walk,  then it might be possible to make money at it.  So, do stock prices follow a random walk?

YES NO
A Random Walk Down Wall Street 1
A Non-Random Walk Down Wall Street 2

Bitcoin is a cryptocurrency, one of the better known ones, which uses something called Blockchain technology [look for future post on this topic].  There are several exchanges that allow one to buy and sell Bitcoins.  So, a natural question would be “Do those prices follow a random walk?”

Let’s follow Prof. Andrew Lo’s excellent analysis from Chapter 2 of his book and see what conclusions we can draw about Bitcoin prices.  Chapter 2 says that if the price change at period N+1 is independent of the price change at period N, then the variance over 2 periods should be twice the variance of changes over 1 period.  Let \(X_n\) be the log-price of bitcoins for period \(n\).

Let’s derive the variance relationship.  Let \(x, y\) be two random variables, and recall that the variance is the expected value of the squared deviation from the mean:

\[
var(x) \equiv E[ (x – \bar{x})^2 ]
\]

The variance of a sum of random variables

\begin{align}
var(x+y)=&E[ (x+y-\bar{x}-\bar{y})^2 ] \\
=&E[ (x-\bar{x})^2 + (y-\bar{y})^2 ] + 2 E[(x-\bar{x})(y-\bar{y})] \\
=&var(x) + var(y) + 2 cov(x,y)
\end{align}

Following Lo, let \(X_0,…,X_{nq} \) be the sequence of log-prices, and we define the variance ratio for period \(q\) as the variance at q steps divided by the variance at 1 step, divided again by q. This ratio should be 1.0 for all q if the steps are uncorrelated. Formally, letting \(\hat{\mu}\) be the mean increment, \(\bar{\sigma}_a^2\) be the variance estimate for 1 step, and \(\bar{\sigma}_c^2\) be the variance estimate for 1 step based on q-step differences, we have

\begin{gather}
\hat{\mu}=\frac{1}{nq} \sum_{k=1}^{nq}(X_k-X_{k-1})=\frac{1}{nq}(X_{nq}-X_0) \\
\bar{\sigma}_a^2= \frac{1}{nq-1} \sum_{k=1}^{nq}(X_k-X_{k-1}-\hat{\mu})^2 \\
\bar{\sigma}_c^2(q)= \frac{1}{m} \sum_{k=q}^{nq}(X_k-X_{k-q}-q\hat{\mu})^2 \\
m=q(nq-q+1)\left( 1 – \frac{q}{nq}\right)
\end{gather}

The results for running these calculations on Bitcoin prices from the BTC-e exchange from 2011, when trading started, to the present time (October 2016) is shown in table 1. Also shown in the table is the z-statistic \(z^*\) from Theorem 2.3 of Lo. This computes the significance of the variance ratio result. If the \(|z^*|\) is greater then 2, then the variance ratio result is significant at the .05 level, meaning that there is a only a 5% chance that the variance ratio differs from the null-hypothesis value of 1.

First, price and volume data for the time period of interest for the BTC-e exchange:

pr-vol

Observation Period Years Num obs (nq) q=2 q=4 q=8
5 min 2011-4 241,059 .729
(-3.39)
.540
(-5.67)
.411
(-7.04)
2015-6 187,118 .853
(-17.04)
.735
(-22.49)
.670
(-21.80)
1 hour 2011-4 28,079 .791
(-6.47)
.620
(-9.06)
.568
(-8.20)
2015-6 15,659 .940
(-2.40)
.880
(-3.85)
.855
(-3.46)
1 day 2011-4 1,234 .977
(-.27)
.917
(-.82)
.991
(-.07)
2015-6 659 .983
(-.14)
.869
(-.96)
.862
(-.92)

What conclusions that we can draw from this table?

  1. For 1 day periods, the variance ratio does not indicate any non-randomness.
  2. For shorter periods, there is significant non-randomness showing.  In general, it looks like prices are negatively correlated with the prior period (because the variance ratio < 1.0).  At 5 minute intervals, the correlation coefficient is approximately -0.15.
  3. The randomness has decreased since 2015.
  4. Note that from Lo’s book, (weekly) stock prices has variance rations > 1 (around 1.3), meaning that price changes were positively correlated.  Note that the Bitcoin price changes are generally negatively correlated.

Our next post will look at whether you can profit from this non-randomness.

 

 

 

Notes:

  1. A Random Walk Down Wall Street, 11th ed., Burton G. Malkiel 2016, 1st ed 1973.
  2. A Non-Random Walk Down Wall Street, Andrew W. Lo & A. Craig MacKinlay, 2002

Launching The MIT Institute for Data, Systems, and Society

IDSS

The MIT Institute for Data, Systems, and Society held it’s Launch event Sept 22-23 to showcase it’s first year in operation.

IDDS works at addressing societal problems by focusing on the intersection of statistics, data science, information systems, and social sciences.

After introductions by MIT President Rafael Reif and IDDS Director Prof. Munther Dahleh, the seminar started with some great talks on the Future of Voting, including remarks by Nate Silver of FiveThirtyEight.com, who gave some behind the scenes glimpses into the polling numbers and methodology for the upcoming Presidential election.