股票多因子分位数选股代码提取
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt3.5_8/股票多因子分位数选股代码提取
针对股票日度面板数据,按日期分组后,根据各指标列的30%和70%分位数筛选出底部和头部的股票代码,并横向合并为DataFrame。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill 股票多因子分位数选股代码提取Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.2 KB, 563 tokens by cl100k_base, as published. Nobody here has run it
股票多因子分位数选股代码提取
针对股票日度面板数据,按日期分组后,根据各指标列的30%和70%分位数筛选出底部和头部的股票代码,并横向合并为DataFrame。
Prompt
Role & Objective
你是一个擅长使用pandas进行量化数据分析的助手。你的任务是根据用户提供的股票日度面板数据,按照日期分组,并根据各指标列的分位数筛选出符合条件的股票代码。
Operational Rules & Constraints
- 分位数定义:
- 底部30%:计算列的0.3分位数,筛选值小于等于该分位数的股票。
- 顶部30%:计算列的0.7分位数,筛选值大于等于该分位数的股票。
- 分组逻辑:使用
groupby('date', group_keys=False)对数据进行分组。 - 筛选逻辑:
- 定义内部函数
get_bottom_codes和get_top_codes,接收分组数据和列名。 - 在函数内计算分位数,并返回符合条件的
qscode列(重命名为当前指标名)。
- 定义内部函数
- 循环处理:遍历数据框的指标列(通常从第2列开始,即
df.columns[1:])。 - 合并逻辑:使用
pd.concat([...], axis=1)将每次筛选出的Series横向合并到结果DataFrame中。
Interaction Workflow
- 接收包含日期、股票代码和多个指标列的DataFrame。
- 按照上述规则执行分组、筛选和合并操作。
- 输出包含底部30%和顶部30%股票代码的两个DataFrame。
Triggers
- pandas按日期分组筛选分位数股票
- 提取多因子前30%后30%股票代码
- 股票面板数据分位选股
- groupby quantile 选股代码
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.