Time Series
Forecast data is served in a similar way to Signal data but the query approach
is much more explicit. The endpoint to access the data is Get Forecast Data
:
http://api.clearmacro.com/api/v3/forecast/market/{market_code}/currency/{currency_iso}/horizon/{horizon_name}/data/
Which takes the path parameters:
market_code: The market code you want a forecast for
currency_iso: The currency iso code of the forecast
horizon_name: The time horizon you want the forecast over
Values for all of these parameters can be found by using the other informational forecast endpoints.
By default the data will be returned in Parquet
format which can be easily read and
manipulated using the Pandas
framework in Python
.
- Python
- Curl
import io
import pandas as pd
import requests
url = "https://api.clearmacro.com/api/v3/forecast/market/EQTUS/currency/USD/horizon/10%20Years/data/?fmt=parquet"
headers = {"X-API-KEY": "YOUR_API_KEY"}
response = requests.get(url=url, headers=headers)
if 200 <= response.status_code < 299:
# On successful request load data into to pandas dataframe
dataframe = pd.read_parquet(io.BytesIO(response.content))
else:
# If the request failed, print the error code and message
print("Error occurred")
print("{response.status_code}: {response.content}")
curl -X "GET" \
https://api.clearmacro.com/api/v3/forecast/market/EQTUS/currency/USD/horizon/10%20Years/data/?fmt=parquet
-H "X-API-KEY:$API_KEY" > EQTUS_USD_10_Years.parquet
Data Structure
The data structure of a forecast dataframe is much more complex than signals and supports numerous columns and will look something like this:
| Date | Forecast | _Trend | _Trend_Growth | _Trend_Income | _Trend_Valuation |
|------------|----------|-----------|---------------|---------------|------------------|
| 1990-07-02 | 0.083477 | 0.083477 | 0.056477 | 0.030647 | -0.003648 |
| 1990-07-03 | 0.083493 | 0.083493 | 0.056456 | 0.030655 | -0.003619 |
| 1990-07-04 | 0.083508 | 0.083508 | 0.056436 | 0.030663 | -0.003591 |
| 1990-07-05 | 0.084066 | 0.084066 | 0.056416 | 0.031064 | -0.003414 |
| 1990-07-06 | 0.083538 | 0.083538 | 0.056396 | 0.030679 | -0.003537 |
| ... ... ... ... ... ...
| 2023-08-20 | 0.056501 | 0.056501 | 0.053200 | 0.017416 | -0.014116 |
| 2023-08-21 | 0.056237 | 0.056237 | 0.053200 | 0.017342 | -0.014305 |
| 2023-08-22 | 0.056251 | 0.056251 | 0.053200 | 0.017416 | -0.014365 |
| 2023-08-23 | 0.055592 | 0.055592 | 0.053200 | 0.017194 | -0.014803 |
| 2023-08-24 | 0.055592 | 0.055592 | 0.053200 | 0.017194 | -0.014803 |
The columns you will find in our Forecast dataframes are as follows:
- Forecast - Our overall forecast for a market.
- _Trend - The
Trend
contribution to our overall forecast. - _Trend_Growth - The
Growth
contribution to ourTrend
forecast. - _Trend_Income - The
Income
contribution to ourTrend
forecast. - _Trend_Valuation- The
Valuation
contribution to ourTrend
forecast. - Cyclical - The
Cyclical
contribution to our overall forecast - _Cyclical_Contraction - The
Contraction
contribution to ourCyclical
forecast. - _Cyclical_Recovery - The
Recovery
contribution to ourCyclical
forecast. - _Cyclical_Expansion - The
Expansion
contribution to ourCyclical
forecast. - _Cyclical_Slowdown - The
Slowdown
contribution to ourCyclical
forecast. - Tactical - The
Tactical
contribution to our overall forecast. - _Tactical_Fundamentals - The
Fundamentals
contribution to ourTactical
forecast. - _Tactical_Market_Technicals - The
Market Technicals
contribution to ourTactical
forecast.
You will find that each contribution level sums to that levels stated forecast.
For example:
Forecast
is the sum of Trend
, Cyclical
& Tactical
.
Trend
is the sum of _Trend_Growth
, _Trend_Income
& _Trend_Valuation
Approach
You can find a detailed explaination about our overall methodology to generating forecasts and what each of the columns represent here.
Alternative data formats
As with Signals, if you wish to load the data into Excel or work on it in another programming
language that does not have a dataframe
analogue; you can also request the data
in CSV
or JSON
formats by using the fmt
parameter.
- Curl
curl -X "GET" \
https://api.clearmacro.com/api/v3/forecast/market/EQTUS/currency/USD/horizon/10%20Years/data/?fmt=json
-H "X-API-KEY:$API_KEY" > EQTUS_USD_10_YEARS.json
More information about each data format can be found using the following links: