This commit is contained in:
2026-08-29 01:50:09 +08:00
parent 28e91366d6
commit 846d6c03e0
11 changed files with 490 additions and 15 deletions

View File

@@ -1,5 +1,17 @@
from .calc import calc_buy_volume, trading_time
from .lockfile import is_lock, write_lockfile
from .market import market_allow_open, status
from .signal import SignalItem, SignalResult, fetch_signal, init_signals
__all__ = ["calc_buy_volume", "trading_time", "market_allow_open", "status", "SignalItem", "SignalResult", "fetch_signal", "init_signals"]
__all__ = [
"calc_buy_volume",
"trading_time",
"is_lock",
"write_lockfile",
"market_allow_open",
"status",
"SignalItem",
"SignalResult",
"fetch_signal",
"init_signals",
]

View File

@@ -0,0 +1,18 @@
"""简单的文件锁标记工具。"""
from __future__ import annotations
from os import PathLike
from pathlib import Path
def is_lock(file_path: str | PathLike[str]) -> bool:
"""判断指定的锁文件是否存在。"""
return Path(file_path).is_file()
def write_lockfile(file_path: str | PathLike[str]) -> None:
"""创建锁文件;父目录不存在时自动创建。"""
path = Path(file_path)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text("LOCK", encoding="utf-8")