neurostats-API 0.0.8__tar.gz → 0.0.9__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/PKG-INFO +2 -2
  2. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/README.md +1 -1
  3. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/fetchers/balance_sheet.py +9 -3
  4. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/fetchers/cash_flow.py +8 -3
  5. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/fetchers/finance_overview.py +12 -4
  6. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/fetchers/month_revenue.py +9 -3
  7. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/fetchers/profit_lose.py +9 -4
  8. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/fetchers/value_invest.py +14 -5
  9. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/utils/datetime.py +8 -0
  10. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API.egg-info/PKG-INFO +2 -2
  11. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/setup.py +1 -1
  12. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/MANIFEST.in +0 -0
  13. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/__init__.py +0 -0
  14. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/cli.py +0 -0
  15. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/fetchers/__init__.py +0 -0
  16. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/fetchers/base.py +0 -0
  17. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/fetchers/tech.py +0 -0
  18. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/main.py +0 -0
  19. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/tools/balance_sheet.yaml +0 -0
  20. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/tools/cash_flow_percentage.yaml +0 -0
  21. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/tools/finance_overview_dict.yaml +0 -0
  22. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/tools/profit_lose.yaml +0 -0
  23. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/tools/seasonal_data_field_dict.txt +0 -0
  24. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/utils/__init__.py +0 -0
  25. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/utils/data_process.py +0 -0
  26. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/utils/db_client.py +0 -0
  27. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API/utils/fetcher.py +0 -0
  28. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API.egg-info/SOURCES.txt +0 -0
  29. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API.egg-info/dependency_links.txt +0 -0
  30. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/neurostats_API.egg-info/top_level.txt +0 -0
  31. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/setup.cfg +0 -0
  32. {neurostats_API-0.0.8 → neurostats_API-0.0.9}/test/test_fetchers.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neurostats_API
3
- Version: 0.0.8
3
+ Version: 0.0.9
4
4
  Summary: The service of NeuroStats website
5
5
  Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
6
6
  Author: JasonWang@Neurowatt
@@ -78,7 +78,7 @@ pip install neurostats-API
78
78
  ```Python
79
79
  >>> import neurostats_API
80
80
  >>> print(neurostats_API.__version__)
81
- 0.0.8
81
+ 0.0.9
82
82
  ```
83
83
 
84
84
  ### 得到最新一期的評價資料與歷年評價
@@ -68,7 +68,7 @@ pip install neurostats-API
68
68
  ```Python
69
69
  >>> import neurostats_API
70
70
  >>> print(neurostats_API.__version__)
71
- 0.0.8
71
+ 0.0.9
72
72
  ```
73
73
 
74
74
  ### 得到最新一期的評價資料與歷年評價
@@ -75,10 +75,16 @@ class BalanceSheetFetcher(StatsFetcher):
75
75
  return fetched_data[-1]
76
76
 
77
77
  def query_data(self):
78
- today = StatsDateTime.get_today()
78
+ try:
79
+ latest_time = StatsDateTime.get_latest_time(
80
+ self.ticker, self.collection)['last_update_time']
81
+ year = latest_time['seasonal_data']['latest_year']
82
+ season = latest_time['seasonal_data']['latest_season']
83
+ except Exception as e:
84
+ today = StatsDateTime.get_today()
85
+ year = today.year - 1 if (today.season == 1) else today.year
86
+ season = 4 if (today.season == 1) else today.season - 1
79
87
 
80
- year = today.year - 1 if (today.season == 1) else today.year
81
- season = 4 if (today.season == 1) else today.season - 2
82
88
  fetched_data = self.collect_data(year, season)
83
89
 
84
90
  return self.process_data(season, fetched_data)
@@ -65,9 +65,14 @@ class CashFlowFetcher(StatsFetcher):
65
65
  return list(fetched_data)[0]
66
66
 
67
67
  def query_data(self):
68
- today = StatsDateTime.get_today()
69
-
70
- target_season = today.season - 1 if (today.season > 1) else 4
68
+
69
+ try:
70
+ latest_time = StatsDateTime.get_latest_time(self.ticker, self.collection)['last_update_time']
71
+ target_season = latest_time['seasonal_data']['latest_season']
72
+
73
+ except:
74
+ today = StatsDateTime.get_today()
75
+ target_season = today.season - 1 if (today.season > 1) else 4
71
76
 
72
77
  fetched_data = self.collect_data(target_season)
73
78
 
@@ -83,10 +83,17 @@ class FinanceOverviewFetcher(StatsFetcher):
83
83
  return fetched_data[0]
84
84
 
85
85
  def query_data(self):
86
- today = StatsDateTime.get_today()
87
86
 
88
- year = today.year - 1 if (today.season == 1) else today.year
89
- season = 4 if (today.season == 1) else today.season - 1
87
+ try:
88
+ latest_time = StatsDateTime.get_latest_time(
89
+ self.ticker, self.collection)['last_update_time']
90
+ year = latest_time['seasonal_data']['latest_year']
91
+ season = latest_time['seasonal_data']['latest_season']
92
+ except Exception as e:
93
+ today = StatsDateTime.get_today()
94
+ year = today.year - 1 if (today.season == 1) else today.year
95
+ season = 4 if (today.season == 1) else today.season - 1
96
+
90
97
  fetched_data = self.collect_data(year, season)
91
98
  finance_dict = fetched_data['seasonal_data'][0]
92
99
  FinanceOverviewProcessor.process_rate(finance_dict)
@@ -142,7 +149,8 @@ class FinanceOverviewProcessor(StatsProcessor):
142
149
  """
143
150
  try:
144
151
  EBIT = (finance_dict['revenue'] - finance_dict['operating_cost'] -
145
- finance_dict['operating_expenses'] - finance_dict['tax_fee'])
152
+ finance_dict['operating_expenses'] -
153
+ finance_dict['tax_fee'])
146
154
  finance_dict['EBIT'] = StatsProcessor.cal_non_percentage(EBIT)
147
155
  except (KeyError, ZeroDivisionError, TypeError) as e:
148
156
  finance_dict['EBIT'] = None
@@ -46,9 +46,15 @@ class MonthRevenueFetcher(StatsFetcher):
46
46
  return fetched_data[-1]
47
47
 
48
48
  def query_data(self):
49
- today = StatsDateTime.get_today()
50
- target_month = today.month
51
- target_year = today.year
49
+ try:
50
+ latest_time = StatsDateTime.get_latest_time(
51
+ self.ticker, self.collection)['last_update_time']
52
+ target_year = latest_time['monthly_data']['latest_year']
53
+ target_month = latest_time['monthly_data']['latest_month']
54
+ except Exception as e:
55
+ today = StatsDateTime.get_today()
56
+ target_month = today.month
57
+ target_year = today.year
52
58
 
53
59
  # Query data
54
60
  fetched_data = self.collect_data(target_year, target_month)
@@ -75,10 +75,15 @@ class ProfitLoseFetcher(StatsFetcher):
75
75
  return list(fetched_data)[-1]
76
76
 
77
77
  def query_data(self):
78
- today = StatsDateTime.get_today()
79
-
80
- target_season = today.season
81
- target_season = target_season - 1 if target_season > 1 else 4
78
+ try:
79
+ latest_time = StatsDateTime.get_latest_time(
80
+ self.ticker, self.collection)['last_update_time']
81
+ target_season = latest_time['seasonal_data']['latest_season']
82
+ except Exception as e:
83
+ today = StatsDateTime.get_today()
84
+
85
+ target_season = today.season
86
+ target_season = target_season - 1 if target_season > 1 else 4
82
87
 
83
88
  fetched_data = self.collect_data(target_season)
84
89
 
@@ -54,11 +54,20 @@ class ValueFetcher(StatsFetcher):
54
54
  return pipeline
55
55
 
56
56
  def query_data(self):
57
- today = StatsDateTime.get_today()
58
-
59
- this_year = today.year - 1911
60
- start_date = (today.date - timedelta(days=31))
61
- end_date = today.date
57
+ try:
58
+ latest_time = StatsDateTime.get_latest_time(
59
+ self.ticker, self.collection)['last_update_time']
60
+ target_year = latest_time['daily_data']['last_update'].year
61
+ start_date = latest_time['daily_data']['last_update'] - timedelta(days=31)
62
+ end_date = latest_time['daily_data']['last_update']
63
+
64
+ except Exception as e:
65
+ today = StatsDateTime.get_today()
66
+ target_year = today.year
67
+ start_date = (today.date - timedelta(days=31))
68
+ end_date = today.date
69
+
70
+ this_year = target_year - 1911
62
71
 
63
72
  fetched_data = self.collect_data(start_date, end_date)
64
73
 
@@ -19,3 +19,11 @@ class StatsDateTime():
19
19
 
20
20
  return StatsDateTime(today, this_year, this_month, this_day,
21
21
  this_season)
22
+
23
+ @classmethod
24
+ def get_latest_time(cls, ticker, collection):
25
+ return collection.find_one(
26
+ { "ticker" : ticker },
27
+ { "_id": 0, "last_update_time": 1 }
28
+ )
29
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neurostats-API
3
- Version: 0.0.8
3
+ Version: 0.0.9
4
4
  Summary: The service of NeuroStats website
5
5
  Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
6
6
  Author: JasonWang@Neurowatt
@@ -78,7 +78,7 @@ pip install neurostats-API
78
78
  ```Python
79
79
  >>> import neurostats_API
80
80
  >>> print(neurostats_API.__version__)
81
- 0.0.8
81
+ 0.0.9
82
82
  ```
83
83
 
84
84
  ### 得到最新一期的評價資料與歷年評價
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='neurostats_API',
5
- version='0.0.8',
5
+ version='0.0.9',
6
6
  long_description=open('README.md', 'r', encoding='utf-8').read(),
7
7
  long_description_content_type='text/markdown',
8
8
  install_requires=[
File without changes