Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

returns_stats throw TypeError #74

Closed
wukan1986 opened this issue Dec 26, 2020 · 0 comments
Closed

returns_stats throw TypeError #74

wukan1986 opened this issue Dec 26, 2020 · 0 comments

Comments

@wukan1986
Copy link

Hi,

import numpy as np
import pandas as pd
import vectorbt as vbt

close = pd.Series([1, 2, 3, 4, 5])
val_price = close
size = [1, np.nan, np.nan, np.nan, -1]
portfolio = vbt.Portfolio.from_orders(close, size,
                                      val_price=val_price,
                                      close_first=True,
                                      freq='1D')

#
print(portfolio.stats())
#
print(portfolio.returns_stats())
D:\Users\Kan\miniconda3\envs\py38_vectorbt\lib\site-packages\vectorbt\utils\datetime.py:23: RuntimeWarning: invalid value encountered in multiply
  return obj * freq_delta(freq)
Traceback (most recent call last):
  File "D:/test_vectorbt/demo_from_orders_3.py", line 16, in <module>
    print(portfolio.returns_stats())
  File "D:\Users\Kan\miniconda3\envs\py38_vectorbt\lib\site-packages\vectorbt\portfolio\base.py", line 1980, in returns_stats
    stats_obj = returns.vbt.returns.stats(**kwargs)
  File "D:\Users\Kan\miniconda3\envs\py38_vectorbt\lib\site-packages\vectorbt\returns\accessors.py", line 343, in stats
    'Duration': self.wrapper.shape[0] * self.wrapper.freq,
TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'

the portfolio.stats() can get Duration 5 days 00:00:00,
but the portfolio.returns_stats() can not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant