Skip to content

Commit

Permalink
upgraded
Browse files Browse the repository at this point in the history
  • Loading branch information
jialuechen committed Sep 24, 2024
1 parent fb133b4 commit a3e2637
Show file tree
Hide file tree
Showing 76 changed files with 20 additions and 19 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<div align=center>
<img src="assets/img/torchderiv_logo.png" width="40%" loc>
<img src="assets/img/torchderiv.png" width="40%" loc>
</div>

<div align=center>

# TorchDeriv : High-Performance PyTorch Library for Derivatives Pricing
# TorchDeriv : High-Performance PyTorch Library for Derivatives Modeling and Pricing

[![PyPI - Version](https://img.shields.io/pypi/v/quantorch)](https://pypi.org/project/quantorch/)
[![PyPI - Version](https://img.shields.io/pypi/v/quantorch)](https://pypi.org/project/torchderiv/)
[![Python Versions](https://img.shields.io/badge/python-3.6%2B-green)](https://pypi.org/project/torchderiv/)
![PyPI downloads](https://img.shields.io/pypi/dm/quantorch)
![PyPI downloads](https://img.shields.io/pypi/dm/torchderiv)
[![Documentation Status](https://readthedocs.org/projects/torchderiv/badge/?version=latest)](https://torchderiv.readthedocs.io/en/latest/?badge=latest)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Coverage Status](https://coveralls.io/repos/github/jialuechen/torchderiv/badge.svg?branch=main)](https://coveralls.io/github/jialuechen/torchderiv?branch=main)
Expand All @@ -21,6 +21,7 @@ differentiable pricing framework with high-accuracy of numerical methods. It pro
## Advantages
- fast and accurate implementation of erf function (hence the normal distribution too), which is actually two orders of magnitude faster than its equivalent in scipy.stats
- overcome the drawbacks of finite difference method in quant finance, such as the need for re-valuation computation and approximation errors
- enable optional hardware acceleration

## Features

Expand Down Expand Up @@ -114,7 +115,7 @@ print(f'Asian Option Price: {price.item()}')

```python
import torch
from torchderiv.risk_management.greeks.malliavin import malliavin_greek
from torchderiv.risk.greeks.malliavin import malliavin_greek

option_price = torch.tensor(10.0)
underlying_price = torch.tensor(100.0)
Expand Down Expand Up @@ -173,8 +174,8 @@ for epoch in range(num_epochs):
## Credit Risk Management Example
```python
import torch
from torchderiv.risk_management.credit_risk.structural_model import merton_model
from torchderiv.risk_management.credit_risk.reduced_form_model import reduced_form_model
from torchderiv.risk.credit_risk.structural_model import merton_model
from torchderiv.risk.credit_risk.reduced_form_model import reduced_form_model

asset_value = torch.tensor(100.0)
debt = torch.tensor(80.0)
Expand Down
File renamed without changes
4 changes: 2 additions & 2 deletions examples/credit_risk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import torch
from torchderiv.risk_management.credit_risk.structural_model import merton_model
from torchderiv.risk_management.credit_risk.reduced_form_model import reduced_form_model
from torchderiv.risk.credit_risk.structural_model import merton_model
from torchderiv.risk.credit_risk.reduced_form_model import reduced_form_model

asset_value = torch.tensor(100.0)
debt = torch.tensor(80.0)
Expand Down
2 changes: 1 addition & 1 deletion examples/malliavin_greeks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import torch
from torchderiv.risk_management.greeks.malliavin import malliavin_greek
from torchderiv.risk.greeks.malliavin import malliavin_greek

option_price = torch.tensor(10.0)
underlying_price = torch.tensor(100.0)
Expand Down
4 changes: 2 additions & 2 deletions examples/market_risk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import torch
from torchderiv.risk_management.market_risk.var import calculate_var
from torchderiv.risk_management.market_risk.expected_shortfall import calculate_es
from torchderiv.risk.market_risk.var import calculate_var
from torchderiv.risk.market_risk.expected_shortfall import calculate_es

returns = torch.tensor([0.01, -0.02, 0.03, -0.01, 0.04, -0.03])
confidence_level = 0.95
Expand Down
4 changes: 2 additions & 2 deletions examples/risk_management.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import torch
from torchderiv.risk_management.market_risk.var import calculate_var
from torchderiv.risk_management.market_risk.expected_shortfall import calculate_es
from torchderiv.risk.market_risk.var import calculate_var
from torchderiv.risk.market_risk.expected_shortfall import calculate_es

returns = torch.tensor([0.01, -0.02, 0.03, -0.01, 0.04, -0.03])
confidence_level = 0.95
Expand Down
8 changes: 4 additions & 4 deletions examples/value_adjustment.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import torch
from torchderiv.risk_management.valuation_adjustments.cva import calculate_cva
from torchderiv.risk_management.valuation_adjustments.dva import calculate_dva
from torchderiv.risk_management.valuation_adjustments.mva import calculate_mva
from torchderiv.risk_management.valuation_adjustments.fva import calculate_fva
from torchderiv.risk.valuation_adjustments.cva import calculate_cva
from torchderiv.risk.valuation_adjustments.dva import calculate_dva
from torchderiv.risk.valuation_adjustments.mva import calculate_mva
from torchderiv.risk.valuation_adjustments.fva import calculate_fva

exposure = torch.tensor(100.0)
default_prob = torch.tensor(0.02)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_malliavin_greeks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import torch
from torchderiv.risk_management.greeks.malliavin import malliavin_greek
from torchderiv.risk.greeks.malliavin import malliavin_greek

def test_malliavin_greek():
option_price = torch.tensor(10.0)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a3e2637

Please sign in to comment.