15 lines
648 B
Python
15 lines
648 B
Python
from fxhnt.application.book_allocator import current_sleeve_weights
|
|
|
|
|
|
def test_current_sleeve_weights_inverse_vol():
|
|
# two edges, edge B higher vol than A -> A gets more inverse-vol weight; weights sum ~1.
|
|
# Cap set above the natural inverse-vol allocation so it does not bind (else both pin to the cap).
|
|
series = {"A": {1: 0.001, 2: -0.001, 3: 0.001}, "B": {1: 0.01, 2: -0.01, 3: 0.01}}
|
|
w = current_sleeve_weights(series, vol_lookback=3, max_sleeve_weight=0.95)
|
|
assert abs(sum(w.values()) - 1.0) < 1e-6
|
|
assert w["A"] > w["B"]
|
|
|
|
|
|
def test_empty_series_is_empty():
|
|
assert current_sleeve_weights({}, vol_lookback=60) == {}
|