ExpressionDFilter result not as expected
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 48.7k
- Forks
- 7.7k
- PR merge metrics
- No merged PRs in 30d
Description
env
python 3.12.9
pylib 0.9.7
data
https://github.com/chenditc/investment_data/releases/tag/2026-01-11
随机验证了一下,$close / $factor = 未复权价格,数据应该没问题
problem
问题:按$close>2000,选出来的票,实际后复权价格不符合$close>2000
from qlib.data import D
from qlib.data.filter import ExpressionDFilter
expressionDFilter = ExpressionDFilter(rule_expression='$close > 2000')
instruments_cfg = D.instruments(market='csi300', filter_pipe=[expressionDFilter])
instruments = D.list_instruments(instruments=instruments_cfg,
start_time='2025-01-01',
end_time='2026-01-09',
as_list=True)
print(instruments)
output
['SH600837', 'SH601989', 'SZ002049']
instruments = ['SZ002049']
fields = ['$close', '$volume', 'Ref($close, 1)', 'Mean($close, 3)', '$high-$low', '$factor']
df = D.features(instruments,
fields,
start_time='2025-01-01',
end_time='2026-01-09',
freq='day')
print(df)
output
$close $volume Ref($close, 1) Mean($close, 3) $high-$low $factor
instrument datetime
SZ002049 2025-01-02 54.424286 272530.312500 57.611427 57.426189 3.606804 0.894989
2025-01-03 53.189999 173090.734375 54.424286 55.075237 1.682606 0.895003
2025-01-06 52.715714 117793.007812 53.189999 53.443333 1.217205 0.895004
2025-01-07 54.022858 137582.578125 52.715714 53.309525 1.440968 0.895011
2025-01-08 53.162857 181623.218750 54.022858 53.300476 2.452293 0.894998
... ... ... ... ... ... ...
2025-12-23 68.699997 163727.125000 69.284286 68.697617 1.185257 0.897922
2025-12-24 69.967140 225979.796875 68.699997 69.317139 1.508530 0.897936
2025-12-25 71.088570 274110.406250 69.967140 69.918571 1.894615 0.897923
2025-12-26 72.031425 330256.906250 71.088570 71.029045 2.496223 0.897924
2025-12-29 70.765717 262366.625000 72.031425 71.295235 1.948502 0.897928
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied ExpressionDFilter example, then trace the ExpressionDFilter and D.instruments entry points to determine how the $close threshold is evaluated. Compare that result with the D.features output and the stated adjustment expectations; the issue is done when the discrepancy is fixed or its intended behavior is covered by a clear regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100