전 봉 BB·일목 조합 분석 및 simulation 단일 실행으로 통합
9개 간격(1~1440분) BB·일목 위치 특징을 3분 타임라인에 맞춰 분석하고, discover로 매수·매도 규칙을 찾은 뒤 HTML 차트에 해당 체결만 표시한다. simulation_1h.py를 simulation.py로 변경했으며, 파라미터 없이 실행하면 analyze→discover→차트가 한 번에 수행된다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
57
monitor.py
57
monitor.py
@@ -307,11 +307,14 @@ class Monitor(HTS):
|
||||
|
||||
def process_wld_mtf(self, symbol: str, balances: dict | None = None) -> None:
|
||||
"""
|
||||
WLD MTF: 모든 봉 BB 상태 비교 후 정책에 따라 매수/매도.
|
||||
WLD: 전 봉(1~1440분) BB·일목 위치 조합 매매.
|
||||
|
||||
mtf_bb_policy.json 이 있으면 해당 정책, 없으면 ACTIVE_MTF_POLICY 사용.
|
||||
USE_DISCOVERED_LIVE=True: discovered_rules.json + combination 특징
|
||||
False: mtf_bb_policy.json BB MTF
|
||||
"""
|
||||
from config import USE_DISCOVERED_LIVE
|
||||
from mtf_bb import load_frames_from_db, load_policy, print_latest_states
|
||||
from candle_features import describe_latest_position
|
||||
|
||||
try:
|
||||
frames = load_frames_from_db(self, symbol)
|
||||
@@ -326,29 +329,41 @@ class Monitor(HTS):
|
||||
if df_1h is None or df_1h.empty:
|
||||
df_1h = frames.get(ENTRY_INTERVAL)
|
||||
|
||||
policy = load_policy() or strategy.ACTIVE_MTF_POLICY
|
||||
cfg = strategy.ACTIVE_CONFIG
|
||||
print_latest_states(frames, cfg)
|
||||
print(
|
||||
f"MTF 정책: {policy.name} | "
|
||||
f"매수={policy.buy_interval}분 | 매도={policy.sell_interval}분 | "
|
||||
f"확인={list(policy.buy_confirm_intervals)}"
|
||||
)
|
||||
|
||||
trend = strategy.get_trend(df_1d, df_1h)
|
||||
print(f"{symbol} 추세: {trend}")
|
||||
print("--- 봉별 BB·일목 위치 ---")
|
||||
for iv in sorted(frames.keys()):
|
||||
pos = describe_latest_position(frames[iv], iv)
|
||||
print(
|
||||
f" {pos['label']:>6} | BB {pos['bb_zone']} {pos['bb_state']:>16} | "
|
||||
f"일목 {pos['ichi_position']} TK={pos['ichi_tk']}"
|
||||
)
|
||||
|
||||
entry = frames.get(ENTRY_INTERVAL)
|
||||
trade = strategy.evaluate(
|
||||
symbol,
|
||||
entry if entry is not None else frames[policy.buy_interval],
|
||||
df_1h,
|
||||
df_1d,
|
||||
config=cfg,
|
||||
frames=frames,
|
||||
policy=policy,
|
||||
)
|
||||
if USE_DISCOVERED_LIVE:
|
||||
print("모드: 전봉 BB·일목 조합 (discovered_rules)")
|
||||
trade = strategy.evaluate_discovered_live(
|
||||
symbol, frames, df_1d, df_1h, balances or {}
|
||||
)
|
||||
else:
|
||||
policy = load_policy() or strategy.ACTIVE_MTF_POLICY
|
||||
cfg = strategy.ACTIVE_CONFIG
|
||||
print_latest_states(frames, cfg)
|
||||
print(
|
||||
f"MTF 정책: {policy.name} | 매수={policy.buy_interval}분 | "
|
||||
f"매도={policy.sell_interval}분"
|
||||
)
|
||||
entry = frames.get(ENTRY_INTERVAL)
|
||||
trade = strategy.evaluate(
|
||||
symbol,
|
||||
entry if entry is not None else frames[policy.buy_interval],
|
||||
df_1h,
|
||||
df_1d,
|
||||
config=cfg,
|
||||
frames=frames,
|
||||
policy=policy,
|
||||
)
|
||||
if trade is None:
|
||||
print("신호 없음")
|
||||
return
|
||||
self.execute_trade_signal(symbol, trade, balances=balances)
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user