tushare 1.4.6__py3-none-any.whl → 1.4.7__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.
Files changed (46) hide show
  1. tushare/__init__.py +1 -1
  2. tushare/pro/data_pro.py +18 -10
  3. tushare/subs/model/tick.py +128 -128
  4. tushare/subs/tgw_subs/convert.py +20 -20
  5. {tushare-1.4.6.dist-info → tushare-1.4.7.dist-info}/METADATA +98 -101
  6. {tushare-1.4.6.dist-info → tushare-1.4.7.dist-info}/RECORD +9 -46
  7. {tushare-1.4.6.dist-info → tushare-1.4.7.dist-info}/WHEEL +1 -1
  8. {tushare-1.4.6.dist-info → tushare-1.4.7.dist-info}/top_level.txt +0 -1
  9. baks/__init__.py +0 -0
  10. baks/demo.py +0 -184
  11. baks/rtqc.py +0 -612
  12. baks/setup.py +0 -15
  13. baks/sss.py +0 -56
  14. test/__init__.py +0 -0
  15. test/bar_test.py +0 -23
  16. test/billboard_test.py +0 -35
  17. test/build_pyd/__init__.py +0 -8
  18. test/build_pyd/rtqc.py +0 -612
  19. test/build_pyd/setup.py +0 -15
  20. 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 +0 -1
  21. test/classifying_test.py +0 -50
  22. test/dateu_test.py +0 -19
  23. test/fund_test.py +0 -43
  24. test/indictor_test.py +0 -23
  25. test/macro_test.py +0 -50
  26. test/nav_test.py +0 -104
  27. test/news_test.py +0 -38
  28. test/pro_test.py +0 -11
  29. test/ref_test.py +0 -57
  30. test/shibor_test.py +0 -33
  31. test/storing_test.py +0 -61
  32. test/test_query.py +0 -16
  33. test/test_realtime.py +0 -24
  34. test/test_realtime_quote.py +0 -13
  35. test/test_sdk_event.py +0 -21
  36. test/test_stk_mins.py +0 -16
  37. test/test_stock_basic.py +0 -16
  38. test/test_tgw_subscribe.py +0 -28
  39. test/test_ts_subscribe.py +0 -22
  40. test/test_websocket.py +0 -52
  41. test/trading_test.py +0 -43
  42. tushare/stock/rtqc.pyd +0 -0
  43. tushare/subs/ht_subs/service/__init__.py +0 -0
  44. tushare/subs/ht_subs/service/covert.py +0 -189
  45. tushare/subs/ts_subs.py +0 -192
  46. {tushare-1.4.6.dist-info → tushare-1.4.7.dist-info}/LICENSE +0 -0
test/bar_test.py DELETED
@@ -1,23 +0,0 @@
1
- # -*- coding:utf-8 -*-
2
- '''
3
- Created on 2017/9/24
4
- @author: Jimmy Liu
5
- '''
6
- import unittest
7
- import tushare.stock.trading as fd
8
-
9
- class Test(unittest.TestCase):
10
-
11
- def set_data(self):
12
- self.code = '600848'
13
- self.start = ''
14
- self.end = ''
15
-
16
- def test_bar_data(self):
17
- self.set_data()
18
- print(fd.bar(self.code, self.start, self.end))
19
-
20
-
21
- if __name__ == "__main__":
22
- #import sys;sys.argv = ['', 'Test.testName']
23
- unittest.main()
test/billboard_test.py DELETED
@@ -1,35 +0,0 @@
1
- # -*- coding:utf-8 -*-
2
- '''
3
- Created on 2015/3/14
4
- @author: Jimmy Liu
5
- '''
6
- import unittest
7
- import tushare.stock.billboard as fd
8
-
9
- class Test(unittest.TestCase):
10
-
11
- def set_data(self):
12
- self.date = '2015-06-12'
13
- self.days = 5
14
-
15
- def test_top_list(self):
16
- self.set_data()
17
- print(fd.top_list(self.date))
18
-
19
- def test_cap_tops(self):
20
- self.set_data()
21
- print(fd.cap_tops(self.days))
22
-
23
- def test_broker_tops(self):
24
- self.set_data()
25
- print(fd.broker_tops(self.days))
26
-
27
- def test_inst_tops(self):
28
- self.set_data()
29
- print(fd.inst_tops(self.days))
30
-
31
- def test_inst_detail(self):
32
- print(fd.inst_detail())
33
-
34
- if __name__ == "__main__":
35
- unittest.main()
@@ -1,8 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on 2021-12-31 09:32:16
4
- ---------
5
- @summary:
6
- ---------
7
- @author: yangyx01
8
- """
test/build_pyd/rtqc.py DELETED
@@ -1,612 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding:utf-8 -*-
3
- """
4
- 所有 A 股的实时行情数据
5
- Created on 2023/12/06
6
- @author: Monday
7
- @group : waditu
8
- @contact:
9
- """
10
- import time
11
- import pandas as pd
12
- import requests
13
- from tqdm import tqdm
14
- from typing import Optional
15
- import re
16
- from tushare.util.format_stock_code import symbol_verify
17
- from tushare.util.format_stock_code import format_stock_code
18
- from tushare.util.form_date import timestemp_to_time
19
- from tushare.stock import rtq_vars as rtqv
20
- from tushare.util.verify_token import require_permission
21
- from tushare.stock import cons as ct
22
- from tushare.stock.rtq_vars import (
23
- zh_sina_a_stock_payload,
24
- zh_sina_a_stock_url,
25
- zh_sina_a_stock_count_url,
26
- zh_sina_a_stock_headers,
27
- zh_sina_a_stock_cookies,
28
-
29
- )
30
-
31
-
32
- def _random(n=13):
33
- from random import randint
34
- start = 10 ** (n - 1)
35
- end = (10 ** n) - 1
36
- return str(randint(start, end))
37
-
38
-
39
- def _get_current_timestamp():
40
- return str(int(time.time() * 1000))
41
-
42
-
43
- @require_permission(event_name="realtime_quote", event_detail="个股实时交易数据")
44
- def realtime_quote(ts_code="688553.SH", src="sina", ):
45
- """
46
- 获取实时交易数据 getting real time quotes data
47
- 用于跟踪交易情况(本次执行的结果-上一次执行的数据)
48
- Parameters
49
- ------
50
- ts_code : string
51
- src : sina ,dc
52
-
53
- return
54
- -------
55
- DataFrame 实时交易数据
56
- 属性:0:name,股票名字
57
- 1:open,今日开盘价
58
- 2:pre_close,昨日收盘价
59
- 3:price,当前价格
60
- 4:high,今日最高价
61
- 5:low,今日最低价
62
- 6:bid,竞买价,即“买一”报价
63
- 7:ask,竞卖价,即“卖一”报价
64
- 8:volumn,成交量 maybe you need do volumn/100
65
- 9:amount,成交金额(元 CNY)
66
- 10:b1_v,委买一(笔数 bid volume)
67
- 11:b1_p,委买一(价格 bid price)
68
- 12:b2_v,“买二”
69
- 13:b2_p,“买二”
70
- 14:b3_v,“买三”
71
- 15:b3_p,“买三”
72
- 16:b4_v,“买四”
73
- 17:b4_p,“买四”
74
- 18:b5_v,“买五”
75
- 19:b5_p,“买五”
76
- 20:a1_v,委卖一(笔数 ask volume)
77
- 21:a1_p,委卖一(价格 ask price)
78
- ...
79
- 30:date,日期;
80
- 31:time,时间;
81
- """
82
- symbols = symbol_verify(ts_code)
83
- if src == "sina":
84
- return get_realtime_quotes_sina(symbols)
85
- else:
86
- return get_realtime_quotes_dc(symbols)
87
-
88
-
89
- sina_stock_code = {}
90
-
91
-
92
- def get_realtime_quotes_sina(symbol="688553"): # "688553"
93
- global sina_stock_code
94
- symbols = []
95
- syms = []
96
- for i in [j for j in symbol.split(",")]:
97
- s = i.split(".")
98
- sina_stock_code[s[0]] = s[1].upper()
99
- symbols.append(s[1].lower() + s[0])
100
- syms.append(s[0])
101
- # symbols = re.search(r"(\d+)", str(symbols), re.S | re.M).group(1)
102
- symbols_list = ''
103
- if isinstance(symbols, list) or isinstance(symbols, set) or \
104
- isinstance(symbols, tuple) or isinstance(symbols, pd.Series):
105
- for code in symbols:
106
- symbols_list += code + ','
107
- else:
108
- symbols_list = symbols
109
- symbols_list = symbols_list[:-1] if len(symbols_list) > 8 else symbols_list
110
- root_url = ct.LIVE_DATA_URL % (ct.P_TYPE['http'], ct.DOMAINS['sinahq'], _get_current_timestamp(), symbols_list)
111
- response = requests.get(root_url,
112
- headers={
113
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0",
114
- 'host': 'hq.sinajs.cn',
115
- 'referer': 'https://finance.sina.com.cn/'
116
- })
117
- text = response.content.decode('GBK')
118
- reg = re.compile(r'\="(.*?)\";')
119
- data = reg.findall(text)
120
- data_list = []
121
- syms_list = []
122
- for index, row in enumerate(data):
123
- if len(row) > 1:
124
- data_list.append([astr for astr in row.split(',')[:33]])
125
- syms_list.append(syms[index])
126
- if len(syms_list) == 0:
127
- return None
128
- df = pd.DataFrame(data_list, columns=ct.LIVE_DATA_COLS)
129
- df = df.drop('s', axis=1)
130
- df['code'] = syms_list
131
- ls = [cls for cls in df.columns if '_v' in cls]
132
- for txt in ls:
133
- df[txt] = df[txt].map(lambda x: x[:-2])
134
- df.columns = rtqv.LIVE_DATA_COLS
135
- df["TS_CODE"] = df["TS_CODE"].apply(format_sina_stock_code)
136
- df["DATE"] = df["DATE"].apply(format_date_str)
137
- new_order = rtqv.LIVE_DATA_COLS_REINDEX
138
- df = df[new_order]
139
- return df
140
-
141
-
142
- def format_sina_stock_code(x):
143
- ts_code = f"{x}.{sina_stock_code[x]}"
144
- return ts_code
145
-
146
-
147
- def format_date_str(date_str):
148
- return date_str.replace("-", "")
149
-
150
-
151
- @require_permission(event_name="realtime_list", event_detail="A股所有实时交易数据")
152
- def realtime_list(src: Optional[str] = None, interval: Optional[int] = 3,
153
- page_count: Optional[int] = None, proxies: Optional[dict] = {}) -> pd.DataFrame:
154
- """
155
- 沪深京 A 股 all -实时行情
156
- @param src: 数据源 新浪sina |东方财富 dc
157
- @param interval: 分页采集时间间隔(默认3秒翻译一夜)
158
- @param page_count: 限制抓取的页数(仅对新浪有效)
159
- @param proxies: 设置代理 防止被封禁
160
- @return: 按涨跌幅 倒序排序
161
- -------
162
- DataFrame 实时交易数据
163
- 东方财富:
164
- 2、代码:TS_CODE
165
- 3、名称:NAME
166
- 4、最新价:PRICE
167
- 5、涨跌幅:PCT_CHANGE
168
- 6、涨跌额:CHANGE
169
- 7、成交量:VOLUME
170
- 8、成交额:AMOUNT
171
- 9、振幅:SWING
172
- 10、最高:HIGH
173
- 11、最低:LOW
174
- 12、今开:OPEN
175
- 13、昨收:CLOSE
176
- 14、量比:VOL_RATIO
177
- 15、换手率:TURNOVER_RATE
178
- 16、市盈率-动态:PE
179
- 17、市净率:PB
180
- 18、总市值:TOTAL_MV
181
- 19、流通市值:FLOAT_MV
182
- 20、涨速:RISE
183
- 21、5分钟涨跌:5MIN
184
- 22、60日涨跌幅:60DAY
185
- 23、年初至今涨跌幅:1YEAR
186
- 新浪财经:
187
- 1、代码:TS_CODE
188
- 2、名称:NAME
189
- 3、最新价:PRICE
190
- 4、涨跌额:CHANGE
191
- 5、涨跌幅:PCT_CHANGE
192
- 6、买入:BUY
193
- 7、卖出:SALE
194
- 8、昨收:CLOSE
195
- 9、今开:OPEN
196
- 10、最高:HIGH
197
- 11、最低:LOW
198
- 12、成交量:VOLUME
199
- 13、成交额:AMOUNT
200
- 14、时间戳:TIME
201
-
202
- """
203
- if src == "dc":
204
- return get_stock_all_a_dc(page_count, proxies)
205
- elif src == "sina":
206
- return get_stock_all_a_sina(interval, page_count, proxies)
207
- else:
208
- return get_stock_all_a_dc(page_count, proxies)
209
-
210
-
211
- def get_stock_all_a_dc(page_count: Optional[int] = None,
212
- proxies: Optional[dict] = {}) -> pd.DataFrame:
213
- """
214
- 东方财富网-沪深京 A 股-实时行情
215
- https://quote.eastmoney.com/center/gridlist.html#hs_a_board
216
- :return: 实时行情
217
- :rtype: pandas.DataFrame
218
- 1、序号:RANK
219
- 2、代码:TS_CODE
220
- 3、名称:NAME
221
- 4、最新价:PRICE
222
- 5、涨跌幅:PCT_CHANGE
223
- 6、涨跌额:CHANGE
224
- 7、成交量:VOLUME
225
- 8、成交额:AMOUNT
226
- 9、振幅:SWING
227
- 10、最高:HIGH
228
- 11、最低:LOW
229
- 12、今开:OPEN
230
- 13、昨收:CLOSE
231
- 14、量比:VOL_RATIO
232
- 15、换手率:TURNOVER_RATE
233
- 16、市盈率-动态:PE
234
- 17、市净率:PB
235
- 18、总市值:TOTAL_MV
236
- 19、流通市值:FLOAT_MV
237
- 20、涨速:RISE
238
- 21、5分钟涨跌:5MIN
239
- 22、60日涨跌幅:60DAY
240
- 23、年初至今涨跌幅:1YEAR
241
- """
242
- url = "http://82.push2.eastmoney.com/api/qt/clist/get"
243
- params = {
244
- "pn": "1",
245
- "pz": "50000",
246
- "po": "1",
247
- "np": "1",
248
- "ut": "bd1d9ddb04089700cf9c27f6f7426281",
249
- "fltt": "2",
250
- "invt": "2",
251
- "fid": "f3",
252
- "fs": "m:0 t:6,m:0 t:80,m:1 t:2,m:1 t:23,m:0 t:81 s:2048",
253
- "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",
254
- "_": "1623833739532",
255
- }
256
- if page_count:
257
- params["pz"] = 20
258
- r = requests.get(url, params=params, proxies=proxies)
259
- data_json = r.json()
260
- if not data_json["data"]["diff"]:
261
- return pd.DataFrame()
262
- temp_df = pd.DataFrame(data_json["data"]["diff"])
263
- temp_df.columns = [
264
- "_",
265
- "最新价",
266
- "涨跌幅",
267
- "涨跌额",
268
- "成交量",
269
- "成交额",
270
- "振幅",
271
- "换手率",
272
- "市盈率-动态",
273
- "量比",
274
- "5分钟涨跌",
275
- "代码",
276
- "_",
277
- "名称",
278
- "最高",
279
- "最低",
280
- "今开",
281
- "昨收",
282
- "总市值",
283
- "流通市值",
284
- "涨速",
285
- "市净率",
286
- "60日涨跌幅",
287
- "年初至今涨跌幅",
288
- "-",
289
- "-",
290
- "-",
291
- "-",
292
- "-",
293
- "-",
294
- "-",
295
- ]
296
- temp_df.reset_index(inplace=True)
297
- # temp_df["index"] = temp_df.index + 1
298
- # temp_df.rename(columns={"index": "序号"}, inplace=True)
299
- temp_df = temp_df[
300
- [
301
- # "序号",
302
- "代码",
303
- "名称",
304
- "最新价",
305
- "涨跌幅",
306
- "涨跌额",
307
- "成交量",
308
- "成交额",
309
- "振幅",
310
- "最高",
311
- "最低",
312
- "今开",
313
- "昨收",
314
- "量比",
315
- "换手率",
316
- "市盈率-动态",
317
- "市净率",
318
- "总市值",
319
- "流通市值",
320
- "涨速",
321
- "5分钟涨跌",
322
- "60日涨跌幅",
323
- "年初至今涨跌幅",
324
- ]
325
- ]
326
-
327
- temp_df["代码"] = temp_df["代码"].apply(format_stock_code)
328
- temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce")
329
- temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"], errors="coerce")
330
- temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"], errors="coerce")
331
- temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
332
- temp_df["成交额"] = pd.to_numeric(temp_df["成交额"], errors="coerce")
333
- temp_df["振幅"] = pd.to_numeric(temp_df["振幅"], errors="coerce")
334
- temp_df["最高"] = pd.to_numeric(temp_df["最高"], errors="coerce")
335
- temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce")
336
- temp_df["今开"] = pd.to_numeric(temp_df["今开"], errors="coerce")
337
- temp_df["昨收"] = pd.to_numeric(temp_df["昨收"], errors="coerce")
338
- temp_df["量比"] = pd.to_numeric(temp_df["量比"], errors="coerce")
339
- temp_df["换手率"] = pd.to_numeric(temp_df["换手率"], errors="coerce")
340
- temp_df["市盈率-动态"] = pd.to_numeric(temp_df["市盈率-动态"], errors="coerce")
341
- temp_df["市净率"] = pd.to_numeric(temp_df["市净率"], errors="coerce")
342
- temp_df["总市值"] = pd.to_numeric(temp_df["总市值"], errors="coerce")
343
- temp_df["流通市值"] = pd.to_numeric(temp_df["流通市值"], errors="coerce")
344
- temp_df["涨速"] = pd.to_numeric(temp_df["涨速"], errors="coerce")
345
- temp_df["5分钟涨跌"] = pd.to_numeric(temp_df["5分钟涨跌"], errors="coerce")
346
- temp_df["60日涨跌幅"] = pd.to_numeric(temp_df["60日涨跌幅"], errors="coerce")
347
- temp_df["年初至今涨跌幅"] = pd.to_numeric(temp_df["年初至今涨跌幅"], errors="coerce")
348
- temp_df.columns = [
349
- # "RANK",
350
- "TS_CODE",
351
- "NAME",
352
- "PRICE",
353
- "PCT_CHANGE",
354
- "CHANGE",
355
- "VOLUME",
356
- "AMOUNT",
357
- "SWING",
358
- "HIGH",
359
- "LOW",
360
- "OPEN",
361
- "CLOSE",
362
- "VOL_RATIO",
363
- "TURNOVER_RATE",
364
- "PE",
365
- "PB",
366
- "TOTAL_MV",
367
- "FLOAT_MV",
368
- "RISE",
369
- "5MIN",
370
- "60DAY",
371
- "1YEAR",
372
- ]
373
- df_sorted = temp_df.sort_values(by='PCT_CHANGE', ascending=False).reset_index(drop=True)
374
- return df_sorted
375
-
376
-
377
- def _get_zh_a_page_count() -> int:
378
- """
379
- 所有股票的总页数
380
- https://vip.stock.finance.sina.com.cn/mkt/#hs_a
381
- :return: 需要采集的股票总页数
382
- :rtype: int
383
- """
384
- res = requests.get(zh_sina_a_stock_count_url)
385
- page_count = int(re.findall(re.compile(r"\d+"), res.text)[0]) / 80
386
- if isinstance(page_count, int):
387
- return page_count
388
- else:
389
- return int(page_count) + 1
390
-
391
-
392
- def get_stock_all_a_sina(interval: Optional[int] = 3, page_count: Optional[int] = None,
393
- proxies: Optional[dict] = {}) -> pd.DataFrame:
394
- """
395
- 新浪财经-所有 A 股的实时行情数据; 重复运行本函数会被新浪暂时封 IP
396
- https://vip.stock.finance.sina.com.cn/mkt/#hs_a
397
- :param interval:请求间隔时间
398
- :param page_count:限制抓取页数
399
- :param proxies: 代理ip {}
400
- :return: 所有股票的实时行情数据
401
- :rtype: pandas.DataFrame
402
- 1、代码:TS_CODE
403
- 2、名称:NAME
404
- 3、最新价:PRICE
405
- 4、涨跌额:CHANGE
406
- 5、涨跌幅:PCT_CHANGE
407
- 6、买入:BUY
408
- 7、卖出:SALE
409
- 8、昨收:CLOSE
410
- 9、今开:OPEN
411
- 10、最高:HIGH
412
- 11、最低:LOW
413
- 12、成交量:VOLUME
414
- 13、成交额:AMOUNT
415
- 14、时间戳:TIME
416
-
417
- """
418
- big_df = pd.DataFrame()
419
- if not page_count:
420
- page_count = _get_zh_a_page_count()
421
- zh_sina_stock_payload_copy = zh_sina_a_stock_payload.copy()
422
- for page in tqdm(
423
- range(1, page_count + 1), leave=False, desc="Please wait for a moment"
424
- ):
425
- zh_sina_stock_payload_copy.update({"page": page})
426
- r = requests.get(
427
- zh_sina_a_stock_url, headers=zh_sina_a_stock_headers,
428
- cookies=zh_sina_a_stock_cookies,
429
- params=zh_sina_stock_payload_copy,
430
- proxies=proxies,
431
- )
432
- data_json = r.json()
433
- big_df = pd.concat(
434
- [big_df, pd.DataFrame(data_json)], ignore_index=True
435
- )
436
-
437
- time.sleep(interval)
438
-
439
- big_df = big_df.astype(
440
- {
441
- "trade": "float",
442
- "pricechange": "float",
443
- "changepercent": "float",
444
- "buy": "float",
445
- "sell": "float",
446
- "settlement": "float",
447
- "open": "float",
448
- "high": "float",
449
- "low": "float",
450
- "volume": "float",
451
- "amount": "float",
452
- "per": "float",
453
- "pb": "float",
454
- "mktcap": "float",
455
- "nmc": "float",
456
- "turnoverratio": "float",
457
- }
458
- )
459
- big_df.columns = [
460
- "代码",
461
- "_",
462
- "名称",
463
- "最新价",
464
- "涨跌额",
465
- "涨跌幅",
466
- "买入",
467
- "卖出",
468
- "昨收",
469
- "今开",
470
- "最高",
471
- "最低",
472
- "成交量",
473
- "成交额",
474
- "时间戳",
475
- "_",
476
- "_",
477
- "_",
478
- "_",
479
- "_",
480
- ]
481
- big_df = big_df[
482
- [
483
- "代码",
484
- "名称",
485
- "最新价",
486
- "涨跌额",
487
- "涨跌幅",
488
- "买入",
489
- "卖出",
490
- "昨收",
491
- "今开",
492
- "最高",
493
- "最低",
494
- "成交量",
495
- "成交额",
496
- "时间戳",
497
- ]
498
- ]
499
- big_df["代码"] = big_df["代码"].apply(format_stock_code)
500
- big_df.columns = [
501
- "TS_CODE",
502
- "NAME",
503
- "PRICE",
504
- "CHANGE",
505
- "PCT_CHANGE",
506
- "BUY",
507
- "SALE",
508
- "CLOSE",
509
- "OPEN",
510
- "HIGH",
511
- "LOW",
512
- "VOLUME",
513
- "AMOUNT",
514
- "TIME",
515
-
516
- ]
517
- df_sorted = big_df.sort_values(by='PCT_CHANGE', ascending=False).reset_index(drop=True)
518
- return df_sorted
519
-
520
-
521
- def get_realtime_quotes_dc(symbols="688553"):
522
- """
523
- https://quote.eastmoney.com/sh601096.html
524
- """
525
- symbols = str(symbols).split(",")[0]
526
- url = "https://push2.eastmoney.com/api/qt/stock/get"
527
- symbol = re.search(r"(\d+)", symbols, re.S | re.M).group(1)
528
- # print(symbol)
529
- params = {
530
- "invt": "2",
531
- "fltt": "1",
532
- # "cb": "jQuery35108939078769986013_1701853424476",
533
- "fields": "f58,f734,f107,f57,f43,f59,f169,f301,f60,f170,f152,f177,f111,f46,f44,f45,f47,f260,f48,f261,f279,f277,f278,f288,f19,f17,f531,f15,f13,f11,f20,f18,f16,f14,f12,f39,f37,f35,f33,f31,f40,f38,f36,f34,f32,f211,f212,f213,f214,f215,f210,f209,f208,f207,f206,f161,f49,f171,f50,f86,f84,f85,f168,f108,f116,f167,f164,f162,f163,f92,f71,f117,f292,f51,f52,f191,f192,f262,f294,f295,f748,f747",
534
- "secid": f"1.{symbol}",
535
- "ut": "fa5fd1943c7b386f172d6893dbfba10b",
536
- "wbp2u": "|0|0|0|web",
537
- "_": _get_current_timestamp()
538
- }
539
- response = requests.get(url, headers=rtqv.dc_cookies, cookies=rtqv.dc_headers, params=params)
540
- data_info = response.json()["data"]
541
- if not data_info:
542
- return pd.DataFrame()
543
- name = data_info["f58"]
544
- open = data_info["f45"] # / 100
545
- high = data_info["f44"] # / 100
546
- pre_close = data_info["f60"] # / 100
547
- low = data_info["f46"] # / 100
548
- price = data_info["f43"] # / 100 if data_info["f43"] != "-" else ""
549
- b5_v = data_info["f12"]
550
- b5_p = data_info["f11"] # / 100 if data_info["f11"] != "-" else ""
551
- b4_v = data_info["f14"]
552
- b4_p = data_info["f13"] # / 100 if data_info["f13"] != "-" else ""
553
- b3_v = data_info["f16"]
554
- b3_p = data_info["f15"] # / 100 if data_info["f15"] != "-" else ""
555
- b2_v = data_info["f18"]
556
- b2_p = data_info["f17"] # / 100 if data_info["f17"] != "-" else ""
557
- b1_v = data_info["f20"]
558
- b1_p = data_info["f19"] # / 100 if data_info["f19"] != "-" else ""
559
- a5_v = data_info["f32"]
560
- a5_p = data_info["f31"] # / 100 if data_info["f31"] != "-" else ""
561
- a4_v = data_info["f34"]
562
- a4_p = data_info["f33"] # / 100 if data_info["f33"] != "-" else ""
563
- a3_v = data_info["f36"]
564
- a3_p = data_info["f35"] # / 100 if data_info["f35"] != "-" else ""
565
- a2_v = data_info["f38"]
566
- a2_p = data_info["f37"] # / 100 if data_info["f38"] != "-" else ""
567
- a1_v = data_info["f40"]
568
- a1_p = data_info["f39"] # / 100 if data_info["f39"] != "-" else ""
569
- date_time = timestemp_to_time(data_info["f86"])
570
- date = date_time[0:10]
571
- times = date_time[10:]
572
- volume = data_info["f47"]
573
- amount = data_info["f48"]
574
- bid = data_info["f19"] # / 100 if data_info["f19"] != "-" else ""
575
- ask = data_info["f39"] # / 100 if data_info["f39"] != "-" else ""
576
- code = symbols
577
- data_list = [[name, open, pre_close, price, high, low, bid, ask, volume, amount,
578
- b1_v, b1_p, b2_v, b2_p, b3_v, b3_p, b4_v, b4_p, b5_v, b5_p,
579
- a1_v, a1_p, a2_v, a2_p, a3_v, a3_p, a4_v, a4_p, a5_v, a5_p, date, times, code]]
580
- df = pd.DataFrame(data_list, columns=rtqv.LIVE_DATA_COLS)
581
- df["DATE"] = df["DATE"].apply(format_date_str)
582
- df["ASK"] = df["ASK"].apply(format_dc_str)
583
- df["OPEN"] = df["OPEN"].apply(format_dc_str)
584
- df["HIGH"] = df["HIGH"].apply(format_dc_str)
585
- df["LOW"] = df["LOW"].apply(format_dc_str)
586
- df["PRE_CLOSE"] = df["PRE_CLOSE"].apply(format_dc_str)
587
- df["BID"] = df["BID"].apply(format_dc_str)
588
- df["A1_P"] = df["A1_P"].apply(format_dc_str)
589
- df["A2_P"] = df["A2_P"].apply(format_dc_str)
590
- df["A3_P"] = df["A3_P"].apply(format_dc_str)
591
- df["A4_P"] = df["A4_P"].apply(format_dc_str)
592
- df["A5_P"] = df["A5_P"].apply(format_dc_str)
593
- df["PRICE"] = df["PRICE"].apply(format_dc_str)
594
- df["B1_P"] = df["B1_P"].apply(format_dc_str)
595
- df["B2_P"] = df["B2_P"].apply(format_dc_str)
596
- df["B3_P"] = df["B3_P"].apply(format_dc_str)
597
- df["B4_P"] = df["B4_P"].apply(format_dc_str)
598
- df["B5_P"] = df["B5_P"].apply(format_dc_str)
599
- new_order = rtqv.LIVE_DATA_COLS_REINDEX
600
- df = df[new_order]
601
- return df
602
-
603
-
604
- def format_dc_str(x):
605
- return x / 100 if x != "-" else ""
606
-
607
-
608
- if __name__ == '__main__':
609
- # df = realtime_quote(ts_code="000688.SH,000010.SH,000012.SH,399005.SZ", src="sina")
610
- df = realtime_list(src="dc", page_count=1)
611
- # print(help(realtime_quote))
612
- print(df)
test/build_pyd/setup.py DELETED
@@ -1,15 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on 2021-12-31 09:32:16
4
- ---------
5
- @summary:
6
- ---------
7
- @author: yangyx01
8
- """
9
- # setup.py
10
- from setuptools import setup
11
- from Cython.Build import cythonize
12
-
13
- setup(
14
- ext_modules=cythonize("rtqc.py")
15
- )