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

python3 跑 alpha075 报错 #6

Open
SunRunAwayAwayAway opened this issue Oct 5, 2022 · 2 comments
Open

python3 跑 alpha075 报错 #6

SunRunAwayAwayAway opened this issue Oct 5, 2022 · 2 comments

Comments

@SunRunAwayAwayAway
Copy link

SunRunAwayAwayAway commented Oct 5, 2022

Traceback (most recent call last):
  File "/Users/xxx/code/futudata/main.py", line 57, in <module>
    ret = l.alpha_075(**kwargs_l)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/ta_cn/alphas/test191.py", line 505, in alpha_075
    return COUNT((CLOSE > OPEN) & (BANCHMARKINDEXCLOSE < BANCHMARKINDEXOPEN), 50) / COUNT(
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/pandas/core/ops/common.py", line 70, in new_method
    return method(self, other)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/pandas/core/arraylike.py", line 124, in __truediv__
    return self._arith_method(other, operator.truediv)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/pandas/core/series.py", line 5639, in _arith_method
    return base.IndexOpsMixin._arith_method(self, other, op)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/pandas/core/base.py", line 1295, in _arith_method
    result = ops.arithmetic_op(lvalues, rvalues, op)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/pandas/core/ops/array_ops.py", line 220, in arithmetic_op
    _bool_arith_check(op, left, right)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/pandas/core/ops/array_ops.py", line 520, in _bool_arith_check
    raise NotImplementedError(
NotImplementedError: operator 'truediv' not implemented for bool dtypes
@SunRunAwayAwayAway
Copy link
Author

数据量(pd._testing._N)变多后就没问题了。。

@wukan1986
Copy link
Owner

t1 = BANCHMARKINDEXCLOSE < BANCHMARKINDEXOPEN
COUNT((CLOSE > OPEN) & t1, 50) / COUNT(t1, 50)

operator 'truediv' not implemented for bool dtypes
除法的参数不能为bool类型

COUNT(bool类型的数组, 50),会将bool类型当成1或0进行求和。按理来说COUNT结果应当是np.ndarray类型的整数,而不是纯bool

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

2 participants