Skip to content

Instantly share code, notes, and snippets.

View anzchy's full-sized avatar

Jack Cheng anzchy

View GitHub Profile
@anzchy
anzchy / Recent_trade_day
Last active October 17, 2025 05:17
recent_trade_day #Python
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:
"""
返回最近的完整交易日:
- 若未指定日期,使用当前时间判断
- 若指定日期,基于该日期判断最近的交易日
"""
@anzchy
anzchy / duckdb_utils.py
Created October 17, 2025 04:43
Duckdb utils #Python #Database
# duckdb_utils.py
import os
from typing import Optional, Union, Iterable, Any
import duckdb
import pandas as pd
class DuckDBWrapper:
"""
@anzchy
anzchy / Is_trading_day method
Last active October 17, 2025 04:46
Is_trading_day #Python
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"