1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-06-30 17:41:18 +08:00
This commit is contained in:
bxdd
2021-05-29 00:31:40 +08:00
parent 96e393b599
commit bf3b757294
4 changed files with 12 additions and 14 deletions

View File

@@ -173,11 +173,11 @@ class MultiLevelTradingWorkflow:
GetData().qlib_data(target_dir=provider_uri_1min, interval="1min", region=REG_CN)
# TODO: update new data
# provider_uri_day = "~/.qlib/qlib_data/cn_data" # target_dir
# if not exists_qlib_data(provider_uri_day):
# print(f"Qlib data is not found in {provider_uri_day}")
# GetData().qlib_data(target_dir=provider_uri_day, region=REG_CN)
provider_uri_day = "/data/csdesign/qlib"
provider_uri_day = "~/.qlib/qlib_data/cn_data" # target_dir
if not exists_qlib_data(provider_uri_day):
print(f"Qlib data is not found in {provider_uri_day}")
GetData().qlib_data(target_dir=provider_uri_day, region=REG_CN)
provider_uri_map = {"1min": provider_uri_1min, "day": provider_uri_day}
client_config = {
"calendar_provider": {
@@ -210,7 +210,7 @@ class MultiLevelTradingWorkflow:
executor_config = self.port_analysis_config["executor"]
# update executor with hierarchical decison freq ["day", "1min"]
executor_config["kwargs"]["time_per_step"] = "day"
executor_config["kwargs"]["inner_executor"]["kwargs"]["time_per_step"] = "1min"
executor_config["kwargs"]["inner_executor"]["kwargs"]["time_per_step"] = "15min"
backtest_config = self.port_analysis_config["backtest"]
# yahoo highfreq data time

View File

@@ -80,12 +80,12 @@ class Report:
fields = ["$close/Ref($close,1)-1"]
try:
_temp_result = D.features(_codes, fields, start_time, end_time, freq=freq, disk_cache=1)
except ValueError:
except (ValueError, KeyError):
_, norm_freq = parse_freq(freq)
if norm_freq in ["month", "week", "day"]:
try:
_temp_result = D.features(_codes, fields, start_time, end_time, freq="day", disk_cache=1)
except ValueError:
except (ValueError, KeyError):
_temp_result = D.features(_codes, fields, start_time, end_time, freq="1min", disk_cache=1)
elif norm_freq == "minute":
_temp_result = D.features(_codes, fields, start_time, end_time, freq="1min", disk_cache=1)

View File

@@ -177,8 +177,6 @@ class TopkDropoutStrategy(ModelStrategy):
# Get the stock list we really want to buy
buy = today[: len(sell) + self.topk - len(last)]
# print("INTRANEL BAR", len(sell), len(sell) + self.topk - len(last), len(last))
# print("flag", len(sell), len(buy), self.topk, len(last))
for code in current_stock_list:
if not self.trade_exchange.is_stock_tradable(
stock_id=code, start_time=trade_start_time, end_time=trade_end_time

View File

@@ -182,7 +182,7 @@ def get_resam_calendar(
try:
_calendar = Cal.calendar(start_time=start_time, end_time=end_time, freq=freq, future=future)
freq, freq_sam = freq, None
except ValueError:
except (ValueError, KeyError):
freq_sam = freq
if norm_freq in ["month", "week", "day"]:
try:
@@ -190,16 +190,16 @@ def get_resam_calendar(
start_time=start_time, end_time=end_time, freq="day", freq_sam=freq, future=future
)
freq = "day"
except ValueError:
except (ValueError, KeyError):
_calendar = Cal.calendar(
start_time=start_time, end_time=end_time, freq="1min", freq_sam=freq, future=future
)
freq = "min"
freq = "1min"
elif norm_freq == "minute":
_calendar = Cal.calendar(
start_time=start_time, end_time=end_time, freq="1min", freq_sam=freq, future=future
)
freq = "min"
freq = "1min"
else:
raise ValueError(f"freq {freq} is not supported")
return _calendar, freq, freq_sam