Commit 7801abf3 authored by pengxiong@wealthgrow.cn's avatar pengxiong@wealthgrow.cn

Merge remote-tracking branch 'origin/dev' into dev

parents 745c54cb 8853b6d0
...@@ -58,9 +58,9 @@ tamp_user_engine = create_engine( ...@@ -58,9 +58,9 @@ tamp_user_engine = create_engine(
), ),
echo=True echo=True
) )
tamp_product_session = sessionmaker(bind=tamp_product_engine)() tamp_product_session = sessionmaker(bind=tamp_product_engine, autocommit=True)()
tamp_order_session = sessionmaker(bind=tamp_order_engine)() tamp_order_session = sessionmaker(bind=tamp_order_engine, autocommit=True)()
tamp_user_session = sessionmaker(bind=tamp_user_engine)() tamp_user_session = sessionmaker(bind=tamp_user_engine, autocommit=True)()
# redis = redis.StrictRedis( # redis = redis.StrictRedis(
# host=config[env]['redis']['host'], # host=config[env]['redis']['host'],
......
...@@ -42,7 +42,7 @@ def sharpe_ratio(excess_return, simple_return, n): ...@@ -42,7 +42,7 @@ def sharpe_ratio(excess_return, simple_return, n):
n: 数据类型, 周(52), 月(12), 日(250) n: 数据类型, 周(52), 月(12), 日(250)
""" """
import math import math
d = math.sqrt(n) * excess_return.mean() / simple_return.std(ddof=1) d = math.sqrt(n) * excess_return / simple_return.std(ddof=1)
return d return d
...@@ -257,3 +257,19 @@ def cvar(returns, alpha): ...@@ -257,3 +257,19 @@ def cvar(returns, alpha):
# Return the average VaR # Return the average VaR
# CVaR should be positive # CVaR should be positive
return abs(sum_var / index) return abs(sum_var / index)
def freq_days(fav_freq):
if fav_freq == 1:
N = 250 # 日更新
elif fav_freq == 2:
N = 52 # 周更新
elif fav_freq == 3:
N = 24 # 半周更新
elif fav_freq == 4:
N = 12 # 月更新
elif fav_freq == 5:
N = 3 # 季度更新
else:
N = 250 # 没有设置freq默认是天更
return N
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment