Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
2.6.5 handle null
  • Loading branch information
1nchaos committed Sep 6, 2024
1 parent 60ccbe3 commit 70ae2f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions adata/common/exception/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception:
print("data null:", func.__name__)
return pd.DataFrame(data=[], columns=[])

return wrapper
6 changes: 4 additions & 2 deletions adata/stock/info/stock_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def __market_rank_baidu(self):
time.sleep(2)
print(e)
continue
if not data:
return pd.DataFrame(data=[], columns=self.__CODE_COLUMNS)
# 4. 封装数据
rename = {'name': 'short_name', 'code': 'stock_code'}
df = pd.DataFrame(data=data)[['code', 'name', 'exchange']].rename(columns=rename)
Expand All @@ -112,7 +114,7 @@ def __new_sub_east(self):
f"sortColumns=APPLY_DATE,SECURITY_CODE&sortTypes=-1,-1&pageSize=50&pageNumber={i + 1}&" \
f"reportName=RPTA_APP_IPOAPPLY&columns=SECURITY_CODE,SECURITY_NAME,TRADE_MARKET,LISTING_DATE&quoteType=0&" \
f"filter=(APPLY_DATE>'2010-01-01')&source=WEB&client=WEB"
res_json = requests.request('get', url, headers={}, proxies={}).json()
res_json = requests.request(method='get', url=url, headers={}, proxies={}).json()
res_data = res_json['result']['data']
for _ in res_data:
exchange = str(_['TRADE_MARKET'])
Expand Down Expand Up @@ -149,7 +151,7 @@ def __market_rank_east(self):
"_": "1623833739532",
}
# 请求数据
r = requests.request(url, timeout=15, params=params)
r = requests.request(url=url, timeout=15, params=params)
data_json = r.json()
if not data_json["data"]["diff"]:
return pd.DataFrame()
Expand Down

0 comments on commit 70ae2f5

Please sign in to comment.