fix: DB路径大面积修复——mofin_db/server/technical_analysis/strategy_tree等脚本的Path(__file__).parent/data错误指向scripts/data而非data/ 导致读写分离
- 量价分析: full_analysis输出volume_deep+成交量存储在price_history.json - FK约束移除: holding_strategies外键->holdings阻止自选股写入 - #000850 重评已写入(止损3.74/止盈4.06/RR1.67)含量价信号
This commit is contained in:
@@ -17,7 +17,7 @@ import urllib.error
|
||||
from datetime import datetime, date, timedelta
|
||||
from typing import Optional
|
||||
|
||||
DATA_DIR = "/home/hmo/web-dashboard/data"
|
||||
DATA_DIR = "/home/hmo/MoFin/data"
|
||||
HISTORY_PATH = os.path.join(DATA_DIR, "price_history.json")
|
||||
# multi_tf_cache.json 已迁移到 DB (mtf_cache 表)
|
||||
|
||||
@@ -92,7 +92,7 @@ def _load_mtf_cache():
|
||||
return _MTF_CACHE_DATA
|
||||
try:
|
||||
import sqlite3
|
||||
db = sqlite3.connect('/home/hmo/web-dashboard/data/mofin.db')
|
||||
db = sqlite3.connect('/home/hmo/MoFin/data/mofin.db')
|
||||
rows = db.execute("SELECT code, cache_json FROM mtf_cache").fetchall()
|
||||
_MTF_CACHE_DATA = {}
|
||||
for code, json_str in rows:
|
||||
@@ -113,7 +113,7 @@ def _save_mtf_cache():
|
||||
return
|
||||
try:
|
||||
import sqlite3
|
||||
db = sqlite3.connect('/home/hmo/web-dashboard/data/mofin.db')
|
||||
db = sqlite3.connect('/home/hmo/MoFin/data/mofin.db')
|
||||
for code, data in _MTF_CACHE_DATA.items():
|
||||
db.execute(
|
||||
"INSERT OR REPLACE INTO mtf_cache (code, cache_json, updated_at) VALUES (?,?,datetime('now','localtime'))",
|
||||
@@ -222,9 +222,21 @@ def calc_moving_averages(klines: list, windows: list = [5, 10, 20, 60]) -> dict:
|
||||
return {f"ma{w}": None for w in windows}
|
||||
|
||||
# 确保按时间正序(旧的在前)
|
||||
# 使用日期判断顺序(不能用价格:下跌趋势下closes[0]>closes[-1]也会触发反转)
|
||||
closes = [k["close"] for k in klines]
|
||||
# 检查是否倒序(最新的在前)
|
||||
if len(closes) >= 2 and closes[0] > closes[-1]:
|
||||
is_reversed = False
|
||||
if len(klines) >= 2:
|
||||
d0 = klines[0].get("date", "")
|
||||
d1 = klines[-1].get("date", "")
|
||||
if d0 and d1:
|
||||
from datetime import datetime
|
||||
try:
|
||||
is_reversed = datetime.strptime(d0, "%Y-%m-%d") > datetime.strptime(d1, "%Y-%m-%d")
|
||||
except:
|
||||
# 日期格式不对时的fallback: 仅当首价显著高于末价才判定倒序(50%阈值)
|
||||
is_reversed = (closes[0] > closes[-1] * 1.5) if len(closes) >= 2 else False
|
||||
|
||||
if is_reversed:
|
||||
closes = list(reversed(closes))
|
||||
|
||||
result = {}
|
||||
|
||||
Reference in New Issue
Block a user