diff --git a/openbb_platform/providers/seeking_alpha/openbb_seeking_alpha/models/forward_eps_estimates.py b/openbb_platform/providers/seeking_alpha/openbb_seeking_alpha/models/forward_eps_estimates.py index 58c7f306ca5..fb0c4458eca 100644 --- a/openbb_platform/providers/seeking_alpha/openbb_seeking_alpha/models/forward_eps_estimates.py +++ b/openbb_platform/providers/seeking_alpha/openbb_seeking_alpha/models/forward_eps_estimates.py @@ -132,9 +132,10 @@ def transform_data( for i in range(0, items - 4): eps_estimates: Dict = {} eps_estimates["symbol"] = ticker - period = seek_object["eps_normalized_num_of_estimates"][str(i)][0].get( - "period", {} - ) + num_estimates = seek_object["eps_normalized_num_of_estimates"].get(str(i)) + if not num_estimates: + continue + period = num_estimates[0].get("period", {}) if period: period_type = period.get("periodtypeid") eps_estimates["calendar_year"] = period.get("calendaryear") @@ -150,9 +151,6 @@ def transform_data( if period_type == "quarterly" else "FY" ) - num_estimates = seek_object["revenue_num_of_estimates"].get(str(i)) - if not num_estimates: - continue eps_estimates["number_of_analysts"] = num_estimates[0].get( "dataitemvalue" ) diff --git a/openbb_platform/providers/seeking_alpha/openbb_seeking_alpha/models/forward_sales_estimates.py b/openbb_platform/providers/seeking_alpha/openbb_seeking_alpha/models/forward_sales_estimates.py index 1bd706ed167..c20e371bac0 100644 --- a/openbb_platform/providers/seeking_alpha/openbb_seeking_alpha/models/forward_sales_estimates.py +++ b/openbb_platform/providers/seeking_alpha/openbb_seeking_alpha/models/forward_sales_estimates.py @@ -114,9 +114,10 @@ def transform_data( for i in range(0, items - 4): rev_estimates: Dict = {} rev_estimates["symbol"] = ticker - period = seek_object["revenue_num_of_estimates"][str(i)][0].get( - "period", {} - ) + num_estimates = seek_object["revenue_num_of_estimates"].get(str(i)) + if not num_estimates: + continue + period = num_estimates[0].get("period", {}) if period: period_type = period.get("periodtypeid") rev_estimates["calendar_year"] = period.get("calendaryear") @@ -132,9 +133,6 @@ def transform_data( if period_type == "quarterly" else "FY" ) - num_estimates = seek_object["revenue_num_of_estimates"].get(str(i)) - if not num_estimates: - continue rev_estimates["number_of_analysts"] = num_estimates[0].get( "dataitemvalue" )