robustfpm.pricing.multival_map module

This submodule implements MultivalMap as an abstract interface for multivalued mappings and some specific mappings.

For any sets \(X, Y\), a multivalued mapping is such a mapping \(\Gamma: X \mapsto Y\), that

\[\forall x \in X \;\; \Gamma(x) \subseteq Y\]

This module also provides two simple instances of IMultivalMap: NoConstraints and LongOnlyConstraints for ease of use. They are defined as:

>>> NoConstraints = IdenticalMap(RealSpaceHandler())
>>> LongOnlyConstraints = IdenticalMap(NonNegativeSpaceHandler())
class robustfpm.pricing.multival_map.IMultivalMap

Bases: abc.ABC

An abstract interface class for multivalued mappings

abstract __call__(x, t)

A.__call__(x,t) is equivalent to A(x,t)

Parameters
  • x (np.ndarray) – A point or a set of points from \(\mathbb{R}^{n}\)

  • t (int) – Value of time

Returns

Value of a mapping at point(s) x, t

Return type

ISetHandler

abstract property dim

The dimension of image or np.inf if return value can be of any dimension (e.g., a robustfpm.pricing.set_handler.RealSpaceHandler)

For a multivalued map \(\Gamma: \mathbb{R}^{n} \times \{0, 1, \dots\} \mapsto \mathbb{R}^{n}\), returns \(n\).

Type

int

class robustfpm.pricing.multival_map.IdenticalMap(support: robustfpm.pricing.set_handler.ISetHandler)

Bases: robustfpm.pricing.multival_map.IMultivalMap

Identical mapping: always returns the same set (its support)

Parameters

support (ISetHandler) – The underlying set to return

__call__(x, t)

A.__call__(x,t) is equivalent to A(x,t)

Parameters
  • x (np.ndarray) – A point or a set of points from \(\mathbb{R}^{n}\)

  • t (int) – Value of time

Returns

Value of a mapping at point(s) x, t

Return type

ISetHandler

property dim

The dimension of image or np.inf if return value can be of any dimension (e.g., a robustfpm.pricing.set_handler.RealSpaceHandler)

For a multivalued map \(\Gamma: \mathbb{R}^{n} \times \{0, 1, \dots\} \mapsto \mathbb{R}^{n}\), returns \(n\).

Type

int

class robustfpm.pricing.multival_map.PriceDynamics

Bases: robustfpm.pricing.multival_map.IMultivalMap

An abstract base class for different price dynamics. Differs from IMultivalMap in that it also has to have:

  • type

  • time horizon

  • method for calculating Lipschitz constant

abstract __call__(x, t=1)

A.__call__(x,t) is equivalent to A(x,t)

Parameters
  • x (np.ndarray, size (t, n)) – A set of previous prices, each price — a point from \(\mathbb{R}^{n}\)

  • t (int) – Value of time

Returns

For additive dynamics, returns increment \(K_t(x)\). For multiplicative dynamics, returns multipliers \(C_t(x)\).

Return type

ISetHandler

abstract property type

Type of price dynamics, either multiplicative or additive

Type

{‘mult’, ‘add’}

abstract property t_max

Time horizon

Type

int

abstract get_lipschitz(t: int)

Get value of a Lipshitz constant for underlying multivalued mapping at time t.

Parameters

t (int) – Time horizon

Returns

Lipschitz constant of \(K_t(x)\)

Return type

np.float64

class robustfpm.pricing.multival_map.PIDynamics

Bases: robustfpm.pricing.multival_map.PriceDynamics

Abstract class for price-independent price dynamics. That is, increment (for additive) or multipliers (for multiplicative) is independent of x.

__call__(x=0, t=1)

A.__call__(x,t) is equivalent to A(x,t)

Parameters
  • x (np.ndarray, size (t, n)) – A set of previous prices, each price — a point from \(\mathbb{R}^{n}\)

  • t (int) – Value of time

Returns

For additive dynamics, returns increment \(K_t(x)\). For multiplicative dynamics, returns multipliers \(C_t(x)\).

Return type

ISetHandler

class robustfpm.pricing.multival_map.ConstantDynamics(support: robustfpm.pricing.set_handler.ISetHandler, type='mult')

Bases: robustfpm.pricing.multival_map.PIDynamics

Time-independent, price-independent price dynamics. It is a price dynamics where increments (for additive) or multipliers (for multiplicative) don’t depend both on previous prices and time.

Parameters
  • support (ISetHandler) – Set of multipliers (or increments, if model is additive)

  • type ({'mult', 'add'}) – Dynamics type: multiplicative or additive

Notes

This class, essentially, functions as IdenticalMap with additional properties type and t_max.

property dim

The dimension of image or np.inf if return value can be of any dimension (e.g., a robustfpm.pricing.set_handler.RealSpaceHandler)

For a multivalued map \(\Gamma: \mathbb{R}^{n} \times \{0, 1, \dots\} \mapsto \mathbb{R}^{n}\), returns \(n\).

Type

int

property type

Type of price dynamics, either multiplicative or additive

Type

{‘mult’, ‘add’}

property t_max

np.inf (since the model is time-independent)

get_lipschitz(t: int)

Get value of a Lipshitz constant for underlying multivalued mapping at time t.

Parameters

t (int) – Time horizon

Returns

Lipschitz constant of \(K_t(x)\)

Return type

np.float64

class robustfpm.pricing.multival_map.MDAFDynamics(support: robustfpm.pricing.set_handler.ISetHandler)

Bases: robustfpm.pricing.multival_map.PriceDynamics

Multiplicative dynamics in additive form (time-independent).

Given as its support a set of price-independent multipliers \(K\), it returns (when called), a set of increments \(\{y = k\cdot x - x:\; k \in K\}\). Here, \(k \cdot x\) denotes element-wise multiplication (Hadamard product) of \(k\) and \(x\).

__call__(x, t=1)

A.__call__(x,t) is equivalent to A(x,t)

Parameters
  • x (np.ndarray, size (t, n)) – A set of previous prices, each price — a point from \(\mathbb{R}^{n}\)

  • t (int) – Value of time

Returns

For additive dynamics, returns increment \(K_t(x)\). For multiplicative dynamics, returns multipliers \(C_t(x)\).

Return type

ISetHandler

property dim

The dimension of image or np.inf if return value can be of any dimension (e.g., a robustfpm.pricing.set_handler.RealSpaceHandler)

For a multivalued map \(\Gamma: \mathbb{R}^{n} \times \{0, 1, \dots\} \mapsto \mathbb{R}^{n}\), returns \(n\).

Type

int

property type

Type of price dynamics, either multiplicative or additive

Type

{‘mult’, ‘add’}

property t_max

Time horizon

Type

int

get_lipschitz(t: int)

Get value of a Lipshitz constant for underlying multivalued mapping at time t.

Parameters

t (int) – Time horizon

Returns

Lipschitz constant of \(K_t(x)\)

Return type

np.float64

class robustfpm.pricing.multival_map.SimplexConstraints(r: numpy.float64)

Bases: robustfpm.pricing.multival_map.IMultivalMap

A simplex mapping that corresponds to the following trading constraints:

  • No short positions;

  • Total value of risky assets at any given time can not exceed given limit r

In mathematical terms, given a vector of discounted prices of risky assets \(x = (x_1, \dots, x_n)\)

\[D_t(x) = \{h = (h_1, \dots, h_n):\; \sum\limits_{i=1}^{n}h_i x_i \leqslant r, \; h_i \geqslant 0, i = 1,\dots, n\}\]
Parameters

r (np.float64) – Limit on total value of risky assets (in discounted prices, i.e., in terms of units of riskless asset)

Notes

We denote these constraints as simplex since \(D_t(x)\) is, in fact, a special type of N-simplex.

__call__(x, t)

A.__call__(x,t) is equivalent to A(x,t)

Parameters
  • x (np.ndarray) – A point or a set of points from \(\mathbb{R}^{n}\)

  • t (int) – Value of time

Returns

Value of a mapping at point(s) x, t

Return type

ISetHandler

property dim

The dimension of image or np.inf if return value can be of any dimension (e.g., a robustfpm.pricing.set_handler.RealSpaceHandler)

For a multivalued map \(\Gamma: \mathbb{R}^{n} \times \{0, 1, \dots\} \mapsto \mathbb{R}^{n}\), returns \(n\).

Type

int