- FastAPI + NiceGUI web application - QuantLib-based Black-Scholes pricing with Greeks - Protective put, laddered, and LEAPS strategies - Real-time WebSocket updates - TradingView-style charts via Lightweight-Charts - Docker containerization - GitLab CI/CD pipeline for VPS deployment - VPN-only access configuration
41 lines
985 B
Python
41 lines
985 B
Python
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
from dataclasses import dataclass
|
|
|
|
from app.models.portfolio import LombardPortfolio
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class StrategyConfig:
|
|
"""Common research inputs used by all strategy implementations."""
|
|
|
|
portfolio: LombardPortfolio
|
|
spot_price: float
|
|
volatility: float
|
|
risk_free_rate: float
|
|
|
|
|
|
class BaseStrategy(ABC):
|
|
"""Abstract strategy interface for paper-based hedge analysis."""
|
|
|
|
def __init__(self, config: StrategyConfig) -> None:
|
|
self.config = config
|
|
|
|
@property
|
|
@abstractmethod
|
|
def name(self) -> str: # pragma: no cover - interface only
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def calculate_cost(self) -> dict:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def calculate_protection(self) -> dict:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def get_scenarios(self) -> list[dict]:
|
|
raise NotImplementedError
|