This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_trading_day(): | |
""" | |
检查当前是否为交易日且已开盘 | |
Returns: | |
tuple: (is_trading_day: bool, trade_day: str, reason: str) | |
""" | |
try: | |
# 从github获取交易日历 | |
csv_path = "https://raw.githubusercontent.com/anzchy/Chinese-Stock-Market-Trading-Calendar/refs/heads/main/trading_calendar.csv" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# duckdb_utils.py | |
import os | |
from typing import Optional, Union, Iterable, Any | |
import duckdb | |
import pandas as pd | |
class DuckDBWrapper: | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from datetime import date, timedelta, datetime | |
from datetime import time as datetime_time | |
def recent_trade_day(d: date | None = None) -> str: | |
""" | |
返回最近的完整交易日: | |
- 若未指定日期,使用当前时间判断 | |
- 若指定日期,基于该日期判断最近的交易日 | |
""" |