Skip to content

Commit

Permalink
Merge pull request #1535 from yutiansut/master
Browse files Browse the repository at this point in the history
fix bug for beta/ sharpe && update to 1.9.23
  • Loading branch information
yutiansut authored May 16, 2020
2 parents 0cf5fb3 + 63010da commit e7ac07d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions QUANTAXIS/QAARP/QARisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,11 @@ def beta(self):
beta比率 组合的系统性风险
"""
try:
res = round(float(self.calc_beta(self.profit_pct.dropna(),
self.benchmark_profitpct.dropna())),
2)
# res = round(float(self.calc_beta(self.profit_pct.dropna(),
# self.benchmark_profitpct.dropna())),
# 2)

res = round(float(self.calc_beta(self.assets.pct_change().dropna().values, self.benchmark_assets.pct_change().dropna().values)),2)
except:
print('贝塔计算错误。。')
res = 0
Expand Down Expand Up @@ -468,7 +470,7 @@ def calc_annualize_return(self, assets, days):

def calc_profitpctchange(self, assets):
#return assets[::-1].pct_change()[::-1]
return assets.diff().pct_change()
return assets.pct_change().fillna(1)

def calc_beta(self, assest_profit, benchmark_profit):

Expand Down
2 changes: 1 addition & 1 deletion QUANTAXIS/QAFetch/QAQuery_Advance.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def QA_fetch_future_day_adv(
end=None,
if_drop_index=True,
# 🛠 todo collections 参数没有用到, 且数据库是固定的, 这个变量后期去掉
collections=DATABASE.index_day
collections=DATABASE.future_day
):
'''
:param code: code: 字符串str eg 600085
Expand Down
2 changes: 1 addition & 1 deletion QUANTAXIS/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
2017/4/8
"""

__version__ = '1.9.20'
__version__ = '1.9.23'
__author__ = 'yutiansut'

import argparse
Expand Down

0 comments on commit e7ac07d

Please sign in to comment.