Latest
Our API also supports retrieving the latest values of our forecasts for any
market using the Get Latest Forecasts
endpoint. It will return a snapshot
of the latest forecast data and is generally much faster than requesting an
entire time series. This endpoint is useful if you only
need the last data point for a large array of forecasts or want to preliminarily
probe our data sets across specific tags.
Furthermore, this endpoint will also return the current signal attribution data for each forecast (if available).
For example if you wish to query the latest forecast data for the EQTUS
market
on a 6 Month
time horizon you would simply:
- Python
- Curl
from __future__ import annotations # Important for pydantic models to self reference (drivers in Forecast)
import datetime
import requests
import pydantic
class Forecast(pydantic.BaseModel):
kind: str
forecast: float
exposure_adjustment: float = 0.0
drivers: list[Forecast]
class Attribution(pydantic.BaseModel):
signal_code: str
variant: dict[str, str]
forecast: float
class ForecastSummary(pydantic.BaseModel):
market_code: str
currency_iso: str
horizon: str
hedging: str
latest: Forecast
attributions: list[Attribution]
url = "https://api.clearmacro.com/api/v3/forecast/latest/"
headers = {"accept": "application/json", "X-API-KEY": "YOUR_API_KEY"}
response = requests.get(url=url, headers=headers)
forecast_summaries = [ForecastSummary(**forecast_summary) for forecast_summary in response.json()]
curl -X "GET" \
https://api.clearmacro.com/api/v3/forecast/latest/?market_code=EQTUS&horizon_name=6%20Months
-H "X-API-KEY:YOUR_API_KEY" | jq
{
"market_code": "EQTUS",
"currency_iso": "USD",
"horizon": "6 Months",
"hedging": "Unhedged",
"latest": {
"kind": "Forecast",
"forecast": 0.17835077543794708,
"exposure_adjustment": 0,
"drivers": [
{
"kind": "Trend",
"forecast": 0.05422009147170696,
"exposure_adjustment": 0,
"drivers": [
{
"kind": "Growth",
"forecast": 0.05302312753055604,
"exposure_adjustment": 0,
"drivers": []
},
{
"kind": "Income",
"forecast": 0.016977463071729,
"exposure_adjustment": 0,
"drivers": []
},
{
"kind": "Valuation",
"forecast": -0.01578049913057808,
"exposure_adjustment": 0,
"drivers": []
}
]
},
{
"kind": "Cyclical",
"forecast": 0.060924655145862205,
"exposure_adjustment": 0,
"drivers": [
{
"kind": "Contraction",
"forecast": 0.001077255557090151,
"exposure_adjustment": 0,
"drivers": []
},
{
"kind": "Expansion",
"forecast": 0,
"exposure_adjustment": 0,
"drivers": []
},
{
"kind": "Recovery",
"forecast": 0.05981557575804897,
"exposure_adjustment": 0,
"drivers": []
},
{
"kind": "Slowdown",
"forecast": -6.131414043153427e-9,
"exposure_adjustment": 0,
"drivers": []
}
]
},
{
"kind": "Tactical",
"forecast": 0.06320602882037792,
"exposure_adjustment": 0,
"drivers": [
{
"kind": "Fundamentals",
"forecast": 0.06320602882037792,
"exposure_adjustment": 0,
"drivers": []
},
{
"kind": "Market Technicals",
"forecast": 0,
"exposure_adjustment": 0,
"drivers": []
}
]
}
]
},
"attributions": [
{
"signal_code": "CDCON",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "EQDIVYC",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNPOLU",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "EQEARRC",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "EQFRECFC",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNHOU",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNOECCLI",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNLEAACTS",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNIND",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNECOL",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNFRA",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNOFF",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNEXH",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNEXPPUL",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNPOLI",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNBALP",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "EQEARGC",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "EQMARPC",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "CDBUS",
"variant": {
"country_iso": "USA"
},
"forecast": 0.03977627315302938
},
{
"signal_code": "EQVOLC",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNBRE",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "CDIMP",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNPUBSECLI",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "EQPOSLI",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "EQLEVRC",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNSIG",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNINF",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "EQBOLBC",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "EQINDSPB",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "BNDBONVOL",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNBALM",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "EQPOSMI",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNNEWS",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNPRISECLI",
"variant": {
"country_iso": "USA"
},
"forecast": 0.023429755667348538
},
{
"signal_code": "EQFLOC",
"variant": {
"country_iso": "USA"
},
"forecast": 0
},
{
"signal_code": "ECNBAL",
"variant": {
"country_iso": "USA"
},
"forecast": 0
}
]
}