Spaces:
Sleeping
Sleeping
Commit
·
8aa5811
1
Parent(s):
f95a740
fetch_forecast: load_dotenv only in the if main block
Browse files- src/fetch_forecast.py +4 -4
src/fetch_forecast.py
CHANGED
|
@@ -18,10 +18,8 @@ class FetchForecast:
|
|
| 18 |
# args
|
| 19 |
self.ticker = ticker
|
| 20 |
# constants
|
| 21 |
-
self.past_horizon =
|
| 22 |
-
#
|
| 23 |
-
# load the env variables fom .env file
|
| 24 |
-
dotenv.load_dotenv(dotenv.find_dotenv())
|
| 25 |
self.api_env = os.environ.get("FORECAST_API_ENV")
|
| 26 |
api_url_temp = os.environ.get("API_URL_TEMPLATE")
|
| 27 |
self.api_url = api_url_temp.replace("ENV", self.api_env)
|
|
@@ -52,6 +50,8 @@ class FetchForecast:
|
|
| 52 |
|
| 53 |
|
| 54 |
if __name__ == "__main__":
|
|
|
|
|
|
|
| 55 |
past_df, fcst_df = FetchForecast("AAPL").run()
|
| 56 |
print("Last available price:\n", past_df.tail(1))
|
| 57 |
print("Forecasts:\n", fcst_df.head())
|
|
|
|
| 18 |
# args
|
| 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")
|
| 25 |
self.api_url = api_url_temp.replace("ENV", self.api_env)
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
if __name__ == "__main__":
|
| 53 |
+
# load the env variables fom .env file
|
| 54 |
+
dotenv.load_dotenv(dotenv.find_dotenv())
|
| 55 |
past_df, fcst_df = FetchForecast("AAPL").run()
|
| 56 |
print("Last available price:\n", past_df.tail(1))
|
| 57 |
print("Forecasts:\n", fcst_df.head())
|