Introduction

One of the most important questions in modern financial theory and practice is related to valuation of derivatives, which are assets whose value depends on the price of another asset called the underlying. The basic types of financial derivatives are futures, forwards, swaps, and options, and they are primarily used for hedging and speculation purposes. The global size of this market is estimated at around $1200 billion of USD, underscoring its importance.

The seminal work on market modeling and derivative valuation dates back to Louis Bachelier’s doctoral thesis in 1900, titled The Theory of Speculation. In this work, Bachelier lays the foundations for modeling the uncertainty associated with the dynamics of risky asset prices, proposing the use of standard Brownian motion to describe random shocks in prices, among many other relevant contributions presented in his work.

The next key development surrounding the problem of derivative valuation is the work of Fisher Black and Myron Scholes [1], in which they consider a market in which, under certain assumptions, the price of the derivative is determined by the solution to a second-order parabolic partial differential equation, with boundary conditions related to the type of derivative under consideration.

Specifically, in the model proposed by Black and Scholes [1], a continuous-time financial market over the interval [0, T] is considered, which is assumed to be frictionless, meaning transaction costs for trades are not considered, there are no taxes, all asset markets are perfectly liquid, and agents are price takers. Three types of assets are considered available for trading. A risk-free asset, with value at time t denoted by \(B_t\), which satisfies the ordinary differential equation:

$$\begin{aligned} dB_t=r B_t dt \end{aligned}$$
(1)

where r is a constant and known risk-free interest rate. This asset can be viewed as a risk-free bond or cash. A risky asset, for example, a stock, with value at time t denoted by \(S_t\), which satisfies the stochastic differential equation:

$$\begin{aligned} dS_t=\alpha S_t dt + \sigma S_t dW_t \end{aligned}$$
(2)

where \(\alpha\) and \(\sigma >0\) are constants representing the instantaneous rate of return and the volatility of the asset respectively, and \(W_t\) is a standard Brownian motion defined on a probability space filtered \((\Omega , \mathcal {F}, P, (\mathcal {F}_t)_t)\).

The third type of asset is a financial derivative, with value at time t denoted by \(V(t,S_t)\), explicitly indicating its dependence on the value of the risky asset. An example of this type of asset is options, which grant their holder the right, but not the obligation, to tradeFootnote 1 a certain quantity of the underlying asset on a specific future date, referred to as maturity or expiration,Footnote 2 at a predetermined value known as the strike price.

The objective is to determine the value of the derivative at any instant t, i.e., to find \(V(t,S_t)\). For this, a portfolio consisting of the underlying asset and the derivative is considered and structured in such a way that it is risk-free. By a no-arbitrage argument,Footnote 3 the return of this portfolio must be equal to the risk-free rate, which allows finding an equation for the function \(V(t,S_t)\) known as the Black–Scholes partial differential equation. The value of this portfolio at time t is denoted by \(\Pi _t\) and is composed of an amount \(w_1\) of the risky asset and an amount \(w_2\) of the derivative. Therefore, its value at time t is:

$$\begin{aligned} \Pi _t=w_1S_t+w_2V(t,S_t) \end{aligned}$$
(3)

By applying Ito’s lemma,Footnote 4 we have:

$$\begin{aligned} d\Pi _t&=w_1dS_t+w_2dV(t,S_t) \nonumber \\&=w_1(\alpha S_tdt+ \sigma S_tdW_t)+w_2\left[ \frac{\partial V}{\partial t}dt+\frac{\partial V}{\partial S_t}dS_t\right. \nonumber \\&\left. \qquad +\frac{1}{2}\frac{\partial ^2 V}{\partial S_t^2}(dS_t)^2\right] \nonumber \\&=\left( w_1+w_2\frac{\partial V}{\partial S_t}\right) \alpha S_tdt+\left( w_1+w_2\frac{\partial V}{\partial S_t}\right) \sigma S_tdW_t\nonumber \\&\qquad +w_2\left( \frac{\partial V}{\partial t}+\frac{1}{2}\sigma ^2 S_t^2\frac{\partial ^2 V}{\partial S_t^2}\right) dt \end{aligned}$$
(4)

If the values of \(w_1\) and \(w_2\) are chosen such that the portfolio is risk-free, by the no-arbitrage principle, the changes in its value \((d\Pi _t)\) must be equal to the changes associated with investing the initial portfolio value at the risk-free rate. One way to achieve this is by setting \(w_1=-\frac{\partial V}{\partial S_t}\) and \(w_2=1\), which means taking a short position in \(\frac{\partial V}{\partial S_t}\) units of the asset and a long position in one unit of the derivative. This way of structuring the portfolio is known as delta hedging. Forming the portfolio in this way, we have:

$$\begin{aligned} d\Pi _t=\left( \frac{\partial V}{\partial t}+\frac{1}{2}\sigma ^2 S_t^2\frac{\partial ^2 V}{\partial S_t^2}\right) dt \end{aligned}$$
(5)

and this must be equal to:

$$\begin{aligned} d\Pi _t=\left( -\frac{\partial V}{\partial S_t}S_t+V(t,S_t)\right) r dt \end{aligned}$$
(6)

from which it follows:

$$\begin{aligned} \frac{\partial V}{\partial t}+rS_t\frac{\partial V}{\partial S_t}+\frac{1}{2}\sigma ^2S_t^2\frac{\partial ^2 V}{\partial S_t^2}-rV=0;\quad V(T, S_T)=\Phi (S_T), \end{aligned}$$
(7)

where \(\Phi (\cdot )\) is the contract function describing potential derivative payouts at maturity. Although this model’s simplifying assumptions allow for analytical valuation expressions, they fail to capture market realities in various aspects. Particularly, they do not account for the existence of liquidity risk. It’s widely acknowledged that market agents devise their trading strategies considering an inherent risk of this nature due to the limited availability of assets in terms of volume and time (see [2]).

In financial literature, various models exist that incorporate the effects of illiquidity on price dynamics and derivative valuation. The primary streams in these studies are: 1. Discussion and characterization of empirical findings regarding illiquidity effects. 2. Development of theoretical models that consider illiquidity in the asset valuation process. Both cases distinguish between models of aggregate and specific illiquidity. In the case of aggregate illiquidity, it’s considered that market-wide illiquidity fluctuates over time and has varying impacts on different sets of assets. Some works following this approach include [3,4,5,6,7]. Regarding specific illiquidity models, they focus on the illiquidity of particular asset groups. This is achieved by explicitly modeling their impact on pricing based on different trading volumes, as seen in works by [8,9,10]. Alternatively, introducing transaction costs in asset valuation models is another approach, illustrated in works by [11,12,13].

A characteristic of these market models is that the resulting valuation partial differential equations (PDEs) are either semilinear or completely nonlinear, extending the Black and Scholes equation (7). For these types of PDEs, obtaining an analytical solution is rare, and commonly used numerical methods for approximating the solution often prove inefficient or suffer from the curse of dimensionality (the Hughes effect). In the works by [14,15,16], comprehensive reviews on the application of numerical methods for these equations and the challenges they pose can be found.

This work proposes a market model where price dynamics incorporate a stochastic illiquidity factor described by a Cox–Ingersoll–Ross (CIR) process, as a novel approach to describing liquidity risk and its effects on asset prices in relation to agents’ strategies. The corresponding valuation equation is developed, leading to a nonlinear partial differential equation. A methodology is also proposed to approximate the solution of this equation by using the nonlinear extension of the Feynman–Kac representation theorem together with backward stochastic differential equations and neural networks. This application is novel in financial literature and opens an interesting line of development in the computational treatment of financial problems.

Market Model

We consider a market model defined on a filtered probability space \((\Omega , \mathcal {F}, P, (\mathcal {F}_t)_t)\), where the risky asset price process \(S_t\) satisfies the stochastic differential equation:

$$\begin{aligned} dS_t = \alpha S_{t} dt + \sigma S_{t} dW_t^{S} + \lambda _t S_{t} dN_t, \end{aligned}$$
(8)

Here, \(\alpha\) and \(\sigma >0\) are constants representing the instantaneous rate of return and volatility of the asset, respectively. \(\lambda _{t}\) represents the market’s illiquidity factor, assumed to be stochastic and almost surely greater than zero for all t. \(W_t^{S}\) denotes a standard Brownian motion, and \(N_t\equiv N(t,S_t,\lambda _t)\) denotes the number of units of the risky asset held by an agent as part of their trading strategy. The term \(\lambda _tdN_t\) describes the impact on the asset price due to a change in the number of units held by the agent, weighted by the market’s illiquidity factor.

This model allows for the consideration of the agent’s trading strategies effects on prices and vice versa. It also captures situations where market illiquidity can be influenced by random shocks, such as unexpected regulatory changes, macroeconomic trends, resource availability, forced closures of economic activity (as seen in quarantine measures taken to control diseases), among others.

We assume that the market’s illiquidity factor follows a mean-reverting process of the Cox–Ingersoll–Ross (CIR) type. The selection of this process is based on considering the dynamics presented by various measures of illiquidity. Particularly, we consider the illiquidity ratio proposed by [4], denoted as \(illi_t\), which has also been adopted in the works of [17, 18], and reviewed in the work of [5]. This measure of illiquidity considers the absolute value of the market index’s return divided by its volume in monetary units:

$$\begin{aligned} illi_t := \frac{|R_t|}{P_t \cdot V_t} \end{aligned}$$
(9)

where \(R_t\) represents the daily return, \(P_t\) is the closing price, and \(V_t\) is the daily traded volume. As an example, in Fig. 1, the Amihud illiquidity ratio calculated for the S &P 500 between May 26, 2016, and May 25, 2021, is represented.

Fig. 1
figure 1

Amihud’s illiquidity ratio for the S &P 500. Own elaboration

According to this type of measures, market illiquidity tends to fluctuate around a mean and only takes positive values. It is then assumed that the illiquidity factor is described by a Cox–Ingersoll–Ross (CIR) process such that:

$$\begin{aligned} d\lambda _t=\kappa (\theta -\lambda _t)dt+\nu \sqrt{\lambda _t}dW_t^{\lambda } \end{aligned}$$
(10)

with \(dW_t^{S}dW_t^{\lambda }=\rho dt\), where \(\rho\) is a constant measuring the correlation between the standard Brownian motions \(W_t^{S}\) and \(W_t^{\lambda }\). In this case: \(\theta\) is a constant long-term level of illiquidity, \(\kappa\) is the speed of reversion to the level \(\theta\), and \(\nu >0\) is the illiquidity volatility. This type of process implies that \(\lambda _t>0\) for all positive values of \(\kappa\) and \(\theta\), and it ensures that \(\lambda _t\) will not be equal to zero if \(2\kappa \theta \ge \nu ^2\).

Price of Risky Assets

The following proposition summarizes the central results about the effect of the stochastic illiquidity process and the agent’s trading strategy on the coefficients of the risky asset price process.


Proposition 1 Let \(W_t^1\) and \(W_t^2\) be two independent standard Brownian motions defined on a filtered probability space \((\Omega , \mathcal {F}, P, (\mathcal {F}_t)_t)\), and let \(N\equiv N(t, S_t, \lambda _t)\) denote the trading strategy of a large agent. In a market with stochastic illiquidity described by a CIR process of the form:

$$\begin{aligned} d\lambda _t=\kappa (\theta -\lambda _t)dt+\gamma \sqrt{\lambda _t}\rho dW_t^{1}+\gamma \sqrt{\lambda _t}\sqrt{1-\rho ^2}dW_t^{2} \ . \end{aligned}$$
(11)

and denoting by:

$$\begin{aligned} \nu _1:=\frac{\sigma +\gamma \rho \lambda _t^{3/2 }\frac{\partial N}{\partial \lambda _t}}{1-\lambda _tS_t\frac{\partial N}{\partial S_t}} \end{aligned}$$
(12)
$$\begin{aligned} \nu _2:=\frac{\gamma \lambda _t^{3/2}\sqrt{1-\rho ^2}\frac{\partial N}{\partial \lambda _t}}{1-\lambda _tS_t\frac{\partial N}{\partial S_t}} \end{aligned}$$
(13)
$$\begin{aligned} b(t,S_t, \lambda _t)&:=\frac{1}{1-\lambda _tS_t\frac{\partial N}{\partial S_t}}\left[ \alpha +\lambda _t\left( \frac{\partial N}{\partial t}+\kappa (\theta -\lambda _t)\frac{\partial N}{\partial \lambda _t}\right. \right. \nonumber \\&\left. \left. +\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 N}{\partial \lambda _t^2} +\frac{\partial ^2 N}{\partial S_t \partial \lambda _t}S_t \gamma \sqrt{\lambda _t}\left( \nu _1 \rho +\nu _2 \sqrt{1-\rho ^2}\right) \right. \right. \nonumber \\&\left. \left. +\frac{\partial ^2 N}{\partial S_t^2}\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\right) \right] \end{aligned}$$
(14)

The stochastic differential equation describing the dynamics of risky asset prices is:

$$\begin{aligned} dS_t= b(t,S_t, \lambda _t)S_tdt+\nu _1S_t dW_t^1+\nu _2S_t dW_t^2 \end{aligned}$$
(15)

In the appendix, you can find the proof of this proposition.

Valuation of Derivatives

According to the previous section, we consider a market consisting of:

  • A risk-free asset with value at time t, denoted by \(B_t\), which satisfies:

    $$\begin{aligned} dB_t=rB_tdt \end{aligned}$$
    (16)
  • A risky asset with value at time t, denoted by \(S_t\), which satisfies:

    $$\begin{aligned} dS_t=b S_tdt +\nu _1 S_t dW_t^1+\nu _2 S_t dW_t^2 \end{aligned}$$
    (17)
  • A liquidity factor at time t, denoted by \(\lambda _t\), which satisfies:

    $$\begin{aligned} d\lambda _t=\kappa (\theta -\lambda _t)dt+\gamma \sqrt{\lambda _t}\rho dW_t^{1}+\gamma \sqrt{\lambda _t}\sqrt{1-\rho ^2}dW_t^{2} \end{aligned}$$
    (18)

and it holds that:

  • $$\begin{aligned} (dS_t)^2=S_t^2(\nu _1^2+\nu _2^2)dt \end{aligned}$$
    (19)
  • $$\begin{aligned} dS_t d\lambda _t=S_t\gamma \sqrt{\lambda _t}(\rho \nu _1+\sqrt{1-\rho ^2}\nu _2)dt \end{aligned}$$
    (20)
  • $$\begin{aligned} (d\lambda _t)^2=\gamma ^2 \lambda _t dt \end{aligned}$$
    (21)

If we consider an agent aiming to hedge their position in the risky asset using derivatives, they will need to do so by taking a position in two derivatives contracted on this asset, with two different maturity dates (\(T_1,\ T_2\)), since they now face two sources of uncertainty. The value at time t of these derivatives will be denoted by:

  • $$\begin{aligned} H_1\equiv H_1(t,S_t,\lambda _t; T_1);\quad \text {Derivative 1}. \end{aligned}$$
    (22)
  • $$\begin{aligned} H_2\equiv H_2(t,S_t,\lambda _t; T_2);\quad \text {Derivative 2}. \end{aligned}$$
    (23)

    and it is assumed that \(H_i \in C^{1,2,2}(\mathbb {R}_{+}\times [0,T]\times [0,T], \mathbb {R})\), for \(i=1,2\).

Applying Ito’s lemma, the stochastic differential of \(H_i\) is:

$$\begin{aligned} dH_i&=\frac{\partial H_i}{\partial t}dt+\frac{\partial H_i}{\partial S_t}dS_t+\frac{\partial H_i}{\partial \lambda _t}d\lambda _t\nonumber \\&\quad +\frac{1}{2}\left\{ \frac{\partial ^2 H_i}{\partial S_t^2}(dS_t)^2+\frac{\partial ^2 H_i}{\partial \lambda _t^2}(d\lambda _t)^2+2 \frac{\partial ^2 H_i}{\partial S_t \partial \lambda _t}(dS_t)(d\lambda _t) \right\} \nonumber \\&=\left\{ \frac{\partial H_i}{\partial t}+bS_t\frac{\partial H_i}{\partial S_t}+ \kappa (\theta -\lambda _t)\frac{\partial H_i}{\partial \lambda _t}\right. \nonumber \\&\quad \left. +\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H_i}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H_i}{\partial \lambda _t^2} \right. \nonumber \\&\quad \left. +S_t\gamma \sqrt{\lambda _t}\left( \rho \nu _1+\sqrt{1-\rho ^2}\nu _2\right) \frac{\partial ^2 H_i}{\partial S_t \partial \lambda _t}\right\} dt\nonumber \\&\quad +\left\{ \nu _1S_t \frac{\partial H_i}{\partial S_t}+\gamma \sqrt{\lambda _t}\rho \frac{\partial H_i}{\partial \lambda _t} \right\} dW_t^1\nonumber \\&\quad +\left\{ \nu _2S_t \frac{\partial H_i}{\partial S_t}+\gamma \sqrt{\lambda _t}\sqrt{1-\rho ^2} \frac{\partial H_i}{\partial \lambda _t} \right\} dW_t^2 \end{aligned}$$
(24)

If we consider a self-financing portfolio consisting of \(N\equiv N(S_t,t)\) units of the risky asset, \(\Delta\) units of derivative 1 (\(H_1\)), and \(\Sigma\) units of derivative 2 (\(H_2\)), the value at time t of the portfolio is:

$$\begin{aligned} \Pi _t=NS_t+\Delta H_1+\Sigma H_2 \end{aligned}$$
(25)

and due to the self-financing condition:

$$\begin{aligned} d\Pi _t&=bS_t\left( N+\Delta \frac{\partial H_1}{\partial S_t}+ \Sigma \frac{\partial H_2}{\partial S_t}\right) dt \quad \quad \quad \quad \quad \quad \quad (26)\\ &+\nu _1S_t \left( N+\Delta \frac{\partial H_1}{\partial S_t}+ \Sigma \frac{\partial H_2}{\partial S_t}\right) dW_t^1\quad\quad \quad \quad \quad (27)\\ &+\nu _2S_t \left( N+\Delta \frac{\partial H_1}{\partial S_t}+ \Sigma \frac{\partial H_2}{\partial S_t}\right) dW_t^2 \quad \quad \quad \quad \quad (28)\\ &+\kappa (\theta -\lambda _t)\left( \Delta \frac{\partial H_1}{\partial \lambda _t}+\Sigma \frac{\partial H_2}{\partial \lambda _t} \right) dt\quad \quad \quad \quad \quad \quad (29)\\ &+\gamma \sqrt{\lambda _t} \rho \left( \Delta \frac{\partial H_1}{\partial \lambda _t}+\Sigma \frac{\partial H_2}{\partial \lambda _t} \right) dW_t^1\quad\quad \quad\quad\quad\quad(30)\\ &+\gamma \sqrt{\lambda _t} \sqrt{1-\rho ^2}\left( \Delta \frac{\partial H_1}{\partial \lambda _t}+\Sigma \frac{\partial H_2}{\partial \lambda _t} \right) dW_t^2\quad\quad\quad(31)\\ &+\Delta \left[ \frac{\partial H_1}{\partial t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H_1}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H_1}{\partial \lambda _t^2}\right. \nonumber \\&\quad \left. +S_t\gamma \sqrt{\lambda _t}\left( \rho \nu _1+\sqrt{1-\rho ^2}\nu _2\right) \frac{\partial ^2 H_1}{\partial S_t \partial \lambda _t}\right] dt\quad \quad(32)\\ &+\Sigma \left[ \frac{\partial H_2}{\partial t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H_2}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H_2}{\partial \lambda _t^2}\right. \nonumber \\&\quad \left. +S_t\gamma \sqrt{\lambda _t}\left( \rho \nu _1+\sqrt{1-\rho ^2}\nu _2\right) \frac{\partial ^2 H_2}{\partial S_t \partial \lambda _t}\right] dt\quad \quad(33) \end{aligned}$$

If considers a strategy aimed at neutralizing the risk of the position in the risky asset, one possibility for the agent is to take:

$$\begin{aligned} \Sigma =1;\quad \Delta =-\frac{\partial H_2/\partial \lambda _t}{\partial H_1/\partial \lambda _t} \end{aligned}$$
(34)

that is, taking a long position in one unit of the second derivative and a short position in \(\Delta\) units of the first derivative. This way, the coefficients of \(dW_t^1\) and \(dW_t^2\) in (29), (30) and (31) cancel out. Furthermore, if one aims to nullify the coefficients of \(dW_t^1\) and \(dW_t^2\) in (26), (27) and (28), one must take:

$$\begin{aligned} N=\left( \frac{\partial H_2/\partial \lambda _t}{\partial H_1/\partial \lambda _t}\right) \left( \frac{\partial H_1}{\partial S_t}\right) -\frac{\partial H_2}{\partial S_t} \end{aligned}$$
(35)

With the portfolio structured in this manner, it follows that:

$$\begin{aligned} d\Pi _t&=\left( -\frac{\partial H_2/\partial \lambda _t}{\partial H_1/\partial \lambda _t} \right) \left[ \frac{\partial H_1}{\partial t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H_1}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H_1}{\partial \lambda _t^2} \right. \nonumber \\&\left. \quad +S_t\gamma \sqrt{\lambda _t}\left( \rho \nu _1+\sqrt{1-\rho ^2}\nu _2\right) \frac{\partial ^2 H_1}{\partial S_t \partial \lambda _t}\right] dt \nonumber \\&\quad +\left[ \frac{\partial H_2}{\partial t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H_2}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H_2}{\partial \lambda _t^2}\right. \nonumber \\&\quad \left. +S_t\gamma \sqrt{\lambda _t}\left( \rho \nu _1+\sqrt{1-\rho ^2}\nu _2\right) \frac{\partial ^2 H_2}{\partial S_t \partial \lambda _t}\right] dt \end{aligned}$$
(36)

Now, consider an alternative investment in which the value of the portfolio at time t is deposited at the risk-free rate r, meaning the amount:

$$\begin{aligned} \Pi _t&=NS_t+\Delta H_1+\Sigma H_2=\left[ \left( \frac{\partial H_2/\partial \lambda _t}{\partial H_1/\partial \lambda _t}\right) \left( \frac{\partial H_1}{\partial S_t}\right) -\frac{\partial H_2}{\partial S_t}\right] S_t\nonumber \\&\quad -\left( \frac{\partial H_2/\partial \lambda _t}{\partial H_1/\partial \lambda _t}\right) H_1+H_2 \end{aligned}$$
(37)

is deposited at the rate r. Thus, it follows that:

$$\begin{aligned} d\Pi _t&=r\Pi _tdt \nonumber \\&=rS_t\left[ \left( \frac{\partial H_2/\partial \lambda _t}{\partial H_1/\partial \lambda _t}\right) \left( \frac{\partial H_1}{\partial S_t}\right) -\frac{\partial H_2}{\partial S_t}\right] dt\nonumber \\&\quad -rH_1\left( \frac{\partial H_2/\partial \lambda _t}{\partial H_1/\partial \lambda _t}\right) dt+rH_2dt \nonumber \\&=\left( -\frac{\partial H_2}{\partial S_t}S_t+H_2\right) rdt-\left( \frac{\partial H_2/\partial \lambda _t}{\partial H_1/\partial \lambda _t}\right) \left( -\frac{\partial H_1}{\partial S_t}S_t+H_1\right) rdt \end{aligned}$$
(38)

If the market is in equilibrium (no arbitrage exists), these two forms of investment should generate the same return, meaning (36) must be equal to (38). Hence:

$$\begin{aligned}&\left( -\frac{\partial H_2/\partial \lambda _t}{\partial H_1/\partial \lambda _t} \right) \left[ \frac{\partial H_1}{\partial t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H_1}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H_1}{\partial \lambda _t^2}\right. \\&\quad \left. +S_t\gamma \sqrt{\lambda _t}\left( \rho \nu _1+\sqrt{1-\rho ^2}\nu _2\right) \frac{\partial ^2 H_1}{\partial S_t \partial \lambda _t}\right] dt\\&\quad +\left[ \frac{\partial H_2}{\partial t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H_2}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H_2}{\partial \lambda _t^2}\right. \nonumber \\&\quad \left. +S_t\gamma \sqrt{\lambda _t}\left( \rho \nu _1+\sqrt{1-\rho ^2}\nu _2\right) \frac{\partial ^2 H_2}{\partial S_t \partial \lambda _t}\right] dt\\&=\left( -\frac{\partial H_2}{\partial S_t}S_t+H_2\right) rdt-\left( \frac{\partial H_2/\partial \lambda _t}{\partial H_1/\partial \lambda _t}\right) \left( -\frac{\partial H_1}{\partial S_t}S_t+H_1\right) rdt \end{aligned}$$

this implies that:

$$\begin{aligned}&\frac{\frac{\partial H_1}{\partial S_t}rS_t+\frac{\partial H_1}{\partial t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H_1}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H_1}{\partial \lambda _t^2}+S_t\gamma \sqrt{\lambda _t}\left( \rho \nu _1+\sqrt{1-\rho ^2}\nu _2\right) \frac{\partial ^2 H_1}{\partial S_t \partial \lambda _t}+rH_1}{\partial H_1/\partial \lambda _t}\nonumber \\&=\frac{\frac{\partial H_2}{\partial S_t}rS_t+\frac{\partial H_2}{\partial t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H_2}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H_2}{\partial \lambda _t^2}+S_t\gamma \sqrt{\lambda _t}\left( \rho \nu _1+\sqrt{1-\rho ^2}\nu _2\right) \frac{\partial ^2 H_2}{\partial S_t \partial \lambda _t}+rH_2}{\partial H_2/\partial \lambda _t} \end{aligned}$$
(39)

The equality (39) indicates that this ratio is independent of time (maturity at \(T_1\) or \(T_2\)) but does depend on the parameters. Therefore, we define the function \(g(t,S_t,\lambda _t)\) as:

$$\begin{aligned} g(t,S_t,\lambda _t):=\frac{\frac{\partial H}{\partial S_t}rS_t+\frac{\partial H}{\partial t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H}{\partial \lambda _t^2}+S_t\gamma \sqrt{\lambda _t}\left( \rho \nu _1+\sqrt{1-\rho ^2}\nu _2\right) \frac{\partial ^2 H}{\partial S_t \partial \lambda _t}+rH}{\partial H/\partial \lambda _t} \end{aligned}$$
(40)

If we denote with:

$$\begin{aligned} \mu _{H_i}\equiv \mu _i=&\frac{\frac{\partial H_i}{\partial t}+bS_t\frac{\partial H_i}{\partial S_t}+ \kappa (\theta -\lambda _t)\frac{\partial H_i}{\partial \lambda _t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H_i}{\partial S_t^2}}{H_i} \nonumber \\&+\frac{\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H_i}{\partial \lambda _t^2}+S_t\gamma \sqrt{\lambda _t}\left( \rho \nu _1+\sqrt{1-\rho ^2}\nu _2\right) \frac{\partial ^2 H_i}{\partial S_t \partial \lambda _t}}{H_i} \end{aligned}$$
(41)
$$\begin{aligned} \sigma _{H_i}\equiv \sigma _i&=\frac{\nu _1S_t \frac{\partial H_i}{\partial S_t}+\gamma \sqrt{\lambda _t}\rho \frac{\partial H_i}{\partial \lambda _t}}{H_i}\end{aligned}$$
(42)
$$\begin{aligned} \xi _{H_i} \equiv \xi _i&=\frac{\nu _2S_t \frac{\partial H_i}{\partial S_t}+\gamma \sqrt{\lambda _t}\sqrt{1-\rho ^2} \frac{\partial H_i}{\partial \lambda _t}}{H_i} \end{aligned}$$
(43)

from expression (24), we have that:

$$\begin{aligned} dH_i=\mu _iH_idt+\sigma _iH_idW_t^1+\xi _iH_idW_t^2 \end{aligned}$$
(44)

If we consider a self-financing portfolio (\(\Pi _t\)) composed of \(\theta _0\) units of the risky asset, \(\theta _1\) units of derivative 1, and \(\theta _2\) units of derivative 2, that is, \(\Pi _t=\theta _0S_t+\theta _1H_1+\theta _2H_2\), then:

$$\begin{aligned} d\Pi _t&=\theta _0dS_t+\theta _1dH_1+\theta _2dH_2\\&=\left( \theta _0 bS_t+\theta _1\mu _1 H_1+\theta _2\mu _2H_2\right) dt+\left( \theta _0 \nu _1S_t+\theta _1\sigma _1 H_1+\theta _2\sigma _2H_2\right) dW_t^1\\&\quad +\left( \theta _0 \nu _2S_t+\theta _1\xi _1 H_1+\theta _2\xi _2H_2\right) dW_t^2 \end{aligned}$$

Taking \(\theta _2=1\), the coefficients of \(W_t^1\) and \(W_t^2\) are: \(\theta _0 \nu _1S_t+\theta _1\sigma _1 H_1+\sigma _2H_2\) and \(\theta _0 \nu _2S_t+\theta _1\xi _1 H_1+\xi _2H_2\). If one aims to nullify them, it results in:

$$\begin{aligned} {\left\{ \begin{array}{ll} \theta _0 \nu _1S_t+\theta _1\sigma _1 H_1+\sigma _2H_2&{}=0\\ \theta _0 \nu _2S_t+\theta _1\xi _1 H_1+\xi _2H_2&{}=0 \end{array}\right. } \end{aligned}$$

hence:

$$\begin{aligned} \theta _1=\frac{\sigma _2H_2\nu _2-\xi _2H_2\nu _1}{\xi _1H_1\nu _1-\sigma _1H_1\nu _2} \end{aligned}$$
(45)
$$\begin{aligned} \theta _0=\frac{\xi _2H_2\sigma _1-\sigma _2H_2\xi _1}{S_t(\xi _1\nu _1-\sigma _1\nu _2)} \end{aligned}$$
(46)

then, \(d\Pi _t\) is:

$$\begin{aligned} d\Pi _t&=\left[ \left( \frac{\xi _2H_2\sigma _1-\sigma _2H_2\xi _1}{\xi _1 \nu _1-\sigma _1 \nu _2}\right) b\right. \nonumber \\&\quad \left. +\left( \frac{\sigma _2 H_2\nu _2-\xi _2H_2\nu _1}{\xi _1 \nu _1-\sigma _1 \nu _2}\right) \mu _1+\mu _2 H_2\right] dt \end{aligned}$$
(47)

Now, if the value of this portfolio at time t is invested at the risk-free rate r, we have:

$$\begin{aligned} d\Pi _t&=\left[ \left( \frac{\xi _2H_2\sigma _1-\sigma _2H_2\xi _1}{\xi _1 \nu _1-\sigma _1 \nu _2}\right) r\right. \nonumber \\&\quad \left. +\left( \frac{\sigma _2 H_2\nu _2-\xi _2H_2\nu _1}{\xi _1 \nu _1-\sigma _1 \nu _2}\right) r+r H_2\right] dt \end{aligned}$$
(48)

due to no arbitrage, expressions (47) and (48) must be equal, leading to \(b=r\), \(\mu _1=r\), and \(\mu _2=r\), then: hence:

$$\begin{aligned}&\frac{rS_t \frac{\partial H}{\partial S_t}+\frac{\partial H}{\partial t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H}{\partial \lambda _t^2}}{\partial H /\partial \lambda _t}\nonumber \\&+\frac{S_t\gamma \sqrt{\lambda _t}(\rho \nu _1 +\sqrt{1-\rho ^{2}} \nu _2)\frac{\partial ^2 H}{\partial S_t \partial \lambda _t}-rH}{\partial H /\partial \lambda _t}=-\kappa (\theta -\lambda _t) \end{aligned}$$
(49)

this implies that \(g(t, S_t, \lambda _t)=-\kappa (\theta -\lambda _t)\), from which we arrive at the partial differential valuation equation:

$$\begin{aligned}&\frac{\partial H}{\partial t}+rS_t \frac{\partial H}{\partial S_t}+\kappa (\theta -\lambda _t)\frac{\partial H}{\partial \lambda _t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H}{\partial \lambda _t^2} \nonumber \\&+S_t\gamma \sqrt{\lambda _t}\left(\rho \nu _1 +\sqrt{1-\rho ^{2}} \nu _2\right)\frac{\partial ^2 H}{\partial S_t \partial \lambda _t}-rH=0 \end{aligned}$$
(50)

and it can be verified that if \(\lambda _t=0\), then Eq. (50) reduces to the Black–Scholes partial differential equation.

This scheme for deriving the valuation PDE follows the no-arbitrage principle of the seminal Black–Scholes model, but extends it by considering a second source of randomness arising from incorporating a stochastic illiquidity parameter. This results in a novel contribution to the field of financial modeling, and as shown later, to the use of computational tools for contingent asset valuation.

The Feynman–Kac Theorem and Partial Differential Equations

Considering the following second-order linear partial differential equation:

$$\begin{aligned} {\left\{ \begin{array}{ll} \partial _t u(t,x)+\frac{1}{2}\sigma (t,x) \sigma ^{T}(t,x):\nabla ^2 u(t,x)+\mu (t,x) \cdot \nabla u(t,x)=0;\quad (t,x)\in [0,T)\times \mathbb {R}^{d}\\ u(T,x)=g(x);\quad x \in \mathbb {R}^{d} \end{array}\right. } \end{aligned}$$
(51)

In this case, \(d \in \mathbb {N}\) represents the spatial dimension, \(\nabla u(t,x)\) and \(\nabla ^2 u(t,x)\) denote the gradient and the Hessian of the function u(tx) respectively. The notation ( : ) represents the Frobenius inner product of \(d \times d\) matrices, defined as \(A: B = \sum _{i,j=1}^{d}a_{ij}b_{ij}\), while \((\cdot )\) represents the Euclidean inner product in \(\mathbb {R}^{d}\). It is assumed that the functions \(\mu :[0,T] \times \mathbb {R}^{d} \rightarrow \mathbb {R}^{d}\) and \(\sigma :[0,T] \times \mathbb {R}^{d} \rightarrow \mathbb {R}^{d \times d}\) are globally continuous in the Lipschitz sense. For this type of differential equations, it is possible to approximate the solution for a fixed time instant and some bounded domain \(D \subset \mathbb {R}^{d}\) using the Feynman–Kac formula.

The Feynman–Kac theorem states that, for every pair \((t, x) \in [0, T] \times \mathbb {R}^d\), the solution u(tx) of Eq. (51) can be expressed as the conditional expected value of a stochastic process \(\{X_s\}_{s\in [t, T]}\) with \(X_t = x\), i.e.:

$$\begin{aligned} u(t,x)=E[g(X_T)|X_t=x] \end{aligned}$$
(52)

where \(g: \mathbb {R}^{d} \rightarrow \mathbb {R}\) is the function given by the boundary condition in (51). An immediate consequence is that for all \(x \in \mathbb {R}^{d}\):

$$\begin{aligned} u(T,x)=E[g(X_T)|X_T=x]=g(x) \end{aligned}$$
(53)

Another implication, following from the law of iterated conditional expectation, is that for all \(s \in [t,T]\):

$$\begin{aligned} u(t,x)=E[u(s,X_s))|X_T=x] \end{aligned}$$
(54)

Considering a filtered probability space \((\Omega , \mathcal {F}, P, (\mathcal {F}_t)_{t \in [0,T]})\), with the filtration \((\mathcal {F}_t)_{t \in [0,T]})\) generated by a d-dimensional Brownian motion \(\{W_t\}_{t \in [0, T]}\), the stochastic process \(\{X_s\}_{s\in [t, T]}\) can be characterized as the solution to the stochastic differential equation (SDE):

$$\begin{aligned} X_s=x+\int \limits _t^{s}\mu (\tau ,X_{\tau })d\tau +\int \limits _t^{s}\sigma (\tau , X_{\tau })dW_{\tau } \end{aligned}$$
(55)

given the coefficients \(\mu\) and \(\sigma\), which are Lipschitz continuous, there exists a unique solution to (55). Considering the solution process \(\{X_s\}_{s\in [t, T]}\) and a function \(v\in C^{1,2}([0,T] \times \mathbb {R}^{d}, \mathbb {R})\), applying Ito’s lemma yields for every \(s \in [t,T]\):

$$\begin{aligned} v(s,X_{s} ) & = v(t,x) + \int\limits_{t}^{s} {\partial _{t} } v(\tau ,X_{\tau } )d\tau + \int\limits_{t}^{s} \nabla v(\tau ,X_{\tau } ) \cdot dX_{\tau } \\ & + \frac{1}{2}\int\limits_{t}^{s} {\nabla ^{2} } v(\tau ,X_{\tau } ):\sigma (\tau ,X_{\tau } )\sigma ^{T} (\tau ,X_{\tau } )d\tau \\ \end{aligned}$$

Substituting \(dX_{\tau }\) with its definition (55) results in:

$$\begin{aligned} v(s,X_s)&=v(t,x)+\int \limits _t^{s}\left( \partial _tv+\frac{1}{2}\nabla ^{2}v:\sigma \sigma ^{T}+\nabla v \cdot \mu \right) \\ {}&(\tau ,X_{\tau }) d\tau +\int \limits _t^{s} \nabla v \cdot \sigma (\tau , X_{\tau })dW_{\tau } \end{aligned}$$

As this holds for every \(s \in [t,T)\), particularly for \(s=t+h\) with \(h>0\), we obtain:

$$\begin{aligned} v(t+h,X_{t+h})&=v(t,x)+\int \limits _t^{t+h}\left( \partial _tv+\frac{1}{2}\nabla ^{2}v:\sigma \sigma ^{T}+\nabla v \cdot \mu \right) (\tau ,X_{\tau }) d\tau \\&\quad +\int \limits _t^{t+h} \nabla v \cdot \sigma (\tau , X_{\tau })dW_{\tau } \end{aligned}$$

Taking \(v=u\) with u given by (54) for \(s=t+h\), we get:

$$\begin{aligned} 0&=E\left[ \int \limits _t^{t+h}\left( \partial _tu+\frac{1}{2}\nabla ^{2}u:\sigma \sigma ^{T}+\nabla u \cdot \mu \right) (\tau ,X_{\tau }) d\tau \right. \\&\quad \left. + \int \limits _t^{t+h} \nabla u \cdot \sigma (\tau , X_{\tau })dW_{\tau }|X_t=x\right] \end{aligned}$$

This equals:

$$\begin{aligned} E\left[ \int \limits _t^{t+h}\left( \partial _tu+\frac{1}{2}\nabla ^{2}u:\sigma \sigma ^{T}+\nabla u \cdot \mu \right) (\tau ,X_{\tau }) d\tau |X_t=x\right] \end{aligned}$$

Dividing by \(h>0\) and taking the limit as h tends to zero, by the mean value theorem:

$$\begin{aligned}{} & {} \partial _t u(t,x)+\frac{1}{2}\sigma (t,x) \sigma ^{T}(t,x):\nabla ^2 u(t,x)\\{} & {} +\mu (t,x) \cdot \nabla u(t,x)=0;\quad \forall (t,x) \in [0,T)\times \mathbb {R}^{d} \end{aligned}$$

This demonstrates that the function given by the Feynman–Kac formula (54) solves the PDE (51).

In the work by [19], they introduce the representation of the solution of the PDE using neural networks. The network is trained through Monte–Carlo sampling and produces an approximation of the solution \(u=u(t, \cdot ): D \rightarrow \mathbb {R}\) for the problem (51). This is constrained to a bounded domain of interest \(D \subset \mathbb {R}^d\) and at a specific time \(t \in [0, T]\). The details of this approximation for \(t=0\) are presented below.

Approximation Using Neural Networks

For the specific case of the neural network used to solve the PDE (51), the training is based on a large amount of data generated by Monte–Carlo sampling from the stochastic process (55) related to the PDE. To be more precise, the training data \(\{(x^i, y^i)\}_{i=1}^{n}\) is considered, where the input or independent variable x is randomly sampled from \(X \sim U(D)\), ensuring sufficient coverage of the domain of interest D. The random output (target variable) y is defined as a function of x via \(Y:=g(X_T)\), where \(X_T\) is the final value of the stochastic process \(\{X_t\}_{t \in [0, T ]}\) starting at \(X_0=x\) and evolving according to the SDE:

$$\begin{aligned} X_t=x+\int \limits _0^{t}\mu (s,X_{s})ds+\int \limits _0^{t}\sigma (s, X_{s})dW_{s} \end{aligned}$$
(56)

If the explicit distribution of \(X_T\) is known, the pairs (xy) can be directly sampled from this distribution. If the distribution is unknown, the Euler–Maruyama scheme from (56) can be used:

$$\begin{aligned} \tilde{X}_{n+1}:=\tilde{X}_{n}+\mu (t_n,\tilde{X}_{n})(t_{n+1}-t_{n})+\sigma (t_n,\tilde{X}_{n})(W_{t_{n+1}}-W_{t_{n}});\,\,\tilde{X}_0:=x \end{aligned}$$
(57)

where \(\tilde{X}_{n} \approx X_{t_n}\) is a discrete stochastic process approximating \(X_t\) at points \(0=t_0<t_1<\cdots <t_N=T\) and x is a realization from \(X \sim U(D)\). Finally, \(Y:=g(\tilde{X}_N)\). Convergence for the Euler–Maruyama scheme is guaranteed if \(N \rightarrow \infty\) and \(\sup _{n}|t_{n}-t_{n-1}| \rightarrow 0\).

In the neural network approximation of the solution of (51) at \(t=0\), the function \(u_{\theta }: D \rightarrow \mathbb {R}\) generated by the neural network is considered, where \(\theta\) gathers all the unknown parameters of the network. Given a training dataset \(\{(x^{i}, y^{i})\}_{i=1}^{n}\), the objective is to minimize the sum of squared errors:

$$\begin{aligned} \frac{1}{n}\sum _{i=1}^{n}[y^{i}-u_{\theta }(x^{i})]^2 \end{aligned}$$
(58)

This corresponds, from the underlying stochastic process perspective, to minimizing:

$$\begin{aligned} E\left\{ [g(X_T)-u_{\theta }(x^{i})]^2\right\} \end{aligned}$$

where \(X_T\) is the solution of (56) starting at \(X_0=x\). The network proposed by [19] has the following structure:

$$\begin{aligned}{} & {} \text {Input} \rightarrow \text {CN} \rightarrow (\text {Dense} \rightarrow \text {CN} \rightarrow \text {TanH})\\{} & {} \quad \rightarrow (\text {Dense} \rightarrow \text {CN} \rightarrow \text {TanH}) \rightarrow \text {Dense} \rightarrow \text {CN} \rightarrow \text {Output} \end{aligned}$$

where:

  • \(\text {CN}\): Normalization step (Normalization during the training of a neural network is a process that aims to standardize or normalize the inputs provided to the network. This is done to help the model learn more effectively and converge faster during training).

  • \(\text {Dense}\): Indicates a layer of fully connected neurons without a bias term, i.e., a product between weight vectors and matrices.

  • \(\text {TanH}\): Indicates the application of the hyperbolic tangent function as an activation function.

The Feynman–Kac formula and the neural network approximation can be extended to the entire class of linear parabolic partial differential equations. Specifically, the considered PDEs can be extended to the type:

$$\begin{aligned} {\left\{ \begin{array}{ll} \partial _t u(t,x)+\frac{1}{2}\sigma (t,x) \sigma ^{T}(t,x):\nabla ^2 u(t,x)+\mu (t,x) \cdot \nabla u(t,x)-r(t,x)u(t,x)+f(t,x)=0 \\ u(T,x)=g(x);\quad x \in \mathbb {R}^{d} \end{array}\right. } \end{aligned}$$
(59)

where \(r: [0,T]\times \mathbb {R}^{d} \rightarrow [0,\infty )\) and \(f:[0,T]\times \mathbb {R}^{d} \rightarrow \mathbb {R}\). Under sufficient smoothness conditions, the solution of (59) admits the Feynman–Kac representation:

$$\begin{aligned} u(t,x)&=E\left[ \int _t^{T}e^{-\int _t^{\tau }r(v,X_v)dv}f(\tau ,X_{\tau })\right. \nonumber \\&\left. +e^{-\int _t^{T}r(v,X_v)dv}g(X_T)|X_t=x\right] ;\forall (t,x) \in [0,T]\times \mathbb {R}^{d} \end{aligned}$$
(60)

Algorithmically, this can be considered within the same framework discussed previously, particularly without modifying the generation of samples from the stochastic process \(\{X_s\}_{s\in [0, T]}\). In the case of the discrete approximation \(\{\tilde{X}_n\}_{n=0}^{N}\) generated by the Euler–Maruyama scheme (57), a simple approximation of the corresponding output variable Y can be provided by:

$$\begin{aligned} Y=\sum _{n=0}^{N-1}\tilde{R}_nf(t_n,\tilde{X}_n)(t_{n+1}-t_n)+\tilde{R}_Ng(\tilde{X}_N) \end{aligned}$$
(61)

where,

$$\begin{aligned} \tilde{R}_n&:=\exp \left( -\sum _{j=0}^{n-1}r(t_j,\tilde{X}_j)(t_{j+1}-t_j)\right) \nonumber \\&=\tilde{R}_{n-1}\exp (-r(t_{n-1},\tilde{X}_{n-1})(t_n-t_{n-1}));\quad \tilde{R}_0:=1 \end{aligned}$$
(62)

In this case, \(\tilde{R}_n\) is a discrete approximation of the term \(e^{-\int _0^{t_n}r(v,X_v)dv}\). The discrete approximation (61) can be used to generate training samples \(\{(x^{i},y^{i})\}_{i=1}^{n}\) for a neural network \(u_{\theta }:D \rightarrow \mathbb {R}\) that approximates the solution of the PDE (59) in a domain of interest D at the instant \(t=0\).

The Feynman–Kac Theorem and Semi-Linear PDEs

The described methodology can be extended to consider solving semi-linear PDEs obtained by allowing the lower-order terms in (59) to depend nonlinearly on the solution and its gradient. This results in the final value problem:

$$\begin{aligned} {\left\{ \begin{array}{ll} \partial _t u(t, x)+ \frac{1}{2} \sigma (t,x)\sigma ^T(t,x):\nabla ^2u(t, x) + \mu (t, x) \cdot \nabla u(t, x) + f(t, x, u(t, x), \sigma ^T(t, x) \nabla u(t, x)) = 0 \\ u(T, x) = g(x);\quad x \in \mathbb {R}^d \end{array}\right. } \end{aligned}$$
(63)

for \(t \in [0,T)\) and \(x \in \mathbb {R}^{d}\). The function \(f:[0,T] \times \mathbb {R}^d \times \mathbb {R} \times \mathbb {R}^d \rightarrow \mathbb {R}\), containing lower-order terms, can generally depend on the independent variables \(t\), \(x\), as well as the solution \(u(t, x)\) and its transformed gradient \((\sigma ^T \nabla ) u(t, x)\). The non-divergent form of the principal term, as well as the specific dependence on \(\sigma ^T \nabla u\), allows revisiting the connection between PDEs and stochastic processes. The presence of these dependencies requires extending the numerical solution method to include additional stochastic processes to approximate \(\nabla u\).

Similar to the previous section, we consider the process \(\{X_t\}_{t \in [0, T ]}\) in the state space \(\mathbb {R}^{d}\) determined by the forward stochastic differential equation (FDE):

$$\begin{aligned} X_t = x + \int \limits _{0}^{t} \mu (s, X_s) ds + \int \limits _{0}^{t} \sigma (s, X_s) dW_s \end{aligned}$$
(64)

with \(x \in \mathbb {R}^d\), and with the underlying probability space \((\Omega , \mathcal {F}, P (\mathcal {F}_t)_{t \in [0,T]})\) where the filtration is generated by a \(d\)-dimensional Brownian motion \(\{W_t\}_{t \in [0, T]}\). Given a sufficiently smooth function \(v: [0, T] \times \mathbb {R}^d \rightarrow \mathbb {R}\), applying Ito’s formula, the dynamics of the value process \(Y_t:=v(t, X_t)\) are governed by the stochastic differential equation (written in differential notation):

$$\begin{aligned} dY_t&= \left( \partial _t v+ \frac{1}{2} \sigma \sigma ^T : \nabla ^2 v + \nabla v \cdot \mu \right) (t, X_t) dt\nonumber \\&\quad + (\sigma ^T \nabla v)(t, X_t) \cdot dW_t \end{aligned}$$
(65)

Assuming a sufficiently smooth solution \(u\) of (63), setting \(v=u\) in (65), and introducing a third stochastic process \(Z_t:= (\sigma ^T \nabla )u(t, X_t)\), we obtain:

$$\begin{aligned} dY_t = -f(t, X_t, Y_t, Z_t) dt - Z_t \cdot dW_t;\quad Y_T = g(X_T) \end{aligned}$$
(66)

This stochastic differential equation with the final condition \(Y_T = g(X_T)\) is known as the backward stochastic differential equation (BSDE) associated with (63). In integral notation, it is expressed as:

$$\begin{aligned} Y_t = g(X_T) - \int \limits _{t}^{T} f(s, X_s, Y_s, Z_s)ds - \int \limits _{t}^{T} Z_s \cdot dW_s \end{aligned}$$
(67)

Under sufficient regularity conditions on the functions \(\mu\), \(\sigma\), \(f\), and \(g\), the FDEs (64) and (66) possess a unique solution \((X_t, Y_t, Z_t)\), and the link with the nonlinear PDE is established through a generalization of the Feynman–Kac formula. This formula asserts that for all \(t \in [0, T]\), it holds almost surely that:

$$\begin{aligned} Y_t = u(t, X_t) \quad \text {and} \quad Z_t = (\sigma ^T \nabla u)(t, X_t) \end{aligned}$$
(68)

These expressions are termed the nonlinear Feynman–Kac representation, and the system of FDEs comprised of (64) and (66) is referred to as the forward–backward stochastic differential equation (FBSDE). A detailed development of these results can be found in [20] and [21].

Note that the FDE (64) does not depend on \(Y_t\) or \(Z _t\), so it can be solved independently. Consequently, the sought value of the solution \(u(0, x)\) can be found by solving the FBSDE and evaluating \(Y_0\) in (68). The difference from the procedure described in the previous section is that the solution of the value process \(\{Y_s\}_{s\in [0,T]}\) is more complex due to the nonlinear term \(f\) and its dependence on \(u(t, x)\) and \((\sigma ^{T}\nabla )u(t, x)\).

Approximation Using Neural Networks

The algorithm proposed in [22], referred to as the deep BSDE solver, constructs an approximation of the solution \(u(0, x)\) of the PDE (63) by solving the associated FBSDE (64) and (66), returning \(u(0, x) = Y_0\) as described in the previous section.

For its implementation using neural networks, a discretization of the time domain \([0,T]\) into \(N\) equidistant subintervals with steps \(0 = t_0< t_1< \cdots < t_N = T\) and step size \(\Delta t = T/N\) is considered. Simulations of the trajectories of the continuous process \(\{X_t\}_{t\in [0,T]}\) are generated using the Euler-Maruyama scheme for the forward EDE (64), leading to the discrete process:

$$\begin{aligned} \tilde{X}_{n+1}&=\tilde{X}_{n}+\mu (t_n,\tilde{X}_{n})(t_{n+1}-t_n)+\sigma (t_n,\tilde{X}_{n})(W_{t_{n+1}}-W_{t_n});\nonumber \\ \tilde{X}_{0}&=x \end{aligned}$$
(69)

Simulations of trajectories for the backward SDE (67) are generated in a similar manner:

$$\begin{aligned} \tilde{Y}_{n+1}&=\tilde{Y}_{n}+f(t_n,\tilde{X}_{n}, \tilde{Y}_{n}, \tilde{Z}_{n})(t_{n+1}-t_n)+\tilde{Z}_{n}(W_{t_{n+1}}-W_{t_n});\nonumber \\ \tilde{Y}_{N}&=g(\tilde{X}_{N}) \end{aligned}$$
(70)

It’s important to note that the changes in the Brownian motion \((W_{t_{n+1}}-W_{t_n})\) are the same in (69) and (70).

The algorithm can be summarized as follows:

  • Simulate trajectories of the discrete process \(\{\tilde{X}_n\}_{n=0}^{N}\) along with the corresponding increments of the Brownian motion \(\{W_{t_{n+1}}-W_{t_n}\}_{n=0}^{N-1}\) according to (69).

  • Similarly, trajectories of the discrete process \(\{\tilde{Y}_n\}_{n=0}^{N}\) are generated according to (70). A closer look reveals that (70) contains unknown quantities necessary to carry out the time step. These quantities include \(\tilde{Y}_0\), an approximation of \(u(0, x)\), and \(\tilde{Z}_n\) for \(n=0, \dots , N-1\), approximations of \((\sigma ^T\nabla u)(t_n,\tilde{X}_n)\). These quantities are obtained through the training of a neural network. The quantities \(\tilde{Y}_0\approx u(0,x)\) and \(\tilde{Z}_0\approx (\sigma ^T\nabla u)(0,\tilde{X}_0)\) are treated as individual parameters, both necessary only at the point \((0, x)\), and are learned during training. The remaining quantities \(\tilde{Z}_n, n=1,...,N-1\) are approximated by neural networks performing the transformation \(x \rightarrow (\sigma ^T\nabla u)(t_n,x)\) for \(n=1, \dots , N-1\). All the parameters of the neural network to be learned are collected in \(\theta =(\theta _{u_0},\theta _{\nabla u_0},\theta _{\nabla u_1},...,\theta _{\nabla u_{N-1}})\), where \(\theta _{u_0}\in \mathbb {R}\), \(\theta _{\nabla u_0}\in \mathbb {R}^d\), and \(\theta _{\nabla u_n}\in \mathbb {R}^{\rho _n}\), with \(\rho _n\) being the number of unknown parameters in the neural network performing the transformation \(x \rightarrow (\sigma ^T\nabla u)(t_n, x)\) for \(n=1,...,N-1\).

  • Since \(\tilde{Y}_N\) approximates \(u(T, \tilde{X}_N) = g(\tilde{X}_N)\) according to (70), the network is trained to minimize the mean squared error between \(\tilde{Y}_N\) and \(g(\tilde{X}_N)\). For a set of \(m\) simulated pairs \((\tilde{X}_N,\tilde{Y}_N)\), this results in the loss function:

    $$\begin{aligned} \phi _{\theta }(\tilde{X}_N,\tilde{Y}_N):=\frac{1}{m}\sum _{i=1}^{m}\left[ \tilde{Y}^{i}_N-g(\tilde{X}^{i}_N)\right] ^2 \end{aligned}$$
    (71)

    where \(\tilde{Y}^{i}_N\) is the output of the neural network. Automatic differentiation is employed on \(\phi _{\theta }\) with respect to the unknown parameters \(\theta\) to obtain the gradient \(\nabla _{\theta }\phi _{\theta }\), which is used in the optimization routine, such as a variant of the stochastic gradient descent method.

The architecture of the subnetworks that perform the transformation \(x \rightarrow (\sigma ^T\nabla u)(t_n, x)\) used is taken similarly to [22], and is given by:

$$\begin{aligned}&Input \mapsto CN \mapsto \ (Dense \mapsto CN \mapsto ReLU) \cdots \\&\mapsto \ (Dense\ \mapsto \ CN\ \mapsto \ ReLU)\ \mapsto \ Dense\ \mapsto \ CN\ \mapsto \ Output \end{aligned}$$

where:

  • CN: normalization step.

  • Dense: denotes a fully connected layer without bias term.

  • ReLU: indicates the application of a rectified linear unit as an activation function. Specifically, \(ReLU(x)=\max \{x,0\}\).

In terms of the layers in Fig. 2, it follows that: first, the inputs \(\tilde{X}_n \in \mathbb {R}^{d}\) are scaled and shifted for each component through normalization, resulting in \(h_n^{0}=CN_n^{0}(\tilde{X}_n)\); second, the outputs of the first layer are processed by the subsequent block \(h_{n}^{1}=ReLU(CN_n^{1}(W_n^{1}h_n^{0}))\), followed by the block \(h_{n}^{2}=ReLU(CN_n^{2}(W_n^{2}h_n^{1}))\); finally, the output is multiplied by another weight matrix \(W_n^{3}\) and normalized again, resulting in \(h_{n}^{3}=CN_n^{3}(W_n^{3}h_n^{2})\approx \tilde{Z}_n\). Figure 2 shows the complete structure of the network.

Fig. 2
figure 2

The first two rows depict the evolution of the forward process \(\{\tilde{X}_n\}_{n=0}^{N}\) starting with \(\tilde{X}_0=0\). The unknown parameters for \(u_{\theta }(0,x)\) and \(\nabla u_{\theta }(0, x)\), as well as the parameters in the approximating neural network \(\tilde{Z}_n\), \(n=1,...,N-1\), are learned through training. The intermediate values \(\tilde{Y}_n\) and \(\tilde{Z}_n\), \(n=1,...,N-1\) are necessary to establish the relationship between the sought-after value of the EDP solution \(u(0, x)\approx \tilde{Y}_0\) and the final value \(\tilde{Y}_N=g(\tilde{X}_N)\)

Solving Nonlinear Valuation PDEs

Below are the results for the approximation of the solution for the nonlinear valuation PDEs found in the context of a market with stochastic illiquidity. The type of derivative being valued comprises European call and put options.

For the stochastic illiquidity market model, the valuation PDE is given by:

$$\begin{aligned} \frac{\partial H}{\partial t}+rS_t \frac{\partial H}{\partial S_t}+&\kappa (\theta -\lambda _t)\frac{\partial H}{\partial \lambda _t}+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\frac{\partial ^2 H}{\partial S_t^2}+\frac{\gamma ^2 \lambda _t}{2}\frac{\partial ^2 H}{\partial \lambda _t^2} \nonumber \\&+S_t\gamma \sqrt{\lambda _t}(\rho \nu _1 +\sqrt{1-\rho ^{2}} \nu _2)\frac{\partial ^2 H}{\partial S_t \partial \lambda _t}-rH=0 \end{aligned}$$
(72)

where \(H_t\equiv H(S_t,t)\) is the function determining the derivative’s value, with \(H(S_T,T)=(S_T-K)^{+}\) for the call option, \(H(S_T,T)=(K-S_T)^{+}\) for the put option, and K is a positive constant.

Following the notation used in “The Feynman–Kac theorem and partial differential equations” section, in this case, the function f associated with the valuation PDE is:

$$\begin{aligned} f&=rS_t \nabla _{S} H+\kappa (\theta -\lambda _t)\nabla _{\lambda } H+\frac{S_t^2(\nu _1^2+\nu _2^2)}{2}\nabla ^2_{S} H+\frac{\gamma ^2 \lambda _t}{2}\nabla ^2_{\lambda } H \nonumber \\&\quad +S_t\gamma \sqrt{\lambda _t}(\rho \nu _1 +\sqrt{1-\rho ^2} \nu _2)\nabla ^2_{\lambda S} H-rH \end{aligned}$$
(73)

Applying the proposed method for valuing European call and put options, with \(S_0=100\), \(K=100\), \(r=0.05\), \(T=1\), \(\kappa =0.1\), \(\theta =0.1\), \(\rho =0.8\), \(\gamma =0.2\), \(d=1\), \(N=365\), and considering that \(N(S_t,\lambda _t,t)\) is the function describing the agent’s strategy, which for implementation purposes, we assume is a modification of the optimization-based strategy \(N(S_t,\lambda _t,t)=\theta _0e^{-\theta _1 t}S_t^{-\theta _2}\lambda _t^{\theta _3}\), where \(\theta _0\), \(\theta _1>0\), \(\theta _2 >0\), and \(\theta _3 >0\) are constants, with \(\theta _0=0.1\), \(\theta _1=\theta _2=\theta _3=0.01\), the results shown in Table 1 were obtained with a level of error associated with the cost function \(\varepsilon =10^{-4}\) and different numbers of iterations.

Table 1 Numerical results for calculating the premium of European call and put options using the proposed method considering \(S_0=100\), \(K=100\), \(r=0.05\), \(T=1\), \(\kappa =0.1\), \(\theta =0.1\), \(\rho =0.8\), \(\gamma =0.2\), \(d=1\), \(N=365\), \(\theta _0=0.1\), and \(\theta _1=\theta _2=\theta _3=0.01\). Self-made

The results from Table 1 show how the mean value of the cost function decreases for both types of options, indicating that the neural network training process is effective. Additionally, the mean values obtained for the premiums of the two options are reasonable in several ways:

  1. 1.

    The values of the call option are higher than those of the put option, which is expected given the parameter values considered for this implementation.

  2. 2.

    When reproducing the exercise considering a market with perfect liquidity (\(\lambda _t=0\)), leading to a passive trading strategy by the agent, the values obtained are those yielded by the basic Black–Scholes model. In other words, the Black–Scholes model can be seen as a particular case of the proposed model and resolution procedure.

  3. 3.

    Compared to the Black–Scholes model, the values obtained by the stochastic illiquidity model present arbitrage opportunities, but the differences are not large enough to generate market distortions, particularly if transaction costs or tax rates are incorporated.

Conclusion

The extension of the Feynman–Kac representation theorem to semi-linear PDEs creates the possibility of discretizing the resulting representation, paving the way for an approximation of the solution to PDEs using Monte–Carlo methods. However, it poses the challenge of estimating the gradient and Hessian of the approximation function. It’s precisely at this juncture where the ability of neural networks to approximate any nonlinear function, coupled with advancements in automatic differentiation, makes a difference, turning the combination of these two techniques into a powerful resolution tool.

Specifically, in adapting and implementing the method for solving valuation PDEs in illiquid markets, the algorithm adjusts relatively easily in each case, albeit under specific assumptions about some parameters and strategies. Yet, in general, if the necessary conditions for implementation are met, it efficiently approximates the equation’s solution. The results shown in the table reflect the approximation of the value of European call and put option premiums for the considered parameters within each proposed market model context. Naturally, there are differences in the convergence value of the algorithm in each case, stemming from how the effect of illiquidity is modeled and incorporated into each model.