请选择 进入手机版 | 继续访问电脑版

AI量化实验室

 找回密码
 免费注册
查看: 91|回复: 1

deap自动挖因子表达式报错

[复制链接]

1

主题

2

帖子

13

积分

量化新人

积分
13
发表于 2024-11-25 19:21:01 | 显示全部楼层 |阅读模式
直接用的星主的quantlab5.7或6.1版本,跑出来经常出现表达式小错误,比如经常出现给rolling_window传入三个参数而报错,想请教一下星主老师和各位大佬有没有解决办法2024-11-25 15:56:58.558 | INFO     | alpha.deap_factor.deap_mgr:__init__:78 - 开始Deap因子挖掘...
2024-11-25 15:56:58.560 | INFO     | alpha.deap_factor.deap_mgr:start:290 - 完成初代种群初始化:30个
0it [00:00, ?it/s]Traceback (most recent call last):
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/dataloader.py", line 77, in calc_expr
    se = calc_expr(df, field)
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr.py", line 21, in calc_expr
    se = eval(expr)
  File "<string>", line 1, in <module>
TypeError: rolling_window() takes 2 positional arguments but 3 were given
ts_argmax(rank(rolling_window(open, volume, 20)), 10)
ts_argmax(rank(rolling_window(open, volume, 20)), 10)错误
None
ts_cov(abs(volume), rank(close), 20)
2it [00:00,  4.26it/s]ta_ma(log(close/5), 10)
ta_ema(rank(high+volume), 60)
4it [00:00,  4.38it/s]Traceback (most recent call last):
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/dataloader.py", line 77, in calc_expr
    se = calc_expr(df, field)
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr.py", line 21, in calc_expr
    se = eval(expr)
  File "<string>", line 1, in <module>
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/ops/common.py", line 76, in new_method
    return method(self, other)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/arraylike.py", line 198, in __rsub__
    return self._arith_method(other, roperator.rsub)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/frame.py", line 7913, in _arith_method
    new_data = self._dispatch_frame_op(other, op, axis=axis)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/frame.py", line 7945, in _dispatch_frame_op
    bm = self._mgr.apply(array_op, right=right)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/internals/managers.py", line 361, in apply
    applied = b.apply(f, **kwargs)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/internals/blocks.py", line 393, in apply
    result = func(self.values, **kwargs)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/ops/array_ops.py", line 283, in arithmetic_op
    res_values = _na_arithmetic_op(left, right, op)  # type: ignore[arg-type]
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/ops/array_ops.py", line 218, in _na_arithmetic_op
    result = func(left, right)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/computation/expressions.py", line 242, in evaluate
    return _evaluate(op, op_str, a, b)  # type: ignore[misc]
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/computation/expressions.py", line 73, in _evaluate_standard
    return op(a, b)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/roperator.py", line 15, in rsub
    return right - left
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'
bbands_down(60)
errors: 0
ts_pct_change(ts_min(inv(ts_delay(open, 10)), 20)+10, 60)
ta_linearreg_slope(ts_argmax(ts_max(bbands_down(60)-numpy_rolling_regress(volume, close, 20), 60), 40), 5)
errors: 0
ta_linearreg_slope(ts_argmax(ts_max(bbands_down(60)-numpy_rolling_regress(volume, close, 20), 60), 40), 5)错误
None
ta_ema(ts_kurt(ts_argmaxmin(low/high*ts_pct_change(close, 5), 120), 10), 20)
8it [00:01,  6.49it/s]Traceback (most recent call last):
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/dataloader.py", line 77, in calc_expr
    se = calc_expr(df, field)
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr.py", line 21, in calc_expr
    se = eval(expr)
  File "<string>", line 1, in <module>
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr_functions/expr_utils.py", line 53, in wrapper
    ret = se_args[0].groupby(level=1, group_keys=False).apply(lambda x: func(x, *other_args, **kwargs))
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/groupby/generic.py", line 230, in apply
    return super().apply(func, *args, **kwargs)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/groupby/groupby.py", line 1824, in apply
    result = self._python_apply_general(f, self._selected_obj)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/groupby/groupby.py", line 1885, in _python_apply_general
    values, mutated = self._grouper.apply_groupwise(f, data, self.axis)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/groupby/ops.py", line 919, in apply_groupwise
    res = f(group)
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr_functions/expr_utils.py", line 53, in <lambda>
    ret = se_args[0].groupby(level=1, group_keys=False).apply(lambda x: func(x, *other_args, **kwargs))
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr_functions/expr_binary_rolling.py", line 14, in ts_corr
    np.isclose(left.rolling(periods, min_periods=1).std(), 0, atol=2e-05)
ValueError: operands could not be broadcast together with shapes (3099,) (5807,2)
slope(40)
errors: 0
rolling_window(ts_delay(volume*high, 20), ts_corr(numpy_rolling_regress(volume, low, 120), ta_linearreg_slope(volume, 10), 120), 5)
rolling_window(ts_delay(volume*high, 20), ts_corr(numpy_rolling_regress(volume, low, 120), ta_linearreg_slope(volume, 10), 120), 5)错误
None


1

主题

2

帖子

13

积分

量化新人

积分
13
 楼主| 发表于 2024-11-25 19:22:09 | 显示全部楼层
2024-11-25 15:56:58.519 | WARNING  | datafeed.dataloader:read_csv:31 - /Users/huwenyao/Desktop/quantlab5 2/data/quotes/000300.SH.csv不存在
2024-11-25 15:56:58.521 | WARNING  | datafeed.dataloader:read_csv:31 - /Users/huwenyao/Desktop/quantlab5 2/data/quotes/000905.SH.csv不存在
2024-11-25 15:56:58.539 | WARNING  | datafeed.dataloader:read_csv:31 - /Users/huwenyao/Desktop/quantlab5 2/data/quotes/N225.csv不存在
2024-11-25 15:56:58.541 | WARNING  | datafeed.dataloader:read_csv:31 - /Users/huwenyao/Desktop/quantlab5 2/data/quotes/HSI.csv不存在
2024-11-25 15:56:58.542 | WARNING  | datafeed.dataloader:read_csv:31 - /Users/huwenyao/Desktop/quantlab5 2/data/quotes/GDAXI.csv不存在
2024-11-25 15:56:58.542 | WARNING  | datafeed.dataloader:read_csv:31 - /Users/huwenyao/Desktop/quantlab5 2/data/quotes/^NDX.csv不存在
2024-11-25 15:56:58.558 | INFO     | alpha.deap_factor.deap_mgr:__init__:78 - 开始Deap因子挖掘...
2024-11-25 15:56:58.560 | INFO     | alpha.deap_factor.deap_mgr:start:290 - 完成初代种群初始化:30个
0it [00:00, ?it/s]Traceback (most recent call last):
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/dataloader.py", line 77, in calc_expr
    se = calc_expr(df, field)
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr.py", line 21, in calc_expr
    se = eval(expr)
  File "<string>", line 1, in <module>
TypeError: rolling_window() takes 2 positional arguments but 3 were given
ts_argmax(rank(rolling_window(open, volume, 20)), 10)
ts_argmax(rank(rolling_window(open, volume, 20)), 10)错误
None
ts_cov(abs(volume), rank(close), 20)
2it [00:00,  4.26it/s]ta_ma(log(close/5), 10)
ta_ema(rank(high+volume), 60)
4it [00:00,  4.38it/s]Traceback (most recent call last):
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/dataloader.py", line 77, in calc_expr
    se = calc_expr(df, field)
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr.py", line 21, in calc_expr
    se = eval(expr)
  File "<string>", line 1, in <module>
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/ops/common.py", line 76, in new_method
    return method(self, other)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/arraylike.py", line 198, in __rsub__
    return self._arith_method(other, roperator.rsub)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/frame.py", line 7913, in _arith_method
    new_data = self._dispatch_frame_op(other, op, axis=axis)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/frame.py", line 7945, in _dispatch_frame_op
    bm = self._mgr.apply(array_op, right=right)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/internals/managers.py", line 361, in apply
    applied = b.apply(f, **kwargs)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/internals/blocks.py", line 393, in apply
    result = func(self.values, **kwargs)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/ops/array_ops.py", line 283, in arithmetic_op
    res_values = _na_arithmetic_op(left, right, op)  # type: ignore[arg-type]
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/ops/array_ops.py", line 218, in _na_arithmetic_op
    result = func(left, right)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/computation/expressions.py", line 242, in evaluate
    return _evaluate(op, op_str, a, b)  # type: ignore[misc]
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/computation/expressions.py", line 73, in _evaluate_standard
    return op(a, b)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/roperator.py", line 15, in rsub
    return right - left
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'
bbands_down(60)
errors: 0
ts_pct_change(ts_min(inv(ts_delay(open, 10)), 20)+10, 60)
ta_linearreg_slope(ts_argmax(ts_max(bbands_down(60)-numpy_rolling_regress(volume, close, 20), 60), 40), 5)
errors: 0
ta_linearreg_slope(ts_argmax(ts_max(bbands_down(60)-numpy_rolling_regress(volume, close, 20), 60), 40), 5)错误
None
ta_ema(ts_kurt(ts_argmaxmin(low/high*ts_pct_change(close, 5), 120), 10), 20)
8it [00:01,  6.49it/s]Traceback (most recent call last):
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/dataloader.py", line 77, in calc_expr
    se = calc_expr(df, field)
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr.py", line 21, in calc_expr
    se = eval(expr)
  File "<string>", line 1, in <module>
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr_functions/expr_utils.py", line 53, in wrapper
    ret = se_args[0].groupby(level=1, group_keys=False).apply(lambda x: func(x, *other_args, **kwargs))
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/groupby/generic.py", line 230, in apply
    return super().apply(func, *args, **kwargs)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/groupby/groupby.py", line 1824, in apply
    result = self._python_apply_general(f, self._selected_obj)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/groupby/groupby.py", line 1885, in _python_apply_general
    values, mutated = self._grouper.apply_groupwise(f, data, self.axis)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/groupby/ops.py", line 919, in apply_groupwise
    res = f(group)
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr_functions/expr_utils.py", line 53, in <lambda>
    ret = se_args[0].groupby(level=1, group_keys=False).apply(lambda x: func(x, *other_args, **kwargs))
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr_functions/expr_binary_rolling.py", line 14, in ts_corr
    np.isclose(left.rolling(periods, min_periods=1).std(), 0, atol=2e-05)
ValueError: operands could not be broadcast together with shapes (3099,) (5807,2)
slope(40)
errors: 0
rolling_window(ts_delay(volume*high, 20), ts_corr(numpy_rolling_regress(volume, low, 120), ta_linearreg_slope(volume, 10), 120), 5)
rolling_window(ts_delay(volume*high, 20), ts_corr(numpy_rolling_regress(volume, low, 120), ta_linearreg_slope(volume, 10), 120), 5)错误
None
sqrt(ts_cov(ts_delay(volume, 40), ts_rank(close, 10), 20))
ts_delta(ts_argmin(ts_argmin(ts_maxmin(close, 60), 60), 10), 10)
13it [00:02,  6.91it/s]Traceback (most recent call last):
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/dataloader.py", line 77, in calc_expr
    se = calc_expr(df, field)
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr.py", line 21, in calc_expr
    se = eval(expr)
  File "<string>", line 1, in <module>
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/numpy/lib/_stride_tricks_impl.py", line 109, in as_strided
    interface['strides'] = tuple(strides)
TypeError: 'int' object is not iterable
ts_cov(ta_ma(ts_min(low, 60), 10), ts_argmax(high, 10)-close*120, 10)
abs(ts_median(strided(ta_kama(ta_dema(high, 10), 120), bbands_up(5), 10), 10))
errors: 0
abs(ts_median(strided(ta_kama(ta_dema(high, 10), 120), bbands_up(5), 10), 10))错误
None
ta_linearreg_angle(ta_ma(ta_dema(ts_delay(ts_delay(close, 20), 10), 40), 120), 10)
Traceback (most recent call last):
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/dataloader.py", line 77, in calc_expr
    se = calc_expr(df, field)
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr.py", line 21, in calc_expr
    se = eval(expr)
  File "<string>", line 1, in <module>
  File "/Users/huwenyao/Desktop/quantlab5 2/策略集/../datafeed/expr_functions/expr_utils.py", line 53, in wrapper
    ret = se_args[0].groupby(level=1, group_keys=False).apply(lambda x: func(x, *other_args, **kwargs))
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/groupby/generic.py", line 230, in apply
    return super().apply(func, *args, **kwargs)
  File "/Users/huwenyao/opt/anaconda3/envs/myenv/lib/python3.9/site-packages/pandas/core/groupby/groupby.py", line 1824, in apply
    result = self._python_apply_general(f, self._selected_obj)
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

AI量化实验室 ( 京ICP备16049031号-2 )

GMT+8, 2024-12-4 16:15 , Processed in 0.061322 second(s), 18 queries .

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表