Skip to content

DirkKuhn/financial_monte_carlo_simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple financial monte carlo simulation

During financial planning, typically a monte carlo simulation is carried out to test which outcomes are likely. In the implemented monte carlo simulation monthly returns, safe deposit rates and inflation rates are drawn randomly with replacement. These numbers are used to calculate the portfolio value at the next month. This is repeated until the specified time horizon is reached. This simulation is carried out many times, afterward the results can be plotted and statistics can be calculated.

The simulation is implemented using taichi. As the code is compiled this makes it much faster compared to numpy and pytorch. Further, since no intermediate arrays are calculated, the memory footprint is dramatically reduced. Additionally, switching between CPU and GPU only requires changing one argument using numba this would be more laborious.

Take a look at example.ipynb to see an example application.

To avoid copyright infringements the necessary data to run the simulations is not provided. Please download the respective data yourself. You only need to download the data which belongs to a HistoricalMonthlyGenerator you actually use.

HistoricalMonthlyGenerator Download instructions
HistoricalACWIIMIUSDReturns First download the historical msci world data from msci. Accept the terms and conditions and select
  • Term: Full History
  • Index Level: Price
  • Currency: USD
  • Frequnecy: Monthly
Click on "Download Data" to download the xls file. Rename this file to world_index_usd.xls and place it in the data folder in the simulation package.
Next download the historical msci acwi imi data from msci. Follow the same steps as before. However, rename this file to acwi_imi_index_usd.xls.
HistoricalACWIIMIEURReturns Download the historical acwi imi data from msci. Accept the terms and conditions and select
  • Term: Full History
  • Index Level: Price
  • Currency: EUR
  • Frequnecy: Monthly
Click on "Download Data" to download the xls file. Rename this file to acwi_imi_index_eur.xls and place it in the data folder in the simulation package.
Historical1YearUSBondYields Download the historical one year us bond yields from macrotrends. Click on "Download Historical Data" to download the csv file. Place this file in the data folder in the simulation package.
HistoricalECBRate Download the rate of the european central bank from statista. For this you need to create an account. Then click on "XLS" to download the xlsx file. Rename this file to ecb_rate.xlsx and place it in the data folder in the simulation package.
HistoricalGermanInflation Download the yearly inflation data provided by the world bank. Click on "EXCEL" under "Download" to download the xls file. Rename this file to world_bank_yearly_inflation.xls and place it in the data folder in the simulation package.
Next download the monthly german inflation data provided by Statistisches Bundesamt. Click on "ZEIT AUSWÄHLEN", then select "Alle verfügbaren Zeitangaben" and click "ÜBERNEHMEN". Then click "WERTEABRUF" and then "XLSX". Rename the downloaded file to german_monthly_inflation.xlsx and place it in the data folder in the simulation package.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published