1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-07 13:00:58 +08:00

Backtest Mypy (#1130)

* Done

* Fix test errors

* Revert profit_attribution.py

* Minor

* A minor update on collect_data type hint

* Resolve PR comments

* Use black to format code

* Fix CI errors
This commit is contained in:
Huoran Li
2022-06-28 22:16:46 +08:00
committed by GitHub
parent 9bf3423a64
commit 23c657a7a2
17 changed files with 363 additions and 315 deletions

View File

@@ -108,14 +108,16 @@ class CalendarProvider(abc.ABC):
_, _, si, ei = self.locate_index(start_time, end_time, freq, future)
return _calendar[si : ei + 1]
def locate_index(self, start_time, end_time, freq, future=False):
def locate_index(
self, start_time: Union[pd.Timestamp, str], end_time: Union[pd.Timestamp, str], freq: str, future: bool = False
):
"""Locate the start time index and end time index in a calendar under certain frequency.
Parameters
----------
start_time : str
start_time : pd.Timestamp
start of the time range.
end_time : str
end_time : pd.Timestamp
end of the time range.
freq : str
time frequency, available: year/quarter/month/week/day.