https://github.com/karelze/mc-var-sim
Monte Carlo Sim of a stock portfolio using c++ AMP
https://github.com/karelze/mc-var-sim
amp cmp202 risk sim stock-portfolio
Last synced: 6 months ago
JSON representation
Monte Carlo Sim of a stock portfolio using c++ AMP
- Host: GitHub
- URL: https://github.com/karelze/mc-var-sim
- Owner: KarelZe
- License: mit
- Created: 2018-03-14T11:31:59.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-01T18:16:05.000Z (almost 8 years ago)
- Last Synced: 2025-06-14T19:09:57.042Z (9 months ago)
- Topics: amp, cmp202, risk, sim, stock-portfolio
- Language: C++
- Size: 4.84 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MC Sim
This Visual Studio project is my coursework for ```CMP 202``` at Abertay University, Scotland.
## underlying concept
Using a Value at Risk approach we try to make a statement similar to this:
I am X percent certain there will not be a loss of more than V dollars in the next N days. (Hull, 2012)
So X is the confidence level, where V is the loss and n is the holding period.
```
dS = μ S dt + σ S ds
S = stock price
μ = exp. return
σ = volatility
```
## approach
```
repeat n times
repeat t times
generate normal distributed number
update end price
save end price to path array
extract the 0th quantile
print results
```
## boundary
- Assuming a stock without dividend payments
- single stock portfolio
- using C++ AMP
- extents that don't require padding
- optimized for a NVIDIA GeForce 940MX
## dependencies
- Commandline parsing is handled through [TCLAP](http://tclap.sourceforge.net/)
- Concurrency Visualizer Marker through [Visual Studio Extension](https://marketplace.visualstudio.com/items?itemName=Diagnostics.ConcurrencyVisualizer2017)
- Random number generation through [amprng](https://archive.codeplex.com/?p=amprng)
## usage
Using the program is simple:
```
cd path
REM access help for explanation on cl arguments
C:\path>ConsoleApplication3 --help
REM sample usage of calculation with a tile size of 16 and 512k paths
C:\path>ConsoleApplication3 -x 16 -p 524288 -i 10 -r 0.05 -v 0.04 -d 300 -t 300
```
sample output:

## Todos
- [x] Prepare proposal
- [x] Implement MC kernel
- [x] Implement path array to value at risk functionality
- [x] Optimize memory access, ~~loop unrolling~~ etc.
- [x] measure performance
- [x] Prepare presentation
- [ ] Enhance to a multi stock portfolio (optional)
- [ ] Download historical data from quandl (optional)
- [ ] Calculate volatility using EWMA method (optional)
## Contact
Feel free to send me a [mail](mailto:1705042@abertay.ac.uk)