Replicating Independent Heston Paths with a Simulation Function
Summary
The document explains how to generate multiple stock-price paths under a discretized Heston stochastic volatility model in R. Its central programming lesson is to put the complete time-stepping procedure inside a function, initialize the state for each run, and pass that function to a replication routine. This avoids reusing or carrying forward state across repetitions, which can otherwise produce repeated values or an unsuitable return object.
The accepted response gives a function that generates correlated Brownian increments, updates variance and log price over time, applies a zero floor to variance, and returns the simulated price path. Replicating the function produces a matrix with paths as columns, illustrated with a plot of sample paths. The example is a practical coding pattern rather than a validation of model accuracy. Its particular discretization and boundary treatment are choices, and the supplied code and dimensions should be checked for consistency before reuse.
Key ideas
- Define one simulation function that initializes and advances a complete path.
- Generate fresh correlated Brownian increments for each replicated path.
- A replication call can collect simulated paths into a matrix.
- Variance truncation and the discretization scheme affect the simulated process.
Tags
Full text
# Can anyone help me to understand why the GMV point is not on the efficient frontier? # Can anyone help me to understand why the GMV point is not on the efficient frontier? I am following a course about portfolio construction with Python. I am able to successfully draw the efficient frontier and capital market line (CML), and the global minimum variance (GMV) point using daily returns of different assets. However, when I try to lower the frequency to 15 minutes or 5 minutes, the CML (green) and GMV(blue) points are plotted in a weird way. The CML becomes non-tangent and doesn't belong to the frontier, and the GMV point does not belong to the efficient frontier. I have attached the code that I am using. main : https://pastebin.com/Y1k5rCk4 efflib : https://pastebin.com/m3XJGEnD Can anyone help me to understand why this happens?
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.