How to use the xalpha.set_backend 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_universal.py View on Github external
import sys
import time
import pytest

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

xa.set_backend(backend="memory", prefix="pytest-")


@pytest.fixture
def proxy():
    xa.provider.set_proxy("socks5://127.0.0.1:1080")
    yield
    xa.provider.set_proxy()


def test_get_xueqiu():
    df = xa.get_daily(start="20200302", end="2020-03-07", code="HK01810")
    assert round(df.iloc[-1]["close"], 2) == 12.98
    df = xa.get_daily(start="2020/03/02", end="20200307", code="PDD")
    assert round(df.iloc[0]["close"], 2) == 37.51
    df = xa.get_daily(start="20200301", end="20200307", code="SZ112517")
    # note how this test would fail when the bond is matured
github refraction-ray / xalpha / tests / test_jq.py View on Github external
def csv_cache():
    xa.set_backend(backend="csv", path="./")
    yield
    xa.set_backend(backend="memory", path="pytest-")
github refraction-ray / xalpha / tests / test_toolbox.py View on Github external
import sys
import pytest

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

xa.set_backend(backend="memory", prefix="pytest-")


def test_compare():
    c = xa.Compare(("37450", "USD"), "SH501018", start="20200101")
    c.corr()
    c.v()


def test_stock_peb():
    h = xa.StockPEBHistory("HK00700")
    h.summary()


def test_overpriced():
    xa.OverPriced("SZ161815", prev=360).v([-1.5, 3.5])
github refraction-ray / xalpha / tests / test_jq.py View on Github external
def csv_cache():
    xa.set_backend(backend="csv", path="./")
    yield
    xa.set_backend(backend="memory", path="pytest-")
github refraction-ray / xalpha / doc / samples / qdiipred.py View on Github external
"""
一个简单展示 qdii 实时净值预测的例子,最大限度的利用缓存而减少网络请求
"""

import pandas as pd
import xalpha as xa
import logging

xa.set_backend(backend="csv", path="../../../lof/data", precached="20200103")

logger = logging.getLogger("xalpha")
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.addHandler(ch)


@xa.universal.lru_cache_time(ttl=180)
def cached_get_rt(code, **kws):
    return xa.get_rt(code, handler=False)


@xa.universal.lru_cache_time(ttl=1800)
def cached_get_bar(code, *args, **kws):
    if code.startswith("commodities/"):