How to use the xalpha.record 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_i.py View on Github external
"""
对于场内数据相关基础设施的测试
"""

import sys

sys.path.insert(0, "../")
import xalpha as xa
import pandas as pd

path3 = "demo3.csv"
path = "demo.csv"
ioconf = {"save": True, "fetch": True, "path": "pytest", "form": "csv"}
ir = xa.irecord(path3)
orc = xa.record(path)


def test_irecord():
    assert len(ir.filter("SH501018")) == 8


def test_itrade():
    t = xa.itrade("SH512880", ir)
    assert round(t.xirrrate("20200313"), 2) == 12.49
    assert t.dailyreport().iloc[0]["基金名称"] == "证券ETF"


def test_imul():
    c = xa.imul(status=ir)
    assert round(c.combsummary("20200309").iloc[0]["投资收益率"], 2) == -1.39
    c.v_positions()
github refraction-ray / xalpha / tests / test_trade.py View on Github external
import sys

sys.path.insert(0, "../")
import xalpha as xa
import pytest
import pandas as pd


path = "demo.csv"
path1 = "demo1.csv"
path2 = "demo2.csv"
cm = xa.fundinfo("164818")
statb = xa.record(path).status
statl = xa.record(path1, format="list").status
statnb = xa.record(path2)
cm_t = xa.trade(cm, statb)
ioconf = {"save": True, "fetch": True, "path": "pytest", "form": "csv"}


def test_trade():
    assert cm_t.cftable.loc[2, "share"] == -129.14
    assert round(cm_t.xirrrate("2018-03-03"), 3) == -0.24
    assert cm_t.dailyreport("2018-07-29").iloc[0]["单位成本"] == 1.346
    cm_t.v_tradecost("2018-08-01")
    cm_t.v_totvalue("2018-07-31")
    cm_t.v_tradevolume(freq="M")


def test_customize_fee():
github refraction-ray / xalpha / tests / test_trade.py View on Github external
import sys

sys.path.insert(0, "../")
import xalpha as xa
import pytest
import pandas as pd


path = "demo.csv"
path1 = "demo1.csv"
path2 = "demo2.csv"
cm = xa.fundinfo("164818")
statb = xa.record(path).status
statl = xa.record(path1, format="list").status
statnb = xa.record(path2)
cm_t = xa.trade(cm, statb)
ioconf = {"save": True, "fetch": True, "path": "pytest", "form": "csv"}


def test_trade():
    assert cm_t.cftable.loc[2, "share"] == -129.14
    assert round(cm_t.xirrrate("2018-03-03"), 3) == -0.24
    assert cm_t.dailyreport("2018-07-29").iloc[0]["单位成本"] == 1.346
    cm_t.v_tradecost("2018-08-01")
    cm_t.v_totvalue("2018-07-31")
    cm_t.v_tradevolume(freq="M")


def test_customize_fee():
    df = pd.DataFrame(
github refraction-ray / xalpha / tests / test_trade.py View on Github external
import sys

sys.path.insert(0, "../")
import xalpha as xa
import pytest
import pandas as pd


path = "demo.csv"
path1 = "demo1.csv"
path2 = "demo2.csv"
cm = xa.fundinfo("164818")
statb = xa.record(path).status
statl = xa.record(path1, format="list").status
statnb = xa.record(path2)
cm_t = xa.trade(cm, statb)
ioconf = {"save": True, "fetch": True, "path": "pytest", "form": "csv"}


def test_trade():
    assert cm_t.cftable.loc[2, "share"] == -129.14
    assert round(cm_t.xirrrate("2018-03-03"), 3) == -0.24
    assert cm_t.dailyreport("2018-07-29").iloc[0]["单位成本"] == 1.346
    cm_t.v_tradecost("2018-08-01")
    cm_t.v_totvalue("2018-07-31")
    cm_t.v_tradevolume(freq="M")


def test_customize_fee():
    df = pd.DataFrame(
        {"date": ["2020-05-28", "2020-06-01"], "519732": [500.005, -0.505]}