-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Refine RL todos #1332
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
Refine RL todos #1332
Changes from 2 commits
c22e19b
9d32b9d
ad4a1da
ea5003d
30fc8ee
493538d
471c674
73851c8
54f9a6c
1f695d6
4039274
8c81135
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,19 +3,15 @@ | |
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any, Generic, Optional, TYPE_CHECKING, TypeVar | ||
| from typing import Any, Generic, TypeVar | ||
|
|
||
| import gym | ||
| import numpy as np | ||
| from gym import spaces | ||
|
|
||
| from qlib.typehint import final | ||
| from .simulator import ActType, StateType | ||
|
|
||
| if TYPE_CHECKING: | ||
| from .utils.env_wrapper import BaseEnvWrapper | ||
|
|
||
| import gym | ||
| from gym import spaces | ||
|
|
||
| ObsType = TypeVar("ObsType") | ||
| PolicyActType = TypeVar("PolicyActType") | ||
|
|
||
|
|
@@ -35,12 +31,19 @@ class Interpreter: | |
| states by calling ``self.env.register_state()``, but it's not planned for first iteration. | ||
| """ | ||
|
|
||
| def __init__(self) -> None: | ||
|
||
| self.cur_step = 0 | ||
|
|
||
| def reset(self) -> None: | ||
| self.cur_step = 0 | ||
|
|
||
| def step(self) -> None: | ||
| self.cur_step += 1 | ||
|
|
||
|
|
||
| class StateInterpreter(Generic[StateType, ObsType], Interpreter): | ||
| """State Interpreter that interpret execution result of qlib executor into rl env state""" | ||
|
|
||
| env: Optional[BaseEnvWrapper] = None | ||
|
|
||
| @property | ||
| def observation_space(self) -> gym.Space: | ||
| raise NotImplementedError() | ||
|
|
@@ -73,8 +76,6 @@ def interpret(self, simulator_state: StateType) -> ObsType: | |
| class ActionInterpreter(Generic[StateType, PolicyActType, ActType], Interpreter): | ||
| """Action Interpreter that interpret rl agent action into qlib orders""" | ||
|
|
||
| env: Optional[BaseEnvWrapper] = None | ||
|
|
||
| @property | ||
| def action_space(self) -> gym.Space: | ||
| raise NotImplementedError() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.