polakowo / vectorbt

Find your trading edge, using the fastest engine for backtesting, algorithmic trading, and research.
https://vectorbt.dev
Other
4.21k stars 609 forks source link

Type must be <class 'vectorbt.utils.decorators.CacheCondition'>, not <class 'collections.CacheCondition'> #287

Open n1cola2222 opened 2 years ago

n1cola2222 commented 2 years ago

I'm trying to run an example from the doc

price = pd.Series([1, 2, 3, 4, 5], dtype=float)
vbt.MA.run(price, [2, 3]).ma

but is met with this assertion error

AssertionError: Type must be <class 'vectorbt.utils.decorators.CacheCondition'>, not <class 'collections.CacheCondition'>

polakowo commented 2 years ago

Hi @n1cola2222, please print the entire error with stack trace.

utekakca commented 2 years ago

Here you go:

vbt.MA.run(price, [2, 3]).ma Traceback (most recent call last):

Input In [47] in <cell line: 1> vbt.MA.run(price, [2, 3]).ma

File C:\ProgramData\Anaconda3\lib\site-packages\vectorbt\indicators\factory.py:2395 in outputprop return self.wrapper.wrap(getattr(self, '' + _output_name))

File C:\ProgramData\Anaconda3\lib\site-packages\vectorbt\base\array_wrapper.py:532 in wrap _self = self.resolve(group_by=group_by)

File C:\ProgramData\Anaconda3\lib\site-packages\vectorbt\utils\decorators.py:418 in wrapper if not should_cache(wrapper.name, instance, func=_func, **wrapper.flags):

File C:\ProgramData\Anaconda3\lib\site-packages\vectorbt\utils\decorators.py:279 in should_cache white_rank = min(white_rank, _get_condition_rank(cond))

File C:\ProgramData\Anaconda3\lib\site-packages\vectorbt\utils\decorators.py:197 in _get_condition_rank checks.assert_instance_of(cond, CacheCondition)

File C:\ProgramData\Anaconda3\lib\site-packages\vectorbt\utils\checks.py:311 in assert_instance_of raise AssertionError(f"Type must be {types}, not {type(arg)}")

AssertionError: Type must be <class 'vectorbt.utils.decorators.CacheCondition'>, not <class 'collections.CacheCondition'>