Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_review(capsys):
st1 = xa.policy.buyandhold(gf, start="2018-08-10", end="2019-01-01")
st2 = xa.policy.scheduled_tune(
gf,
totmoney=1000,
times=pd.date_range("2018-01-01", "2019-01-01", freq="W-MON"),
piece=[(0.1, 2), (0.15, 1)],
)
check = xa.review([st1, st2], ["Plan A", "Plan Z"])
assert isinstance(check.content, str) == True
conf = {}
check.notification(conf)
captured = capsys.readouterr()
assert captured.out == "没有提醒待发送\n"
check.content = "a\nb"
check.notification(conf)
captured = capsys.readouterr()
assert captured.out == "邮件发送失败\n"
def test_weekly_price():
# see https://github.com/refraction-ray/xalpha/issues/27
ryjh = xa.fundinfo("008969")
bah = xa.policy.buyandhold(ryjh, start="2019-01-01", totmoney=100000)
bah.sellout("2020-05-12") # 选定日期全部卖出
jshstrade = xa.trade(ryjh, bah.status)
assert round(jshstrade.xirrrate("2020-05-01", startdate="2020-02-01"), 1) == 0.2
def test_policy_buyandhold():
allin = xa.policy.buyandhold(cm, "2015-06-01")
cm_t2 = xa.trade(cm, allin.status)
cm_m2 = xa.mulfix(cm_t2)
cm_m2.bcmkset(xa.indexinfo("1399971"))
assert round(cm_m2.correlation_coefficient("2018-07-01"), 3) == 0.980
assert round(cm_m2.information_ratio("2016-07-01"), 3) == -0.385
allin.sellout("2018-06-01")
cm_t2 = xa.trade(cm, allin.status)
assert round(cm_t2.xirrrate("2019-08-12", guess=-0.9), 2) == -0.33