Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions efinance/stock/getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from jsonpath import jsonpath
from retry import retry
from tqdm import tqdm
from chinese_calendar import is_workday

from ..common import get_base_info as get_base_info_for_stock
from ..common import get_deal_detail as get_deal_detail_for_stock
Expand Down Expand Up @@ -1453,3 +1454,28 @@ def get_belong_board(stock_code: str) -> pd.DataFrame:
df.insert(0, '股票名称', q.name)
df.insert(1, '股票代码', q.code)
return df

def is_trading_day(date: str):
"""
判断指定日期是否是交易日

Parameters
----------
date : str
日期字符串, 格式: 20230630

Returns
-------
Bool
True: 是, False: 否

Examples
--------
>>> import efinance as ef
>>> ef.stock.is_trading_day('20230630')
True
"""
if is_workday(datetime.strptime(date, '%Y%m%d')):
if datetime.isoweekday(date) < 6:
return True
return False
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ retry
multitasking
jsonpath
rich
beautifulsoup4
beautifulsoup4
chinese_calendar