C++ Programming for Financial Engineering
Finished my C++ Exam and I got an average >90% yay!
A new Baruch certificate with distinction!
Finished my C++ Exam and I got an average >90% yay!
A new Baruch certificate with distinction!
Expectation
Variance: $\mathrm{Var}(X)=\mathbb{E}[(X-m)^2],\qquad m=\mathbb{E}[X].$
Uniform distribution: $X\sim\mathcal{U}([a,b])$
Exponential distribution: $f(x)=\lambda e^{-\lambda x}$
Normal distribuiton: $f_{m,\sigma}(x)=\frac{1}{\sqrt{2\pi\sigma^2}}\exp\!\left(-\frac{(x-m)^2}{2\sigma^2}\right).$
Joint density: X,Y random variables and double integral for probability
Marginal density: We integrate over one variable so only the other is left
Independence: Joint heights factor into product of marginal heights
MLE
Hypothesis testing
Confidence intervals
17.08 finished recap and went through exam
Started recapping probability theory and statistics which I had in 4th semester of ETH.
Laplace means probability have same chance so problem turns into occurences / total set
Conditional Probability: $\mathbb{P}[A\mid B]=\frac{\mathbb{P}[A\cap B]}{\mathbb{P}[B]}.$
Law of total probability: $\mathbb{P}[A]=\sum_{i=1}^n \mathbb{P}[A\mid B_i]\,\mathbb{P}[B_i]$ when B are partition of $\Omega$.
Bayes: $\mathbb{P}[B_i\mid A]=\frac{\mathbb{P}[A\mid B_i]\,\mathbb{P}[B_i]}{\sum_{j=1}^n \mathbb{P}[A\mid B_j]\,\mathbb{P}[B_j]}.$ Given the outcome what is probability of hypothesis.
$A$ and $B$ are independent when $\mathbb{P}[A\cap B]=\mathbb{P}[A]\,\mathbb{P}[B].$
Multiple events: Every subcollection needs to be independent
Random Variables: independent and identically distributed
Measurable map, grouping of events with different payoff (function).
Continous:
Discrete:
Bernouille: one yes/no trial
Binomial: n independent Bernouille trails
Geometric: Bernoille untill first success
Poisson: Approximation of Binomial for rare events, large n small p, $\lambda=np$, $\mathbb{P}[N=k]=e^{-\lambda}\frac{\lambda^k}{k!},\qquad k=0,1,2,\ldots.$
Level 9 — exact BS, perpetual American, Monte Carlo, SD/SE, Excel COM, and explicit FDM puts.
Implementation of European Option Pricing with Black-Scholes Model
Put Call Parity relationships
Matrix Pricer to price multiple options
Option Sensitivities aka Greeks
(so $P = C + K e^{-rT} - S$, and $C = P + S - K e^{-rT}$)
Perpetual American Option Pricing
GBM paths via Euler–Maruyama; European call/put by averaging discounted payoffs; sweep NT / NSim on Batches 1, 2, 4.
NSim).($k = T/N$, $N$ = time steps)
NSim cuts statistical noise; NT cuts Euler time-discretization bias — both needed.N=10) leaves a bias floor even with millions of paths.NSim often matters more than N; long $T=30$ needs much larger NT and NSim.Added generic SD / SE on the vector of discounted path payoffs (Statistics.hpp), wired into TestMC / RunMC; reported SD/SE vs NT / NSim on Batches 1–2.
($M$ = NSim)
N or NSim change.NT barely affects SE.N is large enough, absolute error vs exact is often on the order of SE (MC noise, not Euler bias).NSim → harder to match exact.Ran Duffy Excel demos (TestSingleCurve, TestTwoCurve, TestMultiCurve) on Windows via Parallels + Office 365 (path / #import / Boost / IntDir fixes for Mac→VM). Then TestExactMeshExcel: mesh of $S$, exact BS prices from Group A into a vector, charted in Excel.
Explicit Euler on the Black–Scholes PDE (European put); TestBSPDE1 + Excel. Batches 1–4 with mesh $S_{\max}=2K$, $J=2K$, $N=9999$.
ParabolicPDE.hpp — IBVP callbacks ($\sigma$, $\mu$, $b$, $f$, BCL, BCR, IC)Mesher.hpp — uniform grids in $S$ and $t$FDM.hpp — one explicit Euler time stepFDMDirector.hpp — meshes + IC + time loop to $T$Level 9:
get it working:
Monte Carlo Simulations
FDA (Finite Difference Approximation)
Finite Difference Methods
Lattice methods
Did more lectures the past 2 weeks on C++. Finished Level 2 till 8. Planning on finishing 9 and 10 and take the exam this month.
Started the Baruch C++ Programming for Financial Engineering Certificate
Lecture 1:
Exam for the ODE PDE Baruch course
Interview:
Sanity check at the end is useful, you can tell the interviewer that you will do a sanity check
Did more but not going to put it here for now, as I already have it on my edu site
CAPM: combination of risk free asset and tangent portfolio
Sharpe Ratio: Slope of riskfree + risky of efficient frontier = sharpe ratio
Tangent Portfolio has the highest sharpe ratio among risky assets
2 Weeks of IMC Prosperity 4 Challenge
Analyse the Problem & Data clearly first
Generate clear logic first, then a plan on how to implement it and only then generate the program
Pay attention to small details
Lec 06:
Random vectors and their distributions
Portfolio Management:
Options:
Arbitrage opportunity
Pice bounds for options
Put-call parity
Binomial model
Blackscholes
Pricing by arbitrage
We have multiple linear independent assets (think of polymarket contracts)
Arbitrage portfolio
Economic analysis of asset markets
Uncertain environments:
Preference relation
Complete $for any L and L′∈L(Z ) we have L ⪰L′or L′⪰L$
Transitive $(L1 ⪰L2 and L2 ⪰L3) ⇒L1 ⪰L3$
VNM (Von Neumann and Morgenstern) Expected Utility Theory
Independence
Continuity
Risk Averse
Risk increase
SOSD: Second-order stochastic dominance: if dominant then less risky than other
$EL[x] ≥EL′[x]$
$\int_{-\infty}^{y} F_L(x)dx \leq \int_{-\infty}^{y} F_{L'}(x)dx$ less weight on smaller returns
Mean preserving spread -> more risk
Quantifying Risk Aversion
Lecture on Financial Engineering
Lecture 1-6, not sure which ones I did this month
Exercise notes for Financial Engineering.
Lecture on Financial Economics.
Lecture 1-3:
Introduction to financial markets, asset pricing, and portfolio management.
More notes on this lecture.
Options, debt financing, risk management, financial planning & working capital management, mergers
Interesting Facts
Many traditional banks are not hedging with options yet
Holcim: write put options and buy call options to acquire public companies
Winners quit all the time and at the right time. Quit the wrong stuff, stick with the right stuff
Build wealth by acquiring assets, not liabilities—and shift from working for money to making money work for you
Some life insights from professor Didier Sornette from ETH Zurich