Files
dekun 75b9bffe96 Add auto break-even toggle and WeCom hub notifications.
Desktop can auto-pull stop to open+/-1 after a 3$ favorable move; hub pushes open/close events and a 23:00 BJT daily summary via webhook.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-27 11:25:44 +08:00

53 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
from __future__ import annotations
from typing import Any
from flask import Flask
from app.config import Config
from app.db import init_db, seed_if_empty
from app.routes import register_routes
def _fmt_price(value: Any, digits: int = 3) -> str:
"""价格展示:固定小数位,避免浮点尾巴。"""
if value is None or value == "":
return "—"
try:
return f"{float(value):.{int(digits)}f}"
except (TypeError, ValueError):
return str(value)
def _fmt_money(value: Any, digits: int = 2) -> str:
if value is None or value == "":
return "—"
try:
return f"{float(value):.{int(digits)}f}"
except (TypeError, ValueError):
return str(value)
def create_app() -> Flask:
app = Flask(__name__, template_folder="templates", static_folder="static")
app.config.from_object(Config)
app.secret_key = Config.SECRET_KEY
app.jinja_env.filters["fmt_price"] = _fmt_price
app.jinja_env.filters["fmt_money"] = _fmt_money
init_db()
seed_if_empty()
register_routes(app)
# 企业微信 23:00 日报(daemon 线程;多 worker 靠锁文件去重)
try:
from app.scheduler import start_background_jobs
start_background_jobs()
except Exception: # noqa: BLE001
pass
return app