Skip to content

Commit

Permalink
Merge pull request #104 from 1nchaos/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
1nchaos authored Sep 6, 2024
2 parents b55ee6d + 70ae2f5 commit ba93ab8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion adata/__version__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

VERSION = (2, 6, 2)
VERSION = (2, 6, 4)
PRERELEASE = None # alpha, beta or rc
REVISION = None

Expand Down
4 changes: 2 additions & 2 deletions adata/bond/info/bond_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import copy

import pandas as pd
import requests
from adata.common import requests

from adata.common.headers import ths_headers

Expand Down Expand Up @@ -46,7 +46,7 @@ def __convert_code_ths(self):
headers = copy.deepcopy(ths_headers.text_headers)
headers['Host'] = 'data.10jqka.com.cn'
headers['Referer'] = 'http://data.10jqka.com.cn/ipo/bond/'
res = requests.get(api_url, headers=headers, proxies={})
res = requests.request(url=api_url, headers=headers, proxies={})
res_json = res.json()
if res.status_code != 200 or res_json['status_msg'] != 'ok':
return pd.DataFrame(data=[], columns=COLUMNS)
Expand Down
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
2 changes: 1 addition & 1 deletion adata/stock/finance/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __core_index_east(self, stock_code='300059'):

"ZZCZZTS": 'total_asset_turn_days',
"CHZZTS": 'inv_turn_days',
"YSZKZZTS": 'total_asset_turn_rate',
"YSZKZZTS": 'acct_recv_turn_days',
"TOAZZL": 'total_asset_turn_rate',
"CHZZL": 'inv_turn_rate',
"YSZKZZL": 'acct_recv_turn_rate',
Expand Down
8 changes: 5 additions & 3 deletions adata/stock/info/stock_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __market_rank_baidu(self):
for page_no in range(49):
api_url = f"{api_url}&pn={page_no * max_page_size}&rn={max_page_size}"
try:
res = requests.get(api_url, headers=baidu_headers.json_headers, proxies={})
res = requests.request(url=api_url, headers=baidu_headers.json_headers, proxies={})
res_json = res.json()
if res.status_code != 200 or res_json['ResultCode'] != '0':
continue
Expand All @@ -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.get(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 ba93ab8

Please sign in to comment.