refactor: GT·시뮬·운영 3축 정리 및 hybrid 실거래 정합
Phase C/dry-run·미사용 모듈·재생성 HTML을 제거하고, 운영 체결을 sim_causal_hybrid와 동일한 hybrid 로직으로 통합한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
모든 봉(1~1440분)에 BB·일목 위치·캔들 형태 특징을 계산하고
|
||||
모든 봉(3~1440분 등)에 BB·일목 위치·캔들 형태 특징을 계산하고
|
||||
기준 타임라인(3분)에 맞춰 정렬합니다.
|
||||
"""
|
||||
|
||||
|
||||
@@ -281,6 +281,36 @@ def latest_indicator_snapshot(df: pd.DataFrame) -> dict[str, float | str | None]
|
||||
}
|
||||
|
||||
|
||||
def _trend_from_ma20(df: pd.DataFrame) -> Trend:
|
||||
"""
|
||||
단일 TF에서 종가·MA20·MA40 관계로 추세를 판정합니다.
|
||||
|
||||
Args:
|
||||
df: OHLCV+지표 DataFrame.
|
||||
|
||||
Returns:
|
||||
up | down | range.
|
||||
"""
|
||||
if len(df) < 20:
|
||||
return "range"
|
||||
close = float(df["Close"].iloc[-1])
|
||||
ma20_col = "MA20" if "MA20" in df.columns else "MA"
|
||||
if ma20_col not in df.columns:
|
||||
return "range"
|
||||
ma20 = float(df[ma20_col].iloc[-1])
|
||||
ma40 = float(df["MA40"].iloc[-1]) if "MA40" in df.columns and len(df) >= 40 else ma20
|
||||
if ma40 == 0:
|
||||
return "range"
|
||||
gap = abs(ma20 - ma40) / ma40 * 100
|
||||
if gap < TREND_RANGE_MA_GAP_PCT:
|
||||
return "range"
|
||||
if close > ma20 and ma20 > ma40:
|
||||
return "up"
|
||||
if close < ma20 and ma20 < ma40:
|
||||
return "down"
|
||||
return "range"
|
||||
|
||||
|
||||
def get_trend(df_1d: pd.DataFrame, df_1h: pd.DataFrame) -> Trend:
|
||||
"""
|
||||
일봉·1시간봉 기준 추세(up/down/range)를 반환합니다.
|
||||
@@ -313,3 +343,28 @@ def get_trend(df_1d: pd.DataFrame, df_1h: pd.DataFrame) -> Trend:
|
||||
if d_close < d_ma20 and h_ma20 < h_ma40 and h_close < h_ma20:
|
||||
return "down"
|
||||
return "range"
|
||||
|
||||
|
||||
def get_mtf_trend_summary(
|
||||
frames: dict[int, pd.DataFrame],
|
||||
interval_keys: tuple[int, ...],
|
||||
) -> dict[str, str]:
|
||||
"""
|
||||
여러 TF의 종가·이동평균 기준 추세 요약(주·월봉 포함).
|
||||
|
||||
Args:
|
||||
frames: interval → OHLCV+지표.
|
||||
interval_keys: 요약할 간격(분) 목록.
|
||||
|
||||
Returns:
|
||||
interval_label → up/down/range.
|
||||
"""
|
||||
from deepcoin.data.mtf_bb import interval_label
|
||||
|
||||
out: dict[str, str] = {}
|
||||
for iv in interval_keys:
|
||||
df = frames.get(iv)
|
||||
if df is None or df.empty:
|
||||
continue
|
||||
out[interval_label(iv)] = _trend_from_ma20(df)
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user