问答交流

【代码报错】 PermissionException: Permission Error: 请在查询表 cn_stock_bar1d 时使用 filters 参数指定分区范围

由bq04xu57创建,最终由small_q 被浏览 13 用户

复制的可视化线性策略运行不了,错误如下

  • [2024-12-12 17:17:48] INFO: expr mode
  • [2024-12-12 17:17:48] INFO: extract data ..
  • [2024-12-12 17:17:49] ERROR: dai query failed: CREATE TABLE _t_486a73b900d143f0b3f8bf72501624d2 AS SELECT
  • date,
  • instrument
  • FROM
  • cn_stock_bar1d
  • JOIN cn_stock_basic_info USING (instrument)
  • JOIN cn_stock_factors_base USING(date, instrument)
  • JOIN cn_stock_status USING(date, instrument)
  • WHERE
  • (cn_stock_bar1d.instrument LIKE '%.SH' OR cn_stock_bar1d.instrument LIKE '%.SZ')
  • AND cn_stock_basic_info.list_sector IN (1, 2, 3)
  • AND (cn_stock_factors_base.is_zz500 == 1 OR cn_stock_factors_base.is_szzs == 1 OR cn_stock_factors_base.is_cybz == 1 OR cn_stock_factors_base.is_szcz == 1 OR cn_stock_factors_base.is_sh50 == 1 OR cn_stock_factors_base.is_kc50 == 1 OR cn_stock_factors_base.is_hs300 == 1 OR cn_stock_factors_base.is_zz1000 == 1 OR cn_stock_factors_base.is_zz100 == 1 OR cn_stock_factors_base.is_sz100 == 1)
  • AND cn_stock_status.st_status IN (0,)
  • AND cn_stock_factors_base.suspended = 0
  • QUALIFY
  • 1 = 1
  • ORDER BY date, instrument;
  • SELECT
  • float_market_cap AS score,
  • date,
  • instrument
  • FROM cn_stock_prefactors_community
  • JOIN _t_486a73b900d143f0b3f8bf72501624d2 USING(date, instrument)
  • QUALIFY
  • c_pct_rank(total_market_cap) > 0.20
  • AND c_pct_rank(pe_ttm) < 0.40
  • AND pe_ttm > 0
  • AND COLUMNS(*) IS NOT NULL
  • ORDER BY date, instrument
  • 您可以去社区论坛问答交流板块反馈咨询 去发帖>> --------------------------------------------------------------------------- PermissionException Traceback (most recent call last) Cell In[5], line 81 68 m1 = M.cn_stock_basic_selector.v8( 69 exchanges=["""上交所""", """深交所"""], 70 list_sectors=["""主板""", """创业板""", """科创板"""], (...) 77 m_name="""m1""" 78 ) 80 # @module(position="-315,-731", comment="""因子特征""", comment_collapsed=False) ---> 81 m2 = M.input_features_dai.v30( 82 input_1=m1.data, 83 mode="""表达式""", 84 expr="""-- DAI SQL 算子/函数: https://bigquant.com/wiki/doc/dai-PLSbc1SbZX#h-%E5%87%BD%E6%95%B0 85 -- 数据&字段: 数据文档 <https://bigquant.com/data/home ](https://bigquant.com/data/home)86 -- 数据使用: 表名.字段名, 对于没有指定表名的列,会从 expr_tables 推断 87 88 float_market_cap AS score 89 -- 使用 float 类型。默认是高精度 decimal.Decimal, 不能和float直接相乘""", 90 expr_filters="""-- DAI SQL 算子/函数: https://bigquant.com/wiki/doc/dai-PLSbc1SbZX#h-%E5%87%BD%E6%95%B0 91 -- 数据&字段: 数据文档 <https://bigquant.com/data/home ](https://bigquant.com/data/home)92 93 c_pct_rank(total_market_cap) > 0.20 94 c_pct_rank(pe_ttm) < 0.40 95 pe_ttm > 0 96 97 """, 98 expr_tables="""cn_stock_prefactors_community""", 99 extra_fields="""date, instrument""", 100 order_by="""date, instrument""", 101 expr_drop_na=True, 102 sql="""-- 使用DAI SQL获取数据,构建因子等,如下是一个例子作为参考 103 full_db_scan=True 104 -- DAI SQL 语法: https://bigquant.com/wiki/doc/dai-PLSbc1SbZX#h-sql%E5%85%A5%E9%97%A8%E6%95%99%E7%A8%8B 105 106 SELECT 107 108 -- 在这里输入因子表达式 109 -- DAI SQL 算子/函数: https://bigquant.com/wiki/doc/dai-PLSbc1SbZX#h-%E5%87%BD%E6%95%B0 110 -- 数据&字段: 数据文档 <https://bigquant.com/data/home ](https://bigquant.com/data/home)111 112 c_rank(volume) AS rank_volume, 113 close / m_lag(close, 1) as return_0, 114 115 -- 日期和股票代码 116 date, instrument 117 FROM 118 -- 预计算因子 cn_stock_factors <https://bigquant.com/data/datasources/cn_stock_factors ](https://bigquant.com/data/datasources/cn_stock_factors)119 cn_stock_factors 120 WHERE 121 -- WHERE 过滤,在窗口等计算算子之前执行 122 -- 剔除ST股票 123 st_status = 0 124 QUALIFY 125 -- QUALIFY 过滤,在窗口等计算算子之后执行,比如 m_lag(close, 3) AS close_3,对于 close_3 的过滤需要放到这里 126 -- 去掉有空值的行 127 COLUMNS(*) IS NOT NULL 128 -- 按日期和股票代码排序,从小到大 129 ORDER BY date, instrument 130 """, 131 extract_data=True, 132 m_cached=False, 133 m_name="""m2""" 134 ) 136 # @module(position="-247,-609", comment="""持股数量、打分到仓位""", comment_collapsed=False) 137 m3 = M.score_to_position.v4( 138 input_1=m2.data, 139 score_field="""score ASC""", (...) 152 m_name="""m3""" 153 ) File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/modules.py:28, in call(self, **kwargs) File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/moduleinvoker.py:203, in module_invoke(name, version, kwargs) File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/moduleinvoker.py:169, in _module_invoke(name, version, kwargs) File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/moduleinvoker.py:41, in _module_run(module, kwargs) File dist/build/input_features_dai/v30/init.py:301, in v30.run() File dist/build/input_features_dai/v30/init.py:225, in v30._create_ds_from_sql() File dist/build/input_features_dai/v30/init.py:222, in v30._create_ds_from_sql() File /var/app/enabled/dai/_telemetry.py:191, in wrapper(*args, **kwargs) File /var/app/enabled/dai/_functions.py:395, in query(sql, udf_list, full_db_scan, filters, bind_relations) PermissionException: Permission Error: 请在查询表 cn_stock_bar1d 时使用 filters 参数指定分区范围(一般为 date 或 instrument ):dai.query(sql, filters={"date": ["2020-01-01", "2020-02-01"]})。若确需全表扫描,请设置 full_db_scan 参数:dai.query(sql, full_db_scan=True)

\

评论
  • 如提示所说:请在查询表 cn_stock_bar1d 时使用 filters 参数指定分区范围(一般为 date 或 instrument ):dai.query(sql, filters={"date": ["2020-01-01", "2020-02-01"]})。若确需全表扫描,请设置 full_db_scan 参数:dai.query(sql, full_db_scan=True)
  • 对于这样的行情数据的数据提取,需要指定提取的时间范围,检查数据抽取模块的开始时间和结束时间是否填写
{link}