1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-19 02:14:33 +08:00

update-csi500

This commit is contained in:
Linlang Lv (iSoftStone)
2022-02-28 03:48:07 +08:00
parent 74cc21fc2c
commit 40dd84857c
2 changed files with 96 additions and 97 deletions

View File

@@ -5,7 +5,6 @@ import re
import abc
import sys
import importlib
from tqdm import tqdm
from io import BytesIO
from typing import List, Iterable
from pathlib import Path
@@ -14,7 +13,7 @@ import fire
import requests
import pandas as pd
import baostock as bs
from lxml import etree
from tqdm import tqdm
from loguru import logger
CUR_DIR = Path(__file__).resolve().parent
@@ -47,7 +46,6 @@ def retry_request(url: str, method: str = "get", exclude_status: List = None):
class CSIIndex(IndexBase):
@property
def calendar_list(self) -> List[pd.Timestamp]:
"""get history trading date
@@ -318,7 +316,6 @@ class CSIIndex(IndexBase):
class CSI300(CSIIndex):
@property
def index_code(self):
return "000300"
@@ -329,11 +326,10 @@ class CSI300(CSIIndex):
@property
def html_table_index(self):
return 0
return 1
class CSI100(CSIIndex):
@property
def index_code(self):
return "000903"
@@ -344,11 +340,10 @@ class CSI100(CSIIndex):
@property
def html_table_index(self):
return 1
return 2
class CSI500(CSIIndex):
@property
def index_code(self):
return "000905"
@@ -366,7 +361,7 @@ class CSI500(CSIIndex):
def get_history_companies(self):
"""
Data sourcehttp://baostock.com/baostock/index.php/%E4%B8%AD%E8%AF%81500%E6%88%90%E5%88%86%E8%82%A1
Data source: http://baostock.com/baostock/index.php/%E4%B8%AD%E8%AF%81500%E6%88%90%E5%88%86%E8%82%A1
Avoid a large number of parallel data acquisition,
such as 1000 times of concurrent data acquisition, because IP will be blocked
Returns
@@ -391,7 +386,12 @@ class CSI500(CSIIndex):
def get_instruments(
qlib_dir: str, index_name: str, method: str = "parse_instruments", request_retry: int = 5, retry_sleep: int = 3
qlib_dir: str,
index_name: str,
method: str = "parse_instruments",
freq: str = "day",
request_retry: int = 5,
retry_sleep: int = 3,
):
"""

View File

@@ -34,6 +34,7 @@ CALENDAR_BENCH_URL_MAP = {
"ALL": CALENDAR_URL_BASE.format(market=1, bench_code="000905"),
# NOTE: Use the time series of ^GSPC(SP500) as the sequence of all stocks
"US_ALL": "^GSPC",
"IN_ALL": "^NSEI",
}
_BENCH_CALENDAR_LIST = None
@@ -452,9 +453,7 @@ def symbol_prefix_to_sufix(symbol: str, capital: bool = True) -> str:
def deco_retry(retry: int = 5, retry_sleep: int = 3):
def deco_func(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
_retry = 5 if callable(retry) else retry