Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
4. Informatics
1. Quantitative Finance: a brief overview
Part 4/4 - Informatics
Dr. Matteo L. BEDINI
Central University of Finance and Economics, Beijing, PRC
27 March 2015
2. Disclaimer
The opinions expressed in these lectures are solely of the author and do not
represent in any way those of the present/past employers.
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 2 / 32
3. Objective
The objective of this lecture is to provide two example showing the
ever-growing relevance of Informatics in modern Finance.
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 3 / 32
4. Agenda - IV1
1 The Bitcoin Protocols
Preliminaries
The Bitcoin protocols
bitcoins: Further Considerations
2 Algorithmic Dierentiation
Preliminaries
Motivation
Algorithmic Dierentiation: the main Idea
3 Bibliography and Informatics Brainteasers
1The author would like to thank Ferdinando Ametrano for the interesting discussion
on Bitcoin and cryptocurrencies, and Roberto Daluiso for the useful material on
Algorithmic Dierentiation.
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 4 / 32
5. The Bitcoin Protocols Preliminaries
Agenda - IV
1 The Bitcoin Protocols
Preliminaries
The Bitcoin protocols
bitcoins: Further Considerations
2 Algorithmic Dierentiation
Preliminaries
Motivation
Algorithmic Dierentiation: the main Idea
3 Bibliography and Informatics Brainteasers
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 5 / 32
6. The Bitcoin Protocols Preliminaries
Preliminaries
Hash functions (SHA-256)
Asymmetric cryptography (private/public keys encryption)
Digital signatures
Example
h_SHA256(Hello, world!0) =
1312af178c253f84028d480a6adc1e25e81caa44c749ec81976192e2ec934c64
h_SHA256(Hello, world!4250) =
0000c3af42fc31103f1fdc0151fa747ff87349a4714df7cc52ea464e12dcd4e9
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 6 / 32
7. The Bitcoin Protocols The Bitcoin protocols
Agenda - IV
1 The Bitcoin Protocols
Preliminaries
The Bitcoin protocols
bitcoins: Further Considerations
2 Algorithmic Dierentiation
Preliminaries
Motivation
Algorithmic Dierentiation: the main Idea
3 Bibliography and Informatics Brainteasers
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 7 / 32
8. The Bitcoin Protocols The Bitcoin protocols
Bitcoin 1/62
[...] Digital signatures provide part of the solution [...] [N]
Basic information
I, Alice, am giving
Bob one bitcoin
Better
I, Alice, am giving
+ Alice's digital signature
Bob one bitcoin
Even Better
I, Alice, am giving
+ Alice's digital signature
Bob the bitcoin # 123654
Who's printing serial the serial number 123654? A bank certifying that:
1 bitcoin #123654 actually belongs to Alice
2 Alice hasn't yet spent the bitcoin #123564
hence guaranteeing and authorizing the transaction from Alice to Bob?
2Next slides follows [Ni]
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 8 / 32
9. The Bitcoin Protocols The Bitcoin protocols
Bitcoin 2/6
[...] the main benets are lost if a trusted third party is required to
prevent double spending [...] [N]
Idea: everybody is a bank thanks to a blockchain.
Bob, before accepting a payment from Alice, has to
1 check his own copy of the blockchain
2 broadcast the transaction on the Bitcoin network.
When enough users (50? 50%?) will have conrmed (?) the transaction,
this will be actually registered on Bob's account.
Two problems remain to be solved:
1 Who's printing serial numbers on bitcoins?
2 Double-spending cannot be dicult, it must be practically impossible.
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 9 / 32
10. The Bitcoin Protocols The Bitcoin protocols
Bitcoin 3/6
[...] The network timestamps transactions by hashing them into an ongoing chain of
hash-based proof-of-work, forming a record that cannot be changed without redoing the
proof-of-work [...] [N]
Validating transaction is computationally costly (nd the nonce).
Reward (today 25 BTC) for the user validating a block.
Mining: 1 CPU = 1 vote
1 Check block's transaction integrity
2 Find the nonce satisfying a given target (such that. . . )
3 Broadcast on Bitcoin block + nonce
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 10 / 32
11. The Bitcoin Protocols The Bitcoin protocols
Bitcoin 4/6
[...] The longest chain not only serves as a proof of the sequence of
events witnessed, but proof that it came from the largest pool of CPU
available [...] [N]
Every block points to the previous one (from which then name:
blockchain).
Forks may occur whenever two blocks are simultaneously validated.
Keep track of the forks, but always work on the longest chain.
A transaction is conrmed when 5 other blocks are validated after its
block on the longest chain.
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 11 / 32
12. The Bitcoin Protocols The Bitcoin protocols
Bitcoin 5/6
[...] As long as a majority of CPU power is controlled by nodes that are
not cooperating to attack the network, they'll generate the longest chain
and outpace the attackers [...] [N]
Problem of Double-Spending: how to do it?
1 Two transactions TxB and TxC in the same block B? NO. Even if
Alice validates B, other network users will not.
2 Transaction TxB in block B1 and transaction TxC in block B2? NO.
Even if Alice validates and broadcast the two blocks, only one of the
two blocks will be part of the blockchain (i.e., the one reaching the
pool of miners with greater computing power).
3 Alice waits for Charlie accepting the transaction, goes back of 6
blocks, forks the blockchain and try to outpace it with her new
branch. OK only if Alice (alone) has at least the 51% of
computing power of the whole network.
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 12 / 32
13. The Bitcoin Protocols The Bitcoin protocols
Bitcoin 6/6
Bitcoin is a peer-to-peer protocol enabling transaction in bitcoins.
The result is an online payment system that does not need trusted
third party.
Starting from 2009, 50 BTC are generated and given to those who
validate a block.
This amount halves every four years (today: 25 BTC).
This is the only way of creating new bitcoins.
In 2140 there will be 21 mln of bitcoins and the total supply of
bitcoins will cease to grow.
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 13 / 32
14. The Bitcoin Protocols bitcoins: Further Considerations
Agenda - IV
1 The Bitcoin Protocols
Preliminaries
The Bitcoin protocols
bitcoins: Further Considerations
2 Algorithmic Dierentiation
Preliminaries
Motivation
Algorithmic Dierentiation: the main Idea
3 Bibliography and Informatics Brainteasers
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 14 / 32
15. The Bitcoin Protocols bitcoins: Further Considerations
The bitcoins economy
BTC ecosystem (http://www.coindesk.com/data/bitcoin/) 25th March
2015:
Total blocks: 348,323
Total bitcoins: 13,958,025
Market cap: ≈3,432,676,151.21 USD (≈ 7 770 550 893 USD July '14)
First block mined on the 3rd January 2009
Figure: Closing prices of bitcoins
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 15 / 32
16. The Bitcoin Protocols bitcoins: Further Considerations
A note on mining
Who is (was) getting rich in a gold race?
Figure: Source: BusinessWeek
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 16 / 32
17. The Bitcoin Protocols bitcoins: Further Considerations
A new fast-changing world
1 Are bitcoins good moneys?
BTW: Are bitcoins a currency or a commodity?
Good money should provide stable purchasing power which, in turns,
depends on both demand and supply.
The lack of political manipulation can be viewed both as a plus and as
a minus when it comes to judge the success of bitcoins as a currency.
2 Lot of development
Ethereum https://www.ethereum.org/: decentralized application.
Ripple https://ripple.com/: agnostic peer-to-peer payment system.
Litecoin, Dodgecoin, ...
Hayeck-money (see the paper of Ametrano [A])
...
3 Bitcoin technology holds some promises, bitcoins as a currency is probably
only a (very) successful experiment.
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 17 / 32
18. Algorithmic Dierentiation Preliminaries
Agenda - IV
1 The Bitcoin Protocols
Preliminaries
The Bitcoin protocols
bitcoins: Further Considerations
2 Algorithmic Dierentiation
Preliminaries
Motivation
Algorithmic Dierentiation: the main Idea
3 Bibliography and Informatics Brainteasers
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 18 / 32
19. Algorithmic Dierentiation Preliminaries
The Chain-Rule
In its simplest form:
df (g (x))
dx
=
df (u)
du u=g(x)
·
dg (x)
dx
.
Example: y := f (x1, x2) = x1x2 + sin (x1)
We want to compute y:
1 y = u + v ⇒ ∂y
∂u = 1,
∂y
∂v = 1, where
2 u := x1x2 ⇒ ∂u
∂x1
= x2,
∂u
∂x2
= x1
3 v := sin (x1) ⇒ ∂v
∂x1
= cos (x1),
∂v
∂x2
= 0
Consequently
y =
∂y
∂x1
∂y
∂x2
=
∂y
∂u
∂u
∂x1
+ ∂y
∂v
∂v
∂x1
∂y
∂u
∂u
∂x2
+ ∂y
∂v
∂v
∂x2
=
1 · x2 + 1 · cos (x1)
1 · x1 + 1 · 0
=
x2 + cos (x1)
x1
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 19 / 32
20. Algorithmic Dierentiation Motivation
Agenda - IV
1 The Bitcoin Protocols
Preliminaries
The Bitcoin protocols
bitcoins: Further Considerations
2 Algorithmic Dierentiation
Preliminaries
Motivation
Algorithmic Dierentiation: the main Idea
3 Bibliography and Informatics Brainteasers
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 20 / 32
21. Algorithmic Dierentiation Motivation
Computing the Greeks of an option
The value V of nancial derivative is a function of some input parameter θ
(d-dimensional)
V = V (θ) .
The Greeks represents the sensitivity of the price to changes of the
underlying parameter θ and this is what we are interested in
dV
dθ
.
Example: of a European call option (θ = s)
V (s) = sN (d+) − Ke−rτ N (d−), d± = ln
s
K + r ± σ2
2
τ / (σ
√
τ).
:=
dV
ds
= N (d+) .
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 21 / 32
22. Algorithmic Dierentiation Motivation
How to compute?
Finite dierence:
dV
dθ
≈
V (θ + h) − V (θ)
h
.
Problems:
1 Accuracy: if h is too big the estimate is rough, if h is too small,
numerical error at numerator is amplied.
2 Computational cost:
Cost V (θ) dV
dθ
Cost(V (θ))
= # of partial derivatives + 1.
Note that the number of derivatives may be large, not just 1 or 2: e.g.
for a vanilla 10Y EUR swap it may be 42 (see, e.g., [H]).
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 22 / 32
23. Algorithmic Dierentiation Motivation
Monte Carlo pricing
Keep in mind that the value V (θ) of a derivative is often computed via Monte
Carlo pricing methods, which are computationally expensive:
V (θ) := E[Φ (Z, θ)] , Z is a r.v.
≈
1
N
N
i=1
Φ (Z (ωi ) , θ) , for only one price!
Idea
We compute the derivative path-by-path
dV
dθ
=
d
dθ
E[Φ (Z, θ)]
!
= E
∂
∂θ
Φ (Z, θ) ≈
1
N
N
i=1
∂
∂θ
Φ (Z (ωi ) , θ)
and using Algorithmic Dierentiation (AD) and we can achieve
Cost V (θ)
dV
dθ
Cost (V (θ))
≤ 4.
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 23 / 32
24. Algorithmic Dierentiation Algorithmic Dierentiation: the main Idea
Agenda - IV
1 The Bitcoin Protocols
Preliminaries
The Bitcoin protocols
bitcoins: Further Considerations
2 Algorithmic Dierentiation
Preliminaries
Motivation
Algorithmic Dierentiation: the main Idea
3 Bibliography and Informatics Brainteasers
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 24 / 32
25. Algorithmic Dierentiation Algorithmic Dierentiation: the main Idea
Algorithmic Dierentiation 1/2
The idea is that a function implemented as a computer program is just the
composition of simpler functions and then one can use the chain rule:
[...] Algorithmic dierentiation (AD) [...] is a set of programming
techniques for the ecient calculation of the derivatives of functions
implemented as computer programs. The main idea underlying these
techniques is the fact that any such function, no matter how complicated,
can be interpreted as a composition of basic arithmetic and intrinsic
operations that are easy to dierentiate. [...] [CG]
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 25 / 32
26. Algorithmic Dierentiation Algorithmic Dierentiation: the main Idea
Algorithmic Dierentiation 2/2
[...] What makes AD particularly attractive, when compared to
nite-dierence methods is its computational eciency. In fact, AD
exploits the information on the structure of the computer code in order to
optimize the calculation. In particular, when one requires the derivatives of
a small number of outputs with respect to a large number of inputs, the
calculation can be highly optimized by applying the chain rule through the
instructions of the program in opposite order with respect to their original
evaluation. [...] [CG]
Tangent method: forward application of the chain rule.
Adjoint method: backward application of the chain rule.
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 26 / 32
27. Algorithmic Dierentiation Algorithmic Dierentiation: the main Idea
Example Adjoint Method
Figure: Backward dierentiation of f (x1, x2) = x1x2 + sin (x1). Source [wiki].
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 27 / 32
28. Algorithmic Dierentiation Algorithmic Dierentiation: the main Idea
Other aspects
The interested audience can nd further interesting material in
Marc Henrard's paper [H] which pays attention to the problem of
calibration using the implicit function theorem.
Luca Capriotti's paper [C] which provides interesting numerical
experiments.
References given in the above papers can give an idea of the increasing
interest of the nancial community in this programming technique that can
be of crucial importance.
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 28 / 32
29. Bibliography and Informatics Brainteasers
Agenda - IV
1 The Bitcoin Protocols
Preliminaries
The Bitcoin protocols
bitcoins: Further Considerations
2 Algorithmic Dierentiation
Preliminaries
Motivation
Algorithmic Dierentiation: the main Idea
3 Bibliography and Informatics Brainteasers
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 29 / 32
30. Bibliography and Informatics Brainteasers
Informatics Brainteaser 1/3
Add arithmetic operators (plus, minus, times, divide) to make the following
expression true:
3 1 3 6 = 8.
You can use any parentheses you'd like.
(Source [X2]).
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 30 / 32
31. Bibliography and Informatics Brainteasers
Informatics Brainteaser 2/3
Consider the following piece of code:
double x = 1.0;
double a = x*x - 2.0*x + 1.0;
if(a==0.0){/*do stuff here*/}
Why you may never execute the code inside the if-cycle?
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 31 / 32
32. Bibliography and Informatics Brainteasers
Informatics Brainteaser 3/3
How many are the functions from a set of m elements into a set of n
elements?
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 32 / 32
33. Bibliography and Informatics Brainteasers
F. Ametrano. Hayek Money: The Cryptocurrency Price Stability
Solution. Available at http:
//papers.ssrn.com/sol3/papers.cfm?abstract_id=2425270.
L. Capriotti. Fast Greeks by algorithmic dierentiation. The Journal of
Computational Finance, 3-35, Volume 14/Number 3, Spring 2011.
Available at http://www.luca-capriotti.net/pdfs/Finance/jcf_
capriotti_press_web.pdf.
L. Capriotti, M. Giles. Algorithmic Dierentiation: Adjoint Greeks
Made Easy. 2011. Available at http:
//papers.ssrn.com/sol3/papers.cfm?abstract_id=1801522.
T. F. Crack. Heard on the Street: Quantitative Questions from Wall
Street Job Interview. Paperback, 2014 ([X1] of brainteasers).
M. Henrard. Adjoint Algorithmic Dierentiation: Calibration and
Implicit Function Theorem. OpenGamma Quantitative Research,
November 2011. Available at
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 32 / 32
34. Bibliography and Informatics Brainteasers
http://www.opengamma.com/sites/default/files/
adjoint-algorithmic-differentiation-opengamma1.pdf.
G. Laakmann McDowell. Cracking the Coding Interview: 150
Programming Questions and Solutions. Paperback, 2011 ([X2] of
brainteasers).
S. Nakamoto. Bitcoin: A peer-to-peer electronic cash system.
https://bitcoin.org/bitcoin.pdf, October 2008.
M. Nielsen. How the Bitcoin protocols actually works.
http://www.michaelnielsen.org/ddi/
how-the-bitcoin-protocol-actually-works/, December 2013.
R. Poulsen. Four Things You Might Not Know about the
Black-Scholes Formula. 2007. Paper available at
http://papers.ssrn.com/sol3/papers.cfm?abstract_id=991344
([X3] of brainteasers).
http://en.wikipedia.org/wiki/File:
ReverseaccumulationAD.png
Dr. Matteo L. BEDINI Quantitative Finance IV: Informatics CUFE - 27 March 2015 32 / 32