From 49dd42dc0b72a575c3c66552fd9e27c240c5d966 Mon Sep 17 00:00:00 2001 From: simaki Date: Tue, 10 Aug 2021 10:36:49 +0900 Subject: [PATCH 1/5] DOC: Mention simulation method of CIR and Heston processes #173 (#174) --- pfhedge/stochastic/cir.py | 2 ++ pfhedge/stochastic/heston.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pfhedge/stochastic/cir.py b/pfhedge/stochastic/cir.py index f84730a0..ed6dc265 100644 --- a/pfhedge/stochastic/cir.py +++ b/pfhedge/stochastic/cir.py @@ -21,6 +21,8 @@ def generate_cir( dX(t) = \\kappa (\\theta - X(t)) + \\sigma \\sqrt{X(t)} dW(t) \\,. + Time-series is generated by Andersen's QE-M method (See Reference for details). + Args: n_paths (int): The number of simulated paths. n_steps (int): The number of time steps. diff --git a/pfhedge/stochastic/heston.py b/pfhedge/stochastic/heston.py index fcb00056..2145c49d 100644 --- a/pfhedge/stochastic/heston.py +++ b/pfhedge/stochastic/heston.py @@ -29,7 +29,8 @@ def generate_heston( dV(t) = \\kappa (\\theta - V(t)) + \\sigma \\sqrt{V(t)} dW_2(t) \\,. The correlation between :math:`dW_1` and :math:`dW_2` is :math:`\\rho`. - The correlation between :math:`dW_1` and :math:`dW_2` is `\\rho`. + + Time-series is generated by Andersen's QE-M method (See Reference for details). Args: n_paths (int): The number of simulated paths. From a6c325c03d4ff94b68ce0922dbd93ddb17483995 Mon Sep 17 00:00:00 2001 From: simaki Date: Tue, 10 Aug 2021 10:37:16 +0900 Subject: [PATCH 2/5] DOC: Add reference to BS price formula #129 (#175) --- pfhedge/nn/modules/bs/american_binary.py | 4 ++++ pfhedge/nn/modules/bs/european.py | 3 +++ pfhedge/nn/modules/bs/european_binary.py | 3 +++ pfhedge/nn/modules/bs/lookback.py | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/pfhedge/nn/modules/bs/american_binary.py b/pfhedge/nn/modules/bs/american_binary.py index 48882b46..93880352 100644 --- a/pfhedge/nn/modules/bs/american_binary.py +++ b/pfhedge/nn/modules/bs/american_binary.py @@ -43,6 +43,10 @@ class BSAmericanBinaryOption(BSModuleMixin): tensor([[1.1285], [0.0000], [0.0000]]) + + References: + Dai, M., 2000. A closed-form solution for perpetual American floating strike + lookback options. Journal of Computational Finance, 4(2), pp.63-68. """ def __init__(self, call: bool = True, strike: float = 1.0): diff --git a/pfhedge/nn/modules/bs/european.py b/pfhedge/nn/modules/bs/european.py index 2a8d0723..c9de9e80 100644 --- a/pfhedge/nn/modules/bs/european.py +++ b/pfhedge/nn/modules/bs/european.py @@ -41,6 +41,9 @@ class BSEuropeanOption(BSModuleMixin): tensor([[0.4497], [0.5126], [0.5752]]) + + References: + John C. Hull, 2003. Options futures and other derivatives. Pearson. """ def __init__(self, call: bool = True, strike: float = 1.0): diff --git a/pfhedge/nn/modules/bs/european_binary.py b/pfhedge/nn/modules/bs/european_binary.py index 68f94eb1..c124062c 100644 --- a/pfhedge/nn/modules/bs/european_binary.py +++ b/pfhedge/nn/modules/bs/european_binary.py @@ -42,6 +42,9 @@ class BSEuropeanBinaryOption(BSModuleMixin): tensor([[6.2576], [6.3047], [6.1953]]) + + References: + John C. Hull, 2003. Options futures and other derivatives. Pearson. """ def __init__(self, call: bool = True, strike: float = 1.0): diff --git a/pfhedge/nn/modules/bs/lookback.py b/pfhedge/nn/modules/bs/lookback.py index 04d374cb..b083c30e 100644 --- a/pfhedge/nn/modules/bs/lookback.py +++ b/pfhedge/nn/modules/bs/lookback.py @@ -44,6 +44,10 @@ class BSLookbackOption(BSModuleMixin): tensor([[0.9208], [1.0515], [1.0515]]) + + References: + Conze, A., 1991. Path dependent options: The case of lookback options. + The Journal of Finance, 46(5), pp.1893-1907. """ def __init__(self, call: bool = True, strike: float = 1.0): From 7c6c3b4a67b41b9537c1aa0ea81963237f9e782f Mon Sep 17 00:00:00 2001 From: simaki Date: Tue, 10 Aug 2021 10:37:53 +0900 Subject: [PATCH 3/5] DOC: Fix typo in BSEuropeanOption docstring (close #164) (#177) --- pfhedge/nn/modules/bs/european.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pfhedge/nn/modules/bs/european.py b/pfhedge/nn/modules/bs/european.py index c9de9e80..df6ddc46 100644 --- a/pfhedge/nn/modules/bs/european.py +++ b/pfhedge/nn/modules/bs/european.py @@ -145,7 +145,6 @@ def price( Args: log_moneyness (torch.Tensor): Log moneyness of the underlying asset. - max_log_moneyness (torch.Tensor): Cumulative maximum of the log moneyness. expiry_time (torch.Tensor): Time to expiry of the option. volatility (torch.Tensor): Volatility of the underlying asset. From 8867ca56944c0fe347d3780bd503e4fd44ef806b Mon Sep 17 00:00:00 2001 From: simaki Date: Tue, 10 Aug 2021 10:38:08 +0900 Subject: [PATCH 4/5] DOC: Add equations to docstrings of brownian motion (close #138) (#178) --- pfhedge/instruments/primary/brownian.py | 3 +++ pfhedge/instruments/primary/heston.py | 2 +- pfhedge/stochastic/brownian.py | 12 ++++++++++++ pfhedge/stochastic/cir.py | 2 +- pfhedge/stochastic/heston.py | 2 +- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pfhedge/instruments/primary/brownian.py b/pfhedge/instruments/primary/brownian.py index f8ddf9e8..94b4e83d 100644 --- a/pfhedge/instruments/primary/brownian.py +++ b/pfhedge/instruments/primary/brownian.py @@ -12,6 +12,9 @@ class BrownianStock(Primary): The drift of the spot prices is assumed to be vanishing. + See :func:`pfhedge.stochastic.generate_geometric_brownian` + for details of the process. + Args: volatility (float, default=0.2): The volatility of the price. cost (float, default=0.0): The transaction cost rate. diff --git a/pfhedge/instruments/primary/heston.py b/pfhedge/instruments/primary/heston.py index 4c606d34..82d5d817 100644 --- a/pfhedge/instruments/primary/heston.py +++ b/pfhedge/instruments/primary/heston.py @@ -10,7 +10,7 @@ class HestonStock(Primary): """A stock of which spot price and variance follow Heston process. - See :func:`pfhedge.stochastic.generate_heston` for details of the Heston process. + See :func:`pfhedge.stochastic.generate_heston` for details of the process. Args: kappa (float, default=1.0): The parameter :math:`\\kappa`. diff --git a/pfhedge/stochastic/brownian.py b/pfhedge/stochastic/brownian.py index c9e65d40..f8443c85 100644 --- a/pfhedge/stochastic/brownian.py +++ b/pfhedge/stochastic/brownian.py @@ -17,6 +17,12 @@ def generate_brownian( The drift of the time series is assumed to be vanishing. + The time evolution of the process is given by: + + .. math :: + + dS(t) = \\sigma dW(t) \\,. + Args: n_paths (int): The number of simulated paths. n_steps (int): The number of time steps. @@ -66,6 +72,12 @@ def generate_geometric_brownian( The drift of the time series is assumed to be vanishing. + The time evolution of the process is given by: + + .. math :: + + dS(t) = \\sigma S(t) dW(t) \\,. + Args: n_paths (int): The number of simulated paths. n_steps (int): The number of time steps. diff --git a/pfhedge/stochastic/cir.py b/pfhedge/stochastic/cir.py index ed6dc265..f27f196b 100644 --- a/pfhedge/stochastic/cir.py +++ b/pfhedge/stochastic/cir.py @@ -15,7 +15,7 @@ def generate_cir( ) -> Tensor: """Returns time series following Cox-Ingersoll-Ross process. - The time evolution of CIR process is given by: + The time evolution of the process is given by: .. math :: diff --git a/pfhedge/stochastic/heston.py b/pfhedge/stochastic/heston.py index 2145c49d..b3376e21 100644 --- a/pfhedge/stochastic/heston.py +++ b/pfhedge/stochastic/heston.py @@ -21,7 +21,7 @@ def generate_heston( ) -> Tuple[Tensor, Tensor]: """Returns time series following Heston model. - The time evolution of Heston process is given by: + The time evolution of the process is given by: .. math :: From 36dc154295864967b87d8304a6197e80cfc2c212 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 10 Aug 2021 10:39:13 +0900 Subject: [PATCH 5/5] bump version (#180) Co-authored-by: GitHub Actions --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d4df0eb3..e736671c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pfhedge" -version = "0.7.3" +version = "0.7.4" description = "Deep Hedging in PyTorch" authors = ["Shota Imaki "] license = "MIT"