MCPcopy
hub / github.com/microsoft/qlib / get_forecast_report_df

Method get_forecast_report_df

scripts/data_collector/pit/collector.py:146–166  ·  view source on GitHub ↗
(code: str, start_date: str, end_date: str)

Source from the content-addressed store, hash-verified

144
145 @staticmethod
146 def get_forecast_report_df(code: str, start_date: str, end_date: str) -> pd.DataFrame:
147 column_mapping = {
148 "profitForcastExpPubDate": "date",
149 "profitForcastExpStatDate": "period",
150 "value": "value",
151 }
152 resp = bs.query_forecast_report(code=code, start_date=start_date, end_date=end_date)
153 forecast_list = []
154 while (resp.error_code == "0") and resp.next():
155 forecast_list.append(resp.get_row_data())
156 forecast_df = pd.DataFrame(forecast_list, columns=resp.fields)
157 numeric_fields = ["profitForcastChgPctUp", "profitForcastChgPctDwn"]
158 try:
159 forecast_df[numeric_fields] = forecast_df[numeric_fields].apply(pd.to_numeric, errors="ignore")
160 except KeyError:
161 return pd.DataFrame()
162 forecast_df["value"] = (forecast_df["profitForcastChgPctUp"] + forecast_df["profitForcastChgPctDwn"]) / 200
163 forecast_df = forecast_df[list(column_mapping.keys())]
164 forecast_df.rename(columns=column_mapping, inplace=True)
165 forecast_df["field"] = "YOYNI"
166 return forecast_df
167
168 @staticmethod
169 def get_growth_df(code: str, start_date: str, end_date: str) -> pd.DataFrame:

Callers 1

get_dataMethod · 0.95

Calls 1

applyMethod · 0.45

Tested by

no test coverage detected