-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmcap.gpl
173 lines (155 loc) · 6.2 KB
/
mcap.gpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# Gnuplot script to generate the Stock to Flow graph
# based on daily price and total bitcoins from blockstream.com
#
set terminal png enhanced size 1600, 900
set output "alltimeprice.png"
SLOPE=system("awk NR==1 < gpvars.txt")
E2INTC=system("awk NR==2 < gpvars.txt")
RMSE=system("awk NR==3 < gpvars.txt")
R2=system("awk NR==4 < gpvars.txt")
E2SE=system("awk NR==5 < gpvars.txt")
TODAY=system("date +%F -d @`awk NR==6 < gpvars.txt`")
S2FL=system("awk NR==7 < gpvars.txt")
S2FH=system("awk NR==8 < gpvars.txt")
YMAX=system("awk NR==9 < gpvars.txt")
INTERC=system("awk NR==10 < gpvars.txt")
BANN1="Model by PlanB (Twitter \\@100trillionUSD)\n"
BANN2="Chart by Rob Wolfram (Twitter \\@hamal03)\n"
BANN3="Data retrieved from coinmetrics.io"
BANNER=BANN1.BANN2.BANN3
CAPSLOPE=system("awk NR==11 < gpvars.txt")
CAPE2INTC=system("awk NR==12 < gpvars.txt")
CAPRMSE=system("awk NR==13 < gpvars.txt")
CAPR2=system("awk NR==14 < gpvars.txt")
CAPE2SE=system("awk NR==15 < gpvars.txt")
CAPINTERC=system("awk NR==16 < gpvars.txt")
ENDEPOCH=system("date +%s -d @`awk NR==6 < gpvars.txt`")+182*86400
# All time price plot
set timefmt "%s"
set xdata time
set format x "%Y"
set decimal locale
set ytics ( '' 0.01, '$0.10' 0.1, '$1' 1, '$10' 10, '$100' 100, '$1000' 1000, \
'$10,000' 10000, '$100,000' 100000, '$1,000,000' 1000000, '$10,000,000' 10000000, \
'$100,000,000' 100000000)
set xtics 31556736
set y2tics ( "0.56" 10**.75/10, "1" 1, "1,78" 10**.25, "3.16" 10**.5, "5.62" 10**.75, "10" 10, \
"17.8" 10**.25*10, "31.6" 10**.5*10, "56.2" 10**.75*10, "100" 100, \
"178" 10**.25*100, "316" 10**.5*100 )
set xrange [1262300400:ENDEPOCH]
set yrange [0.01:YMAX]
set y2range [S2FL:S2FH]
set ylabel 'US$ per BTC' font "Helvetica,16"
set y2label 'Stock-to-Flow' font "Helvetica,16"
set logscale y
set logscale y2
set grid xtics ytics
set key box opaque height 2 left
set datafile separator ","
set key font 'Helvetica Narrow,12'
set title "Bitcoin daily stock-to-flow and price" font "Helvetica Bold,30"
LABEL1 = "Predicted price: S2F^{".SLOPE."} × ".E2INTC
LABEL2 = "Predicted market cap: S2F^{".CAPSLOPE."} × ".CAPE2INTC
LABEL3 = "Price data: 2010-07-18 to ".TODAY
set obj 1 rect at graph 0 + .7, graph 0 + .065 size char strlen(LABEL2), char 4
set label 1 at graph 0 + .7, graph 0 + .090 LABEL1."\n".LABEL2."\n".LABEL3 front center font 'Helvetica,11'
set obj 3 rect at graph 0 + .4, graph 1 - .06 size char 41, char 4
set label 3 at graph 0 + .4, graph 1 - .04 BANNER front center font 'Helvetica,11'
plot \
"sftime.csv" using 1:4 axes x1y1 with lines lw 0 lc '0xeeeeff' notitle, \
"sftime.csv" using 1:6 axes x1y1 with lines lw 0 lc '0xeeeeff' notitle, \
"sftime.csv" using 1:4:6 axes x1y1 with filledcu fs solid 0.1 noborder notitle, \
"sftime.csv" using 1:3 axes x1y1 with lines lw 0 lc '0xddddff' notitle, \
"sftime.csv" using 1:5 axes x1y1 with lines lw 0 lc '0xddddff' notitle, \
"sftime.csv" using 1:3:5 axes x1y1 with filledcu fs solid 0.2 noborder notitle, \
"sftime.csv" using 1:2 axes x1y1 with lines lw 2 lc '0x808080' t "S2F on price", \
"sftime.csv" using 1:8 axes x1y1 with lines lw 2 lc '0xa000a0' t "S2F on MCap", \
"sftime.csv" using 1:7 axes x1y1 with lines lw 2 lc 'red' t 'Daily US$'
reset
# Stock to flow regression on price
set terminal png size 1600,960
set output 's2fprice.png'
set format y "%#.1f"
set format x "%#.1f"
set ytics
set xtics
set grid xtics ytics
set datafile separator ","
set title "Bitcoin log stock-to-flow vs log price" font "Helvetica Bold,30"
set xlabel 'ln(S2F)' font "Helvetica,16"
set ylabel 'ln(US$/BTC)' font "Helvetica,16"
set key box opaque height 2 left
set pointsize 1.5
PRCBAN="R^{2} value: " . R2
set obj 4 rect at 1.5, graph 0 + .055 size char 41, char 4 front
set label 4 at 1.5, graph 0 + .075 BANNER front center font 'Helvetica,11'
set obj 5 rect at 3.5, graph 0 + .030 size char 20, char 2 front
set label 5 at 3.5, graph 0 + .030 PRCBAN front center font 'Helvetica,11'
f(x) = a*x + b
b = INTERC
g(x) = a*x + c
c = INTERC+RMSE
h(x) = a*x + d
a = SLOPE
d = INTERC-RMSE
plot "sfdata.csv" u 1:2 axes x1y1 t 'Daily price points' with points pt 1 lc 'blue',\
f(x) title sprintf("ln(price) = %s × ln(S2F) + %s",SLOPE,INTERC) lw 2 lc 'red',\
g(x) notitle lw 1 lc 'gray', \
h(x) notitle lw 1 lc 'gray'
reset
# Stock to flow regression on market cap
set terminal png size 1600,960
set output 's2fcap.png'
set format y "%#.1f"
set format x "%#.1f"
set ytics
set xtics
set grid xtics ytics
set datafile separator ","
set title "Bitcoin log stock-to-flow vs log market cap" font "Helvetica Bold,30"
set xlabel 'ln(S2F)' font "Helvetica,16"
set ylabel 'ln(BTC mcap)' font "Helvetica,16"
set key box opaque height 2 left
set pointsize 1.5
set obj 4 rect at 1.5, graph 0 + .055 size char 41, char 4 front
set label 4 at 1.5, graph 0 + .075 BANNER front center font 'Helvetica,11'
CAPBAN="R^{2} value: " . CAPR2
set obj 5 rect at 3.5, graph 0 + .030 size char 20, char 2 front
set label 5 at 3.5, graph 0 + .030 CAPBAN front center font 'Helvetica,11'
f(x) = a*x + b
b = CAPINTERC
g(x) = a*x + c
c = CAPINTERC+CAPRMSE
h(x) = a*x + d
a = CAPSLOPE
d = CAPINTERC-CAPRMSE
plot "sfdata.csv" u 1:3 axes x1y1 t 'Daily market cap points' with points pt 1 lc 'blue',\
f(x) title sprintf("ln(mcap) = %s × ln(S2F) + %s",CAPSLOPE,CAPINTERC) lw 2 lc 'red',\
g(x) notitle lw 1 lc 'gray', \
h(x) notitle lw 1 lc 'gray'
reset
# MCap vs Price
set terminal png size 1600,960
set output 'c2pfactor.png'
set format y "%#.2f"
set timefmt "%s"
set xdata time
set format x "%Y"
set decimal locale
set ytics ( .25, .35, .50, .71, 1.00, 1.41, 2.00, 2.83, 4.00 )
set xtics 31556736
set xrange [1262300400:ENDEPOCH]
set yrange [.35:4]
set ylabel 'mcap prediction / price prediction' font "Helvetica,16"
set logscale y
set grid xtics ytics
#set key box opaque height 2 left
set datafile separator ","
#set key font 'Helvetica Narrow,12'
set title "S2F prediction on market cap vs price" font "Helvetica Bold,30"
set arrow from graph 0, first 1 to graph 1, first 1 nohead lt 2 lc 'blue' lw 2
set obj 3 rect at graph 0 + .4, graph 1 - .06 size char 41, char 4
set label 3 at graph 0 + .4, graph 1 - .04 BANNER front center font 'Helvetica,11'
plot \
"sftime.csv" using 1:9 axes x1y1 with lines lw 3 lc 'red' notitle
reset