neurostats-API 0.0.16__tar.gz → 0.0.17__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/PKG-INFO +1 -1
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/base.py +17 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/tech.py +54 -25
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API.egg-info/PKG-INFO +1 -1
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/setup.py +1 -1
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/MANIFEST.in +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/README.md +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/__init__.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/cli.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/__init__.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/balance_sheet.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/cash_flow.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/finance_overview.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/institution.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/margin_trading.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/month_revenue.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/profit_lose.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/tej_finance_report.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/value_invest.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/main.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/tools/balance_sheet.yaml +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/tools/cash_flow_percentage.yaml +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/tools/finance_overview_dict.yaml +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/tools/profit_lose.yaml +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/tools/seasonal_data_field_dict.txt +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/utils/__init__.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/utils/calculate_value.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/utils/data_process.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/utils/datetime.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/utils/db_client.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/utils/fetcher.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API.egg-info/SOURCES.txt +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API.egg-info/dependency_links.txt +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API.egg-info/requires.txt +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API.egg-info/top_level.txt +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/setup.cfg +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/test/test_fetchers.py +0 -0
- {neurostats_api-0.0.16 → neurostats_api-0.0.17}/test/test_tej.py +0 -0
@@ -53,6 +53,23 @@ class StatsFetcher:
|
|
53
53
|
season = (month - 1) // 3 + 1
|
54
54
|
|
55
55
|
return StatsDateTime(date, year, month, day, season)
|
56
|
+
|
57
|
+
def has_required_columns(self, df:pd.DataFrame, required_cols=None):
|
58
|
+
"""
|
59
|
+
Check if the required columns are present in the DataFrame.
|
60
|
+
|
61
|
+
Args:
|
62
|
+
df (pd.DataFrame): The DataFrame to check.
|
63
|
+
required_cols (list, optional): List of required column names.
|
64
|
+
Defaults to ['date', 'open', 'high', 'low', 'close', 'volume'].
|
65
|
+
|
66
|
+
Returns:
|
67
|
+
bool: True if all required columns are present, False otherwise.
|
68
|
+
"""
|
69
|
+
if required_cols is None:
|
70
|
+
required_cols = ['date', 'open', 'high', 'low', 'close', 'volume']
|
71
|
+
|
72
|
+
return all(col in df.columns for col in required_cols)
|
56
73
|
|
57
74
|
|
58
75
|
class BaseTEJFetcher(abc.ABC):
|
@@ -47,40 +47,46 @@ class TechFetcher(StatsFetcher):
|
|
47
47
|
)
|
48
48
|
|
49
49
|
def _get_ohlcv(self):
|
50
|
-
|
51
|
-
if self.ticker in ['GSPC', 'IXIC', 'DJI', 'TWII']:
|
52
|
-
|
53
|
-
full_tick = f'^{self.ticker}'
|
54
|
-
yf_ticker = yf.Ticker(full_tick)
|
55
|
-
origin_df = yf_ticker.history(period="10y")
|
56
|
-
origin_df = origin_df.reset_index()
|
57
|
-
origin_df["Date"] = pd.to_datetime(origin_df["Date"]).dt.date
|
58
|
-
df = origin_df.rename(
|
59
|
-
columns={
|
60
|
-
"Date": "date",
|
61
|
-
"Open": "open",
|
62
|
-
"High": "high",
|
63
|
-
"Low": "low",
|
64
|
-
"Close": "close",
|
65
|
-
"Volume": "volume"
|
66
|
-
}
|
67
|
-
)
|
68
|
-
else:
|
69
50
|
|
51
|
+
required_cols = ['date', 'open', 'high', 'low', 'close', 'volume']
|
52
|
+
|
53
|
+
try:
|
70
54
|
query = {'ticker': self.ticker}
|
71
|
-
ticker_full =
|
55
|
+
ticker_full = self.collection.find_one(query)
|
72
56
|
|
73
57
|
if not ticker_full:
|
74
58
|
raise ValueError(f"No data found for ticker: {self.ticker}")
|
75
59
|
|
76
|
-
|
77
|
-
|
60
|
+
daily_data = ticker_full.get("daily_data", [])
|
61
|
+
if not isinstance(daily_data, list):
|
62
|
+
raise TypeError("Expected 'daily_data' to be a list.")
|
63
|
+
|
64
|
+
df = pd.DataFrame(daily_data)
|
78
65
|
|
79
|
-
|
66
|
+
if not self.has_required_columns(df, required_cols):
|
67
|
+
raise KeyError(f"Missing required columns")
|
80
68
|
|
81
|
-
|
69
|
+
except (KeyError, ValueError, TypeError) as e:
|
70
|
+
|
71
|
+
print(f"Conduct yf searching")
|
72
|
+
|
73
|
+
if self.ticker in ['GSPC', 'IXIC', 'DJI', 'TWII']:
|
74
|
+
full_tick = f'^{self.ticker}'
|
75
|
+
else:
|
76
|
+
full_tick = f'{self.ticker}.tw'
|
77
|
+
|
78
|
+
df = self.conduct_yf_search(full_tick)
|
79
|
+
|
80
|
+
if not self.has_required_columns(df, required_cols):
|
81
|
+
|
82
|
+
print(f".tw failed, try .two")
|
83
|
+
|
84
|
+
full_tick = f'{self.ticker}.two'
|
85
|
+
|
86
|
+
df = self.conduct_yf_search(full_tick)
|
87
|
+
|
88
|
+
return df[required_cols]
|
82
89
|
|
83
|
-
return df[selected_cols]
|
84
90
|
|
85
91
|
def get_daily(self):
|
86
92
|
|
@@ -101,6 +107,29 @@ class TechFetcher(StatsFetcher):
|
|
101
107
|
def get_yearly(self):
|
102
108
|
|
103
109
|
return self.yearly_index
|
110
|
+
|
111
|
+
def conduct_yf_search(self, ticker:str):
|
112
|
+
|
113
|
+
yf_ticker = yf.Ticker(ticker)
|
114
|
+
origin_df = yf_ticker.history(period="10y")
|
115
|
+
|
116
|
+
if origin_df.empty:
|
117
|
+
return origin_df
|
118
|
+
|
119
|
+
origin_df = origin_df.reset_index()
|
120
|
+
origin_df["Date"] = pd.to_datetime(origin_df["Date"])
|
121
|
+
df = origin_df.rename(
|
122
|
+
columns={
|
123
|
+
"Date": "date",
|
124
|
+
"Open": "open",
|
125
|
+
"High": "high",
|
126
|
+
"Low": "low",
|
127
|
+
"Close": "close",
|
128
|
+
"Volume": "volume"
|
129
|
+
}
|
130
|
+
)
|
131
|
+
|
132
|
+
return df
|
104
133
|
|
105
134
|
class TechProcessor:
|
106
135
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/fetchers/tej_finance_report.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/tools/cash_flow_percentage.yaml
RENAMED
File without changes
|
{neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/tools/finance_overview_dict.yaml
RENAMED
File without changes
|
File without changes
|
{neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API/tools/seasonal_data_field_dict.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{neurostats_api-0.0.16 → neurostats_api-0.0.17}/neurostats_API.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|