File size: 1,796 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
"""
QuantLib Pro SDK — Macro Resource
"""
from typing import Any, Dict, List
from quantlib_api.resources.base import BaseResource


class MacroResource(BaseResource):
    """Macro analysis and economic indicators."""

    PREFIX = "/api/v1/macro"

    def indicators(
        self,
        indicators: List[str] = None,
        period: str = "1Y",
    ) -> Dict[str, Any]:
        """
        Get economic indicator values from FRED.

        Parameters
        ----------
        indicators : list of str
            Indicator codes (e.g., ["GDP_GROWTH", "UNEMPLOYMENT", "CPI", "FED_RATE"])
        period : str
            Time period (e.g., "1Y", "5Y", "10Y")

        Returns
        -------
        dict
            Real economic indicator values and time series from Federal Reserve
        """
        return self._http.post(
            self._url("/indicators"),
            json={
                "indicators": indicators or ["GDP_GROWTH", "UNEMPLOYMENT", "CPI", "FED_RATE"],
                "period": period,
            },
        )

    def correlation_regime(
        self,
        asset: str,
        macro_indicators: List[str] = None,
    ) -> Dict[str, Any]:
        """Analyze correlation regime between asset and macro indicators."""
        return self._http.post(
            self._url("/correlation-regime"),
            json={
                "asset": asset,
                "macro_indicators": macro_indicators or ["SPY", "TLT", "GLD", "DXY"],
            },
        )

    def sentiment(
        self,
        sources: List[str] = None,
    ) -> Dict[str, Any]:
        """Get market sentiment indicators."""
        return self._http.get(
            self._url("/sentiment"),
            params={"sources": ",".join(sources or ["vix", "put_call", "aaii"])},
        )