How to use the xalpha.mulfix function in xalpha

To help you get started, we’ve selected a few xalpha examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github refraction-ray / xalpha / tests / test_trade.py View on Github external
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
github refraction-ray / xalpha / tests / test_trade.py View on Github external
def test_mulfix():
    tot = xa.mulfix(status=statb, totmoney=5000)
    tot.v_positions()
    tot.v_positions_history("2017-01-01")
    assert round(tot.summary("2018-08-04").iloc[0]["投资收益率"], 1) == 1.0
    assert round(tot.xirrrate(date="2020-01-01", startdate="2018-05-01"), 2) == 0.04
    eva = tot.evaluation()
    assert round(eva.correlation_table(end="2018-07-30").iloc[2, 4], 3) == 0.095
github refraction-ray / xalpha / tests / test_trade.py View on Github external
def test_mul():
    with pytest.raises(Exception) as excinfo:
        cm_m = xa.mulfix(cm_t, totmoney=200)
    assert str(excinfo.value) == "You cannot sell first when you never buy"
    with pytest.raises(Exception) as excinfo:
        cm_m = xa.mulfix(cm_t, totmoney=300)
    assert str(excinfo.value) == "the initial total cash is too low"

    cm_m = xa.mulfix(cm_t, totmoney=500)
    cm_m.bcmkset(xa.indexinfo("1399971"), start="2016-09-28")
    assert round(cm_m.xirrrate("2018-07-29"), 3) == -0.129
    assert round(cm_m.sharpe("2018-07-30"), 3) == -1.734
    cm_m.v_netvalue(benchmark=False)
    assert round(cm_m.total_return("2018-07-01"), 3) == -0.209
    assert round(cm_m.benchmark_volatility("2018-07-22"), 3) == 0.192
    assert round(cm_m.max_drawdown("2018-08-01")[2], 2) == -0.24
    cm_m.v_tradevolume()
    cm_m.v_tradecost()
github refraction-ray / xalpha / tests / test_trade.py View on Github external
def test_mul():
    with pytest.raises(Exception) as excinfo:
        cm_m = xa.mulfix(cm_t, totmoney=200)
    assert str(excinfo.value) == "You cannot sell first when you never buy"
    with pytest.raises(Exception) as excinfo:
        cm_m = xa.mulfix(cm_t, totmoney=300)
    assert str(excinfo.value) == "the initial total cash is too low"

    cm_m = xa.mulfix(cm_t, totmoney=500)
    cm_m.bcmkset(xa.indexinfo("1399971"), start="2016-09-28")
    assert round(cm_m.xirrrate("2018-07-29"), 3) == -0.129
    assert round(cm_m.sharpe("2018-07-30"), 3) == -1.734
    cm_m.v_netvalue(benchmark=False)
    assert round(cm_m.total_return("2018-07-01"), 3) == -0.209
    assert round(cm_m.benchmark_volatility("2018-07-22"), 3) == 0.192
    assert round(cm_m.max_drawdown("2018-08-01")[2], 2) == -0.24
    cm_m.v_tradevolume()
    cm_m.v_tradecost()
github refraction-ray / xalpha / tests / test_i.py View on Github external
def test_imulfix():
    c = xa.mulfix(status=orc, istatus=ir, totmoney=100000, **ioconf)
    c.summary()
    c.v_category_positions("2020-04-08")
    c.get_stock_holdings()
    c.get_portfolio(date="20200501")
github refraction-ray / xalpha / tests / test_trade.py View on Github external
def test_mul():
    with pytest.raises(Exception) as excinfo:
        cm_m = xa.mulfix(cm_t, totmoney=200)
    assert str(excinfo.value) == "You cannot sell first when you never buy"
    with pytest.raises(Exception) as excinfo:
        cm_m = xa.mulfix(cm_t, totmoney=300)
    assert str(excinfo.value) == "the initial total cash is too low"

    cm_m = xa.mulfix(cm_t, totmoney=500)
    cm_m.bcmkset(xa.indexinfo("1399971"), start="2016-09-28")
    assert round(cm_m.xirrrate("2018-07-29"), 3) == -0.129
    assert round(cm_m.sharpe("2018-07-30"), 3) == -1.734
    cm_m.v_netvalue(benchmark=False)
    assert round(cm_m.total_return("2018-07-01"), 3) == -0.209
    assert round(cm_m.benchmark_volatility("2018-07-22"), 3) == 0.192
    assert round(cm_m.max_drawdown("2018-08-01")[2], 2) == -0.24
    cm_m.v_tradevolume()
    cm_m.v_tradecost()
github refraction-ray / xalpha / tests / test_trade.py View on Github external
def test_record_list():
    tot = xa.mulfix(status=statl, totmoney=50000, **ioconf)
    assert round(tot.combsummary("2019-05-04").iloc[0]["投资收益率"], 1) == 10.5