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_ioconf_keyfunc():
get_daily_key = xa.universal.cachedio(
path="./", backend="csv", key_func=lambda s: s[::-1]
)(xa.universal._get_daily)
df1 = get_daily_key("BA", start="2020-03-03")
get_daily_key = xa.universal.cachedio(path="./", backend="csv")(
xa.universal._get_daily
)
df2 = get_daily_key("AB", fetchonly=True)
assert df2.iloc[-1]["close"] == df1.iloc[-1]["close"]
def test_cache_io():
get_daily_csv = xa.universal.cachedio(path="./", prefix="pytestl-", backend="csv")(
xa.universal._get_daily
)
df = get_daily_csv("SH501018", start="2020-01-24", end="2020/02/02")
assert len(df) == 0
df = get_daily_csv("SH501018", start="2020-01-23", end="20200203")
assert len(df) == 2
df = get_daily_csv("SH501018", start="2020-01-24", end="20200205")
assert len(df) == 3
df = get_daily_csv("SH501018", start="2020-01-23")
df = get_daily_csv("SH501018")
df = get_daily_csv("SH501018", end="2020-02-01")
assert df.iloc[0]["date"].strftime("%Y%m%d") == "20190201"
xa.universal.check_cache("SH501018", prev=32, omit_lines=1)
def test_ioconf_keyfunc():
get_daily_key = xa.universal.cachedio(
path="./", backend="csv", key_func=lambda s: s[::-1]
)(xa.universal._get_daily)
df1 = get_daily_key("BA", start="2020-03-03")
get_daily_key = xa.universal.cachedio(path="./", backend="csv")(
xa.universal._get_daily
)
df2 = get_daily_key("AB", fetchonly=True)
assert df2.iloc[-1]["close"] == df1.iloc[-1]["close"]