Marigold / universal-portfolios

Collection of algorithms for online portfolio selection
Other
779 stars 214 forks source link

Assertion error # update logarithms, fees, etc. AssertionError:` #90

Closed pinpss closed 1 year ago

pinpss commented 1 year ago

I am trying to run the example. But I got the following assertion error.

`/usr/local/lib/python3.8/dist-packages/universal/result.py in init(self, X, B) 44 self._X = X 45 ---> 46 assert self.X.max().max() < np.inf 47 48 # update logarithms, fees, etc.

AssertionError:`

I don't know if I should (and how to) define fees before running algo.run. By the default, I think they should be 0, right?

pinpss commented 1 year ago

Even while testing test_turnover_and_fees from test_result.

def test_turnover_and_fees(S):
    algo = algos.BAH()
    result = algo.run(S)
    result.fee = 0.01
    result.plot(**plot_kwargs, title='BAH strategy')

    assert abs(result.turnover) < 1e-10
    assert abs(result.fees.sum().sum()) < 1e-10

I got the following assertion error.

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
[<ipython-input-59-29ac9b54e3ad>](https://klryoida6m-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20221220-060108-RC02_496713401#) in <module>
----> 1 test_turnover_and_fees(S)

2 frames
[/usr/local/lib/python3.8/dist-packages/universal/result.py](https://klryoida6m-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20221220-060108-RC02_496713401#) in __init__(self, X, B)
     44         self._X = X
     45 
---> 46         assert self.X.max().max() < np.inf
     47 
     48         # update logarithms, fees, etc.

AssertionError:
Marigold commented 1 year ago

Huh, not sure what's going on. The unit test works for me. You'd define fees after you create result object (dumb, right?). For instance

algo = algos.BAH()
result = algo.run(S)
result.fee = 0.01
# fees will be deducted
result.summary()