Skip to content

Commit b7a068d

Browse files
authored
Merge pull request #680 from ricequant/develop
Develop
2 parents 8399a15 + ca85574 commit b7a068d

File tree

18 files changed

+15
-20
lines changed

18 files changed

+15
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ persist/
2121
rqalpha_test_coverage_report/
2222
.tmp.pkl
2323
.env
24+
.DS_Store

rqalpha/mod/rqalpha_mod_sys_analyser/mod.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ def tear_down(self, code, exception=None):
345345
benchmark_annualized_returns = (benchmark_total_returns + 1) ** (DAYS_CNT.TRADING_DAYS_A_YEAR / date_count) - 1
346346
summary['benchmark_annualized_returns'] = benchmark_annualized_returns
347347

348+
# 新增一个超额累计收益
349+
summary['excess_cum_returns'] = summary["total_returns"] - summary["benchmark_total_returns"]
350+
348351
trades = pd.DataFrame(self._trades)
349352
if 'datetime' in trades.columns:
350353
trades = trades.set_index(pd.DatetimeIndex(trades['datetime']))
@@ -369,7 +372,7 @@ def tear_down(self, code, exception=None):
369372
summary["turnover"] = trades_values.sum() / market_values.mean() / 2
370373
avg_daily_turnover = (trades_values.groupby(trades.index.date).sum() / market_values / 2)
371374
with pd.option_context('mode.use_inf_as_na', True):
372-
summary["avg_daily_turnover"] = avg_daily_turnover.dropna().mean()
375+
summary["avg_daily_turnover"] = avg_daily_turnover.fillna(0).mean()
373376
else:
374377
summary["turnover"] = np.nan
375378

rqalpha/mod/rqalpha_mod_sys_analyser/plot/consts.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@
9696
]
9797

9898
EXCESS_INDICATORS = [
99+
IndicatorInfo("excess_cum_returns", _("ExcessCumReturns"), RED, "{0:.3%}", 11),
99100
IndicatorInfo("excess_returns", _("ExcessReturns"), RED, "{0:.3%}", 11),
100-
IndicatorInfo("excess_annual_returns", _("ExcessAnnual"), RED, "{0:.3%}", 11),
101+
IndicatorInfo("excess_annual_returns", _("ExcessAnnual"), BLACK, "{0:.3%}", 11),
101102
IndicatorInfo("excess_sharpe", _("ExcessSharpe"), BLACK, "{0:.4}", 11),
102103
IndicatorInfo("excess_volatility", _("ExcessVolatility"), BLACK, "{0:.4}", 11),
103-
IndicatorInfo("excess_annual_volatility", _("ExcessAnnualVolatility"), BLACK, "{0:.4}", 11),
104+
# IndicatorInfo("excess_annual_volatility", _("ExcessAnnualVolatility"), BLACK, "{0:.4}", 11),
104105
IndicatorInfo("excess_max_drawdown", _("ExcessMaxDD"), BLACK, "{0:.4}", 11),
105106
IndicatorInfo("excess_max_dd_ddd", _("ExcessMaxDD/ExcessMaxDDD"), BLACK, "{}", 6),
106107
]

rqalpha/utils/i18n.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def __init__(self, lc=None):
3333
if os.name == "nt":
3434
lc = locale.windows_locale[ctypes.windll.kernel32.GetUserDefaultUILanguage()]
3535
else:
36-
lc = os.getenv("LANG")
36+
# 修改虚拟环境的本地语言读取
37+
lc = os.getenv("LANG") or os.getenv("LC_CTYPE")
3738
self.trans = self.get_trans(lc)
3839

3940
@classmethod
775 Bytes
Binary file not shown.

rqalpha/utils/translations/zh_Hans_CN/LC_MESSAGES/messages.po

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ msgstr "超额收益波动率"
561561
msgid "ExcessAnnualVolatility"
562562
msgstr "超额收益年化波动率"
563563

564+
#: rqalpha/mod/rqalpha_mod_sys_analyser/plot/consts.py:99
565+
msgid "ExcessCumReturns"
566+
msgstr "超额累计收益"
567+
564568
#: rqalpha/mod/rqalpha_mod_sys_analyser/plot/consts.py:104
565569
msgid "ExcessMaxDD"
566570
msgstr "超额收益最大回撤"
@@ -1294,21 +1298,6 @@ msgstr "不支持 API {}。请确保您设置了该 API 所需的账户并开启
12941298
#~ msgid "The balance({balance}) is less than the withdrawal amount={amount}"
12951299
#~ msgstr "出金数额 {amount} 不小于账户余额 {balance}"
12961300

1297-
#~ msgid "Order Creation Failed: 0 order quantity, order_book_id={order_book_id}"
1298-
#~ msgstr "订单创建失败: {order_book_id} 下单量为 0"
1299-
1300-
#~ msgid ""
1301-
#~ "Order Creation Failed: limit order price"
1302-
#~ " {limit_price} is higher than limit "
1303-
#~ "up {limit_up}, order_book_id={order_book_id}"
1304-
#~ msgstr "订单创建失败: {order_book_id} 订单价格 {limit_price} 超过当天涨停板价格 {limit_up}"
1305-
1306-
#~ msgid ""
1307-
#~ "Order Creation Failed: limit order price"
1308-
#~ " {limit_price} is lower than limit "
1309-
#~ "down {limit_down}, order_book_id={order_book_id}"
1310-
#~ msgstr "订单创建失败: {order_book_id} 订单价格 {limit_price} 低于当天跌停板价格 {limit_down}。"
1311-
13121301
#~ msgid "Order Creation Failed: Order amount is 0."
13131302
#~ msgstr ""
13141303

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 = 4.8.0
8+
version = 4.8.1
99

1010
[versioneer]
1111
VCS = git

tests/outs/test_f_buy_and_hold.pkl

-66 Bytes
Binary file not shown.

tests/outs/test_f_macd.pkl

-101 Bytes
Binary file not shown.

tests/outs/test_f_macd_signal.pkl

-112 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)