refactor(market_data): 优化交易日和停牌状态检查逻辑
- 精简导入,移除未使用的functools.lru_cache依赖 - 新增is_trading_day函数,基于缓存交易日期集合快速判断交易日 - 优化get_latest_trade_date函数,避免整文件读取,改为逐行读取首条有效数据 - 简化calculate_trading_days_diff日期处理,改用字符串直接比较日期顺序 - 重构check_stock_suspended函数,统一处理单日和区间停牌数据格式并改进日志记录 - 统一输出字段命名,替换中文字段为英文is_suspended和suspend_dates - 规范日志和打印输出,修正检查文件数和检查日期显示 - 优化输出CSV字段顺序和内容,保证数据一致性和清晰度
This commit is contained in:
13
test_time.py
Normal file
13
test_time.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import datetime
|
||||
|
||||
now = datetime.datetime.now()
|
||||
print('当前时间:', now)
|
||||
print('小时:', now.hour)
|
||||
|
||||
if now.hour < 16:
|
||||
yesterday = now - datetime.timedelta(days=1)
|
||||
check_date = yesterday.strftime('%Y%m%d')
|
||||
print('检查日期:', check_date)
|
||||
else:
|
||||
check_date = now.strftime('%Y%m%d')
|
||||
print('检查日期:', check_date)
|
||||
Reference in New Issue
Block a user