Skip to content
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

Qlib simulator refinement #1244

Merged
merged 23 commits into from
Aug 24, 2022
Merged

Qlib simulator refinement #1244

merged 23 commits into from
Aug 24, 2022

Conversation

lihuoran
Copy link
Contributor

@lihuoran lihuoran commented Aug 3, 2022

Description

  • Qlib Simulator
    • Use dict-like config to create strategies & executors. Totally abandon the hardcoded version.
    • Make Qlib simulator more general.
  • Executor
    • Add is_collecting
    • Call inner_strategy.post_upper_level_exe_step() in NestedExecutor
  • Strategy
    • Add post_upper_level_exe_step() method
    • Add SAOEStrategy, strategies that use SAOEState as states. Make DecomposedStrategy a subclass of SAOEStrategy.
    • Move StateMaintainer inside SAOEStrategy. Now each SAOEStrategy can have its own state maintainer, so it can maintain its own state.
  • Other
    • Remove qlib/rl/from_neutrader. Move all necessary components into simulator_qlib.
    • Re-organize file structure
      • qlib/rl/strategy
      • qlib/rl/order_execution/objects
      • qlib/rl/order_execution/state

Motivation and Context

How Has This Been Tested?

  • Pass the test by running: pytest qlib/tests/test_all_pipeline.py under upper directory of qlib.
  • If you are adding a new feature, test on your own test scripts.

Screenshots of Test Results (if appropriate):

  1. Pipeline test:
  2. Your own tests:

Types of changes

  • Fix bugs
  • Add new feature
  • Update documentation

qlib/rl/order_execution/objects.py Outdated Show resolved Hide resolved
Function used to get the inner level executor.
exchange_config (ExchangeConfig):
Configuration used to create the Exchange instance.
strategy_config (dict):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring format does not conform numpy doc format.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please review the latest version and provide some details?

qlib/rl/order_execution/simulator_qlib.py Outdated Show resolved Hide resolved
qlib/rl/order_execution/simulator_qlib.py Outdated Show resolved Hide resolved
qlib/rl/order_execution/state.py Outdated Show resolved Hide resolved
qlib/rl/strategy/saoe.py Outdated Show resolved Hide resolved
@lihuoran lihuoran marked this pull request as draft August 4, 2022 06:27
@lihuoran lihuoran marked this pull request as ready for review August 5, 2022 06:22
qlib/rl/order_execution/simulator_qlib.py Outdated Show resolved Hide resolved
qlib/rl/order_execution/strategy.py Outdated Show resolved Hide resolved
qlib/backtest/utils.py Outdated Show resolved Hide resolved
qlib/rl/strategy/single_order.py Show resolved Hide resolved
qlib/strategy/base.py Outdated Show resolved Hide resolved
qlib/rl/order_execution/strategy.py Outdated Show resolved Hide resolved
qlib/backtest/decision.py Show resolved Hide resolved
qlib/backtest/utils.py Outdated Show resolved Hide resolved
qlib/backtest/executor.py Outdated Show resolved Hide resolved
qlib/backtest/executor.py Outdated Show resolved Hide resolved
qlib/strategy/base.py Show resolved Hide resolved
qlib/rl/order_execution/strategy.py Outdated Show resolved Hide resolved
qlib/rl/order_execution/strategy.py Outdated Show resolved Hide resolved
qlib/rl/order_execution/strategy.py Outdated Show resolved Hide resolved
qlib/backtest/decision.py Outdated Show resolved Hide resolved
qlib/rl/order_execution/strategy.py Outdated Show resolved Hide resolved
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest moving this file into order_execution/integration.py.

Okay to keep it for now.


class SAOEStateAdapter:
"""
Maintain states of the environment.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some explanations of "what" should be adapted and "how".

def __init__(
self,
order: Order,
trade_range: TradeRange,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think trade_range can be None?

@lihuoran lihuoran merged commit aa481bc into main Aug 24, 2022
@lihuoran lihuoran deleted the huoran/qlib_rl_followup branch August 24, 2022 05:38
@lihuoran lihuoran restored the huoran/qlib_rl_followup branch August 24, 2022 05:49
@lihuoran lihuoran deleted the huoran/qlib_rl_followup branch September 16, 2022 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants