feat libs,sdk,trend

This commit is contained in:
2026-09-07 14:04:26 +08:00
parent d37f9edefc
commit e320de3241
30 changed files with 515 additions and 507 deletions

View File

@@ -34,6 +34,7 @@ logging.getLogger("httpx").setLevel(logging.WARNING)
from sdk import APIError, Client
from libs.market import refresh_market
from libs.collector import submit_trend_data
from strategy.trend.boot import StartTrend
from strategy.zt.boot import StartZT
from strategy.ipo import AutoBuyIpo
@@ -109,6 +110,7 @@ def wait_for_any_key() -> None:
def main() -> int:
scheduler = None
try:
if not require_windows():
logging.error("本程序仅支持 Windows 环境运行")
@@ -143,18 +145,29 @@ def main() -> int:
replace_existing=True,
next_run_time=datetime.now(),
)
scheduler.add_job(
submit_trend_data,
trigger="interval",
minutes=5,
id="trend_collector",
replace_existing=True,
)
logging.info("趋势策略数据提交任务已注册每5分钟读取缓存提交")
scheduler.start()
logging.info("IPO 自动打新定时任务已启动:每日 10:00、14:00")
logging.info("大盘信号后台刷新已启动:每分钟一次")
STRATEGIES[config.account_config.strategy].start_strategy()
logging.info("%s 策略启动成功",config.account_config.strateg)
logging.info("%s 策略已结束", config.account_config.strategy)
return 0
except (OSError, yaml.YAMLError, ValueError, RuntimeError, KeyError) as e:
print(f"启动失败: {e}", file=sys.stderr, flush=True)
traceback.print_exception(type(e), e, e.__traceback__)
wait_for_any_key()
return 1
finally:
if scheduler is not None and scheduler.running:
scheduler.shutdown(wait=True)
if __name__ == "__main__":