akshare-one 0.3.2__py3-none-any.whl → 0.3.4__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.
- akshare_one/__init__.py +198 -15
- akshare_one/modules/cache.py +20 -2
- akshare_one/modules/financial/base.py +5 -0
- akshare_one/modules/financial/factory.py +2 -0
- akshare_one/modules/financial/sina.py +125 -106
- akshare_one/modules/historical/base.py +1 -1
- akshare_one/modules/historical/eastmoney.py +9 -14
- akshare_one/modules/historical/eastmoney_direct.py +5 -6
- akshare_one/modules/historical/sina.py +6 -10
- akshare_one/modules/info/base.py +25 -0
- akshare_one/modules/info/eastmoney.py +51 -0
- akshare_one/modules/info/factory.py +44 -0
- akshare_one/modules/insider/base.py +1 -1
- akshare_one/modules/insider/xueqiu.py +8 -13
- akshare_one/modules/news/base.py +1 -1
- akshare_one/modules/news/eastmoney.py +5 -9
- akshare_one/modules/realtime/eastmoney.py +4 -8
- akshare_one/modules/realtime/eastmoney_direct.py +5 -6
- akshare_one/modules/realtime/xueqiu.py +4 -7
- {akshare_one-0.3.2.dist-info → akshare_one-0.3.4.dist-info}/METADATA +9 -5
- akshare_one-0.3.4.dist-info/RECORD +36 -0
- akshare_one/financial.py +0 -46
- akshare_one/insider.py +0 -33
- akshare_one/modules/eastmoney/client.py +0 -88
- akshare_one/modules/eastmoney/utils.py +0 -104
- akshare_one/news.py +0 -27
- akshare_one/stock.py +0 -78
- akshare_one-0.3.2.dist-info/RECORD +0 -39
- {akshare_one-0.3.2.dist-info → akshare_one-0.3.4.dist-info}/WHEEL +0 -0
- {akshare_one-0.3.2.dist-info → akshare_one-0.3.4.dist-info}/licenses/LICENSE +0 -0
- {akshare_one-0.3.2.dist-info → akshare_one-0.3.4.dist-info}/top_level.txt +0 -0
@@ -1,104 +0,0 @@
|
|
1
|
-
import pandas as pd
|
2
|
-
from typing import Dict, Any
|
3
|
-
|
4
|
-
|
5
|
-
def parse_kline_data(data: Dict[str, Any]) -> pd.DataFrame:
|
6
|
-
"""
|
7
|
-
Parses K-line data from the API response into a pandas DataFrame.
|
8
|
-
"""
|
9
|
-
klines = data.get("data", {}).get("klines", [])
|
10
|
-
if not klines:
|
11
|
-
return pd.DataFrame(
|
12
|
-
columns=["timestamp", "open", "high", "low", "close", "volume"]
|
13
|
-
)
|
14
|
-
|
15
|
-
records = []
|
16
|
-
for kline in klines:
|
17
|
-
parts = kline.split(",")
|
18
|
-
if len(parts) >= 6:
|
19
|
-
records.append(
|
20
|
-
{
|
21
|
-
"timestamp": parts[0],
|
22
|
-
"open": float(parts[1]),
|
23
|
-
"close": float(parts[2]),
|
24
|
-
"high": float(parts[3]),
|
25
|
-
"low": float(parts[4]),
|
26
|
-
"volume": int(parts[5]),
|
27
|
-
}
|
28
|
-
)
|
29
|
-
|
30
|
-
df = pd.DataFrame(records)
|
31
|
-
if not df.empty:
|
32
|
-
df["timestamp"] = pd.to_datetime(df["timestamp"])
|
33
|
-
df["timestamp"] = (
|
34
|
-
df["timestamp"].dt.tz_localize("Asia/Shanghai").dt.tz_convert("UTC")
|
35
|
-
)
|
36
|
-
df = df[["timestamp", "open", "high", "low", "close", "volume"]]
|
37
|
-
return df
|
38
|
-
|
39
|
-
|
40
|
-
def parse_realtime_data(data: Dict[str, Any]) -> pd.DataFrame:
|
41
|
-
"""
|
42
|
-
Parses real-time quote data from the API response into a pandas DataFrame.
|
43
|
-
"""
|
44
|
-
stock_data = data.get("data")
|
45
|
-
if not stock_data:
|
46
|
-
return pd.DataFrame()
|
47
|
-
|
48
|
-
df = pd.DataFrame(
|
49
|
-
[
|
50
|
-
{
|
51
|
-
"symbol": stock_data.get("f57"),
|
52
|
-
"price": stock_data.get("f43"),
|
53
|
-
"change": stock_data.get("f169"),
|
54
|
-
"pct_change": stock_data.get("f170"),
|
55
|
-
"volume": stock_data.get("f47"),
|
56
|
-
"amount": stock_data.get("f48"),
|
57
|
-
"open": stock_data.get("f46"),
|
58
|
-
"high": stock_data.get("f44"),
|
59
|
-
"low": stock_data.get("f45"),
|
60
|
-
"prev_close": stock_data.get("f60"),
|
61
|
-
}
|
62
|
-
]
|
63
|
-
)
|
64
|
-
df["timestamp"] = pd.Timestamp.now(tz="Asia/Shanghai").tz_convert("UTC")
|
65
|
-
return df
|
66
|
-
|
67
|
-
|
68
|
-
def resample_historical_data(
|
69
|
-
df: pd.DataFrame, interval: str, multiplier: int
|
70
|
-
) -> pd.DataFrame:
|
71
|
-
"""
|
72
|
-
Resamples historical data to a specified frequency.
|
73
|
-
"""
|
74
|
-
if df.empty or multiplier <= 1:
|
75
|
-
return df
|
76
|
-
|
77
|
-
df = df.set_index("timestamp")
|
78
|
-
|
79
|
-
freq_map = {
|
80
|
-
"day": f"{multiplier}D",
|
81
|
-
"week": f"{multiplier}W-MON",
|
82
|
-
"month": f"{multiplier}MS",
|
83
|
-
"year": f"{multiplier * 12}MS",
|
84
|
-
}
|
85
|
-
freq = freq_map.get(interval)
|
86
|
-
|
87
|
-
if not freq:
|
88
|
-
return df.reset_index()
|
89
|
-
|
90
|
-
resampled = (
|
91
|
-
df.resample(freq)
|
92
|
-
.agg(
|
93
|
-
{
|
94
|
-
"open": "first",
|
95
|
-
"high": "max",
|
96
|
-
"low": "min",
|
97
|
-
"close": "last",
|
98
|
-
"volume": "sum",
|
99
|
-
}
|
100
|
-
)
|
101
|
-
.dropna()
|
102
|
-
)
|
103
|
-
|
104
|
-
return resampled.reset_index()
|
akshare_one/news.py
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
"""新闻数据模块
|
2
|
-
|
3
|
-
包含股票新闻相关功能
|
4
|
-
"""
|
5
|
-
|
6
|
-
import pandas as pd
|
7
|
-
from .modules.news.factory import NewsDataFactory
|
8
|
-
|
9
|
-
|
10
|
-
def get_news_data(symbol: str, source: str = "eastmoney") -> "pd.DataFrame":
|
11
|
-
"""获取个股新闻数据
|
12
|
-
|
13
|
-
Args:
|
14
|
-
symbol: 股票代码 (如 "300059")
|
15
|
-
source: 数据源 ('eastmoney')
|
16
|
-
|
17
|
-
Returns:
|
18
|
-
pd.DataFrame:
|
19
|
-
- keyword: 关键词
|
20
|
-
- title: 新闻标题
|
21
|
-
- content: 新闻内容
|
22
|
-
- publish_time: 发布时间
|
23
|
-
- source: 文章来源
|
24
|
-
- url: 新闻链接
|
25
|
-
"""
|
26
|
-
provider = NewsDataFactory.get_provider(source, symbol=symbol)
|
27
|
-
return provider.get_news_data()
|
akshare_one/stock.py
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
"""股票市场数据模块
|
2
|
-
|
3
|
-
包含股票历史数据和实时数据相关功能
|
4
|
-
"""
|
5
|
-
|
6
|
-
from typing import Optional
|
7
|
-
import pandas as pd
|
8
|
-
|
9
|
-
from akshare_one.modules.historical.factory import HistoricalDataFactory
|
10
|
-
from akshare_one.modules.realtime.factory import RealtimeDataFactory
|
11
|
-
|
12
|
-
|
13
|
-
def get_hist_data(
|
14
|
-
symbol: str,
|
15
|
-
interval: str = "day",
|
16
|
-
interval_multiplier: int = 1,
|
17
|
-
start_date: str = "1970-01-01",
|
18
|
-
end_date: str = "2030-12-31",
|
19
|
-
adjust: str = "none",
|
20
|
-
source: str = "eastmoney",
|
21
|
-
) -> "pd.DataFrame":
|
22
|
-
"""Get historical market data
|
23
|
-
|
24
|
-
Args:
|
25
|
-
symbol: 股票代码 (e.g. '600000')
|
26
|
-
interval: 时间间隔 ('minute','hour','day','week','month','year')
|
27
|
-
interval_multiplier: 时间间隔倍数 (e.g. 5 for 5 minutes)
|
28
|
-
start_date: 开始日期 (YYYY-MM-DD)
|
29
|
-
end_date: 结束日期 (YYYY-MM-DD)
|
30
|
-
adjust: 复权类型 ('none','qfq','hfq')
|
31
|
-
source: 数据源 ('eastmoney', 'eastmoney_direct', 'sina') (default: 'eastmoney')
|
32
|
-
|
33
|
-
Returns:
|
34
|
-
pd.DataFrame:
|
35
|
-
- timestamp: 时间戳(UTC时区)
|
36
|
-
- open: 开盘价
|
37
|
-
- high: 最高价
|
38
|
-
- low: 最低价
|
39
|
-
- close: 收盘价
|
40
|
-
- volume: 成交量
|
41
|
-
"""
|
42
|
-
kwargs = {
|
43
|
-
"symbol": symbol,
|
44
|
-
"interval": interval,
|
45
|
-
"interval_multiplier": interval_multiplier,
|
46
|
-
"start_date": start_date,
|
47
|
-
"end_date": end_date,
|
48
|
-
"adjust": adjust,
|
49
|
-
}
|
50
|
-
provider = HistoricalDataFactory.get_provider(source, **kwargs)
|
51
|
-
return provider.get_hist_data()
|
52
|
-
|
53
|
-
|
54
|
-
def get_realtime_data(
|
55
|
-
symbol: Optional[str] = None, source: str = "xueqiu"
|
56
|
-
) -> "pd.DataFrame":
|
57
|
-
"""Get real-time market quotes
|
58
|
-
|
59
|
-
Args:
|
60
|
-
symbol: 股票代码 (如 "600000")
|
61
|
-
source: 数据源 ('eastmoney', 'eastmoney_direct', 'xueqiu')
|
62
|
-
|
63
|
-
Returns:
|
64
|
-
pd.DataFrame:
|
65
|
-
- symbol: 股票代码
|
66
|
-
- price: 最新价
|
67
|
-
- change: 涨跌额
|
68
|
-
- pct_change: 涨跌幅(%)
|
69
|
-
- timestamp: 时间戳
|
70
|
-
- volume: 成交量(手)
|
71
|
-
- amount: 成交额(元)
|
72
|
-
- open: 今开
|
73
|
-
- high: 最高
|
74
|
-
- low: 最低
|
75
|
-
- prev_close: 昨收
|
76
|
-
"""
|
77
|
-
provider = RealtimeDataFactory.get_provider(source, symbol=symbol)
|
78
|
-
return provider.get_current_data()
|
@@ -1,39 +0,0 @@
|
|
1
|
-
akshare_one/__init__.py,sha256=W8FpPEXHDYu6JKPuAXylA3fpFt_axj3vNQC_kevjmY8,909
|
2
|
-
akshare_one/financial.py,sha256=uCTFpcoeCxDo1iwewGPq9_TppwoHXBJFT4QlMgFOgRQ,1472
|
3
|
-
akshare_one/indicators.py,sha256=x3Amff9CG_GvQpA-sqGfFwEAIvaaXlBxDfzTxD05taQ,12533
|
4
|
-
akshare_one/insider.py,sha256=ugr7TXjZvHkaQ-3cNmXeo9LCUqfmcbIwQx-gs-RItAA,1125
|
5
|
-
akshare_one/news.py,sha256=Pqap-23VCosG9vf70eEeFAC4O0emS-CORHjwkuDuoUA,696
|
6
|
-
akshare_one/stock.py,sha256=VFMNn3Sqa2P9dKZueOa8ekqbxo4jc08iXS94B8eClMo,2344
|
7
|
-
akshare_one/modules/cache.py,sha256=LBOfMQE9-Mr49GRS7d0dATGdMZCZcQWiY41p4GUI2DA,382
|
8
|
-
akshare_one/modules/utils.py,sha256=msHqsjWSRULbX-3Bnit1p26a4a7MOEuNfkPSaECXr4k,333
|
9
|
-
akshare_one/modules/eastmoney/client.py,sha256=npxW6H8tfehDBAVAsUBOD0T4zpn7OnXfM-t2ZWr02hs,3206
|
10
|
-
akshare_one/modules/eastmoney/utils.py,sha256=0hs1kE51kZs3A9cOK448w5K8YKHaKZi0WWgtGZHVPGc,3000
|
11
|
-
akshare_one/modules/financial/base.py,sha256=D-leZAXdKe5srbB4rrxdjNc8TWk2bflt7qtL_KBddY0,558
|
12
|
-
akshare_one/modules/financial/factory.py,sha256=Lv66xSmmQyE8jZZvnYcgl_oZ0VUmBISN2yegsN38_oM,1345
|
13
|
-
akshare_one/modules/financial/sina.py,sha256=xKR8RqePfi_vFBntet7e5xjvYHolVrXfOJHRK4x54b4,11187
|
14
|
-
akshare_one/modules/historical/base.py,sha256=4jdHW99-5U1mzv0WPopIkxeh20yYUDrNFzn7xazfwZU,1292
|
15
|
-
akshare_one/modules/historical/eastmoney.py,sha256=VbOaf0zXxuGmmm60x4FMh-9T5N9mYTUGmG1suMFUPfU,8489
|
16
|
-
akshare_one/modules/historical/eastmoney_direct.py,sha256=EF5AhViBwdNywqZnJYacRrdw4Up0gbuUr7RgssK7rpw,2893
|
17
|
-
akshare_one/modules/historical/factory.py,sha256=qfMod5HSV-itE-i1ludIp0w8Zq7Vjp2LPomajVd5Kjc,1548
|
18
|
-
akshare_one/modules/historical/sina.py,sha256=CI7eiXG7xo-2J6TEyq0Lr25vogAedbSa3mMHI9REgIQ,8939
|
19
|
-
akshare_one/modules/indicators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
|
-
akshare_one/modules/indicators/base.py,sha256=DhFivpVIUIkdIv24U2WoOy1GCDySxsw0tD0-rBRe5Lc,4376
|
21
|
-
akshare_one/modules/indicators/factory.py,sha256=pKx57oej_L0Lz3kkXwzVievKpOYph0T_Y7fzSwO3Zd4,1021
|
22
|
-
akshare_one/modules/indicators/simple.py,sha256=vAqE3v9HYpW-Sy6KsG9oV5fppWchQTxtz1M_508sQtY,9342
|
23
|
-
akshare_one/modules/indicators/talib.py,sha256=w0KpV-BXVxU0LmWs_EbXJUFgo9dbMeUQijjJMkjtWtU,10773
|
24
|
-
akshare_one/modules/insider/base.py,sha256=NE45w-B9sQ2AoUSSKNPU9U6wPHK4fiLV5Zgj_byrBMQ,977
|
25
|
-
akshare_one/modules/insider/factory.py,sha256=32bueJA3E8yCZc0v5EAen_48RZ23yojYzpzaZyQ6WnA,1324
|
26
|
-
akshare_one/modules/insider/xueqiu.py,sha256=6WKEvdE-8cjVQjTsJIkgnqhaQUS5sXZCyxKPLMLyers,4109
|
27
|
-
akshare_one/modules/news/base.py,sha256=D5BDtRQ9vdi1Gj-ikbtjAaCAbimW6mCEhRo_NJTmqN4,581
|
28
|
-
akshare_one/modules/news/eastmoney.py,sha256=2gPEnzQ347MJMXAUsxxu8MnizvCrfGPse9V83wfCsXE,1380
|
29
|
-
akshare_one/modules/news/factory.py,sha256=3FMkNBpYF7l-v2NHHR5TzbvklQNzJ-R_XzG8AlRjJcg,1308
|
30
|
-
akshare_one/modules/realtime/base.py,sha256=eYicSs7E4qmcpQ-8TnbfmJvsK0VQoezVK7Zobqh5xPk,729
|
31
|
-
akshare_one/modules/realtime/eastmoney.py,sha256=IRAPokCm_-aOn16w5_dkbKVjdYcqL-y7GSHrSgOjT2E,1707
|
32
|
-
akshare_one/modules/realtime/eastmoney_direct.py,sha256=HiHrhsTcDTswMg4b7JSUXHLtf-oYziWxLGXLhFJ2pYo,1275
|
33
|
-
akshare_one/modules/realtime/factory.py,sha256=_7jBDgqWqkt5xTTT1SpZoUHM9IpMRpcUQeyyCglM5z0,1528
|
34
|
-
akshare_one/modules/realtime/xueqiu.py,sha256=j_cjJZD0fTva_jgXKeQAJSFVHKJHb5zMu3Crf_8zLs0,2301
|
35
|
-
akshare_one-0.3.2.dist-info/licenses/LICENSE,sha256=3bqxoD7aU4QS7kpNtQmRd4MikxXe6Gtm_DrojyFHGAc,1087
|
36
|
-
akshare_one-0.3.2.dist-info/METADATA,sha256=1qV4rAqnvSDrYHQHbtho8lJgXhzCvbbSdfvup6zk400,2132
|
37
|
-
akshare_one-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
38
|
-
akshare_one-0.3.2.dist-info/top_level.txt,sha256=kNiucyLVAGa89wmUSpXbBLWD7pF_RuahuiaOfLHZSyw,12
|
39
|
-
akshare_one-0.3.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|