-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Qlib RL framework (stage 1) - single-asset order execution (#1076)
* rl init * aux info * Reward config * update * simple * update saoe init * update simulator and seed * minor * minor * update sim * checkpoint * obs * Update interpreter * init qlib simulator * checkpoint * Refine codebase * checkpoint * checkpoint * Add one test * More tests * Simulator checkpoint * checkpoint * First-step tested * Checkpoint * Update data_queue API * Checkpoint * Update test * Move files * Checkpoint * Single-quote -> double-quote * Fix finite env tests * Tested with mypy * pep-574 * No call for env done * Update finite env docs * Fix csv writer * Refine tester * Update logger * Add another logger test * Checkpoint * Add network sanity test * steps per episode is not correct * Cleanup code, ready for PR * Reformat with black * Fix pylint for py37 * Fix lint * Fix lint * Fix flake * update mypy command * mypy * Update exclude pattern * Use pyproject.toml * test * . * . * Refactor pipeline * . * defaults run bash * . * Revert and skip follow_imports * Fix toml issue * fix mypy * . * . * . * Fix install * Minor fix * Fix test * Fix test * Remove requirements * Revert * fix tests * Fix lint * . * . * . * . * . * update install from source command * . * Fix data download * . * . * . * . * . * . * Fix py37 * Ignore tests on non-linux * resolve comments * fix tests * resolve comments * some typo * style updates * More comments * fix dummy * add warning * Align precision in some system * Added some impl notes Co-authored-by: Young <afe.young@gmail.com>
- Loading branch information
Showing
36 changed files
with
3,680 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[mypy] | ||
exclude = (?x)( | ||
^qlib/backtest | ||
| ^qlib/contrib | ||
| ^qlib/data | ||
| ^qlib/model | ||
| ^qlib/strategy | ||
| ^qlib/tests | ||
| ^qlib/utils | ||
| ^qlib/workflow | ||
| ^qlib/config\.py$ | ||
| ^qlib/log\.py$ | ||
| ^qlib/__init__\.py$ | ||
) | ||
ignore_missing_imports = true | ||
disallow_incomplete_defs = true | ||
follow_imports = skip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ | |
|
||
# Epsilon for avoiding division by zero. | ||
EPS = 1e-12 | ||
|
||
# Infinity in integer | ||
INF = 10**18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Generic, TYPE_CHECKING, TypeVar | ||
|
||
from qlib.typehint import final | ||
|
||
from .simulator import StateType | ||
|
||
if TYPE_CHECKING: | ||
from .utils.env_wrapper import EnvWrapper | ||
|
||
|
||
__all__ = ["AuxiliaryInfoCollector"] | ||
|
||
AuxInfoType = TypeVar("AuxInfoType") | ||
|
||
|
||
class AuxiliaryInfoCollector(Generic[StateType, AuxInfoType]): | ||
"""Override this class to collect customized auxiliary information from environment.""" | ||
|
||
env: EnvWrapper | None = None | ||
|
||
@final | ||
def __call__(self, simulator_state: StateType) -> AuxInfoType: | ||
return self.collect(simulator_state) | ||
|
||
def collect(self, simulator_state: StateType) -> AuxInfoType: | ||
"""Override this for customized auxiliary info. | ||
Usually useful in Multi-agent RL. | ||
Parameters | ||
---------- | ||
simulator_state | ||
Retrieved with ``simulator.get_state()``. | ||
Returns | ||
------- | ||
Auxiliary information. | ||
""" | ||
raise NotImplementedError("collect is not implemented!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
"""Common utilities to handle ad-hoc-styled data. | ||
Most of these snippets comes from research project (paper code). | ||
Please take caution when using them in production. | ||
""" |
Oops, something went wrong.