mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-12 15:26:54 +08:00
fix bugs
This commit is contained in:
@@ -173,11 +173,11 @@ class MultiLevelTradingWorkflow:
|
|||||||
GetData().qlib_data(target_dir=provider_uri_1min, interval="1min", region=REG_CN)
|
GetData().qlib_data(target_dir=provider_uri_1min, interval="1min", region=REG_CN)
|
||||||
|
|
||||||
# TODO: update new data
|
# TODO: update new data
|
||||||
# provider_uri_day = "~/.qlib/qlib_data/cn_data" # target_dir
|
provider_uri_day = "~/.qlib/qlib_data/cn_data" # target_dir
|
||||||
# if not exists_qlib_data(provider_uri_day):
|
if not exists_qlib_data(provider_uri_day):
|
||||||
# print(f"Qlib data is not found in {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)
|
GetData().qlib_data(target_dir=provider_uri_day, region=REG_CN)
|
||||||
provider_uri_day = "/data/csdesign/qlib"
|
|
||||||
provider_uri_map = {"1min": provider_uri_1min, "day": provider_uri_day}
|
provider_uri_map = {"1min": provider_uri_1min, "day": provider_uri_day}
|
||||||
client_config = {
|
client_config = {
|
||||||
"calendar_provider": {
|
"calendar_provider": {
|
||||||
@@ -210,7 +210,7 @@ class MultiLevelTradingWorkflow:
|
|||||||
executor_config = self.port_analysis_config["executor"]
|
executor_config = self.port_analysis_config["executor"]
|
||||||
# update executor with hierarchical decison freq ["day", "1min"]
|
# update executor with hierarchical decison freq ["day", "1min"]
|
||||||
executor_config["kwargs"]["time_per_step"] = "day"
|
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"]
|
backtest_config = self.port_analysis_config["backtest"]
|
||||||
|
|
||||||
# yahoo highfreq data time
|
# yahoo highfreq data time
|
||||||
|
|||||||
@@ -80,12 +80,12 @@ class Report:
|
|||||||
fields = ["$close/Ref($close,1)-1"]
|
fields = ["$close/Ref($close,1)-1"]
|
||||||
try:
|
try:
|
||||||
_temp_result = D.features(_codes, fields, start_time, end_time, freq=freq, disk_cache=1)
|
_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)
|
_, norm_freq = parse_freq(freq)
|
||||||
if norm_freq in ["month", "week", "day"]:
|
if norm_freq in ["month", "week", "day"]:
|
||||||
try:
|
try:
|
||||||
_temp_result = D.features(_codes, fields, start_time, end_time, freq="day", disk_cache=1)
|
_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)
|
_temp_result = D.features(_codes, fields, start_time, end_time, freq="1min", disk_cache=1)
|
||||||
elif norm_freq == "minute":
|
elif norm_freq == "minute":
|
||||||
_temp_result = D.features(_codes, fields, start_time, end_time, freq="1min", disk_cache=1)
|
_temp_result = D.features(_codes, fields, start_time, end_time, freq="1min", disk_cache=1)
|
||||||
|
|||||||
@@ -177,8 +177,6 @@ class TopkDropoutStrategy(ModelStrategy):
|
|||||||
|
|
||||||
# Get the stock list we really want to buy
|
# Get the stock list we really want to buy
|
||||||
buy = today[: len(sell) + self.topk - len(last)]
|
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:
|
for code in current_stock_list:
|
||||||
if not self.trade_exchange.is_stock_tradable(
|
if not self.trade_exchange.is_stock_tradable(
|
||||||
stock_id=code, start_time=trade_start_time, end_time=trade_end_time
|
stock_id=code, start_time=trade_start_time, end_time=trade_end_time
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ def get_resam_calendar(
|
|||||||
try:
|
try:
|
||||||
_calendar = Cal.calendar(start_time=start_time, end_time=end_time, freq=freq, future=future)
|
_calendar = Cal.calendar(start_time=start_time, end_time=end_time, freq=freq, future=future)
|
||||||
freq, freq_sam = freq, None
|
freq, freq_sam = freq, None
|
||||||
except ValueError:
|
except (ValueError, KeyError):
|
||||||
freq_sam = freq
|
freq_sam = freq
|
||||||
if norm_freq in ["month", "week", "day"]:
|
if norm_freq in ["month", "week", "day"]:
|
||||||
try:
|
try:
|
||||||
@@ -190,16 +190,16 @@ def get_resam_calendar(
|
|||||||
start_time=start_time, end_time=end_time, freq="day", freq_sam=freq, future=future
|
start_time=start_time, end_time=end_time, freq="day", freq_sam=freq, future=future
|
||||||
)
|
)
|
||||||
freq = "day"
|
freq = "day"
|
||||||
except ValueError:
|
except (ValueError, KeyError):
|
||||||
_calendar = Cal.calendar(
|
_calendar = Cal.calendar(
|
||||||
start_time=start_time, end_time=end_time, freq="1min", freq_sam=freq, future=future
|
start_time=start_time, end_time=end_time, freq="1min", freq_sam=freq, future=future
|
||||||
)
|
)
|
||||||
freq = "min"
|
freq = "1min"
|
||||||
elif norm_freq == "minute":
|
elif norm_freq == "minute":
|
||||||
_calendar = Cal.calendar(
|
_calendar = Cal.calendar(
|
||||||
start_time=start_time, end_time=end_time, freq="1min", freq_sam=freq, future=future
|
start_time=start_time, end_time=end_time, freq="1min", freq_sam=freq, future=future
|
||||||
)
|
)
|
||||||
freq = "min"
|
freq = "1min"
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"freq {freq} is not supported")
|
raise ValueError(f"freq {freq} is not supported")
|
||||||
return _calendar, freq, freq_sam
|
return _calendar, freq, freq_sam
|
||||||
|
|||||||
Reference in New Issue
Block a user