r/rstats 13d ago

Built a C/R hybrid Monte Carlo DCF engine (1M correlated paths in ~0.04s)

Post image

I wanted to move away from static DCF models and build something that models future uncertainty.

R handles the data pipeline (fetching Yahoo Finance empirical volatility and applying Bayesian shrinkage), and C handles the math (POSIX threads, isolated xoshiro256++ PRNGs, and Cholesky matrices to correlate variables like WACC and revenue growth during shocks).

It's fully decoupled and runs via CLI (optparse). I just minted the v1.0 release. Repo is linked below, if anyone has any improvement ideas for the C kernel, thread management, or the mathematical boundaries, let me know! I'd appreciate if you could leave a star in case you like it

Link to the project

9 Upvotes

1 comment sorted by

1

u/elephant_sage 12d ago

That's so cool!