You are on page 1of 15

Bayesian regression and

Bitcoin
Devevrat Shah and Kang
Zhang

P2P cryptographic, virtual currency


Created in 2009 by Satoshi Nakamoto (alias)
Unregulated
Can be purchased at handful of exchanges e.g
Okcoin.com
Mined by solving/computing cryptographic
puzzles (2.5 bitcoin/min)
Market cap US $4B
Daily transaction volume US $10M - $50M

Is Bitcoin price predictable?


Can it result into profitable strategy?

Data
February 2014 till July 2014
Price of Bitcoin
Order book at the exchange
60 best prices and associated and associated
for ask
60 best prices and associated and associated
for bid

Over 200M raw data points


Converted into evenly spaced (10 sec)
time-series

Trading strategy
Minimal position
-1, 0 or +1 Bitcoin

At each chosen* time instance


Predict average price change p over next 10s
If p > threshold and current position is 0
Buy 1 Bitcoin

If p < threshold and current position is 0


Sell 1 Bitcoin

Else do nothing

* Selection of time instances are done by looking for


inflection points in price

Performance: May 6-June


24, 2014

Profit of 3362 yuan over 50 days


Average investment of 3781 yuan

89% return

Performance: May 6-June


24, 2014
How consistent is the strategy?
Sharpe ratio is 4.10 over N = 2872
trades
profit riskfree
Recall
profit
ave

Sharpe ratio =

std

Where

profit ave

1 N
= profit i
N i=1

1
riskfree = startprice endprice
N
N

profit

2
std

1
= ( profiti profitave )
N i=1

Regression
x R y R,
Given observation
Training labeled data
{ x1, y1},L ,{ x n , y n }
Approach from non-parametric statistics
d

y = f (x) +

Example
f (x) = x T *
Noise
standard Gaussian
n
2
Estimate
T
LS argmin ( y i x i )
R
Predict
i=1
T
x LS
y=

Bayesian Regression
x Rd y R ,
Given observation
Training labeled data
{ x1, y1},L ,{ x n , y n }
Bayesian Inference

PXY

ComputeP(y | x)
n
Use data as proxy
P(y | x) 1(y i = y, x i = x)
i=1
Predicty=
E p [Y | x ]

Bayesian Regression [cf. Bishop and Tipping 2003]

Bayesian Regression and Latent


Source
Model
d
x R y R ,
Given observation
Training labeled data
{ x1, y1},L ,{ x n , y n }
PXY
Latent Source Model

K sources x1,L , x K R d
with probabilities
{1,K , K }

Distribution over

,K}
{1,K

K distributions
P1,L ,PK
Choose
T

over
{1,K ,K } P(T = k) = k

Generate
X = sT +
standard Gaussian
Y ~ PT

Draw

each
R over
noise
where

is

Latent Source Model by [Chen, Nikolov, Shah 13] [Bresler, Chen,

Predicting Price

Segments of Price Variation

Bayesian Regression and Latent


Source Model
y R
x R
Given observation
, predict
Training labeled data
{ x1, y1},L ,{ x n , y n }
d

Bayesian regression for latent source model


n

Gaussian
(BR-LSM)
? 1
2 ?
x x i 2 ?Noise
y i exp ?
? 4
?

i=1
E emp [y | x] = n
y
? 1
2 ?
x x i 2 ?
exp ?
? 4
?
i=1

X(x)y
y=

Predicting Price: BR-LSM


Data = Model

Current
Price

Historical
Data

future
prediction

Predicting Price: BR-LSM

Current
Price

future
prediction

Predicting Price using BR-LSM


Predicting price change
p
Create price time-series segments from Feb-late March 2014
price data.
Three different lengths 30 mins, 60 mins, 120 mins
Select representative
segments for each of these lengths
S1, S2, S3
Denote
Si
i {1,2,3}
pi
Using BR-LSM over
predict
for

(v bid v ask )
r=
book data

From order

compute
(v bid + v ask )

Predict
3

w j p j + w 4 r
p = w 0 +
j =1

weights are fitted using data in late March-early May


2014

Representative Patterns

Triangle

cf[Caginalp and Laurent 88, Lo and MacKinlay 98 and 99]

You might also like