mirror of
https://github.com/1nchaos/adata.git
synced 2024-11-25 16:32:39 +08:00
MOD: example fix some pylint warning/error
This commit is contained in:
parent
78b9de6683
commit
ad0c53649f
@ -16,11 +16,12 @@ from adata.common.utils import requests
|
||||
from adata.sentiment.alist import AList
|
||||
|
||||
|
||||
class Hot(AList):
|
||||
class Hot(AList): # 参考 pylint 改完之后实际上这个 Hot 和 AList 没有啥实例化的意义
|
||||
"""热门榜单"""
|
||||
|
||||
# 东方财富人气榜
|
||||
def pop_rank_100_east(self):
|
||||
@staticmethod
|
||||
def pop_rank_100_east():
|
||||
"""
|
||||
东方财富人气榜100
|
||||
http://guba.eastmoney.com/rank/
|
||||
@ -40,7 +41,6 @@ class Hot(AList):
|
||||
df = pd.DataFrame(res["data"])
|
||||
|
||||
df["mark"] = ["0" + "." + item[2:] if "SZ" in item else "1" + "." + item[2:] for item in df["sc"]]
|
||||
",".join(df["mark"]) + "?v=08926209912590994"
|
||||
params = {
|
||||
"ut": "f057cbcbce2a86e2866ab8877db1d059",
|
||||
"fltt": "2",
|
||||
@ -66,7 +66,8 @@ class Hot(AList):
|
||||
rank_df["rank"] = range(1, len(rank_df) + 1)
|
||||
return rank_df[["rank", "stock_code", "short_name", "price", "change", "change_pct"]]
|
||||
|
||||
def hot_rank_100_ths(self):
|
||||
@staticmethod
|
||||
def hot_rank_100_ths():
|
||||
"""
|
||||
同花顺热股100
|
||||
https://dq.10jqka.com.cn/fuyao/hot_list_data/out/hot_list/v1/stock?stock_type=a&type=hour&list_type=normal
|
||||
@ -96,7 +97,8 @@ class Hot(AList):
|
||||
rank_df = rank_df[["rank", "stock_code", "short_name", "change_pct", "hot_value", "pop_tag", "concept_tag"]]
|
||||
return rank_df
|
||||
|
||||
def hot_concept_20_ths(self, plate_type=1):
|
||||
@staticmethod
|
||||
def hot_concept_20_ths(plate_type=1):
|
||||
"""
|
||||
同花热门概念板块
|
||||
:param plate_type: 1.概念板块,2.行业板块;默认:概念板块
|
||||
|
@ -19,6 +19,7 @@ import math
|
||||
|
||||
import pandas as pd
|
||||
|
||||
import adata # 函数内 import,挪过来
|
||||
from adata.common import requests
|
||||
from adata.common.base.base_ths import BaseThs
|
||||
from adata.common.exception.exception_msg import THS_IP_LIMIT_RES, THS_IP_LIMIT_MSG
|
||||
@ -42,9 +43,6 @@ class NorthFlow(BaseThs):
|
||||
__NORTH_FLOW_MIN_COLUMNS = ["trade_time", "net_hgt", "net_sgt", "net_tgt"]
|
||||
__NORTH_FLOW_CURRENT_COLUMNS = __NORTH_FLOW_MIN_COLUMNS
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
def north_flow(self, start_date=None):
|
||||
"""
|
||||
获取北向资金历史的数据,开始时间到最新的历史数据,
|
||||
@ -71,8 +69,7 @@ class NorthFlow(BaseThs):
|
||||
if start_date:
|
||||
start_date = datetime.datetime.strptime(start_date, "%Y-%m-%d")
|
||||
date_min = datetime.datetime.strptime("2017-01-01", "%Y-%m-%d")
|
||||
if start_date < date_min:
|
||||
start_date = date_min
|
||||
start_date = max(start_date, date_min)
|
||||
curr_page = 1
|
||||
data = []
|
||||
while curr_page < 18:
|
||||
@ -95,28 +92,29 @@ class NorthFlow(BaseThs):
|
||||
if not sgt_data:
|
||||
break
|
||||
is_end = False
|
||||
for i in range(len(sgt_data)):
|
||||
# pylint 报的用 enumerate,所以这里保留一下 i 做示范
|
||||
for i, (hgt_item, sgt_item) in enumerate(zip(hgt_data, sgt_data)):
|
||||
if not start_date and i >= 30:
|
||||
is_end = True
|
||||
break
|
||||
if start_date:
|
||||
date_min = datetime.datetime.strptime(hgt_data[i]["TRADE_DATE"], "%Y-%m-%d %H:%M:%S")
|
||||
date_min = datetime.datetime.strptime(hgt_item["TRADE_DATE"], "%Y-%m-%d %H:%M:%S")
|
||||
if start_date > date_min:
|
||||
is_end = True
|
||||
break
|
||||
|
||||
data.append(
|
||||
{
|
||||
"trade_date": hgt_data[i]["TRADE_DATE"],
|
||||
"net_hgt": math.ceil(hgt_data[i]["NET_DEAL_AMT"] * 1000000),
|
||||
"buy_hgt": math.ceil(hgt_data[i]["BUY_AMT"] * 1000000),
|
||||
"sell_hgt": math.ceil(hgt_data[i]["SELL_AMT"] * 1000000),
|
||||
"net_sgt": math.ceil(sgt_data[i]["NET_DEAL_AMT"] * 1000000),
|
||||
"buy_sgt": math.ceil(sgt_data[i]["BUY_AMT"] * 1000000),
|
||||
"sell_sgt": math.ceil(sgt_data[i]["SELL_AMT"] * 1000000),
|
||||
"net_tgt": math.ceil((hgt_data[i]["NET_DEAL_AMT"] + sgt_data[i]["NET_DEAL_AMT"]) * 1000000),
|
||||
"buy_tgt": math.ceil((hgt_data[i]["BUY_AMT"] + sgt_data[i]["BUY_AMT"]) * 1000000),
|
||||
"sell_tgt": math.ceil((hgt_data[i]["SELL_AMT"] + sgt_data[i]["SELL_AMT"]) * 1000000),
|
||||
"trade_date": hgt_item["TRADE_DATE"],
|
||||
"net_hgt": math.ceil(hgt_item["NET_DEAL_AMT"] * 1000000),
|
||||
"buy_hgt": math.ceil(hgt_item["BUY_AMT"] * 1000000),
|
||||
"sell_hgt": math.ceil(hgt_item["SELL_AMT"] * 1000000),
|
||||
"net_sgt": math.ceil(sgt_item["NET_DEAL_AMT"] * 1000000),
|
||||
"buy_sgt": math.ceil(sgt_item["BUY_AMT"] * 1000000),
|
||||
"sell_sgt": math.ceil(sgt_item["SELL_AMT"] * 1000000),
|
||||
"net_tgt": math.ceil((hgt_item["NET_DEAL_AMT"] + sgt_item["NET_DEAL_AMT"]) * 1000000),
|
||||
"buy_tgt": math.ceil((hgt_item["BUY_AMT"] + sgt_item["BUY_AMT"]) * 1000000),
|
||||
"sell_tgt": math.ceil((hgt_item["SELL_AMT"] + sgt_item["SELL_AMT"]) * 1000000),
|
||||
}
|
||||
)
|
||||
|
||||
@ -149,7 +147,7 @@ class NorthFlow(BaseThs):
|
||||
|
||||
def __north_flow_min_ths(self):
|
||||
# 1.接口 url
|
||||
api_url = f" https://data.hexin.cn/market/hsgtApi/method/dayChart/"
|
||||
api_url = "https://data.hexin.cn/market/hsgtApi/method/dayChart/"
|
||||
headers = copy.deepcopy(ths_headers.json_headers)
|
||||
headers["Host"] = "data.hexin.cn"
|
||||
res = requests.request("get", api_url, headers=headers, proxies={})
|
||||
@ -164,17 +162,16 @@ class NorthFlow(BaseThs):
|
||||
hgt_list = result_json["hgt"]
|
||||
sgt_list = result_json["sgt"]
|
||||
data = []
|
||||
for i in range(len(time_list)):
|
||||
for time_item, hgt_item, sgt_item in zip(time_list, hgt_list, sgt_list):
|
||||
row = [
|
||||
time_list[i],
|
||||
math.ceil(hgt_list[i] * 100000000),
|
||||
math.ceil(sgt_list[i] * 100000000),
|
||||
math.ceil((hgt_list[i] + sgt_list[i]) * 100000000),
|
||||
time_item,
|
||||
math.ceil(hgt_item * 100000000),
|
||||
math.ceil(sgt_item * 100000000),
|
||||
math.ceil((hgt_item + sgt_item) * 100000000),
|
||||
]
|
||||
data.append(row)
|
||||
# 3. 封装数据
|
||||
result_df = pd.DataFrame(data=data, columns=self.__NORTH_FLOW_MIN_COLUMNS)
|
||||
import adata
|
||||
|
||||
trade_year = adata.stock.info.trade_calendar()
|
||||
# 获取当前日期
|
||||
@ -216,7 +213,7 @@ class NorthFlow(BaseThs):
|
||||
math.ceil(float(row[3]) * 10000),
|
||||
]
|
||||
)
|
||||
except Exception as e:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
print("north_flow_min_east is ERROR!!!")
|
||||
return pd.DataFrame(data=data, columns=self.__NORTH_FLOW_MIN_COLUMNS)
|
||||
result_df = pd.DataFrame(data=data, columns=self.__NORTH_FLOW_MIN_COLUMNS)
|
||||
|
@ -21,12 +21,9 @@ from adata.common import requests
|
||||
from adata.common.headers import east_headers
|
||||
|
||||
|
||||
class SecuritiesMargin(object):
|
||||
class SecuritiesMargin:
|
||||
__SECURITIES_MARGIN_COLUMN = ["trade_date", "rzye", "rqye", "rzrqye", "rzrqyecz"]
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
def securities_margin(self, start_date=None):
|
||||
"""
|
||||
查询开始时间到现在的融资融券余额数据,默认:查询最近一年的数据
|
||||
|
@ -20,12 +20,9 @@ from adata.common.headers import ths_headers
|
||||
from adata.common.utils import cookie
|
||||
|
||||
|
||||
class StockLifting(object):
|
||||
class StockLifting:
|
||||
__STOCK_LIFTING_COLUMN = ["stock_code", "short_name", "lift_date", "volume", "amount", "ratio", "price"]
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
def stock_lifting_last_month(self):
|
||||
"""
|
||||
查询最近一个月的股票解禁列表
|
||||
@ -45,7 +42,7 @@ class StockLifting(object):
|
||||
total_pages = 1
|
||||
curr_page = 1
|
||||
while curr_page <= total_pages:
|
||||
api_url = f"http://data.10jqka.com.cn/market/xsjj/field/enddate/order/desc/ajax/1/free/1/"
|
||||
api_url = "http://data.10jqka.com.cn/market/xsjj/field/enddate/order/desc/ajax/1/free/1/"
|
||||
if curr_page > 1:
|
||||
api_url = api_url + f"page/{curr_page}/free/1/"
|
||||
headers = copy.deepcopy(ths_headers.text_headers)
|
||||
|
3
pylintrc
3
pylintrc
@ -96,6 +96,9 @@ disable=raw-checker-failed,
|
||||
missing-function-docstring,
|
||||
missing-module-docstring,
|
||||
invalid-name,
|
||||
unsubscriptable-object, # dataframe 相关操作
|
||||
unsupported-assignment-operation, # dataframe 相关操作
|
||||
|
||||
|
||||
# Enable the message, report, category or checker with the given id(s). You can
|
||||
# either give multiple identifier separated by comma (,) or put this option
|
||||
|
Loading…
Reference in New Issue
Block a user