neurostats-API 0.0.8__py3-none-any.whl → 0.0.9__py3-none-any.whl

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.
@@ -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,14 +2,14 @@ neurostats_API/__init__.py,sha256=9_jSwg7P5SlFv0Ci2ZSYBcAbygp9XV2C8sryRO8tvko,19
2
2
  neurostats_API/cli.py,sha256=UJSWLIw03P24p-gkBb6JSEI5dW5U12UvLf1L8HjQD-o,873
3
3
  neurostats_API/main.py,sha256=QcsfmWivg2Dnqw3MTJWiI0QvEiRs0VuH-BjwQHFCv00,677
4
4
  neurostats_API/fetchers/__init__.py,sha256=U_OMG-mLpsVKYnCBrW2OjFuCzvPeVQ__7A676vGzztY,313
5
- neurostats_API/fetchers/balance_sheet.py,sha256=kOpk_83qeNgfhjF44UEmma8k6V6qTsIaFYiEcSVV20A,4910
5
+ neurostats_API/fetchers/balance_sheet.py,sha256=VeWhd8Z2XZnL5RzxmenLzAd4eyK2sWTuiRGkqWsEmzk,5219
6
6
  neurostats_API/fetchers/base.py,sha256=NW2SFzrimyAIrdJx1LVmTazelyZOAtcj54kJKHc4Vaw,1662
7
- neurostats_API/fetchers/cash_flow.py,sha256=5xN5YPGb7i4slDYe_KI2ucL4kh733iC5LLOEmm4J8mM,7137
8
- neurostats_API/fetchers/finance_overview.py,sha256=-cUb4wWr02xKhNCAXLuduhpvXsO0b14hJLqJqhagooY,25307
9
- neurostats_API/fetchers/month_revenue.py,sha256=RNA7ROl2vm8Xbib3k50p_1shsHDVSKIbHkyNiRa8yMw,3182
10
- neurostats_API/fetchers/profit_lose.py,sha256=aCvcTbe1FjR3oi8QIDZg0c6G7-r0B-cCdfj6Rtlw0Jw,4870
7
+ neurostats_API/fetchers/cash_flow.py,sha256=4G4SIUoBSwT-BePmz-SprQ0IJRL2QNWqWdQtlgaRKd4,7371
8
+ neurostats_API/fetchers/finance_overview.py,sha256=EVP7k0JkQq3ydXy0f3t2kzy12iIQEwDniTLn98qZ460,25637
9
+ neurostats_API/fetchers/month_revenue.py,sha256=QmhMAO8jbkjg2R1LR0TAPE3bmDnyuLNjnD24ZsFkTBU,3501
10
+ neurostats_API/fetchers/profit_lose.py,sha256=C0y42RBA-s20XcG6CJ10Rt6Gm_rB6lcvBmIzbTpn64o,5123
11
11
  neurostats_API/fetchers/tech.py,sha256=wH1kkqiETQhF0HAhk-UIiucnZ3EiL85Q-yMWCcVOiFM,11395
12
- neurostats_API/fetchers/value_invest.py,sha256=tg8yELbVnTFTEclrwgXnCRW377KkcoLiP-Gk2pyM-9Y,2886
12
+ neurostats_API/fetchers/value_invest.py,sha256=O5IKC8Nl7p5-E-1zoyAyWtiDznaxNemeabanmaHDdJs,3327
13
13
  neurostats_API/tools/balance_sheet.yaml,sha256=dKTMbsYR9EFp48WAzmm_ISHMiJQLyE0V-XWS_gkxmr0,541
14
14
  neurostats_API/tools/cash_flow_percentage.yaml,sha256=fk2Z4eb1JjGFvP134eJatHacB7BgTkBenhDJr83w8RE,1345
15
15
  neurostats_API/tools/finance_overview_dict.yaml,sha256=URL1IFqO0j5uOwN3xETHriy_u9lYbLvdwghuznenP2Q,2500
@@ -17,10 +17,10 @@ neurostats_API/tools/profit_lose.yaml,sha256=qHBnqG7fR4Pxc_c3n4raL-3l7o5RnABLz9Y
17
17
  neurostats_API/tools/seasonal_data_field_dict.txt,sha256=Za1fJR1yERbqrX8TgsS2kmMYMbaye43Gu_5ukUNBCNM,7904
18
18
  neurostats_API/utils/__init__.py,sha256=FTYKRFzW2XVXdnSHXnS3mQQaHlKF9xGqrMsgZZ2kroc,142
19
19
  neurostats_API/utils/data_process.py,sha256=m1B4EhCNSzOMfTBDtYCjkQSjbDTAEFC6TNf3NNxV36k,5657
20
- neurostats_API/utils/datetime.py,sha256=I9CIgZdE5OMzUciOS5wvapOVEIrXG_0Qb6iDKfIod6c,574
20
+ neurostats_API/utils/datetime.py,sha256=XJya4G8b_-ZOaBbMXgQjWh2MC4wc-o6goQ7EQJQMWrQ,773
21
21
  neurostats_API/utils/db_client.py,sha256=OYe6yazcR4Aa6jYmy47JrryUeh2NnKGqY2K_lSZe6i8,455
22
22
  neurostats_API/utils/fetcher.py,sha256=VbrUhjA-GG5AyjPX2SHtFIbZM4dm3jo0RgZzuCbb_Io,40927
23
- neurostats_API-0.0.8.dist-info/METADATA,sha256=SCspApNeq7b9pflJC30SaOVCdZtQjBIbh6QOps9HnGw,18232
24
- neurostats_API-0.0.8.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
25
- neurostats_API-0.0.8.dist-info/top_level.txt,sha256=nSlQPMG0VtXivJyedp4Bkf86EOy2TpW10VGxolXrqnU,15
26
- neurostats_API-0.0.8.dist-info/RECORD,,
23
+ neurostats_API-0.0.9.dist-info/METADATA,sha256=z--BAc0e6HHBuXSQgc5ikwjPFzTfe-2o02gFLmgY_do,18232
24
+ neurostats_API-0.0.9.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
25
+ neurostats_API-0.0.9.dist-info/top_level.txt,sha256=nSlQPMG0VtXivJyedp4Bkf86EOy2TpW10VGxolXrqnU,15
26
+ neurostats_API-0.0.9.dist-info/RECORD,,