File size: 2,446 Bytes
72fc0ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""
QuantLib Pro SDK — Market Analysis Resource
"""
from typing import Any, Dict, List
from quantlib_api.resources.base import BaseResource


class MarketAnalysisResource(BaseResource):
    """Technical indicators and market analysis."""

    PREFIX = "/api/v1/market-analysis"

    def technical_analysis(
        self,
        ticker: str,
        indicators: List[str] = None,
        lookback_days: int = 60,
    ) -> Dict[str, Any]:
        """
        Calculate technical indicators.

        Parameters
        ----------
        ticker : str
            Stock ticker symbol
        indicators : list of str
            Indicators to compute (e.g., ["RSI", "MACD", "BB", "ATR", "SMA", "EMA"])
        lookback_days : int
            Historical lookback period

        Returns
        -------
        dict
            Indicator values and signals
        """
        return self._http.post(
            self._url("/technical-analysis"),
            json={
                "ticker": ticker,
                "indicators": indicators or ["RSI", "MACD", "BB", "ATR", "SMA_20", "EMA_12"],
                "lookback_days": lookback_days,
            },
        )

    def volatility_comparison(
        self,
        tickers: List[str],
        period_days: int = 30,
    ) -> Dict[str, Any]:
        """Compare volatility across multiple tickers."""
        return self._http.post(
            self._url("/volatility-comparison"),
            json={"tickers": tickers, "period_days": period_days},
        )

    def trend_analysis(
        self,
        ticker: str,
        lookback_days: int = 60,
    ) -> Dict[str, Any]:
        """Analyze price trend using linear regression and Hurst exponent."""
        return self._http.post(
            self._url("/trend-analysis"),
            json={"ticker": ticker, "lookback_days": lookback_days},
        )

    def screener(
        self,
        criteria: str = "oversold",
        universe: List[str] = None,
    ) -> Dict[str, Any]:
        """Screen stocks by technical criteria."""
        return self._http.get(
            self._url("/screener"),
            params={
                "criteria": criteria,
                "universe": ",".join(universe) if universe else None,
            },
        )

    def price_levels(self, ticker: str) -> Dict[str, Any]:
        """Calculate support and resistance levels."""
        return self._http.get(self._url(f"/price-levels/{ticker}"))