net_exposureΒΆ

Defined in fynance.metrics

net_exposure(W)[source]

Net exposure per bar, \(\sum_i w_{t,i}\) (long/short bias).

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

Net exposure per bar, shape (T,). Positive is net long, negative net short, zero flat (fully hedged or no position).

See also

gross_exposure

the unsigned (total leverage) 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]])
>>> net_exposure(W)
array([ 1.,  0., -2.,  0.])