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

alpha83 报错 #7

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

alpha83 报错 #7

SunRunAwayAwayAway opened this issue Oct 5, 2022 · 6 comments

Comments

@SunRunAwayAwayAway
Copy link

Traceback (most recent call last):
  File "/Users/xxx/code/futudata/main.py", line 46, in <module>
    ret = func(**kwargs)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/ta_cn/alphas/alpha191.py", line 622, in alpha_083
    t1 = COVIANCE(RANK(HIGH), RANK(VOLUME), 5)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/ta_cn/utils_long.py", line 88, in decorated
    s3 = s2.groupby(by=by, group_keys=False).apply(to_pd(dataframe_split(func)), **_kwargs)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/pandas/core/groupby/groupby.py", line 1423, in apply
    result = self._python_apply_general(f, self._selected_obj)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/pandas/core/groupby/groupby.py", line 1464, in _python_apply_general
    values, mutated = self.grouper.apply(f, data, self.axis)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/pandas/core/groupby/ops.py", line 761, in apply
    res = f(group)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/pandas/core/groupby/groupby.py", line 1397, in f
    return func(g, *args, **kwargs)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/ta_cn/utils.py", line 14, in decorated
    return np_to_pd(func(*args, **kwargs),
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/ta_cn/utils_long.py", line 107, in decorated
    return func(*args_input, *args, **kwargs_input, **kwargs)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/ta_cn/statistics.py", line 79, in COVAR
    return numpy_rolling_apply([pd_to_np(real0), pd_to_np(real1)],
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/ta_cn/nb.py", line 289, in numpy_rolling_apply
    return func1(*arrs, out, window, func2, *args)
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/numba/core/dispatcher.py", line 468, in _compile_for_args
    error_rewrite(e, 'typing')
  File "/Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/numba/core/dispatcher.py", line 409, in error_rewrite
    raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Failed in nopython mode pipeline (step: nopython frontend)
No implementation of function Function(<function cov at 0x10408ecb0>) found for signature:
 
 >>> cov(readonly array(float64, 1d, A), readonly array(float64, 1d, A))
 
There are 2 candidate implementations:
  - Of which 2 did not match due to:
  Overload in function 'np_cov': File: numba/np/arraymath.py: Line 2888.
    With argument(s): '(readonly array(float64, 1d, A), readonly array(float64, 1d, A))':
   Rejected as the implementation raised a specific error:
     TypingError: Failed in nopython mode pipeline (step: nopython frontend)
   No implementation of function Function(<function np_cov_impl_inner at 0x148201240>) found for signature:
    
    >>> np_cov_impl_inner(array(float64, 2d, C), Literal[bool](False), none)
    
   There are 2 candidate implementations:
         - Of which 2 did not match due to:
         Overload in function 'register_jitable.<locals>.wrap.<locals>.ov_wrap': File: numba/core/extending.py: Line 159.
           With argument(s): '(array(float64, 2d, C), bool, none)':
          Rejected as the implementation raised a specific error:
            TypingError: Failed in nopython mode pipeline (step: nopython frontend)
          No implementation of function Function(<function dot at 0x103259870>) found for signature:
           
           >>> dot(array(float64, 2d, C), array(float64, 2d, F))
           
          There are 4 candidate implementations:
                - Of which 4 did not match due to:
                Overload in function '_OverloadWrapper._build.<locals>.ol_generated': File: numba/core/overload_glue.py: Line 131.
                  With argument(s): '(array(float64, 2d, C), array(float64, 2d, F))':
                 Rejected as the implementation raised a specific error:
                   LoweringError: Failed in nopython mode pipeline (step: native lowering)
                 scipy 0.16+ is required for linear algebra
                 
                 File "<string>", line 3:
                 <source missing, REPL/exec in use?>
                 
                 During: lowering "$8call_function.3 = call $2load_global.0(tmp0, tmp1, func=$2load_global.0, args=[Var(tmp0, <string>:3), Var(tmp1, <string>:3)], kws=(), vararg=None, target=None)" at <string> (3)
            raised from /Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/numba/core/errors.py:837
          
          During: resolving callee type: Function(<function dot at 0x103259870>)
          During: typing of call at /Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/numba/np/arraymath.py (2739)
          
          
          File "../../.conda/envs/futudata/lib/python3.10/site-packages/numba/np/arraymath.py", line 2739:
          def np_cov_impl_inner(X, bias, ddof):
              <source elided>
              # calculate result - requires blas
              c = np.dot(X, np.conj(X.T))
              ^
   
     raised from /Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/numba/core/typeinfer.py:1086
   
   During: resolving callee type: Function(<function np_cov_impl_inner at 0x148201240>)
   During: typing of call at /Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/numba/np/arraymath.py (2927)
   
   
   File "../../.conda/envs/futudata/lib/python3.10/site-packages/numba/np/arraymath.py", line 2927:
       def np_cov_impl(m, y=None, rowvar=True, bias=False, ddof=None):
           <source elided>
           else:
               return np_cov_impl_inner(X, bias, ddof)
               ^

  raised from /Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/numba/core/typeinfer.py:1086

During: resolving callee type: Function(<function cov at 0x10408ecb0>)
During: typing of call at /Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/ta_cn/nb.py (207)


File "../../.conda/envs/futudata/lib/python3.10/site-packages/ta_cn/nb.py", line 207:
def _cov_nb(arr0, arr1):
    <source elided>
    """协方差矩阵"""
    return _np.cov(arr0, arr1)[0, 1]
    ^

During: resolving callee type: type(CPUDispatcher(<function _cov_nb at 0x13709edd0>))
During: typing of call at /Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/ta_cn/nb.py (239)

During: resolving callee type: type(CPUDispatcher(<function _cov_nb at 0x13709edd0>))
During: typing of call at /Users/xxx/.conda/envs/futudata/lib/python3.10/site-packages/ta_cn/nb.py (239)


File "../../.conda/envs/futudata/lib/python3.10/site-packages/ta_cn/nb.py", line 239:
def _rolling_func_2_nb(arr0, arr1, out, timeperiod, func, *args):
    <source elided>
        for i, (a, b) in enumerate(zip(arr0, arr1)):
            out[i + timeperiod - 1] = func(a, b, *args)
            ^
@wukan1986
Copy link
Owner

wukan1986 commented Oct 6, 2022

会不会是一维和二维混用导致?

我这边没办法复现

@wukan1986
Copy link
Owner

你用的版本可能过老。

参考readme中,开发人员安装 这一节

@SunRunAwayAwayAway
Copy link
Author

SunRunAwayAwayAway commented Oct 6, 2022

更新到最新版(0.5.1)后还是一样。
补充一下调试信息

    print(kwargs['HIGH'])
    print(kwargs['VOLUME'])
    import ta_cn.alphas.alpha191 as l
    ret = l.alpha_083(**kwargs)
date        asset    
2021-01-04  SH.000905    6501.589200
            SH.601919       9.460759
2021-01-05  SH.000905    6539.731500
            SH.601919       9.929989
2021-01-06  SH.000905    6569.199000
                            ...     
2022-09-28  SH.601919      11.390000
2022-09-29  SH.000905    5856.160200
            SH.601919      11.300000
2022-09-30  SH.000905    5804.202200
            SH.601919      11.140000
Name: HIGH, Length: 850, dtype: float64
date        asset    
2021-01-04  SH.000905    1.866212e+10
            SH.601919    3.020644e+08
2021-01-05  SH.000905    1.967263e+10
            SH.601919    2.907695e+08
2021-01-06  SH.000905    1.785211e+10
                             ...     
2022-09-28  SH.601919    9.839720e+07
2022-09-29  SH.000905    9.538580e+09
            SH.601919    8.621553e+07
2022-09-30  SH.000905    8.554517e+09
            SH.601919    6.257926e+07
Name: VOLUME, Length: 850, dtype: float64

@SunRunAwayAwayAway
Copy link
Author

我直接跑 examples/alpha191.py 也是一样。

@wukan1986
Copy link
Owner

https://github.com/wukan1986/ta_cn/blob/main/ta_cn/__init__.py#L5

numba报错时,一般把cache关了就可以了,但你这地方好像并不是这个问题导致。

也有可能是python版本与numba版本问题。

我现在环境中版本为:
Package Version


Bottleneck 1.3.4
numba 0.55.2
numexpr 2.8.1
numpy 1.22.4
pandas 1.4.1

Python 3.8.3

@stormslayerwd
Copy link

大佬解决了么

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

3 participants