Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test_qlib_from_pip.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Test qlib from pip

concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}

on:
push:
branches: [ main ]
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test_qlib_from_source.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Test qlib from source

concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}

on:
push:
branches: [ main ]
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test_qlib_from_source_slow.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Test qlib from source slow

concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}

on:
push:
branches: [ main ]
Expand Down
17 changes: 13 additions & 4 deletions scripts/data_collector/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from functools import partial
from concurrent.futures import ProcessPoolExecutor
from bs4 import BeautifulSoup
import baostock as bs

from qlib.utils.pickle_utils import restricted_pickle_load

Expand Down Expand Up @@ -68,9 +69,16 @@ def get_calendar_list(bench_code="CSI300") -> List[pd.Timestamp]:

logger.info(f"get calendar list: {bench_code}......")

def _get_calendar(url):
_value_list = requests.get(url, timeout=None).json()["data"]["klines"]
return sorted(map(lambda x: pd.Timestamp(x.split(",")[0]), _value_list))
def _get_calendar(end_date):
bs.login()
rs = bs.query_trade_dates(start_date="2005-01-01", end_date=end_date)
data_list = []
while (rs.error_code == "0") & rs.next():
data_list.append(rs.get_row_data())
bs.logout()
df = pd.DataFrame(data_list, columns=rs.fields)
trade_days = df[df["is_trading_day"] == "1"]["calendar_date"]
return sorted(map(pd.Timestamp, trade_days.to_list()))

calendar = _CALENDAR_MAP.get(bench_code, None)
if calendar is None:
Expand All @@ -90,7 +98,8 @@ def _get_calendar(url):
filtered_dates = dates[(dates >= "2000-01-04") & (dates <= pd.Timestamp.today().normalize())]
calendar = filtered_dates.tolist()
else:
calendar = _get_calendar(CALENDAR_BENCH_URL_MAP[bench_code])
end_date = time.strftime("%Y-%m-%d", time.localtime())
calendar = _get_calendar(end_date=end_date)
_CALENDAR_MAP[bench_code] = calendar
logger.info(f"end of get calendar list: {bench_code}.")
return calendar
Expand Down
Loading