-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUGFIX] allow sell in limit-up case and allow buy in limit-down case in topk strategy #1407
Conversation
Believe it's just some arbitrary number. The excess return is expected to change when trading logic changes.
@@ -216,7 +217,7 @@ def filter_stock(li): | |||
buy = today[: len(sell) + self.topk - len(last)] | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.py
under upper directory ofqlib
.Screenshots of Test Results (if appropriate):
Types of changes