Skip to content

Commit 6c93381

Browse files
committed
Fixed an issue in check_cache
1 parent 464bd5c commit 6c93381

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

openbb_akshare/utils/helpers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ def check_cache(symbol: str,
6262
Check if the cache contains the latest data for the given symbol.
6363
"""
6464
from mysharelib.tools import last_closing_day
65+
from mysharelib.em.orginfo import get_listing_date
6566

66-
start = get_list_date(symbol)
67+
start = get_listing_date(symbol)
6768
end = last_closing_day()
6869
# Please note that the format of the date string must be "YYYY-MM-DD" in database.
6970
cache_df = cache.fetch_date_range(start.strftime("%Y-%m-%d"), end.strftime("%Y-%m-%d"))
@@ -149,7 +150,7 @@ def ak_download(
149150

150151
# If not in cache, download data
151152
# Download data using AKShare
152-
data_util_today_df = ak_download_without_cache(symbol_b, period=period, api_key=api_key, start_date=start, end_date=end)
153+
data_util_today_df = ak_download_without_cache(symbol_b, period=period, api_key=api_key, start_date=start_dt.strftime("%Y%m%d"), end_date=end_dt.strftime("%Y%m%d"))
153154
cache.write_dataframe(data_util_today_df)
154155

155156
return cache.fetch_date_range(start_dt.strftime("%Y-%m-%d"), end_dt.strftime("%Y-%m-%d"))

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "openbb-akshare"
3-
version = "0.9.21"
3+
version = "0.9.23"
44
description = "AKShare extension for OpenBB"
55
authors = ["Roger Ye <shugaoye@yahoo.com>"]
66
license = "AGPL-3.0-only"
@@ -11,7 +11,7 @@ packages = [{ include = "openbb_akshare" }]
1111
python = ">=3.9.21,<3.13"
1212
akshare = "1.17.39"
1313
openbb-core = { version = "^1.4.7" }
14-
mysharelib = "^0.8.11"
14+
mysharelib = "^0.9.0"
1515
ipywidgets = "^8.1.7"
1616

1717
[tool.poetry.group.dev.dependencies]

tests/test_equity_historical.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@
55
@pytest.mark.parametrize("symbol", ["001979","600177","000333","601857","600050","600941","601728","601319",
66
"600704","600886","601880","601998","600999","000001","601318",
77
"601288","601988","601939","601398"])
8-
def test_equity_historical(symbol, default_provider):
9-
df = obb.equity.price.historical(symbol=symbol, provider=default_provider).to_dataframe()
8+
@pytest.mark.parametrize("use_cache", [True, False])
9+
def test_equity_historical(symbol, default_provider, use_cache):
10+
df = obb.equity.price.historical(symbol=symbol, provider=default_provider, use_cache=use_cache).to_dataframe()
1011
assert isinstance(df, pd.DataFrame)
1112

1213

13-
@pytest.mark.parametrize("symbol", ["001979","600177","000333","601857","600050","600941","601728","601319",
14+
@pytest.mark.parametrize("symbol", ["01658", "00300"])
15+
@pytest.mark.parametrize("use_cache", [True, False])
16+
def test_equity_historical_with_dates(symbol, default_provider, use_cache):
17+
df = obb.equity.price.historical(symbol=symbol, provider=default_provider,
18+
start_date="2024-09-08", end_date="2025-09-08",
19+
use_cache=use_cache).to_dataframe()
20+
assert isinstance(df, pd.DataFrame)
21+
22+
23+
@pytest.mark.parametrize("symbol", ["01658", "001979","600177","000333","601857","600050","600941","601728","601319",
1424
"600704","600886","601880","601998","600999","000001","601318",
1525
"601288","601988","601939","601398"])
1626
def test_equity_info(symbol, akshare_api_key, logger):

0 commit comments

Comments
 (0)