quantdev.blog
  • About
  • Sell-side Quant
  • C++ Roadmap
Categories
All (54)
Back to the basics (2)
C++ (18)
Credit Derivatives (1)
Linear Algebra (4)
Machine Learning (5)
Numerical Methods (5)
Probability Theory (1)
Python (3)
Rates Modelling (2)
Stochastic Calculus (11)
Vanilla Options (1)
Volatility modelling (1)

Hi there! Welcome to my blog. I’m Quasar. I am a software engineer turned quantitative analyst.

Here, I’ll document my coding conquests, exploring practical modern C++ and financial math, building practical and impractical tools, to playing around with numerics!

Quanto Options
Stochastic Calculus
A quanto option is…
Quasar
May 16, 2025

Custom iterators and Iterator concepts
C++
An iterator is a generalization of a pointer. C++ STL containers usually expose iterators as part of their…
Quasar
May 5, 2025

A note on make_shared<T>(Args&&...) and make_unique<T>(Args&&...)
C++
Since C++14, unique_ptr<T> has been accpompanied by the factory function make_unique<T>(Args&&...) that perfectly forwards its arguments to the constructor of T. Why standard library implementors provide a separate…
Quasar
May 4, 2025

unique_ptr - A custom implementation
C++
In this post, I try to write a simple homegrown version of std::unique_ptr<T>. This post is partly inspired by the fantastic book C++ Memory Management by Patrice Roy. Tghe toy examples in this book are very instructive and I highly reckon you order a copy. Our goal is just to build intuition for the kind of code required to write such a…
Quasar
Apr 21, 2025

shared_ptr - A custom implementation
C++
shared_ptr<T> is tricky to implement, since it is a wrapper over raw underlying pointer of type T* and a reference counter. This post is partly inspired by the fantastic book C++ Memory…
Quasar
Apr 21, 2025

C++ Atomics
C++
Atomic operations are indivisible. Consider, for instance a shared variable counter that is initialized to 0.…
Quasar
Mar 8, 2025

numpy and pandas CheatSheet
Python
np.arange(start, stop, step) returns evenly spaced values in a given interval.
Quasar
Mar 6, 2025

Python lists, dicts, tuples
Python
Python dicts are a collection of key-value pairs implemented as hash tables. dicts can be updated in place and dictionaries can grow and shrink as needed.
Quasar
Mar 5, 2025

DIY asyncio
Python
In single-core processors, the machine can only perform one task at a time, but can…
Quasar
Feb 28, 2025

A thread-safe queue implementation
C++
In the producer-consumer problem, we have two classes of threads, producers and consumers and a buffer containing a fixed number of slots. A producer thread attempts to put something into the next empty…
Quasar
Feb 23, 2025

Thread-Safe Stack Implementation
C++
We can use C++ synchronization primitives to implement a basic thread-safe stack and queue.
Quasar
Feb 23, 2025

Margrabe’s formula
Back to the basics
Let \(S_1(t)\) and \(S_2(t)\) denote the prices of two risky assets which have dynamics:
Quasar
Feb 22, 2025

Levenberg-Marquardt Algorithm
Numerical Methods
The Levenberg-Marquardt(LM) method consists of an iterative least-squares minimization of a function based on a modification of the Newton method. It’s a super-intuitive…
Quasar
Feb 1, 2025

C++ Ranges
C++
C++ ranges are a programmatic abstraction for any container/type T that allows iteration over its elements by providing begin and end iterators. A std::ranges::range is…
Quasar
Jan 31, 2025

Collateralized Discounting
Back to the basics
In the past, standard derivatives pricing theory assumed the existence of a risk-free rate for derivatives discounting. Until the…
Quasar
Jan 27, 2025

IRS, Caps, Floors and Swaptions
Rates Modelling
I review here a few basic definitions relevant to the interest-rate world.
Quasar
Jan 24, 2025

CRTP(Curiously recurring template pattern)
C++
Imagine you have an inheritance hierarchy to implement mathematical interpolation.
Quasar
Dec 28, 2024

Rule of Five
C++
The rule-of-five states that, if a class C has one of user-declared
Quasar
Dec 27, 2024

Currying and partial function application
C++
Let \(u=f(x_1,\ldots,x_n)\) be a function of \(n\) variables. curry<n>(f) is an operator form of the function \(f\), such that:
Quasar
Dec 11, 2024

Copy-and-swap idiom
C++
The canonical way to write the copy assignment operator is the following:
Quasar
Dec 10, 2024

SFINAE
C++
When we write templates, we sometimes need to restrict the template arguments. For instance, we have a function that should work for any…
Quasar
Dec 7, 2024

C++20 concepts
C++
A class template, function template (including lambdas) may be associated with a constraint, which specifies requirements on the template arguments. This…
Quasar
Dec 7, 2024

A gentle introduction to the Girsanov Theorem - Back to the basics
Stochastic Calculus
One of the most popular technical tools in…
Quasar
Dec 1, 2024

Fun with numeraires!
Stochastic Calculus
A proficiency in the change-of-measure technique is useful to the working quant. An excellent summary of the important results is the note Girsanov, Numeraires and all that, by Andrew Lesniewski. In this post, I would like to derive relevant results and then we can enjoy pricing some payoffs…
Quasar
Nov 28, 2024

Class Template Argument Deduction(CTAD)
C++
Its…
Quasar
Nov 25, 2024

Type Traits 101
C++
Meta-programs are programs that treat other programs as data. They could be other programs or itself. A meta-function is not a function, but a class or struct. Metafunctions are not part of the language and have no formal language support. They exist purely as an idiomatic use of the existing language features. Now, since their use is not…
Quasar
Nov 25, 2024

Tridiagonal Systems
Numerical Methods
The special case of a system of linear equations that is tridiagonal, that is, has non-zero elements…
Quasar
Nov 15, 2024

Interpolation and Approximation
Numerical Methods
In this blog post, I would like to implement some interpolation algorithms using modern C++. It’s important we understand how and why these algorithms work. Because there are nuances, exceptions and corner-cases, we need to understand. It’s a great learning experience!…
Quasar
Nov 13, 2024

Numerical Integration
Numerical Methods
We are interested in an approximate calculation of the definite integral
Quasar
Nov 11, 2024

Template programming
C++
C++11 introduced variadic templates which permit functions to accept a variable number of arguments. They also permit template types such as std::tuple that can hold a variable number of elements. The main language mechanism…
Quasar
Nov 10, 2024

A hitchhiker’s guide to move semantics and perfect forwarding
C++
To understand the basic principles of move semantics, let’s look at the execution of a small piece of code. I’ve written a toy Vector class. I choose the…
Quasar
Oct 26, 2024

Norms
Numerical Methods
Consider geometric vectors \(\mathbf{x}, \mathbf{y} \in \mathbf{R}^2\). The scalar product(dot-product) of these two vectors is defined by:
Quasar
Jul 25, 2024

Singular Value Decomposition(SVD)
Linear Algebra
Rectangular matrices do not have eigenvalues. However, we might look at the eigenvalues of the symmetric, positive semidefinite square Gram matrix \(K=AA^T\). Perhaps…
Quasar
Jul 24, 2024

Eigenthingies and Diagonalizability
Linear Algebra
Each square matrix possesses a collection of one or more complex scalars, called eigenvalues and associated vectors called eigenvectors. A matrix is a concrete realization of a linear transformation on a vector space. The eigenvectors indicate the directions of pure stretch and the…
Quasar
Jul 23, 2024

The Spectral Theorem
Linear Algebra
Every real, symmetric matrix is orthogonally diagonalizable.
Quasar
Jul 23, 2024

Ito Calculus
Stochastic Calculus
Exercise 1 (A strange martingale) Let \((B_t,t\geq 0)\) be a standard Brownian motion. Consider the process:
Quasar
Jul 12, 2024

Martingales
Stochastic Calculus
In elementary probability, the conditional expectation of a variable \(Y\) given another random variable \(X\) refers to the expectation of \(Y\) give…
Quasar
Jul 12, 2024

The Markov Property
Stochastic Calculus
Let’s start by exhibiting the Markov property of Brownian motion. To see this, consider \((\mathcal{F}_t,t\geq 0)\), the natural filtration of the Brownian motion \((B…
Quasar
Jul 12, 2024

Ito Processes and Stochastic Differential Equations
Stochastic Calculus
Let’s start with the definition of Ito processes.
Quasar
Jul 8, 2024

Multivariate Ito Calculus
Stochastic Calculus
We can generalize the theory to functions of several brownian motions. This unleashes the full power of Ito calculus.
Quasar
Jul 4, 2024

The distribution of the first passage time of Brownian Motion
Stochastic Calculus
The distribution of Brownian motion enjoys many interesting symmetries. The reflection of a Brownian motion about any time \(s\) is also a Brownian motion.
Quasar
Jul 2, 2024

Borel-Cantelli Lemmas
Probability Theory
Borel-Cantelli Lemmas.
Quasar
Jun 28, 2024

Positive Definiteness
Linear Algebra
Definition 1. A real-valued symmetric matrix \(A\) is positive-definite (written as \(A \succ 0\)), if for every real valued vector \(\mathbf{x}…
Quasar
Jun 20, 2024

Optimization Algorithms
Machine Learning
Definition. Let \(f:\mathbf{R}^n \to \mathbf{R}\) be a scalar-valued function. The gradient vector of \(f\) is defined as:
Quasar
Jun 10, 2024

Backpropogation
Machine Learning
With a randomly initialized model, or even a model initialized with more sophisticated approaches, our goal is to train, or…
Quasar
Jun 5, 2024

Coding a neural network layer
Machine Learning
In 1943, McCulloch and Pitts introduced artificial intelligence to the world. Their idea was…
Quasar
May 28, 2024

Classification Algorithms
Machine Learning
Let’s say that you have input data \(\mathcal{D}=\{(\mathbf{x}_i,y_i): i=1,2,\ldots,N\}\), and suppose that \(y_i \in \{0,1\}\). Each input has \(D\)-features, so \(\mathbf{x}_i \in…
Quasar
May 28, 2024

Derivation of the Least Squares Estimate Beta in Linear Regression
Machine Learning
The following post is going to derive the least squares estimate of the coefficients of linear regression. Our data consists of \(p\) predictors or features \(X_1,\ldots,X_p\) and a…
Quasar
May 16, 2024

Standard CDS Pricing Theory
Credit Derivatives
I summarize below standard CDS pricing formulas.
Quasar
May 8, 2024

Cox-Ingersoll-Ross (CIR) model
Rates Modelling
The short rate under the CIR model has the dynamics:
Quasar
May 8, 2024

Black Scholes Formula for a European Call
Stochastic Calculus
The mean rate of growth of all assets under the risk-neutral measure \(\mathbb{Q}\) is risk-free rate \(r\).
Quasar
May 3, 2024

Exploring Option Greeks
Vanilla Options
I derived the Black-Scholes formula for European style vanilla FX options in a previous post here. The Black-Scholes model \(Bl(S_0,K,T,r_{DOM},r_{FOR},\sigma)\) equipped with a single flat…
Quasar
May 3, 2024

Properties of Brownian Motion
Stochastic Calculus
Let \(B(t)\) be a fixed Brownian motion. We give below some simple properties that follow directly from the definition of the Brownian Motion.
Quasar
Apr 27, 2024

Implementing Vanna Volga
Volatility modelling
It is possible to calculate analytically the values of…
Quasar
Nov 26, 2023
No matching items