8000 qdl-xbt-bitcoin.ipynb: references, new quandlcodes · lnsongxf/fecon235@04dc450 · GitHub
[go: up one dir, main page]

Skip to content

Commit 04dc450

Browse files
committed
qdl-xbt-bitcoin.ipynb: references, new quandlcodes
This revision validates d7xbtusd and d7xbtcount as quandlcodes, as well as, the introduction of names() in yi_quandl.py References to Bernanke letter, BoA report, and portfolio inclusion.
1 parent 6bc9ad0 commit 04dc450

File tree

1 file changed

+69
-52
lines changed

1 file changed

+69
-52
lines changed

nb/qdl-xbt-bitcoin.ipynb

Lines changed: 69 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,40 @@
66
"source": [
77
"## Bitcoin XBTUSD\n",
88
"\n",
9-
"We demonstrate how easily Bitcoin data can be statistically analyzed \n",
9+
"Federal Reserve Chairman Ben Bernanke in his 6 September 2013 letter \n",
10+
"to a Senate committee stated that Bitcoin and other virtual currencies \n",
11+
"\"*may hold long-term promise, particularly if the innovations\n",
12+
"promote a faster, more secure and more efficient payment system*.\" \n",
13+
"[See http://goo.gl/49I5ZI for the full letter.] \n",
14+
"\n",
15+
"Here demonstrate how Bitcoin data can be statistically analyzed \n",
1016
"by fecon235 as a financial asset.\n",
1117
"\n",
1218
"- 2016-12-30 The annualized volatility is 112%, which is astonishing. \n",
1319
"This implies (within less than one standard deviation) that it is \n",
1420
"equally probable in the coming year that Bitcoin will be \n",
1521
"totally worthless or roughly double in price.\n",
1622
"\n",
23+
"**This high volatility may hinder its general acceptance as a means of payments.** \n",
24+
"It role as store of value is speculative, but it may provide \n",
25+
"diversification to a portfolio (see Appendix 1).\n",
26+
"\n",
27+
"- For comparative valuation, we investigate XBTXAU (in terms of gold troy ounces) and XBTCNY (in terms of Chinese yuan, due to predominant Bitcoin mining activity in China). \n",
28+
"\n",
29+
" - As of 2017-02-07, one Bitcoin was insufficient to buy one troy ounce \n",
30+
"of gold, but the peaks of XBTXAU indicates temporary surge efforts \n",
31+
"(all-time high was 0.945 troy ounces on 2017-01-05 \n",
32+
"which is comparable to the 2013-12-04 record).\n",
33+
"\n",
1734
"\n",
1835
"- The upper bound on the number of Bitcoins is 21 million. \n",
19-
"This limit has economic consequences [to be discussed, perhaps in another notebook]."
36+
"This limit has economic consequences [to be discussed, perhaps in another notebook].\n",
37+
"\n",
38+
"In 2013, the Foreign Exchange team at Bank of America (David Woo, Ian Gordan, et al.) \n",
39+
"produced its first assessment in an extensive 14-page report:\n",
40+
"\"our fair value analysis implies a maximum market capitalization of Bitcoin \n",
41+
"of \\$15bn (1 BTC = 1300 USD).\" Capitalization is in fact currently about 16 billion USD, \n",
42+
"and we provide the means to compute that statistic.\n"
2043
]
2144
},
2245
{
@@ -49,6 +72,8 @@
4972
" \n",
5073
"*CHANGE LOG*\n",
5174
"\n",
75+
" TODO [ ] Add XBTCNY analysis.\n",
76+
" 2017-02-07 Add references. Use newly defined quandlcodes.\n",
5277
" 2016-12-31 First version."
5378
]
5479
},
@@ -107,33 +132,14 @@
107132
"source": [
108133
"## Bitcoin data\n",
109134
"\n",
110-
"We first define some Quandl symbols used by Blockchain, \n",
111-
"then retrieve selected data.\n",
112-
"\n",
113-
"Source: https://www.quandl.com/data/BCHAIN-Blockchain\n",
114-
"which also offers:\n",
135+
"Source: https://www.quandl.com/data/BCHAIN-Blockchain which also offers:\n",
115136
"\n",
116137
"- Number of Unique Bitcoin Addresses Used\n",
117138
"- Total Number of Transactions\n",
118139
"- Average Transaction Confirmation Time\n",
119-
"- Miners Revenue\n"
120-
]
121-
},
122-
{
123-
"cell_type": "code",
124-
"execution_count": null,
125-
"metadata": {
126-
"collapsed": true
127-
},
128-
"outputs": [],
129-
"source": [
130-
"# These may get defined globally in the main module.\n",
131-
"\n",
132-
"d4xbt = 'BCHAIN/MKPRU' # Price in USD (approx. $960)\n",
133-
"d4xbtN = 'BCHAIN/TOTBC' # Number of Bitcoins (approx. 16 million)\n",
140+
"- Miners Revenue\n",
134141
"\n",
135-
"# d4xbtCap = 'BCHAIN/MKTCP' # Market capitalization (approx. 16 billion USD)\n",
136-
"# This series can be largely replicated by multiplying the forementioned."
142+
"We pre-defined quandcodes for Bitcoin count and USD price."
137143
]
138144
},
139145
{
@@ -144,24 +150,12 @@
144150
},
145151
"outputs": [],
146152
"source": [
147-
"xbt = get( d4xbt )\n",
148-
"xbtN = get( d4xbtN )"
149-
]
150-
},
151-
{
152-
"cell_type": "code",
153-
"execution_count": null,
154-
"metadata": {
155-
"collapsed": false
156-
},
157-
"outputs": [],
158-
"source": [
159-
"dflist = [xbt, xbtN]\n",
153+
"# d7 means frequency of 7 days per week:\n",
154+
"xbt = get( d7xbtusd ) # Bitcoin price in USD (approx. 960 USD)\n",
155+
"xbtN = get( d7xbtcount ) # number of Bitcoins mined thus far (approx. 16 million)\n",
160156
"\n",
161-
"for df in dflist:\n",
162-
" df.index.names = ['T']\n",
163-
" df.columns = ['Y']\n",
164-
" # These names are fecon235 conventions."
157+
"# Market capitalization will computed by multiplying the two: approx. 16 billion USD.\n",
158+
"# Double check: d4xbtCap = 'BCHAIN/MKTCP' "
165159
]
166160
},
167161
{
@@ -232,7 +226,12 @@
232226
"and unclaimed rewards, the maximum number of Bitcoins is \n",
233227
"technically 20999999.9769.]\n",
234228
"\n",
235-
"Currently about 98% of Bitcoin mining originates from China."
229+
"**Currently about 98% of Bitcoin mining originates from China.** \n",
230+
"David Woo at Bank of America back in 2013 pointed out: \n",
231+
"\"The correlation between CNY’s share of volume of all Bitcoin exchanges \n",
232+
"and price of Bitcoin is high and rising.\" \n",
233+
"Later we shall investigate Bitcoin's relationship to \n",
234+
"the Chinese yuan."
236235
]
237236
},
238237
{
@@ -281,7 +280,7 @@
281280
},
282281
"outputs": [],
283282
"source": [
284-
"# Append xbtCap to dflist:\n",
283+
"# List of dataframes:\n",
285284
"dflist = [xbt, xbtN, xbtCap]\n",
286285
"\n",
287286
"# Create Bitcoin DataFrame:\n",
@@ -450,11 +449,12 @@
450449
"cell_type": "markdown",
451450
"metadata": {},
452451
"source": [
453-
"## Relationship to Gold, XAU\n",
452+
"## Relationship to Gold: XAU\n",
454453
"\n",
455454
"First we investigate whether any linear relationship \n",
456-
"exists between XBT and XAU. We shall rely on Python's *pandas* \n",
457-
"to handle the date alignment correctly in our regression analysis."
455+
"exists between XBT and XAU, the perennial store of value. \n",
456+
"We shall rely on Python's *pandas* to handle the date alignment \n",
457+
"correctly in our regression analysis."
458458
]
459459
},
460460
{
@@ -478,9 +478,7 @@
478478
"outputs": [],
479479
"source": [
480480
"# We shall use the fitted XBT price in our regression:\n",
481-
"stat2( xbtema[begin:]['Y'], xau[begin:]['Y'] )\n",
482-
"\n",
483-
"# Our time index T is used for date alignment."
481+
"stat2( xbtema[begin:]['Y'], xau[begin:]['Y'] )"
484482
]
485483
},
486484
{
@@ -560,9 +558,28 @@
560558
"will look very similar since the correlation between the two \n",
561559
"ranges from 0.97 to 0.99 depending on the time frame.\n",
562560
"\n",
563-
"As of 2016-12-30, one Bitcoin was insufficient to buy one troy ounce \n",
561+
"As of 2017-02-07, one Bitcoin was insufficient to buy one troy ounce \n",
564562
"of gold, but the peaks of XBTXAU indicates temporary surge efforts \n",
565-
"(all-time high was 0.926 troy ounces on 2013-12-04)."
563+
"(all-time high was 0.945 troy ounces on 2017-01-05 \n",
564+
"which is comparable to the 2013-12-04 record)."
565+
]
566+
},
567+
{
568+
"cell_type": "markdown",
569+
"metadata": {
570+
"collapsed": true
571+
},
572+
"source": [
573+
"---\n",
574+
"\n",
575+
"## Appendix 1: Reference notes\n",
576+
"\n",
577+
"- Brière M., K. Oosterlinck and A. Szafarz, “*Virtual Currency, Tangible Return: Portfolio Diversification with Bitcoins*\", SSRN Working Paper N°2324780, 2013. http://goo.gl/40VIxr\n",
578+
"\n",
579+
"Despite the extreme volatilty, Brière et al. claim Bitcoin-inclusive portfolios \n",
580+
"will deliver superior mean-variance trade-offs than similar BTC-free portfolios. \n",
581+
"They proposed about 3% BTC inclusion.\n",
582+
"\n"
566583
]
567584
},
568585
{
@@ -591,7 +608,7 @@
591608
"name": "python",
592609
"nbconvert_exporter": "python",
593610
"pygments_lexer": "ipython2",
594-
"version": "2.7.11"
611+
"version": "2.7.13"
595612
}
596613
},
597614
"nbformat": 4,

0 commit comments

Comments
 (0)
0