<jupyter_start><jupyter_text>btc-analysis-1

The following analysis shows BTC/USD follows a squareroot trend on logarithmic scale, particularly $e^{-3 + 4\sqrt{t}}$. 

 interpretation

As this day of 9/25/201, every BTC trader trusts halvenings to strongly predict price growth.
Halvenings are moments when new BTC generated supply halves. Halvenings occur every 4 years.
The data supports this pattern extremely strongly, as shown through the $4\sqrt{t}$ term.
Essentially, we see that demand is roughly constant as price is almost entirely determined by the BTC generation rate.<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
AZURE_ML_DATA_PATH = '/home/azureuser/cloudfiles/code/Users/wdurno/notebooks/btc-analysis-1/btc-usd.csv'

## load data 
df = pd.read_csv(AZURE_ML_DATA_PATH)
n = df.shape[0]

print('BTC/USD pairs were gathered manually') 
print(df)

## fit quadratic 
ones = np.ones(n) 
t = df['t']
t2 = np.square(df['t'])
x = np.stack((ones, t, t2), axis=1) # design matrix 
y = np.log(df['btc-usd'])
model = np.linalg.lstsq(x, y)

## predict quadratic 
tt = np.linspace(t[0], t[n-1], 1000)
b = model[0]
yy = (tt**0)*b[0] + tt*b[1] + (tt**2)*b[2]

fig, ax = plt.subplots()
plt.title('quadratic is a poor fit')
ax.scatter(df['t'], np.log(df['btc-usd'])) # prices 
ax.plot(tt, yy) # quadratic 
plt.show()

## try log

ones = np.ones(n) 
t = df['t']
t_log = np.log(df['t'])
x = np.stack((ones, t_log), axis=1) # design matrix 
y = np.log(df['btc-usd'])
model = np.linalg.lstsq(x, y)

## predict sqrt
tt = np.linspace(t[0], t[n-1], 1000)
b = model[0]
yy = (tt**0)*b[0] + np.log(tt)*b[1]

fig, ax = plt.subplots()
plt.title('log is imperfect')
ax.scatter(df['t'], np.log(df['btc-usd'])) # prices 
ax.plot(tt, yy) # log
plt.show()

## try sqrt

ones = np.ones(n) 
t = df['t']
t_sqrt = np.sqrt(df['t'])
x = np.stack((ones, t_sqrt), axis=1) # design matrix 
y = np.log(df['btc-usd'])
model = np.linalg.lstsq(x, y)

## predict sqrt
tt = np.linspace(t[0], t[n-1], 1000)
b = model[0]
yy = (tt**0)*b[0] + (tt**0.5)*b[1]

fig, ax = plt.subplots()
plt.title('square root looks perfect')
ax.scatter(df['t'], np.log(df['btc-usd'])) # prices 
ax.plot(tt, yy) # sqrt 
plt.show()

print('weights: '+str(b))

## define a predictive function
def pred(t):
    return np.exp(-3. + 4.*np.sqrt(t))

print('predictions per year, at Jan, 2022 through 2030:')
ttt = [t+.5 for t in range(11, 20)]
print(pred(ttt))

## plot predictions

ttt = np.linspace(t[0], 19.5, 1000) 
yyy = pred(ttt) 

fig, ax = plt.subplots()
plt.title('square plot with predictions')
ax.scatter(df['t'], np.log(df['btc-usd'])) # prices 
ax.plot(ttt, np.log(yyy)) # sqrt 
plt.show()<jupyter_output>BTC/USD pairs were gathered manually
    Unnamed: 0    btc-usd     t      time
0            0      0.296   0.5  01/01/11
1            1     15.420   1.0  07/01/11
2            2      5.048   1.5  01/01/12
3            3      6.659   2.0  07/01/12
4            4     13.410   2.5  01/01/13
5            5     89.830   3.0  07/01/13
6            6    779.800   3.5  01/01/14
7            7    649.300   4.0  07/01/14
8            8    315.600   4.5  01/01/15
9            9    257.600   5.0  07/01/15
10          10    432.300   5.5  01/01/16
11          11    647.300   6.0  07/01/16
12          12    971.000   6.5  01/01/17
13          13   2513.000   7.0  07/01/17
14          14  13924.000   7.5  01/01/18
15          15   6388.000   8.0  07/01/18
16          16   3744.000   8.5  01/01/19
17          17  10323.000   9.0  07/01/19
18          18   7238.000   9.5  01/01/20
19          19   9224.000  10.0  07/01/20
20          20  29260.000  10.5  01/01/21
{'fraction_non_alphanumeric': 0.15828877005347594, 'fraction_numerical': 0.11711229946524064, 'mean_word_length': 2.3106194690265487, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '503148', 'license': 'MIT', 'n_tokens_mistral': 1782, 'n_tokens_neox': 1553, 'n_words': 400, 'path': 'btc-analysis-1/.ipynb_aml_checkpoints/btc-log-sqrt-checkpoint2021-8-25-21-2-6Z.ipynb', 'repo_name': 'wdurno/notebooks', 'size': '3740'}