gross_exposureΒΆ

Defined in fynance.metrics

gross_exposure(W)[source]

Gross exposure per bar, \(\sum_i |w_{t,i}|\) (total book leverage).

Parameters:
Warray_like

Weights held at each step, shape (T,) or (T, N). A 1-D input is reshaped to (T, 1).

Returns:
numpy.ndarray

Gross exposure per bar, shape (T,).

See also

net_exposure

the signed (long/short bias) counterpart.

Examples

>>> import numpy as np
>>> W = np.array([[1.0, 0.0], [0.5, -0.5], [-1.0, -1.0], [0.0, 0.0]])
>>> gross_exposure(W)
array([1., 1., 2., 0.])