Download strategy/base.py from raghava4u/Trading-Bot-M20: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/raghava4u/Trading-Bot-M20/resolve/main/strategy/base.py
- Command line
-
hf download hf://raghava4u/Trading-Bot-M20/strategy/base.py
-
curl -L -o base.py https://huggingface.co/raghava4u/Trading-Bot-M20/resolve/main/strategy/base.py
1.21 kB
| """ | |
| strategy/base.py — Abstract strategy interface. | |
| All strategies must implement generate_signal(). | |
| """ | |
| from __future__ import annotations | |
| from abc import ABC, abstractmethod | |
| import pandas as pd | |
| from contracts import TechnicalScore, PriceTarget | |
| class Strategy(ABC): | |
| """Abstract base class for all trading strategies.""" | |
| name: str = "base" | |
| def generate_signal( | |
| self, | |
| symbol: str, | |
| df_5m: pd.DataFrame, | |
| df_1h: pd.DataFrame | None = None, | |
| df_1d: pd.DataFrame | None = None, | |
| open_positions: dict[str, str] | None = None, | |
| corr_matrix: pd.DataFrame | None = None, | |
| ) -> tuple[TechnicalScore, PriceTarget]: | |
| """Generate a technical signal and price target for a symbol. | |
| Args: | |
| symbol: Stock symbol | |
| df_5m: 5-minute OHLCV bars | |
| df_1h: 1-hour OHLCV bars (optional, for multi-timeframe) | |
| df_1d: Daily OHLCV bars (optional, for trend filter) | |
| open_positions: {symbol: "buy"|"sell"} of open positions | |
| corr_matrix: Correlation matrix for guard | |
| Returns: (TechnicalScore, PriceTarget) | |
| """ | |