Spaces:
Sleeping
Sleeping
Commit
·
8726d5b
1
Parent(s):
445f538
fetch_forecast: API endpoint defined in init
Browse files- src/fetch_forecast.py +2 -1
src/fetch_forecast.py
CHANGED
|
@@ -19,6 +19,7 @@ class FetchForecast:
|
|
| 19 |
self.ticker = ticker
|
| 20 |
# constants
|
| 21 |
self.past_horizon = 5 # number of past business days
|
|
|
|
| 22 |
# build the api-url based on env variables
|
| 23 |
self.api_env = os.environ.get("FORECAST_API_ENV")
|
| 24 |
api_url_temp = os.environ.get("API_URL_TEMPLATE")
|
|
@@ -31,7 +32,7 @@ class FetchForecast:
|
|
| 31 |
def call_api(self) -> tuple:
|
| 32 |
pl_in = {"ticker": self.ticker, "past_horizon": self.past_horizon}
|
| 33 |
self.logger.info(f"Calling forecast API ({self.api_env}) for ticker: {self.ticker}")
|
| 34 |
-
resp = requests.post(f"{self.api_url}/
|
| 35 |
if resp.status_code == 200:
|
| 36 |
data = resp.json()
|
| 37 |
past_df, fcst_df = self.transform_data(data)
|
|
|
|
| 19 |
self.ticker = ticker
|
| 20 |
# constants
|
| 21 |
self.past_horizon = 5 # number of past business days
|
| 22 |
+
self.endpoint = "v1/forecast/from_symbol"
|
| 23 |
# build the api-url based on env variables
|
| 24 |
self.api_env = os.environ.get("FORECAST_API_ENV")
|
| 25 |
api_url_temp = os.environ.get("API_URL_TEMPLATE")
|
|
|
|
| 32 |
def call_api(self) -> tuple:
|
| 33 |
pl_in = {"ticker": self.ticker, "past_horizon": self.past_horizon}
|
| 34 |
self.logger.info(f"Calling forecast API ({self.api_env}) for ticker: {self.ticker}")
|
| 35 |
+
resp = requests.post(f"{self.api_url}/{self.endpoint}", json=pl_in, timeout=30)
|
| 36 |
if resp.status_code == 200:
|
| 37 |
data = resp.json()
|
| 38 |
past_df, fcst_df = self.transform_data(data)
|