πŸš€ Nexus Agent V5.5: 3λΆ„ 퀡 μŠ€νƒ€νŠΈ κ°€μ΄λ“œ (μ‚¬μš© 방법)

<aside> βœ… κ΅¬λ…μž μ—¬λŸ¬λΆ„, μ•„λž˜ μˆœμ„œλŒ€λ‘œ νŒŒμΌμ„ λ§Œλ“€κ³  μ‹€ν–‰λ§Œ ν•˜μ‹œλ©΄ λ―Έκ΅­ μ‹œμž₯ 전체λ₯Ό μŠ€μΊ”ν•˜λŠ” AI μ—μ΄μ „νŠΈκ°€ κ°€λ™λ©λ‹ˆλ‹€.

</aside>

<b>1단계:</b> λ™μΌν•œ 폴더에 μ•„λž˜ 제곡된 3개의 파이썬 파일(data_loader.py, analysis_core.py, nexus_run.py)을 λ§Œλ“­λ‹ˆλ‹€.\\n<b>2단계:</b> nexus_run.py μƒλ‹¨μ˜ CAPITAL_KRW에 본인의 νˆ¬μžκΈˆμ„ μž…λ ₯ν•©λ‹ˆλ‹€.\\n<b>3단계:</b> 터미널(CMD)μ—μ„œ python nexus_run.pyλ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.


βš™οΈ μ‹œμž₯ μœ λ‹ˆλ²„μŠ€ 선택 방법

nexus_run.py 파일의 9행에 μžˆλŠ” target_universe λ³€μˆ˜λ₯Ό μˆ˜μ •ν•˜μ—¬ 뢄석 λŒ€μƒμ„ λ°”κΏ€ 수 μžˆμŠ΅λ‹ˆλ‹€.

target_universe = "nasdaq100"  # λ‚˜μŠ€λ‹₯ 100만 뢄석
target_universe = "sp500"      # S&P 500 μ „μˆ˜ 쑰사
target_universe = "smallcap"   # 슀λͺ°μΊ‘(주도주ꡰ) 뢄석
target_universe = "all"        # λ‚˜μŠ€λ‹₯+S&P+슀λͺ°μΊ‘ 톡합 뢄석 (κ°•λ ₯ μΆ”μ²œ!)

πŸ› οΈ μ™„μ„±ν˜• 톡합 μ†ŒμŠ€μ½”λ“œ (V5.5)

1. data_loader.py (μ „λ―Έ μ‹œμž₯ μœ λ‹ˆλ²„μŠ€ μˆ˜μ§‘κΈ°)

2. analysis_core.py (μ „λž΅ μ—°μ‚° μ—”μ§„)

3. nexus_run.py (μ˜€μΌ€μŠ€νŠΈλ ˆμ΄ν„° - μ‹€ν–‰ 파일)

1. data_loader.py (μ „λ―Έ μ‹œμž₯ μœ λ‹ˆλ²„μŠ€ μˆ˜μ§‘κΈ°)

# data_loader.py
import yfinance as yf
import pandas as pd
from typing import List, Optional

def get_market_universe(index_type: str = "nasdaq100") -> List[str]:
    """μ„ νƒν•œ μ§€μˆ˜μ˜ 티컀 λͺ©λ‘ μžλ™ μˆ˜μ§‘ (all 선택 μ‹œ 톡합 μˆ˜μ§‘)"""
    try:
        tickers = []
        if index_type in ["nasdaq100", "all"]:
            url = "<https://en.wikipedia.org/wiki/Nasdaq-100>"
            tickers += pd.read_html(url)[4]['Ticker'].tolist()
        if index_type in ["sp500", "all"]:
            url = "<https://en.wikipedia.org/wiki/List_of_S%26P_500_companies>"
            tickers += pd.read_html(url)[0]['Symbol'].tolist()
        if index_type in ["smallcap", "all"]:
            tickers += ["CIFR", "MRAM", "INOD", "MSTR", "CLSK", "MARA", "RIOT", "WULF"]
        return list(set(tickers)) # 쀑볡 제거
    except Exception as e:
        print(f"Error fetching universe: {e}")
        return ["TSLA", "NVDA", "AVGO", "PLTR"]

def fetch_historical_data(ticker: str, period="1y"):
    data = yf.download(ticker, period=period, progress=False)
    if data.empty: return None
    if isinstance(data.columns, pd.MultiIndex):
        data.columns = ['_'.join(col).strip() for col in data.columns]
    return data

2. analysis_core.py (μ „λž΅ μ—°μ‚° μ—”μ§„)

# analysis_core.py
import pandas as pd
import numpy as np

def analyze_v6_vcp_quantitative(data):
    """RS 점수 및 VCP(변동성 μˆ˜μΆ•) 뢄석"""
    if len(data) < 100: return 0, 0
    close = data['Close']
    rs_score = (close.iloc[-1] / close.iloc[-63]) - 1 # 3κ°œμ›” 수읡λ₯  기반 RS
    
    high_low = data['High'] - data['Low']
    high_close = np.abs(data['High'] - close.shift(1))
    low_close = np.abs(data['Low'] - close.shift(1))
    atr = pd.concat([high_low, high_close, low_close], axis=1).max(axis=1).rolling(14).mean().iloc[-1]
    return rs_score, atr

def calculate_v7_sizing(price, atr, risk_amt, cap_amt):
    """이쀑 리슀크 관리 사이징"""
    stop_dist = max(atr * 1.5, price * 0.05)
    shares = min(risk_amt / stop_dist, cap_amt / price)
    return int(shares), price - stop_dist

3. nexus_run.py (μ˜€μΌ€μŠ€νŠΈλ ˆμ΄ν„° - μ‹€ν–‰ 파일)

# nexus_run.py
from data_loader import get_market_universe, fetch_historical_data
from analysis_core import analyze_v6_vcp_quantitative, calculate_v7_sizing
import pandas as pd
from datetime import datetime

# [μ„€μ •] 본인의 상황에 맞게 μˆ˜μ •ν•˜μ„Έμš”
CAPITAL_KRW = 10000000   # 투자 μ›κΈˆ (KRW)
target_universe = "all"   # nasdaq100, sp500, smallcap, all 쀑 선택
FX_RATE = 1350

risk_usd = (CAPITAL_KRW * 0.01) / FX_RATE
cap_usd = (CAPITAL_KRW * 0.25) / FX_RATE

if __name__ == "__main__":
    print(f"πŸš€ Nexus Agent V5.5 가동... μœ λ‹ˆλ²„μŠ€: {target_universe}")
    tickers = get_market_universe(target_universe)
    results = []
    
    for t in tickers:
        df = fetch_historical_data(t)
        if df is None: continue
        rs, atr = analyze_v6_vcp_quantitative(df)
        if rs < 0.2: continue # κ°•ν•œ μ’…λͺ©λ§Œ 선별
        
        price = df['Close'].iloc[-1]
        shares, sl = calculate_v7_sizing(price, atr, risk_usd, cap_usd)
        if shares > 0:
            results.append([t, round(rs, 2), price, shares, round(sl, 2)])
            print(f"   [발꡴] {t} | RS: {rs:.2f} | μΆ”μ²œ: {shares}μ£Ό")

    report = pd.DataFrame(results, columns=['Ticker', 'RS', 'Price', 'Shares', 'StopLoss'])
    print("\n" + "="*50 + "\nμ΅œμ’… 뢄석 리포트\n" + "="*50)
    print(report.sort_values(by='RS', ascending=False).to_markdown(index=False))