mirror of
https://github.com/microsoft/qlib.git
synced 2026-06-06 05:51:17 +08:00
fix(backtest): avoid calendar overflow when end_time is missing (#2127)
* fix(backtest): avoid calendar overflow when end_time is missing * fix: pkg_source not found error when build docs
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pkg_resources
|
||||
from importlib.metadata import version as ver
|
||||
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
@@ -63,9 +63,9 @@ author = "Microsoft"
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = pkg_resources.get_distribution("pyqlib").version
|
||||
version = ver("pyqlib")
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = pkg_resources.get_distribution("pyqlib").version
|
||||
release = version
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
@@ -476,7 +476,13 @@ class PortAnaRecord(ACRecordTemp):
|
||||
if self.backtest_config["start_time"] is None:
|
||||
self.backtest_config["start_time"] = dt_values.min()
|
||||
if self.backtest_config["end_time"] is None:
|
||||
self.backtest_config["end_time"] = get_date_by_shift(dt_values.max(), 1)
|
||||
self.backtest_config["end_time"] = get_date_by_shift(dt_values.max(), -1)
|
||||
warnings.warn(
|
||||
"No explicit backtest end_time provided. "
|
||||
"Qlib requires one extra calendar step to determine the right boundary of a bar. "
|
||||
"Therefore the end_time is shifted backward by one trading day from "
|
||||
f"{dt_values.max()} -> {self.backtest_config['end_time']}."
|
||||
)
|
||||
|
||||
artifact_objects = {}
|
||||
# custom strategy and get backtest
|
||||
|
||||
Reference in New Issue
Block a user