[BUGFIX] allow sell in limit-up case and allow buy in limit-down case in topk strategy#1407
[BUGFIX] allow sell in limit-up case and allow buy in limit-down case in topk strategy#1407you-n-g merged 7 commits intomicrosoft:mainfrom
Conversation
Believe it's just some arbitrary number. The excess return is expected to change when trading logic changes.
| for code in current_stock_list: | ||
| if not self.trade_exchange.is_stock_tradable( | ||
| stock_id=code, start_time=trade_start_time, end_time=trade_end_time | ||
| stock_id=code, start_time=trade_start_time, end_time=trade_end_time, direction=OrderDir.SELL |
There was a problem hiding this comment.
Thanks for your contribution. @qianyun210603
Not selling limit-up stocks and buying limit-down could be considered as a part of the strategy in A-stock.
Although current implementation seems a little weird, but it is a reasonable results.
Your version is better. But if we merge it currently, all the previous results should be updated to make the code and results consistent (it will take a long time to update all the results).
Would it be better if we add it as a feature (a parameter in the init method) and keep the previous version as the default behavior?
(Besides, TODOs to switch to your version should be added in the docs/docstrings)
There was a problem hiding this comment.
Added a flag in TopkDropoutStrategy defaults to True to keep previous behaviour as suggested.
|
Thanks! It looks great now! |
… in topk strategy (microsoft#1407) * 1) check limit_up/down should consider direction; 2) fix some typo, typehint etc * fix error * Update test_all_pipeline.py Believe it's just some arbitrary number. The excess return is expected to change when trading logic changes. * add flag forbid_all_trade_at_limit to keep previous behivour for backward compatibility
… in topk strategy (microsoft#1407) * 1) check limit_up/down should consider direction; 2) fix some typo, typehint etc * fix error * Update test_all_pipeline.py Believe it's just some arbitrary number. The excess return is expected to change when trading logic changes. * add flag forbid_all_trade_at_limit to keep previous behivour for backward compatibility
… in topk strategy (microsoft#1407) * 1) check limit_up/down should consider direction; 2) fix some typo, typehint etc * fix error * Update test_all_pipeline.py Believe it's just some arbitrary number. The excess return is expected to change when trading logic changes. * add flag forbid_all_trade_at_limit to keep previous behivour for backward compatibility
Description
Allow sell in limit-up case and allow buy in limit-down case
Also fixed some typo/typehints.
Motivation and Context
To be consistent with real world, in which we can buy at limit-down (跌停) and sell at limit up (涨停).
How Has This Been Tested?
pytest qlib/tests/test_all_pipeline.pyunder upper directory ofqlib.Screenshots of Test Results (if appropriate):
Types of changes