Skip to content

Commit

Permalink
Fix a bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
LITZY0619 committed Jul 7, 2023
1 parent e6e6baf commit e4e0d3f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
17 changes: 17 additions & 0 deletions qlib/backtest/decision.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,23 @@ def date(self) -> pd.Timestamp:
"""Date of the order."""
return pd.Timestamp(self.start_time.replace(hour=0, minute=0, second=0))

@dataclass
class Task:
"""
stock_id : str
cash : float
start_time : pd.Timestamp
closed start time for order trading
end_time : pd.Timestamp
closed end time for order trading
factor : float
presents the weight factor assigned in Exchange()
"""

stock_id: str
cash: float
start_time: pd.Timestamp
end_time: pd.Timestamp

class OrderHelper:
"""
Expand Down
2 changes: 0 additions & 2 deletions qlib/rl/algorithm_trading/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@

from __future__ import annotations

import math
from typing import Any, List, Optional, cast

import numpy as np
import pandas as pd
from gym import spaces

from qlib.constant import EPS
from qlib.rl.data.base import ProcessedDataProvider
from qlib.rl.interpreter import ActionInterpreter, StateInterpreter
from qlib.rl.algorithm_trading.state import SAATState
Expand Down
10 changes: 5 additions & 5 deletions qlib/rl/contrib/train_at_onpolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@

import numpy as np
import pandas as pd
import qlib
import torch
import yaml
import torch
from tianshou.policy import BasePolicy
from torch.utils.data import Dataset

import qlib
from qlib.backtest.decision import Task
from qlib.constant import ONE_MIN
from qlib.rl.data.pickle_styled import load_simple_intraday_backtest_data
Expand All @@ -22,9 +25,6 @@
from qlib.rl.trainer.callbacks import Callback, EarlyStopping, MetricsWriter
from qlib.rl.utils.log import CsvWriter
from qlib.utils import init_instance_by_config
from tianshou.policy import BasePolicy
from torch.utils.data import Dataset


def seed_everything(seed: int) -> None:
torch.manual_seed(seed)
Expand Down

0 comments on commit e4e0d3f

Please sign in to comment.