repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/examples/nested_decision_execution/workflow.py
examples/nested_decision_execution/workflow.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ The expect result of `backtest` is following in current version 'The following are analysis results of benchmark return(1day).' risk mean 0.000651 std 0.012472 annualized_return 0.154967 ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/examples/rl_order_execution/scripts/gen_pickle_data.py
examples/rl_order_execution/scripts/gen_pickle_data.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import yaml import argparse import os import shutil from copy import deepcopy from qlib.contrib.data.highfreq_provider import HighFreqProvider loader = yaml.FullLoader if __name__ == "__main__": parser = argparse.ArgumentParser() parse...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/examples/rl_order_execution/scripts/merge_orders.py
examples/rl_order_execution/scripts/merge_orders.py
import pickle import os import pandas as pd from tqdm import tqdm for tag in ["test", "valid"]: files = os.listdir(os.path.join("data/orders/", tag)) dfs = [] for f in tqdm(files): df = pickle.load(open(os.path.join("data/orders/", tag, f), "rb")) df = df.drop(["$close0"], axis=1) d...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/examples/rl_order_execution/scripts/gen_training_orders.py
examples/rl_order_execution/scripts/gen_training_orders.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import os import numpy as np import pandas as pd from pathlib import Path DATA_PATH = Path(os.path.join("data", "pickle", "backtest")) OUTPUT_PATH = Path(os.path.join("data", "orders")) def generate_order(stock: str, start_idx: int, end_idx: ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/typehint.py
qlib/typehint.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """Commonly used types.""" import sys from typing import Union from pathlib import Path __all__ = ["Literal", "TypedDict", "final"] if sys.version_info >= (3, 8): from typing import Literal, TypedDict, final # type: ignore # pylint: disa...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/log.py
qlib/log.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import logging from typing import Optional, Text, Dict, Any import re from logging import config as logging_config from time import time from contextlib import contextmanager from .config import C class MetaLogger(type): def __new__(mcs, ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/config.py
qlib/config.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ About the configs ================= The config will be based on _default_config. Two modes are supported - client - server """ from __future__ import annotations import os import re import copy import logging import platform import multipro...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/__init__.py
qlib/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from pathlib import Path from setuptools_scm import get_version try: from ._version import version as __version__ except ImportError: __version__ = get_version(root="..", relative_to=__file__) __version__bak = __version__ # This version...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/constant.py
qlib/constant.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # REGION CONST from typing import TypeVar import numpy as np import pandas as pd REG_CN = "cn" REG_US = "us" REG_TW = "tw" # Epsilon for avoiding division by zero. EPS = 1e-12 # Infinity in integer INF = int(1e18) ONE_DAY = pd.Timedelta("1day...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/aux_info.py
qlib/rl/aux_info.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from typing import TYPE_CHECKING, Generic, Optional, TypeVar from qlib.typehint import final from .simulator import StateType if TYPE_CHECKING: from .utils.env_wrapper import EnvWrapper __all__ = ["Aux...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/seed.py
qlib/rl/seed.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """Defines a set of initial state definitions and state-set definitions. With single-asset order execution only, the only seed is order. """ from typing import TypeVar InitialStateType = TypeVar("InitialStateType") """Type of data that creates...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/reward.py
qlib/rl/reward.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from typing import TYPE_CHECKING, Any, Dict, Generic, Optional, Tuple, TypeVar from qlib.typehint import final if TYPE_CHECKING: from .utils.env_wrapper import EnvWrapper SimulatorState = TypeVar("Simula...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/interpreter.py
qlib/rl/interpreter.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations 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 ObsType = TypeVar("ObsType") PolicyActT...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/__init__.py
qlib/rl/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from .interpreter import Interpreter, StateInterpreter, ActionInterpreter from .reward import Reward, RewardCombination from .simulator import Simulator __all__ = ["Interpreter", "StateInterpreter", "ActionInterpreter", "Reward", "RewardCombinat...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/simulator.py
qlib/rl/simulator.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from typing import TYPE_CHECKING, Any, Generic, Optional, TypeVar from .seed import InitialStateType if TYPE_CHECKING: from .utils.env_wrapper import EnvWrapper StateType = TypeVar("StateType") """StateT...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/contrib/naive_config_parser.py
qlib/rl/contrib/naive_config_parser.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import os import platform import shutil import sys import tempfile from importlib import import_module from ruamel.yaml import YAML DELETE_KEY = "_delete_" def merge_a_into_b(a: dict, b: dict) -> dict: b = b.copy() for k, v in a.items...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/contrib/backtest.py
qlib/rl/contrib/backtest.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations import argparse import copy import os import pickle from collections import defaultdict from pathlib import Path from typing import Dict, List, Optional, Tuple, Union, cast import numpy as np import pandas as p...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/contrib/utils.py
qlib/rl/contrib/utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from pathlib import Path import pandas as pd def read_order_file(order_file: Path | pd.DataFrame) -> pd.DataFrame: if isinstance(order_file, pd.DataFrame): return order_file order_file = Pat...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/contrib/train_onpolicy.py
qlib/rl/contrib/train_onpolicy.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations import argparse import os import random import sys import warnings from pathlib import Path from ruamel.yaml import YAML from typing import cast, List, Optional import numpy as np import pandas as pd import tor...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/contrib/__init__.py
qlib/rl/contrib/__init__.py
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/order_execution/state.py
qlib/rl/order_execution/state.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations import typing from typing import NamedTuple, Optional import numpy as np import pandas as pd from qlib.backtest import Order from qlib.typehint import TypedDict if typing.TYPE_CHECKING: from qlib.rl.data....
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/order_execution/network.py
qlib/rl/order_execution/network.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from typing import List, Tuple, cast import torch import torch.nn as nn from tianshou.data import Batch from qlib.typehint import Literal from .interpreter import FullHistoryObs __all__ = ["Recurrent"] cl...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/order_execution/simulator_simple.py
qlib/rl/order_execution/simulator_simple.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from typing import Any, cast, List, Optional import numpy as np import pandas as pd from pathlib import Path from qlib.backtest.decision import Order, OrderDir from qlib.constant import EPS, EPS_T, float_or_n...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/order_execution/policy.py
qlib/rl/order_execution/policy.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from pathlib import Path from typing import Any, Dict, Generator, Iterable, Optional, OrderedDict, Tuple, cast import gym import numpy as np import torch import torch.nn as nn from gym.spaces import Discrete f...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/order_execution/utils.py
qlib/rl/order_execution/utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from typing import Any, cast import numpy as np import pandas as pd from qlib.backtest.decision import OrderDir from qlib.backtest.executor import BaseExecutor, NestedExecutor, SimulatorExecutor from qlib.con...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/order_execution/reward.py
qlib/rl/order_execution/reward.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from typing import cast import numpy as np from qlib.backtest.decision import OrderDir from qlib.rl.order_execution.state import SAOEMetrics, SAOEState from qlib.rl.reward import Reward __all__ = ["PAPenalty...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/order_execution/simulator_qlib.py
qlib/rl/order_execution/simulator_qlib.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from typing import Generator, List, Optional import pandas as pd from qlib.backtest import collect_data_loop, get_strategy_executor from qlib.backtest.decision import BaseTradeDecision, Order, TradeRangeByTim...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/order_execution/interpreter.py
qlib/rl/order_execution/interpreter.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. 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 ql...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/order_execution/__init__.py
qlib/rl/order_execution/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ Currently it supports single-asset order execution. Multi-asset is on the way. """ from .interpreter import ( FullHistoryStateInterpreter, CurrentStepStateInterpreter, CategoricalActionInterpreter, TwapRelativeActionInterpret...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/order_execution/strategy.py
qlib/rl/order_execution/strategy.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations import collections from types import GeneratorType from typing import Any, Callable, cast, Dict, Generator, List, Optional, Tuple, Union import warnings import numpy as np import pandas as pd import torch from...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/trainer/api.py
qlib/rl/trainer/api.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from typing import Any, Callable, Dict, List, Sequence, cast from tianshou.policy import BasePolicy from qlib.rl.interpreter import ActionInterpreter, StateInterpreter from qlib.rl.reward import Reward from q...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/trainer/vessel.py
qlib/rl/trainer/vessel.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations import weakref from typing import TYPE_CHECKING, Any, Callable, ContextManager, Dict, Generic, Iterable, Sequence, TypeVar, cast import numpy as np from tianshou.data import Collector, VectorReplayBuffer from ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/trainer/callbacks.py
qlib/rl/trainer/callbacks.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """Callbacks to insert customized recipes during the training. Mimicks the hooks of Keras / PyTorch-Lightning, but tailored for the context of RL. """ from __future__ import annotations import copy import os import shutil import time from datet...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/trainer/trainer.py
qlib/rl/trainer/trainer.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations import collections import copy from contextlib import AbstractContextManager, contextmanager from datetime import datetime from pathlib import Path from typing import Any, Dict, Iterable, List, OrderedDict, Seq...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/trainer/__init__.py
qlib/rl/trainer/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """Train, test, inference utilities.""" from .api import backtest, train from .callbacks import Checkpoint, EarlyStopping, MetricsWriter from .trainer import Trainer from .vessel import TrainingVessel, TrainingVesselBase __all__ = [ "Traine...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/utils/data_queue.py
qlib/rl/utils/data_queue.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations import multiprocessing from multiprocessing.sharedctypes import Synchronized import os import threading import time import warnings from queue import Empty from typing import Any, Generator, Generic, Sequence, ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/utils/log.py
qlib/rl/utils/log.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """Distributed logger for RL. :class:`LogCollector` runs in every environment workers. It collects log info from simulator states, and add them (as a dict) to auxiliary info returned for each step. :class:`LogWriter` runs in the central worker....
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/utils/env_wrapper.py
qlib/rl/utils/env_wrapper.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations import weakref from typing import Any, Callable, cast, Dict, Generic, Iterable, Iterator, Optional, Tuple import gym from gym import Space from qlib.rl.aux_info import AuxiliaryInfoCollector from qlib.rl.inte...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/utils/finite_env.py
qlib/rl/utils/finite_env.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ This is to support finite env in vector env. See https://github.com/thu-ml/tianshou/issues/322 for details. """ from __future__ import annotations import copy import warnings from contextlib import contextmanager from typing import Any, Cal...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/utils/__init__.py
qlib/rl/utils/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from .data_queue import DataQueue from .env_wrapper import EnvWrapper, EnvWrapperStatus from .finite_env import FiniteEnvType, vectorize_env from .log import ConsoleWriter, CsvWriter, LogBuffer, LogCollector, LogLevel, LogWriter __all__ = [ ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/data/integration.py
qlib/rl/data/integration.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ TODO: This file is used to integrate NeuTrader with Qlib to run the existing projects. TODO: The implementation here is kind of adhoc. It is better to design a more uniformed & general implementation. """ from __future__ import annotations ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/data/native.py
qlib/rl/data/native.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations import os from pathlib import Path from typing import List, cast import cachetools import pandas as pd from qlib.backtest import Exchange, Order from qlib.backtest.decision import TradeRange, TradeRangeByTime ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/data/pickle_styled.py
qlib/rl/data/pickle_styled.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """This module contains utilities to read financial data from pickle-styled files. This is the format used in `OPD paper <https://seqml.github.io/opd/>`__. NOT the standard data format in qlib. The data here are all wrapped with ``@lru_cache``,...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/data/__init__.py
qlib/rl/data/__init__.py
# 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. """
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/data/base.py
qlib/rl/data/base.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from abc import abstractmethod import pandas as pd class BaseIntradayBacktestData: """ Raw market data that is often used in backtesting (thus called BacktestData). Base class for all types of ba...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/strategy/__init__.py
qlib/rl/strategy/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from .single_order import SingleOrderStrategy __all__ = ["SingleOrderStrategy"]
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/rl/strategy/single_order.py
qlib/rl/strategy/single_order.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import annotations from qlib.backtest import Order from qlib.backtest.decision import OrderHelper, TradeDecisionWO, TradeRange from qlib.strategy.base import BaseStrategy class SingleOrderStrategy(BaseStrategy): """Strategy...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/utils.py
qlib/model/utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from torch.utils.data import Dataset class ConcatDataset(Dataset): def __init__(self, *datasets): self.datasets = datasets def __getitem__(self, i): return tuple(d[i] for d in self.datasets) def __len__(self): ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/trainer.py
qlib/model/trainer.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ The Trainer will train a list of tasks and return a list of model recorders. There are two steps in each Trainer including ``train`` (make model recorder) and ``end_train`` (modify model recorder). This is a concept called ``DelayTrainer``, ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/__init__.py
qlib/model/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import warnings from .base import Model __all__ = ["Model", "warnings"]
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/base.py
qlib/model/base.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import abc from typing import Text, Union from ..utils.serial import Serializable from ..data.dataset import Dataset from ..data.dataset.weight import Reweighter class BaseModel(Serializable, metaclass=abc.ABCMeta): """Modeling things""" ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/ens/ensemble.py
qlib/model/ens/ensemble.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ Ensemble module can merge the objects in an Ensemble. For example, if there are many submodels predictions, we may need to merge them into an ensemble prediction. """ from typing import Union import pandas as pd from qlib.utils import FLATTE...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/ens/group.py
qlib/model/ens/group.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ Group can group a set of objects based on `group_func` and change them to a dict. After group, we provide a method to reduce them. For example: group: {(A,B,C1): object, (A,B,C2): object} -> {(A,B): {C1: object, C2: object}} reduce: {(A,B):...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/ens/__init__.py
qlib/model/ens/__init__.py
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/riskmodel/structured.py
qlib/model/riskmodel/structured.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import numpy as np from typing import Union from sklearn.decomposition import PCA, FactorAnalysis from qlib.model.riskmodel import RiskModel class StructuredCovEstimator(RiskModel): """Structured Covariance Estimator This estimator as...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/riskmodel/shrink.py
qlib/model/riskmodel/shrink.py
import numpy as np from typing import Union from qlib.model.riskmodel import RiskModel class ShrinkCovEstimator(RiskModel): """Shrinkage Covariance Estimator This estimator will shrink the sample covariance matrix towards an identify matrix: S_hat = (1 - alpha) * S + alpha * F where `alpha` ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/riskmodel/__init__.py
qlib/model/riskmodel/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from .base import RiskModel from .poet import POETCovEstimator from .shrink import ShrinkCovEstimator from .structured import StructuredCovEstimator __all__ = [ "RiskModel", "POETCovEstimator", "ShrinkCovEstimator", "StructuredC...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/riskmodel/poet.py
qlib/model/riskmodel/poet.py
import numpy as np from qlib.model.riskmodel import RiskModel class POETCovEstimator(RiskModel): """Principal Orthogonal Complement Thresholding Estimator (POET) Reference: [1] Fan, J., Liao, Y., & Mincheva, M. (2013). Large covariance estimation by thresholding principal orthogonal complements. ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/riskmodel/base.py
qlib/model/riskmodel/base.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import inspect import numpy as np import pandas as pd from typing import Union from qlib.model.base import BaseModel class RiskModel(BaseModel): """Risk Model A risk model is used to estimate the covariance matrix of stock returns. ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/interpret/__init__.py
qlib/model/interpret/__init__.py
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/interpret/base.py
qlib/model/interpret/base.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ Interfaces to interpret models """ import pandas as pd from abc import abstractmethod class FeatureInt: """Feature (Int)erpreter""" @abstractmethod def get_feature_importance(self) -> pd.Series: """get feature import...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/meta/task.py
qlib/model/meta/task.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from qlib.data.dataset import Dataset from ...utils import init_instance_by_config class MetaTask: """ A single meta-task, a meta-dataset contains a list of them. It serves as a component as in MetaDatasetDS The data processing...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/meta/model.py
qlib/model/meta/model.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import abc from typing import List from .dataset import MetaTaskDataset class MetaModel(metaclass=abc.ABCMeta): """ The meta-model guiding the model learning. The word `Guiding` can be categorized into two types based on the stage...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/meta/dataset.py
qlib/model/meta/dataset.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import abc from qlib.model.meta.task import MetaTask from typing import Dict, Union, List, Tuple, Text from ...utils.serial import Serializable class MetaTaskDataset(Serializable, metaclass=abc.ABCMeta): """ A dataset fetching the data ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/model/meta/__init__.py
qlib/model/meta/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from .task import MetaTask from .dataset import MetaTaskDataset __all__ = ["MetaTask", "MetaTaskDataset"]
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/evaluate_portfolio.py
qlib/contrib/evaluate_portfolio.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd from scipy.stats import spearmanr, pearsonr from ..data import D from collections import OrderedDict def _get_position_value_from_d...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/__init__.py
qlib/contrib/__init__.py
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/evaluate.py
qlib/contrib/evaluate.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd import warnings from typing import Union, Literal from ..log import get_module_logger from ..utils import get_date_range from ..utils.r...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/torch.py
qlib/contrib/torch.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ This module is not a necessary part of Qlib. They are just some tools for convenience It is should not imported into the core part of qlib """ import torch import numpy as np import pandas as pd def data_to_tensor(data, device="cpu", raise_e...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/rolling/__main__.py
qlib/contrib/rolling/__main__.py
import fire from qlib import auto_init from qlib.contrib.rolling.base import Rolling from qlib.utils.mod import find_all_classes if __name__ == "__main__": sub_commands = {} for cls in find_all_classes("qlib.contrib.rolling", Rolling): sub_commands[cls.__module__.split(".")[-1]] = cls # The sub_com...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/rolling/__init__.py
qlib/contrib/rolling/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ The difference between me and the scripts in examples/benchmarks/benchmarks_dynamic - This module only focus provide a general rolling implementation. Anything specific that benchmark is placed in examples/benchmarks/benchmarks_dynamic """
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/rolling/ddgda.py
qlib/contrib/rolling/ddgda.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from pathlib import Path import pickle from typing import Optional, Union import pandas as pd import yaml from qlib.contrib.meta.data_selection.dataset import InternalData, MetaDatasetDS from qlib.contrib.meta.data_selection.model import MetaMod...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/rolling/base.py
qlib/contrib/rolling/base.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from copy import deepcopy from pathlib import Path from ruamel.yaml import YAML from typing import List, Optional, Union import fire import pandas as pd from qlib import auto_init from qlib.log import get_module_logger from qlib.model.ens.ensemb...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/tuner/tuner.py
qlib/contrib/tuner/tuner.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # pylint: skip-file # flake8: noqa import os import yaml import json import copy import pickle import logging import importlib import subprocess import pandas as pd import numpy as np from abc import abstractmethod from ...log import get_modul...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/tuner/launcher.py
qlib/contrib/tuner/launcher.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # pylint: skip-file # flake8: noqa # coding=utf-8 import argparse import importlib import os import yaml from .config import TunerConfigManager args_parser = argparse.ArgumentParser(prog="tuner") args_parser.add_argument( "-c", "--co...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/tuner/config.py
qlib/contrib/tuner/config.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # pylint: skip-file # flake8: noqa import copy import os from ruamel.yaml import YAML class TunerConfigManager: def __init__(self, config_path): if not config_path: raise ValueError("Config path is invalid.") se...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/tuner/pipeline.py
qlib/contrib/tuner/pipeline.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # pylint: skip-file # flake8: noqa import os import json import logging import importlib from abc import abstractmethod from ...log import get_module_logger, TimeInspector from ...utils import get_module_by_module_path class Pipeline: GLO...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/tuner/__init__.py
qlib/contrib/tuner/__init__.py
# pylint: skip-file # flake8: noqa
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/tuner/space.py
qlib/contrib/tuner/space.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # pylint: skip-file # flake8: noqa from hyperopt import hp TopkAmountStrategySpace = { "topk": hp.choice("topk", [30, 35, 40]), "buffer_margin": hp.choice("buffer_margin", [200, 250, 300]), } QLibDataLabelSpace = { "labels": hp.ch...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_transformer.py
qlib/contrib/model/pytorch_transformer.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd from typing import Text, Union import copy import math from ...utils import get_or_create_path from ...log import get_module_logger im...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_alstm_ts.py
qlib/contrib/model/pytorch_alstm_ts.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd from typing import Text, Union import copy from ...utils import get_or_create_path from ...log import get_module_logger import torch i...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_lstm.py
qlib/contrib/model/pytorch_lstm.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd from typing import Text, Union import copy from ...utils import get_or_create_path from ...log import get_module_logger import torch i...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_alstm.py
qlib/contrib/model/pytorch_alstm.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd from typing import Text, Union import copy from ...utils import get_or_create_path from ...log import get_module_logger import torch i...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_add.py
qlib/contrib/model/pytorch_add.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import copy import math from typing import Text, Union import numpy as np import pandas as pd import torch import torch.nn as nn import torch.nn.functional as F import torch...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_tabnet.py
qlib/contrib/model/pytorch_tabnet.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd from typing import Text, Union import copy from ...utils import get_or_create_path from ...log import get_module_logger import torch imp...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_tcts.py
qlib/contrib/model/pytorch_tcts.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd import copy import random from ...utils import get_or_create_path from ...log import get_module_logger import torch import torch.nn as...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_lstm_ts.py
qlib/contrib/model/pytorch_lstm_ts.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd import copy from ...utils import get_or_create_path from ...log import get_module_logger import torch import torch.nn as nn import tor...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/tcn.py
qlib/contrib/model/tcn.py
# MIT License # Copyright (c) 2018 CMU Locus Lab import torch.nn as nn from torch.nn.utils import weight_norm class Chomp1d(nn.Module): def __init__(self, chomp_size): super(Chomp1d, self).__init__() self.chomp_size = chomp_size def forward(self, x): return x[:, :, : -self.chomp_size]...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_tra.py
qlib/contrib/model/pytorch_tra.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import io import os import copy import math import json import numpy as np import pandas as pd import matplotlib.pyplot as plt import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F try: from torch.ut...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
true
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/double_ensemble.py
qlib/contrib/model/double_ensemble.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import lightgbm as lgb import numpy as np import pandas as pd from typing import Text, Union from ...model.base import Model from ...data.dataset import DatasetH from ...data.dataset.handler import DataHandlerLP from ...model.interpret.base impor...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_sandwich.py
qlib/contrib/model/pytorch_sandwich.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd from typing import Text, Union import copy from ...utils import get_or_create_path from ...log import get_module_logger import torch i...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/highfreq_gdbt_model.py
qlib/contrib/model/highfreq_gdbt_model.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import warnings import numpy as np import pandas as pd import lightgbm as lgb from ...model.base import ModelFT from ...data.dataset import DatasetH from ...data.dataset.handler import DataHandlerLP from ...model.interpret.base import LightGBMFI...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_nn.py
qlib/contrib/model/pytorch_nn.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function from collections import defaultdict import os import gc import numpy as np import pandas as pd from typing import Callable, Optional, Text, Union from sklearn.metrics import ...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_adarnn.py
qlib/contrib/model/pytorch_adarnn.py
# Copyright (c) Microsoft Corporation. import os from torch.utils.data import Dataset, DataLoader import copy from typing import Text, Union import numpy as np import pandas as pd import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torch.autograd import Function from ql...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_gats_ts.py
qlib/contrib/model/pytorch_gats_ts.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd import copy from ...utils import get_or_create_path from ...log import get_module_logger import torch import torch.nn as nn import torc...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_localformer_ts.py
qlib/contrib/model/pytorch_localformer_ts.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd import copy import math from ...utils import get_or_create_path from ...log import get_module_logger import torch import torch.nn as n...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_general_nn.py
qlib/contrib/model/pytorch_general_nn.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function from torch.utils.data import DataLoader import numpy as np import pandas as pd from typing import Union import copy import torch import torch.optim as optim from torch.optim...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_gats.py
qlib/contrib/model/pytorch_gats.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd from typing import Text, Union import copy from ...utils import get_or_create_path from ...log import get_module_logger import torch im...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/catboost_model.py
qlib/contrib/model/catboost_model.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import numpy as np import pandas as pd from typing import Text, Union from catboost import Pool, CatBoost from catboost.utils import get_gpu_device_count from ...model.base import Model from ...data.dataset import DatasetH from ...data.dataset.h...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false
microsoft/qlib
https://github.com/microsoft/qlib/blob/477160e4ac3b4273ae0d4007982ae794a91d9f47/qlib/contrib/model/pytorch_localformer.py
qlib/contrib/model/pytorch_localformer.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import division from __future__ import print_function import numpy as np import pandas as pd from typing import Text, Union import copy import math from ...utils import get_or_create_path from ...log import get_module_logger im...
python
MIT
477160e4ac3b4273ae0d4007982ae794a91d9f47
2026-01-04T14:42:12.012974Z
false