DerivativesTools 1.0
Python // C++ package for options pricing, Asset price simulation, VaR and distribution Analysis, Volatility Smile, Surface

# Simulation Process 

 Description : Package use for simulate statistics distribution and asset paths by monte carlo simulation.

### Status : PRODUCTION

## Table of Contents
1. [Install](#install)
2. [Models](#models)
3. [Functions](#functions)
4. [Next Steps](#next-steps)

# Install

```yaml
cd /your folder
git clone git@github.com:ahgperrin/simulation_stochastic.git
cd /simulation_stochastic
pip install -e .
```


# Models

| Models                | Type                      |
| :--------------------:|:--------------------------|
| Ornstein_Uhlenbeck    | Mean Reverting            |
| Brownian Motion       | Standard                  |
| Merton Jump Diffusion | Jump Diffusion            |
| Heston                | Stochastic volatility     |
| Correlated_portfolio  | Portfolio risk management |

- Ornstein-Ulhenbeck : Rates, mean Reverting process
  
    *Example Ornstein-Ulhenbeck:*
  
  ```yaml
  test = OrnsteinUhlenbeckParams(100, 0.4, 1, 360, 100, 10)
  simul = ornstein_uhlenbeck_path(test, 10)
  simul.plot_simulation("OU PROCESS")
  ```
  ![](https://github.com/ahgperrin/simulation_stochastic/blob/master/test/example/ou_example.png?raw=true)
- Brownian Motion : Diffusion model
  
    *Example Brownian:*
    
    ```yaml
    data = pd.read_csv("/Users/antoineperrin/Documents/Work/python_programing/simulation_stochastic/test/data_set.csv").RMS
    test = GeometricBrownianParams(0.02, 0.2, 1, 365, 100)
    params = brownian_histo_calibration(test, np.log(data) - np.log(data.shift(1)), 252)
    simul = brownian_path(params,1000)
    simul.plot_simulation("Brownian Motion")
    ```
  ![](https://github.com/ahgperrin/simulation_stochastic/blob/master/test/example/bm_example.png?raw=true)
- Jump Diffusion : Geometric Brownian + jumps
    
    *Example Jump Diffusion:*
  
    ```yaml
    data = pd.read_csv("/Users/antoineperrin/Documents/Work/python_programing/simulation_stochastic/test/data_set.csv").RMS
    test = JumpDiffusionParams(0.02, 0.2, 1, 252, 100, 1, -0.05, 0.05)
    params = merton_jump_histo_calibration(test, np.log(data) - np.log(data.shift(1)), 252, 0.09)
    simul = merton_jump_path(params, 30)
    simul.plot_simulation("MJD")
    ```
    ![](https://github.com/ahgperrin/simulation_stochastic/blob/master/test/example/mjd_example.png?raw=true)
- Heston : Brownian Motion with stochastic volatility (volatility follow a OU process)
    
    *Example Heston:*
  
    ```yaml
    value = HestonParams(0.1478,1,252,100,0.24,4,0.99,0.26,-0.0279)
    data = pd.read_csv("/Users/antoineperrin/Documents/Work/python_programing/simulation_stochastic/test/data_set.csv")
    data.index = data.Date
    data = data[["RMS"]]
    test = heston_histo_calibration(value, data, 252)
    simul = heston_path(test,10,True)
    simul.plot_both("Heston")
    ```
    ![](https://github.com/ahgperrin/simulation_stochastic/blob/master/test/example/heston_example.png?raw=true)

- correlated_portfolio : Brownian motion for multiple assets using correlated brownian motion
    ```yaml
    test = pd.read_csv("/Users/antoineperrin/Documents/Work/python_programing/simulation_stochastic/test/data_set.csv",
                       index_col="Date")
    del test["RF"]
    test = (np.log(test) - np.log(test.shift(1))).dropna()
    matrix_test = (np.array([[1., 0.80],
                             [0.8, 1.]]), [0, 0])
    geo_params = [brownian_histo_calibration(GeometricBrownianParams(0.03, 0.1, 1, 365, 100), test.RMS, 365),
                  brownian_histo_calibration(GeometricBrownianParams(0.02, 0.3, 1, 365, 100), test.CAC, 365)]
    simul = portfolio_paths(matrix_test[0], matrix_test[1], geo_params, [-0.5, 1], 200)
    simul.plot_simulation("test")
    ```

# Functions

> Using a simulation object 

| Functions          | Description                           | 
| :-----------------:|:--------------------------------------|
| european_call      | European Call Option pricing          |
| european_put       | European Put Option pricing           |
| value_at_risk      | Value at risk computation             |
| plot_distribution  | plot distribution against normal      |
| plot_simulation    | Visualisation of paths simulated      | 
| plot_boths         | Paths + Volatility process for heston |


# Next Steps

- Robust Calibration for each models