neurostats-API 0.0.23b2__tar.gz → 0.0.24__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/PKG-INFO +2 -2
  2. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/README.md +1 -1
  3. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/__init__.py +1 -1
  4. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/fetchers/balance_sheet.py +63 -39
  5. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/fetchers/base.py +6 -2
  6. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/fetchers/cash_flow.py +91 -70
  7. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/fetchers/finance_overview.py +26 -26
  8. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/fetchers/institution.py +80 -7
  9. neurostats_api-0.0.24/neurostats_API/fetchers/macro_daily_event.py +8 -0
  10. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/fetchers/margin_trading.py +0 -3
  11. neurostats_api-0.0.24/neurostats_API/fetchers/month_revenue.py +195 -0
  12. neurostats_api-0.0.24/neurostats_API/fetchers/profit_lose.py +253 -0
  13. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/fetchers/tech.py +0 -58
  14. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/fetchers/tej_finance_report.py +101 -69
  15. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/fetchers/value_invest.py +26 -9
  16. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/utils/calculate_value.py +5 -2
  17. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/utils/data_process.py +12 -6
  18. neurostats_api-0.0.24/neurostats_API/utils/logger.py +21 -0
  19. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API.egg-info/PKG-INFO +2 -2
  20. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API.egg-info/SOURCES.txt +2 -0
  21. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/setup.py +1 -1
  22. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/test/test_fetchers.py +11 -12
  23. neurostats_api-0.0.23b2/neurostats_API/fetchers/month_revenue.py +0 -161
  24. neurostats_api-0.0.23b2/neurostats_API/fetchers/profit_lose.py +0 -233
  25. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/MANIFEST.in +0 -0
  26. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/cli.py +0 -0
  27. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/fetchers/__init__.py +0 -0
  28. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/main.py +0 -0
  29. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/tools/company_list/tw.json +0 -0
  30. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/tools/tej_db/tej_db_index.yaml +0 -0
  31. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/tools/tej_db/tej_db_percent_index.yaml +0 -0
  32. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/tools/tej_db/tej_db_skip_index.yaml +0 -0
  33. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/tools/tej_db/tej_db_thousand_index.yaml +0 -0
  34. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/tools/twse/balance_sheet.yaml +0 -0
  35. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/tools/twse/cash_flow_percentage.yaml +0 -0
  36. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/tools/twse/finance_overview_dict.yaml +0 -0
  37. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/tools/twse/profit_lose.yaml +0 -0
  38. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/tools/twse/seasonal_data_field_dict.txt +0 -0
  39. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/utils/__init__.py +0 -0
  40. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/utils/datetime.py +0 -0
  41. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API/utils/db_client.py +0 -0
  42. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API.egg-info/dependency_links.txt +0 -0
  43. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API.egg-info/requires.txt +0 -0
  44. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/neurostats_API.egg-info/top_level.txt +0 -0
  45. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/setup.cfg +0 -0
  46. {neurostats_api-0.0.23b2 → neurostats_api-0.0.24}/test/test_tej.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neurostats_API
3
- Version: 0.0.23b2
3
+ Version: 0.0.24
4
4
  Summary: The service of NeuroStats website
5
5
  Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
6
6
  Author: JasonWang@Neurowatt
@@ -89,7 +89,7 @@ pip install neurostats-API
89
89
  ```Python
90
90
  >>> import neurostats_API
91
91
  >>> print(neurostats_API.__version__)
92
- 0.0.23b2
92
+ 0.0.23
93
93
  ```
94
94
 
95
95
  ### 得到最新一期的評價資料與歷年評價
@@ -73,7 +73,7 @@ pip install neurostats-API
73
73
  ```Python
74
74
  >>> import neurostats_API
75
75
  >>> print(neurostats_API.__version__)
76
- 0.0.23b2
76
+ 0.0.23
77
77
  ```
78
78
 
79
79
  ### 得到最新一期的評價資料與歷年評價
@@ -1,4 +1,4 @@
1
- __version__='0.0.23b2'
1
+ __version__='0.0.24'
2
2
 
3
3
  from .fetchers import (
4
4
  BalanceSheetFetcher,
@@ -19,32 +19,43 @@ class BalanceSheetFetcher(StatsFetcher):
19
19
  "us_stats": self.process_data_us
20
20
  }
21
21
 
22
+ self.return_keys = [
23
+ 'balance_sheet', 'total_asset', 'current_asset', 'non_current_asset',
24
+ 'current_debt', 'non_current_debt', 'equity', 'balance_sheet_all', 'balance_sheet_YoY'
25
+ ]
26
+
22
27
  def prepare_query(self):
23
28
  pipeline = super().prepare_query()
24
29
 
25
- pipeline = pipeline + [
26
- {
27
- "$unwind": "$seasonal_data" # 展開 seasonal_data 陣列
28
- },
29
- {
30
- "$project": {
31
- "_id": 0,
32
- "ticker": 1,
33
- "company_name": 1,
34
- "year": "$seasonal_data.year",
35
- "season": "$seasonal_data.season",
36
- "balance_sheet": {
37
- "$ifNull": ["$seasonal_data.balance_sheet", []]
38
- } # 避免 null
39
- }
40
- },
41
- {
42
- "$sort": {
43
- "year": -1,
44
- "season": -1
30
+ name_map = {
31
+ "twse_stats": "balance_sheet",
32
+ "us_stats": "balance_sheet"
33
+ }
34
+
35
+
36
+ chart_name = name_map.get(self.collection_name, "balance_sheet")
37
+
38
+ append_pipeline = [
39
+ {
40
+ "$project": {
41
+ "_id": 0,
42
+ "ticker": 1,
43
+ "company_name": 1,
44
+ "seasonal_data": {
45
+ "$map": {
46
+ "input": {"$ifNull": ["$seasonal_data", []]},
47
+ "as": "season",
48
+ "in": {
49
+ "year": "$$season.year",
50
+ "season": "$$season.season",
51
+ "data": {"$ifNull": [f"$$season.{chart_name}", []]}
52
+ }
53
+ }
45
54
  }
46
55
  }
47
- ]
56
+ }
57
+ ]
58
+ pipeline = pipeline + append_pipeline
48
59
 
49
60
  return pipeline
50
61
 
@@ -53,6 +64,7 @@ class BalanceSheetFetcher(StatsFetcher):
53
64
 
54
65
  def query_data(self):
55
66
  fetched_data = self.collect_data()
67
+ fetched_data = fetched_data[0]
56
68
 
57
69
  process_fn = self.process_function_map[self.collection_name]
58
70
  processed_data = process_fn(fetched_data)
@@ -72,14 +84,19 @@ class BalanceSheetFetcher(StatsFetcher):
72
84
 
73
85
  return_dict = {
74
86
  "ticker": self.ticker,
75
- "company_name": fetched_data[-1]['company_name']
87
+ "company_name": fetched_data['company_name']
76
88
  }
77
89
  table_dict = {}
78
90
 
91
+ seasonal_data = fetched_data.get('seasonal_data')
92
+ if not seasonal_data:
93
+ return_dict.update(self._get_empty_structure())
94
+ return return_dict
95
+
79
96
  # 將value與percentage跟著年分季度一筆筆取出
80
- for data in fetched_data:
97
+ for data in seasonal_data:
81
98
  year, season, balance_sheet = data['year'], data['season'], data[
82
- 'balance_sheet']
99
+ 'data']
83
100
  time_index = f"{year}Q{season}"
84
101
 
85
102
  new_balance_sheet = dict()
@@ -96,35 +113,37 @@ class BalanceSheetFetcher(StatsFetcher):
96
113
  old_balance_sheet = old_balance_sheet.loc[:, target_season_col]
97
114
  old_balance_sheet = StatsProcessor.expand_value_percentage(old_balance_sheet)
98
115
 
116
+ # 處理QoQ版BalanceSheet
99
117
  for time_index, data_dict in table_dict.items():
100
118
  new_balance_sheet = self.flatten_dict(
101
- balance_sheet,
119
+ data_dict,
102
120
  indexes = index_names,
103
121
  target_keys=["value", "percentage"]
104
122
  )
105
123
 
106
124
  table_dict[time_index] = new_balance_sheet
107
125
 
108
- total_table = pd.DataFrame.from_dict(table_dict)
109
- value_index = total_table.index.str.endswith("_value")
110
- total_table.loc[value_index, :] = (
111
- total_table.loc[value_index, :].apply(
112
- lambda x: StatsProcessor.cal_non_percentage(x, postfix="元"),
113
- axis=0
126
+ total_table = pd.DataFrame.from_dict(table_dict).T
127
+ value_index = total_table.columns.str.endswith("_value")
128
+ value_cols = total_table.loc[:, value_index].columns
129
+ total_table[value_cols] = (
130
+ total_table[value_cols].map(
131
+ lambda x: StatsProcessor.cal_non_percentage(x, postfix="千元"),
114
132
  )
115
133
  )
116
134
 
117
- percenrage_index = total_table.index.str.endswith(
135
+ percentage_index = total_table.columns.str.endswith(
118
136
  "_percentage"
119
137
  )
120
- total_table.loc[percenrage_index, :] = (
121
- total_table.loc[percenrage_index, :].apply(
138
+ percentage_cols = total_table.loc[:, percentage_index].columns
139
+ total_table[percentage_cols] = (
140
+ total_table[percentage_cols].map(
122
141
  lambda x: StatsProcessor.
123
142
  cal_non_percentage(x, to_str=True, postfix="%"),
124
- axis=0
125
143
  )
126
144
  )
127
145
 
146
+ total_table = total_table.T
128
147
  target_season_columns = total_table.columns.str.endswith(
129
148
  f"Q{target_season}"
130
149
  )
@@ -140,7 +159,6 @@ class BalanceSheetFetcher(StatsFetcher):
140
159
  )
141
160
  break
142
161
  except Exception as e:
143
- print(f"error : {str(e)}")
144
162
  continue
145
163
 
146
164
  return_dict.update(
@@ -157,22 +175,28 @@ class BalanceSheetFetcher(StatsFetcher):
157
175
  "ticker": self.ticker,
158
176
  "company_name": fetched_data[-1]['company_name']
159
177
  }
178
+ table_dict = {}
160
179
 
161
180
  table_dict = dict()
162
181
 
163
- for data in fetched_data:
182
+ for data in fetched_data['seasonal_data']:
164
183
  year, season, balance_sheet = data['year'], data['season'], data[
165
- 'balance_sheet']
184
+ 'data']
166
185
  table_dict[f"{year}Q{season}"] = balance_sheet
167
186
 
168
187
  table_dict = pd.DataFrame.from_dict(table_dict)
169
188
 
170
189
  return_dict["balance_sheet"] = table_dict
171
190
 
172
- latest_season = fetched_data[0]['season']
191
+ latest_season = fetched_data['seasonal_data'][0]['season']
173
192
  target_season_columns = table_dict.columns.str.endswith(
174
193
  f"Q{latest_season}"
175
194
  )
176
195
  table_dict_YoY = table_dict.loc[:, target_season_columns]
177
196
  return_dict["balance_sheet_YoY"] = table_dict_YoY
178
197
  return return_dict
198
+
199
+ def _get_empty_structure(self):
200
+ return {
201
+ key: pd.DataFrame(columns= pd.Index([], name = 'date')) for key in self.return_keys
202
+ }
@@ -97,8 +97,12 @@ class BaseTEJFetcher(abc.ABC):
97
97
  }
98
98
  )
99
99
 
100
- # return 得到最新日期或None
101
- return latest_data.get('last_update', {}).get("latest_data_date", None)
100
+ if (latest_data):
101
+ # return 得到最新日期或None
102
+ return latest_data.get('last_update', {}).get("latest_data_date", None)
103
+
104
+ else:
105
+ return None
102
106
 
103
107
  def process_value(self, value):
104
108
  if isinstance(value, str) and "%" in value:
@@ -18,6 +18,8 @@ class CashFlowFetcher(StatsFetcher):
18
18
  "twse_stats": self.process_data_twse,
19
19
  "us_stats": self.process_data_us
20
20
  }
21
+
22
+ self.return_keys = ['cash_flow', 'CASHO', 'CASHI', 'CASHF', 'cash_flow_all', 'cash_flow_YoY']
21
23
 
22
24
  def prepare_query(self):
23
25
  pipeline = super().prepare_query()
@@ -31,28 +33,25 @@ class CashFlowFetcher(StatsFetcher):
31
33
  chart_name = name_map.get(self.collection_name, "cash_flow")
32
34
 
33
35
  append_pipeline = [
34
- {
35
- "$unwind": "$seasonal_data" # 展開 seasonal_data 陣列
36
- },
37
- {
38
- "$project": {
39
- "_id": 0,
40
- "ticker": 1,
41
- "company_name": 1,
42
- "year": "$seasonal_data.year",
43
- "season": "$seasonal_data.season",
44
- "cash_flow": {
45
- "$ifNull": [f"$seasonal_data.{chart_name}", []]
46
- } # 避免 null
47
- }
48
- },
49
- {
50
- "$sort": {
51
- "year": -1,
52
- "season": -1
36
+ {
37
+ "$project": {
38
+ "_id": 0,
39
+ "ticker": 1,
40
+ "company_name": 1,
41
+ "seasonal_data": {
42
+ "$map": {
43
+ "input": {"$ifNull": ["$seasonal_data", []]},
44
+ "as": "season",
45
+ "in": {
46
+ "year": "$$season.year",
47
+ "season": "$$season.season",
48
+ "data": {"$ifNull": [f"$$season.{chart_name}", []]}
49
+ }
50
+ }
53
51
  }
54
52
  }
55
- ]
53
+ }
54
+ ]
56
55
 
57
56
  pipeline = pipeline + append_pipeline
58
57
 
@@ -63,6 +62,7 @@ class CashFlowFetcher(StatsFetcher):
63
62
 
64
63
  def query_data(self):
65
64
  fetched_data = self.collect_data()
65
+ fetched_data = fetched_data[0]
66
66
 
67
67
  process_fn = self.process_function_map.get(self.collection_name, self.process_data_us)
68
68
  return process_fn(fetched_data)
@@ -78,27 +78,36 @@ class CashFlowFetcher(StatsFetcher):
78
78
  index_names = []
79
79
  column_names = []
80
80
 
81
- table_dict = dict()
82
- CASHO_dict = dict()
83
- CASHI_dict = dict()
84
- CASHF_dict = dict()
81
+ table_dict = {}
82
+ CASHO_dict = {}
83
+ CASHI_dict = {}
84
+ CASHF_dict = {}
85
85
 
86
86
  # 處理cash_flow 比例
87
87
  checkpoints = ["營業活動之現金流量-間接法", "投資活動之現金流量", "籌資活動之現金流量", "匯率變動對現金及約當現金之影響"]
88
88
  main_cash_flows = [
89
- "營業活動之淨現金流入(流出)", "投資活動之淨現金流入(流出)", "籌資活動之淨現金流入(流出)", None
89
+ "營業活動之淨現金流入(流出)", "投資活動之淨現金流入(流出)", "籌資活動之淨現金流入(流出)", "其他"
90
90
  ] # 主要的比例對象
91
91
  partial_cash_flows = [CASHO_dict, CASHI_dict, CASHF_dict, dict()]
92
92
 
93
93
  # 作法: dictionary中也有checkpoints,如果出現了就換下一個index去計算
94
94
 
95
- for data in fetched_data:
96
- year, season, cash_flow = data['year'], data['season'], data['cash_flow']
95
+ return_dict = {
96
+ "ticker": self.ticker,
97
+ "company_name": fetched_data['company_name']
98
+ }
99
+ seasonal_data = fetched_data.get('seasonal_data')
100
+ if not seasonal_data:
101
+ return_dict.update(self._get_empty_structure())
102
+ return return_dict
103
+
104
+ for data in seasonal_data:
105
+ year, season, cash_flow = data['year'], data['season'], data['data']
97
106
 
98
107
  time_index = f"{year}Q{season}"
99
108
 
100
- main_cash_flow_name = None
101
- partial_cash_flow = None
109
+ main_cash_flow_name = ""
110
+ partial_cash_flow = {}
102
111
  next_checkpoint = 0
103
112
 
104
113
  temp_dict = {}
@@ -110,34 +119,34 @@ class CashFlowFetcher(StatsFetcher):
110
119
  partial_cash_flow = partial_cash_flows[next_checkpoint]
111
120
  partial_cash_flow[time_index] = {}
112
121
  next_checkpoint += 1
122
+
123
+ if main_cash_flow_name: # 有取得cash flow name再進行接下來的計算percentage
124
+ if (isinstance(cash_flow_value, dict)):
125
+ value = cash_flow_value.get('value', None)
126
+ else:
127
+ value = cash_flow_value
113
128
 
114
- if (isinstance(cash_flow_value, dict)):
115
- value = cash_flow_value.get('value', None)
116
- else:
117
- value = cash_flow_value
118
-
119
-
120
- main_value = cash_flow.get(main_cash_flow_name, None)
121
- if (isinstance(main_value, dict)):
122
- main_value = main_value.get('value', None)
123
- else:
124
- pass
125
-
126
- try:
127
- ratio = np.round(
128
- (value / main_value) * 100, 2
129
- )
130
- ratio = f"{ratio}%"
131
- except:
132
- ratio = None
133
-
134
- value = StatsProcessor.cal_non_percentage(value, postfix="千元")
135
- temp_dict[index_name] = {
136
- "value" : value,
137
- "percentage": ratio
138
- }
139
-
140
- partial_cash_flow[time_index][index_name] = temp_dict[index_name]
129
+ # 處理cashflow percentage部分(取2位 + 接%)
130
+ main_value = cash_flow.get(main_cash_flow_name, None)
131
+ if (isinstance(main_value, dict)):
132
+ main_value = main_value.get('value', None)
133
+ else:
134
+ pass
135
+
136
+ try:
137
+ ratio = np.round(
138
+ (value / main_value) * 100, 2
139
+ )
140
+ ratio = f"{ratio}%"
141
+ except:
142
+ ratio = None
143
+
144
+ value = StatsProcessor.cal_non_percentage(value, postfix="千元")
145
+ temp_dict[index_name] = {
146
+ "value" : value,
147
+ "percentage": ratio
148
+ }
149
+ partial_cash_flow[time_index][index_name] = temp_dict[index_name]
141
150
 
142
151
  table_dict[time_index] = temp_dict
143
152
  index_names += list(cash_flow.keys())
@@ -157,35 +166,42 @@ class CashFlowFetcher(StatsFetcher):
157
166
  CASHF_table = pd.DataFrame(CASHF_dict)
158
167
  CASHF_table = StatsProcessor.expand_value_percentage(CASHF_table)
159
168
 
160
- for time_index in table_dict.keys():
161
- table_dict[time_index] = self.flatten_dict(table_dict[time_index], index_names, target_keys=['value', 'percentage'])
162
- cash_flow_flatten = pd.DataFrame.from_dict(table_dict)
169
+ # 回傳歷來格式
170
+ target_season = seasonal_data[0]['season']
163
171
 
164
- target_season = fetched_data[0]['season']
165
- target_season_column = cash_flow_flatten.columns.str.endswith(f"Q{target_season}")
172
+ cash_flow_flatten, cash_flow_flatten_YoY = self.flatten_twse(
173
+ table_dict, target_season, index_names
174
+ )
166
175
 
167
- return_dict = {
168
- "ticker": self.ticker,
169
- "company_name": fetched_data[-1]['company_name'],
176
+ return_dict.update({
170
177
  "cash_flow": cash_flow_table_stats,
171
178
  "CASHO": CASHO_table,
172
179
  "CASHI": CASHI_table,
173
180
  "CASHF": CASHF_table,
174
181
  "cash_flow_all": cash_flow_flatten,
175
- "cash_flow_YoY": cash_flow_flatten.loc[:, target_season_column]
176
- }
182
+ "cash_flow_YoY": cash_flow_flatten_YoY
183
+ })
177
184
  return return_dict
185
+
186
+ def flatten_twse(self, data_dict: dict, target_season: int, index_names: list):
187
+ for time_index in data_dict.keys():
188
+ data_dict[time_index] = self.flatten_dict(data_dict[time_index], index_names, target_keys=['value', 'percentage'])
189
+ cash_flow_flatten = pd.DataFrame.from_dict(data_dict)
190
+
191
+ target_season_column = cash_flow_flatten.columns.str.endswith(f"Q{target_season}")
192
+
193
+ return cash_flow_flatten, cash_flow_flatten.loc[:, target_season_column]
178
194
 
179
195
  def process_data_us(self, fetched_data):
180
196
 
181
197
  table_dict = {
182
- f"{data['year']}Q{data['season']}": data['cash_flow']
183
- for data in fetched_data
198
+ f"{data['year']}Q{data['season']}": data['data']
199
+ for data in fetched_data['seasonal_data']
184
200
  }
185
201
 
186
202
  cash_flow_df = pd.DataFrame.from_dict(table_dict)
187
203
 
188
- latest_season = fetched_data[0]['season']
204
+ latest_season = fetched_data['seasonal_data'][0]['season']
189
205
  target_season_columns = cash_flow_df.columns.str.endswith(
190
206
  f"Q{latest_season}"
191
207
  )
@@ -193,8 +209,13 @@ class CashFlowFetcher(StatsFetcher):
193
209
 
194
210
  return_dict = {
195
211
  "ticker": self.ticker,
196
- "company_name": fetched_data[-1]['company_name'],
212
+ "company_name": fetched_data['company_name'],
197
213
  "cash_flow": cash_flow_df,
198
214
  "cash_flow_YoY": cash_flow_df_YoY
199
215
  }
200
216
  return return_dict
217
+
218
+ def _get_empty_structure(self):
219
+ return {
220
+ key: pd.DataFrame(columns= pd.Index([], name = 'date')) for key in self.return_keys
221
+ }