问答交流

【代码报错】高频数据自建因子策略SQL输出为空数据

由bqkbdhd8创建,最终由small_q 被浏览 9 用户

基于高频数据自建因子构建策略 sql 输出为空数据

import dai
sql = """
SELECT
    wq_test_1016_.factor as factor,
    ln(cn_stock_prefactors.total_market_cap) as marcket_cap,
    cn_stock_prefactors.sw2021_level1 as sw2021_level1,
    m_avg(c_neutralize(factor,sw2021_level1,marcket_cap),10) as score,
    date,
    instrument
FROM cn_stock_prefactors
    JOIN wq_test_1016_ USING(date, instrument)
WHERE cn_stock_prefactors.sw2021_level1 is not null    
    AND cn_stock_prefactors.total_market_cap is not null 
QUALIFY
    is_risk_warning = 0
    
    AND net_profit_to_parent_deducted_ttm>0
    AND c_pct_rank(total_market_cap) < 0.1
    
    AND close/adjust_factor>1.5
    AND list_sector IN (1, 2)
    AND list_days > 365
    AND suspended = 0
    AND price_limit_status  != 1
    AND COLUMNS(*) IS NOT NULL
ORDER BY date, instrument
"""
df_all = dai.query(sql,filters={"date": ["2024-01-01", "2024-10-19"]}).df()
df_all

#输出是空

\

标签

数据分析
评论
  • wq_test_1016_ 如果这张表是高频数据,那date是带时分秒的,而cn_stock_prefactors的date不带时分秒,所以join出来为空,请把数据对齐之后再join
{link}