Monte Carlo Simulation - Black-Scholes-Merton Put Option (European Option)
Continuous Compounding Interest Formula - Code in C++
A = Per*t
Daily Compounding:
A = P(1 + r/365)365*t
Monthly Compounding:
A = P(1 + r/12)12*t
Quaterly Compounding:
A = P(1 + r/4)4*t
Yearly Compounding:
A = P(1 + r)t
Where:
A = end amount
P = principal amount
e = Euler constant
r = rate of growth
t = time period
The e
constant is defined as:
To find r or t you have to use the natural logarithm -- std::log()
.
This program uses references and vectors instead of pointers and arrays -- initially it was done this way (using pointers and arrays), but I decided to change it to make it more compatible with C++.
Using arrays and pointers is allowed in C++, but it is more of a C implementation.
#compile with clang++ or g++
g++ compound_interest.cpp -o ci
#run
./ci
Compound Interest Formula- Code in C
Uses pointers and arrays.
Will try to add a struct that contains all the variables needed for the formula.
#compile with clang or gcc
gcc compound_interest.c -lm
#run
./a.out
Shorting the Market
Python script that shows what happens when short selling
Two methods:
- Price if the stock increases
- Price if the stock decreases
Results are a dataframe with the different price movements
Options Analysis
Languages:
- Python
- Go
P/L -- profit/loss analysis
Greeks (Delta, Theta, Gamma, Vega, Rho) -- using the Black-Scholes formula and solving the derivation
d1 = (np.log(S / K) + (r + 0.5 * sigma ** 2) * T) / (sigma * np.sqrt(T))
Citation:
Python for Finance, Yves Hilpisch - O'reilly Books
Black-Scholes-Merton - UCD
Euler Methods - MIT
More Information on Growth Formula - Continuous Growth and Decay
Applied Finance Example - Certificates of Deposit
The C Programming Language Dennis Ritchie and Brian Kernighan - Pointers and Arrays (Chapter 5) - CS Princeton University
Euler Constant Image - CodeCogs
Short Example - Investopedia - Minimum Margin Requirements
Dynamic Hedging, Nassim Nicholas Taleb - Book