refactor: rename stock-lab → stock (graduation)
- git mv stock-lab/ → stock/ - docker-compose.yml: 서비스 키 + container_name + build.context + frontend.depends_on + agent-office STOCK_LAB_URL → STOCK_URL - agent-office/app: config.py, service_proxy.py, agents/stock.py, tests/ STOCK_LAB_URL → STOCK_URL - nginx/default.conf: proxy_pass http://stock-lab → http://stock (3 lines) - CLAUDE.md / README.md / STATUS.md / scripts/ 문구 갱신 - stock/ 내부 자기 참조 갱신 lab 네이밍 정책 (feedback_lab_naming.md) graduation. API URL / Python import / DB 파일명 변경 없음.
This commit is contained in:
40
stock/app/screener/nodes/base.py
Normal file
40
stock/app/screener/nodes/base.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""Node base classes + helpers."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any, ClassVar
|
||||
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class ScoreNode(ABC):
|
||||
name: ClassVar[str]
|
||||
label: ClassVar[str]
|
||||
default_params: ClassVar[dict]
|
||||
param_schema: ClassVar[dict]
|
||||
|
||||
@abstractmethod
|
||||
def compute(self, ctx: "Any", params: dict) -> pd.Series:
|
||||
"""returns Series indexed by ticker, 0..100 float."""
|
||||
|
||||
|
||||
class GateNode(ABC):
|
||||
name: ClassVar[str]
|
||||
label: ClassVar[str]
|
||||
default_params: ClassVar[dict]
|
||||
param_schema: ClassVar[dict]
|
||||
|
||||
@abstractmethod
|
||||
def filter(self, ctx: "Any", params: dict) -> pd.Index:
|
||||
"""returns surviving tickers."""
|
||||
|
||||
|
||||
def percentile_rank(series: pd.Series) -> pd.Series:
|
||||
"""Percentile rank in [0, 100]. All-equal → 50. NaN preserved."""
|
||||
if series.empty:
|
||||
return series.astype(float)
|
||||
if series.dropna().nunique() == 1:
|
||||
return pd.Series(50.0, index=series.index)
|
||||
ranked = series.rank(pct=True, na_option="keep") * 100.0
|
||||
return ranked
|
||||
Reference in New Issue
Block a user