How to use the xalpha.QDIIPredict 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_toolbox.py View on Github external
def test_qdii_predict():
    hb = xa.QDIIPredict(
        "SZ162411",
        t1dict={".SPSIOP": 91},
        t0dict={"commodities/brent-oil": 40 * 0.9, "commodities/crude-oil": 60 * 0.9,},
        positions=True,
    )
    hb.get_t1()
    hb.get_t0(percent=True)
    hb.benchmark_test("20200202", "20200302")
    hb.analyse()
github refraction-ray / xalpha / tests / test_toolbox.py View on Github external
def test_qdii_predict_local():
    xc = xa.QDIIPredict("SZ165513", positions=True)
    xc.get_t0_rate()
github refraction-ray / xalpha / doc / samples / qdiipred.py View on Github external
"SH512500",
    "SZ159920",
]
data = {
    "code": [],
    "name": [],
    "t1": [],
    "t0": [],
    "now": [],
    "t1rate": [],
    "t0rate": [],
    "position": [],
}

for c in qdiis:
    p = xa.QDIIPredict(c, fetch=True, save=True, positions=True)
    try:
        data["t1"].append(round(p.get_t1(return_date=False), 4))
        data["t1rate"].append(round(p.get_t1_rate(return_date=False), 2))
        try:
            data["t0"].append(round(p.get_t0(return_date=False), 4))
            data["t0rate"].append(round(p.get_t0_rate(return_date=False), 2))
        except ValueError:
            data["t0"].append("-")
            data["t0rate"].append("-")
        data["position"].append(round(p.get_position(return_date=False), 3))
        data["now"].append(xa.get_rt(c)["current"])
        data["code"].append(c)
        data["name"].append(xa.get_rt(c)["name"])
    except xa.exceptions.NonAccurate as e:
        print("%s cannot be predicted exactly now" % c)
        print(e.reason)