Code Samples.
"Premature optimization is the root of all evil."
— Donald Knuth, "Structured Programming with go to Statements" (1974, ACM Computing Surveys)
"Premature optimization is the root of all evil."
— Donald Knuth, "Structured Programming with go to Statements" (1974, ACM Computing Surveys)
This page contains a sample of some coding that I did for various research projects, advanced statistics and econometrics courses, and courses that I have taught personally.
On-Line Portfolio Optimization. [Python Functions] [Console Output]
{Description: I wrote this library of Python Functions (e.g., using numpy and scipy) as part of a practicum for ECON 647: Optimal Portfolio Choice.}
Efficient Computation of Risk Parity (or Risk-Budgeted) Portfolios. [Python Code]
{Description: I composed this scientific Python program as part of a computational project on Risk Parity and Risk Budgeting for ECON 647: Optimal Portfolio Choice.}
Practical Calculation of Cover's (1991) Universal Portfolio. [Python Program]
{Description: I produced this elegant Python program for the sake of a quantitative research project on Cover's (1991) Universal Portfolio selection algorithm for my coursework in ECON 647: Optimal Portfolio Choice.}
{Description: I wrote this R script for Chapter 2 of my Ph.D. Thesis.}
Hurst Exponent and Half-Life Mean Reversion. [R Script] [LaTeX Output] [Permission Required]
{Description: This R script was done for part of my research project in ECON 793: Financial & Time-Series Econometrics.}
Variance Stabilization in Beta Regression. [R Script] [LaTeX Output]
{Description: I wrote this R code as part of a research project for STAT 644: Generalized Linear Models.}
Complex Portfolio Optimization. [R Script] [LaTeX Output]
{Description: I wrote this R code as part of the class material for FINA 6339: Quantitative Portfolio Management at Northeastern University.}
Complex Portfolio Optimization (Simulated Portfolios). [R Script] [LaTeX Output]
{Description: I wrote this R code as part of the class material for FINA 6339: Quantitative Portfolio Management at Northeastern University.}
Stock and Crypto Market Risk Assessment: Bootstrap and Filtered Historical Simulation. [MATLAB® Script] [MATLAB® Output] [Permission Required]
{Description: This is an updated version of the MATLAB® code that I used for my research project in ECON 743: Financial Economics II.}
Distribution of Log Returns & Spectral Analysis of Cryptos. [MATLAB® Script] [MATLAB® Output] [Permission Required]
{Description: This MATLAB® script was written to solve some research problems that I encountered in Chapter 3 of my Ph.D. Thesis.}
BMA & Stochastic Volatility: Data Visualization. [MATLAB® Script] [MATLAB® Output]
{Description: This MATLAB® program was written for the sake of data visualization in relation to Chapter 3 of my Ph.D. Thesis.}
Statistical Distributions (PDFs, CDFs and Beyond). [MATLAB® Script] [MATLAB® Output]
{Description: This MATLAB® program was written as a part of the class material for FINA 6332: Fundamentals of Financial Math and Financial Markets at Northeastern University.}
Unconstrained Optimization. [MATLAB® Script] [MATLAB® Output]
{Description: This MATLAB® program was written as a part of the class material for FINA 6332: Fundamentals of Financial Math and Financial Markets at Northeastern University.}
Linear Programming. [MATLAB® Script] [MATLAB® Output]
{Description: This MATLAB® program was written as a part of the class material for FINA 6332: Fundamentals of Financial Math and Financial Markets at Northeastern University.}
Log and Exponential Functions. [MATLAB® Script] [MATLAB® Output]
{Description: This MATLAB® program was written as a part of the class material for FINA 6332: Fundamentals of Financial Math and Financial Markets at Northeastern University.}
Quadratic Forms. [MATLAB® Script] [MATLAB® Output]
{Description: This MATLAB® program was written as a part of the class material for FINA 6332: Fundamentals of Financial Math and Financial Markets at Northeastern University.}
Simulated Returns, Conditional Variance, and Innovations. [MATLAB® Script] [MATLAB® Output]
{Description: This MATLAB® program was written as a part of the class material for FINA 6332: Fundamentals of Financial Math and Financial Markets at Northeastern University.}
Heston Stochastic Volatility Model: Monte Carlo via the QE Scheme. [Julia Output]
{Description: Simulates the Heston model using Andersen's Quadratic-Exponential scheme to guarantee nonnegative variance, then recovers the implied volatility smile.}
Fourier Pricing via Riccati Systems vs. Hermite-Edgeworth Expansion. [Julia Output]
{Description: Prices options by integrating the Heston Riccati ODEs directly via RK4 and Fourier inversion, then shows where a Hermite-Edgeworth approximation departs from this exact price. }
Finite Element Method for the Black-Scholes PDE. [Julia Output]
{Description: Solves the Black-Scholes PDE with linear finite elements and Crank-Nicolson time-stepping, validated against the closed-form price and delta. }
Bayesian Stochastic Volatility Estimation. [Julia Output]
{Description: Recovers latent, time-varying volatility and its parameters from return data using Metropolis-within-Gibbs MCMC. }
Black-Litterman Portfolio Optimization. [Julia Output]
{Description: Blends market-implied equilibrium returns with investor views to produce more stable portfolio weights than raw mean-variance optimization. }
Semi-Numerical Mean-Variance (Markowitz) Portfolio Optimization. [Maple® Worksheet] [Maple® Output]
{Description: I designed this Maple® worksheet as part of a quantitative project for ECON 647: Optimal Portfolio Choice. The worksheet explores both symbolic and numerical computations of Mean-Variance (Markowitz) efficient portfolios.}
Symbolic Computation of Risk Parity and Risk-Budgeted Portfolios. [Maple® Worksheet] [Maple® Output]
{Description: I wrote this Maple® worksheet as part of a computational research project for ECON 647: Optimal Portfolio Choice. The worksheet focuses on symbolic and numerical computation of Risk Parity (and more generally, Risk-Budgeted) portfolios.}
Model Selection in Survival Analysis. [SAS® Script] [SAS® Output]
{Description: This SAS® program was a vital part of my research project for STAT 644: Generalized Linear Models.}
Panel Data Fixed Effect, Random Effect, and Mixed-Effect Models. [SAS® Script] [SAS® Output]
{Description: This block of SAS® code was vital for my empirical research project in STAT 640: Longitudinal Data Analysis.}
Panel Data Poisson Regression Models. [SAS® Script] [SAS® Output]
{Description: This SAS® code was written for the sake of my applied research project in STAT 640: Longitudinal Data Analysis.}