Skip to content

Commit 411289c

Browse files
Lin-DongzhaoCuizi7jiangfengDonLin123
authored
Rqsdk 815 (#938)
* Remove debug print statement from the plot function in the system analyser module. * Add debug logging for Matplotlib backend in plot function of system analyser module * add FutureArbitrage * update version * update * update --------- Co-authored-by: 崔子琦 <oscarcui@ricequant.com> Co-authored-by: Cuizi7 <Cuizi7@users.noreply.github.com> Co-authored-by: pitaya <wangjiangfeng77qq@163.com> Co-authored-by: Don <lin.dongzhao@ricequant.com>
1 parent f8d5c31 commit 411289c

14 files changed

Lines changed: 16 additions & 5 deletions

File tree

rqalpha/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class INSTRUMENT_TYPE(CustomEnum):
158158
SPOT = "Spot"
159159
REPO = "Repo"
160160
REITs = "REITs"
161+
FutureArbitrage = "FutureArbitrage"
161162

162163

163164
# noinspection PyPep8Naming

rqalpha/data/base_data_source/data_source.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from rqalpha.utils.exception import RQInvalidArgument
3232
from rqalpha.utils.functools import lru_cache
3333
from rqalpha.utils.typing import DateLike
34+
from rqalpha.utils.logger import system_log
3435
from rqalpha.environment import Environment
3536
from rqalpha.data.base_data_source.adjust import FIELDS_REQUIRE_ADJUSTMENT, adjust_bars
3637
from rqalpha.data.base_data_source.storage_interface import (AbstractCalendarStore, AbstractDateSet,
@@ -94,10 +95,16 @@ def _p(name):
9495
instruments = []
9596

9697
env = Environment.get_instance()
98+
unsupported_types = []
9799
with open(_p('instruments.pk'), 'rb') as f:
98100
for i in pickle.load(f):
99101
if i["type"] == "Future" and Instrument.is_future_continuous_contract(i["order_book_id"]):
100102
i["listed_date"] = datetime(1990, 1, 1)
103+
if i["type"] not in INSTRUMENT_TYPE:
104+
if i["type"] not in unsupported_types:
105+
unsupported_types.append(i["type"])
106+
system_log.warning(f"Unsupported type: {i['type']}")
107+
continue
101108
instruments.append(Instrument(
102109
i,
103110
lambda i: self._future_info_store.get_tick_size(i),

rqalpha/data/base_data_source/storages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __init__(self, instruments, instrument_type):
135135

136136
for ins in instruments:
137137
if ins.type != instrument_type:
138-
continue
138+
continue
139139
self._instruments[ins.order_book_id] = ins
140140
self._sym_id_map[ins.symbol] = ins.order_book_id
141141

rqalpha/mod/rqalpha_mod_sys_analyser/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ def plot(result_pickle_file_path, show, plot_save_file, plot_open_close_points,
108108
from .plot import plot_result
109109

110110
result_dict = pd.read_pickle(result_pickle_file_path)
111-
print(plot_open_close_points, plot_weekly_indicators)
112111
plot_result(result_dict, show, plot_save_file, plot_weekly_indicators, plot_open_close_points)
113112

114113

rqalpha/mod/rqalpha_mod_sys_analyser/mod.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ def tear_down(self, code, exception=None):
420420
total_portfolios = df.set_index('date').sort_index()
421421
if self._benchmark:
422422
total_portfolios["benchmark_unit_net_value"] = (self._benchmark_daily_returns + 1).cumprod()
423-
total_portfolios["excess_unit_net_value"] = total_portfolios["unit_net_value"] - total_portfolios["benchmark_unit_net_value"]
423+
total_portfolios["arithmetic_excess_unit_net_value"] = total_portfolios["unit_net_value"] - total_portfolios["benchmark_unit_net_value"]
424+
total_portfolios["geometric_excess_unit_net_value"] = total_portfolios["unit_net_value"] / total_portfolios["benchmark_unit_net_value"] - 1
424425
df.index = df['date']
425426
weekly_nav = df.resample("W").last().set_index("date").unit_net_value.dropna()
426427
monthly_nav = df.resample("M").last().set_index("date").unit_net_value.dropna()

rqalpha/mod/rqalpha_mod_sys_analyser/plot/plot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import rqalpha
2828
from rqalpha.const import POSITION_EFFECT
29+
from rqalpha.utils.logger import system_log
2930
from .utils import IndicatorInfo, LineInfo, max_dd as _max_dd, SpotInfo, max_ddd as _max_ddd
3031
from .utils import weekly_returns, trading_dates_index
3132
from .consts import PlotTemplate, DefaultPlot
@@ -245,6 +246,8 @@ def plot_result(
245246

246247
_plot(summary["strategy_file"], sub_plots, strategy_name)
247248

249+
system_log.debug(f"Matplotlib backend: {pyplot.get_backend()}")
250+
248251
if save:
249252
file_path = save
250253
if os.path.isdir(save):

rqalpha/model/instrument.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def de_listed_date(self):
109109
def type(self):
110110
# type: () -> str
111111
"""
112-
[sty] 合约类型,目前支持的类型有: ‘CS’, ‘INDX’, ‘LOF’, ‘ETF’, ‘Future’
112+
[str] 合约类型,目前支持的类型有: ‘CS’, ‘INDX’, ‘LOF’, ‘ETF’, ‘Future’
113113
"""
114114
return INSTRUMENT_TYPE[self.__dict__["type"]]
115115

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
[metadata]
77
name = rqalpha
8-
version = 5.6.3
8+
version = 5.6.4
99

1010
[versioneer]
1111
VCS = git

tests/outs/test_s_buy_and_hold.pkl

3.38 KB
Binary file not shown.

tests/outs/test_s_dual_thrust.pkl

8.81 KB
Binary file not shown.

0 commit comments

Comments
 (0)