tushare 1.4.4__py3-none-any.whl → 1.4.6__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.
- baks/__init__.py +0 -0
- baks/demo.py +184 -0
- baks/rtqc.py +612 -0
- baks/setup.py +15 -0
- baks/sss.py +56 -0
- test/__init__.py +0 -0
- test/bar_test.py +23 -0
- test/billboard_test.py +35 -0
- test/build_pyd/__init__.py +8 -0
- test/build_pyd/rtqc.py +612 -0
- test/build_pyd/setup.py +15 -0
- test/build_pyd//321/206/320/231/320/243/321/205/320/234/320/225pyd/321/205/320/241/342/225/234/321/204/342/225/227/320/264.txt +1 -0
- test/classifying_test.py +50 -0
- test/dateu_test.py +19 -0
- test/fund_test.py +43 -0
- test/indictor_test.py +23 -0
- test/macro_test.py +50 -0
- test/nav_test.py +104 -0
- test/news_test.py +38 -0
- test/pro_test.py +11 -0
- test/ref_test.py +57 -0
- test/shibor_test.py +33 -0
- test/storing_test.py +61 -0
- test/test_query.py +16 -0
- test/test_realtime.py +24 -0
- test/test_realtime_quote.py +13 -0
- test/test_sdk_event.py +21 -0
- test/test_stk_mins.py +16 -0
- test/test_stock_basic.py +16 -0
- test/test_tgw_subscribe.py +28 -0
- test/test_ts_subscribe.py +22 -0
- test/test_websocket.py +52 -0
- test/trading_test.py +43 -0
- tushare/__init__.py +1 -1
- tushare/stock/rtq.py +6 -4
- tushare/stock/rtqc.pyd +0 -0
- tushare/subs/ht_subs/service/__init__.py +0 -0
- tushare/subs/ht_subs/service/covert.py +189 -0
- tushare/subs/model/tick.py +128 -128
- tushare/subs/ts_subs.py +192 -0
- {tushare-1.4.4.dist-info → tushare-1.4.6.dist-info}/METADATA +101 -101
- {tushare-1.4.4.dist-info → tushare-1.4.6.dist-info}/RECORD +45 -8
- {tushare-1.4.4.dist-info → tushare-1.4.6.dist-info}/WHEEL +1 -1
- {tushare-1.4.4.dist-info → tushare-1.4.6.dist-info}/top_level.txt +1 -0
- {tushare-1.4.4.dist-info → tushare-1.4.6.dist-info}/LICENSE +0 -0
baks/__init__.py
ADDED
File without changes
|
baks/demo.py
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
Created on 2021-12-31 09:32:16
|
4
|
+
---------
|
5
|
+
@summary:
|
6
|
+
---------
|
7
|
+
@author: yangyx01
|
8
|
+
"""
|
9
|
+
import pandas as pd
|
10
|
+
import requests
|
11
|
+
from typing import Optional
|
12
|
+
from tushare.util.format_stock_code import format_stock_code
|
13
|
+
|
14
|
+
|
15
|
+
def get_stock_all_a_dc(page_count: Optional[int] = None,
|
16
|
+
proxies: Optional[dict] = {}) -> pd.DataFrame:
|
17
|
+
"""
|
18
|
+
东方财富网-沪深京 A 股-实时行情
|
19
|
+
https://quote.eastmoney.com/center/gridlist.html#hs_a_board
|
20
|
+
:return: 实时行情
|
21
|
+
:rtype: pandas.DataFrame
|
22
|
+
1、序号:RANK
|
23
|
+
2、代码:TS_CODE
|
24
|
+
3、名称:NAME
|
25
|
+
4、最新价:PRICE
|
26
|
+
5、涨跌幅:PCT_CHANGE
|
27
|
+
6、涨跌额:CHANGE
|
28
|
+
7、成交量:VOLUME
|
29
|
+
8、成交额:AMOUNT
|
30
|
+
9、振幅:SWING
|
31
|
+
10、最高:HIGH
|
32
|
+
11、最低:LOW
|
33
|
+
12、今开:OPEN
|
34
|
+
13、昨收:CLOSE
|
35
|
+
14、量比:VOL_RATIO
|
36
|
+
15、换手率:TURNOVER_RATE
|
37
|
+
16、市盈率-动态:PE
|
38
|
+
17、市净率:PB
|
39
|
+
18、总市值:TOTAL_MV
|
40
|
+
19、流通市值:FLOAT_MV
|
41
|
+
20、涨速:RISE
|
42
|
+
21、5分钟涨跌:5MIN
|
43
|
+
22、60日涨跌幅:60DAY
|
44
|
+
23、年初至今涨跌幅:1YEAR
|
45
|
+
"""
|
46
|
+
url = "http://82.push2.eastmoney.com/api/qt/clist/get"
|
47
|
+
params = {
|
48
|
+
"pn": "1",
|
49
|
+
"pz": "50000",
|
50
|
+
"po": "1",
|
51
|
+
"np": "1",
|
52
|
+
"ut": "bd1d9ddb04089700cf9c27f6f7426281",
|
53
|
+
"fltt": "2",
|
54
|
+
"invt": "2",
|
55
|
+
"fid": "f3",
|
56
|
+
"fs": "m:0 t:6,m:0 t:80,m:1 t:2,m:1 t:23,m:0 t:81 s:2048",
|
57
|
+
"fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
|
58
|
+
"_": "1623833739532",
|
59
|
+
}
|
60
|
+
if page_count:
|
61
|
+
params["pz"] = 20
|
62
|
+
r = requests.get(url, params=params, proxies=proxies)
|
63
|
+
data_json = r.json()
|
64
|
+
if not data_json["data"]["diff"]:
|
65
|
+
return pd.DataFrame()
|
66
|
+
temp_df = pd.DataFrame(data_json["data"]["diff"])
|
67
|
+
temp_df.columns = [
|
68
|
+
"_",
|
69
|
+
"最新价",
|
70
|
+
"涨跌幅",
|
71
|
+
"涨跌额",
|
72
|
+
"成交量",
|
73
|
+
"成交额",
|
74
|
+
"振幅",
|
75
|
+
"换手率",
|
76
|
+
"市盈率-动态",
|
77
|
+
"量比",
|
78
|
+
"5分钟涨跌",
|
79
|
+
"代码",
|
80
|
+
"_",
|
81
|
+
"名称",
|
82
|
+
"最高",
|
83
|
+
"最低",
|
84
|
+
"今开",
|
85
|
+
"昨收",
|
86
|
+
"总市值",
|
87
|
+
"流通市值",
|
88
|
+
"涨速",
|
89
|
+
"市净率",
|
90
|
+
"60日涨跌幅",
|
91
|
+
"年初至今涨跌幅",
|
92
|
+
"-",
|
93
|
+
"-",
|
94
|
+
"-",
|
95
|
+
"-",
|
96
|
+
"-",
|
97
|
+
"-",
|
98
|
+
"-",
|
99
|
+
]
|
100
|
+
temp_df.reset_index(inplace=True)
|
101
|
+
# temp_df["index"] = temp_df.index + 1
|
102
|
+
# temp_df.rename(columns={"index": "序号"}, inplace=True)
|
103
|
+
temp_df = temp_df[
|
104
|
+
[
|
105
|
+
# "序号",
|
106
|
+
"代码",
|
107
|
+
"名称",
|
108
|
+
"最新价",
|
109
|
+
"涨跌幅",
|
110
|
+
"涨跌额",
|
111
|
+
"成交量",
|
112
|
+
"成交额",
|
113
|
+
"振幅",
|
114
|
+
"最高",
|
115
|
+
"最低",
|
116
|
+
"今开",
|
117
|
+
"昨收",
|
118
|
+
"量比",
|
119
|
+
"换手率",
|
120
|
+
"市盈率-动态",
|
121
|
+
"市净率",
|
122
|
+
"总市值",
|
123
|
+
"流通市值",
|
124
|
+
"涨速",
|
125
|
+
"5分钟涨跌",
|
126
|
+
"60日涨跌幅",
|
127
|
+
"年初至今涨跌幅",
|
128
|
+
]
|
129
|
+
]
|
130
|
+
|
131
|
+
temp_df["代码"] = temp_df["代码"].apply(format_stock_code)
|
132
|
+
temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce")
|
133
|
+
temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"], errors="coerce")
|
134
|
+
temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"], errors="coerce")
|
135
|
+
temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
|
136
|
+
temp_df["成交额"] = pd.to_numeric(temp_df["成交额"], errors="coerce")
|
137
|
+
temp_df["振幅"] = pd.to_numeric(temp_df["振幅"], errors="coerce")
|
138
|
+
temp_df["最高"] = pd.to_numeric(temp_df["最高"], errors="coerce")
|
139
|
+
temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce")
|
140
|
+
temp_df["今开"] = pd.to_numeric(temp_df["今开"], errors="coerce")
|
141
|
+
temp_df["昨收"] = pd.to_numeric(temp_df["昨收"], errors="coerce")
|
142
|
+
temp_df["量比"] = pd.to_numeric(temp_df["量比"], errors="coerce")
|
143
|
+
temp_df["换手率"] = pd.to_numeric(temp_df["换手率"], errors="coerce")
|
144
|
+
temp_df["市盈率-动态"] = pd.to_numeric(temp_df["市盈率-动态"], errors="coerce")
|
145
|
+
temp_df["市净率"] = pd.to_numeric(temp_df["市净率"], errors="coerce")
|
146
|
+
temp_df["总市值"] = pd.to_numeric(temp_df["总市值"], errors="coerce")
|
147
|
+
temp_df["流通市值"] = pd.to_numeric(temp_df["流通市值"], errors="coerce")
|
148
|
+
temp_df["涨速"] = pd.to_numeric(temp_df["涨速"], errors="coerce")
|
149
|
+
temp_df["5分钟涨跌"] = pd.to_numeric(temp_df["5分钟涨跌"], errors="coerce")
|
150
|
+
temp_df["60日涨跌幅"] = pd.to_numeric(temp_df["60日涨跌幅"], errors="coerce")
|
151
|
+
temp_df["年初至今涨跌幅"] = pd.to_numeric(temp_df["年初至今涨跌幅"], errors="coerce")
|
152
|
+
temp_df.columns = [
|
153
|
+
# "RANK",
|
154
|
+
"TS_CODE",
|
155
|
+
"NAME",
|
156
|
+
"PRICE",
|
157
|
+
"PCT_CHANGE",
|
158
|
+
"CHANGE",
|
159
|
+
"VOLUME",
|
160
|
+
"AMOUNT",
|
161
|
+
"SWING",
|
162
|
+
"HIGH",
|
163
|
+
"LOW",
|
164
|
+
"OPEN",
|
165
|
+
"CLOSE",
|
166
|
+
"VOL_RATIO",
|
167
|
+
"TURNOVER_RATE",
|
168
|
+
"PE",
|
169
|
+
"PB",
|
170
|
+
"TOTAL_MV",
|
171
|
+
"FLOAT_MV",
|
172
|
+
"RISE",
|
173
|
+
"5MIN",
|
174
|
+
"60DAY",
|
175
|
+
"1YEAR",
|
176
|
+
]
|
177
|
+
temp_df = temp_df.iloc[:, [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12]]
|
178
|
+
df_sorted = temp_df.sort_values(by='PCT_CHANGE', ascending=False).reset_index(drop=True)
|
179
|
+
return df_sorted
|
180
|
+
|
181
|
+
|
182
|
+
if __name__ == '__main__':
|
183
|
+
df = get_stock_all_a_dc(page_count=1)
|
184
|
+
print(df)
|