tushare 1.4.5__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.
tushare/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
  import codecs
3
3
  import os
4
4
 
5
- __version__ = '1.4.5'
5
+ __version__ = '1.4.7'
6
6
  __author__ = 'Jimmy Liu'
7
7
 
8
8
  """
tushare/pro/data_pro.py CHANGED
@@ -3,7 +3,7 @@
3
3
  pro init
4
4
  Created on 2018/07/01
5
5
  @author: Jimmy Liu
6
- @group : https://waditu.com
6
+ @group : https://tushare.pro
7
7
  @contact: jimmysoa@sina.cn
8
8
  """
9
9
  from __future__ import division
@@ -12,8 +12,8 @@ from tushare.pro import client
12
12
  from tushare.util import upass
13
13
  from tushare.util.formula import MA
14
14
 
15
- PRICE_COLS = ['open', 'close', 'high', 'low']
16
- FORMAT = lambda x: '%.4f' % x
15
+ PRICE_COLS = ['open', 'close', 'high', 'low', 'pre_close']
16
+ FORMAT = lambda x: '%.2f' % x
17
17
  FREQS = {'D': '1DAY',
18
18
  'W': '1WEEK',
19
19
  'Y': '1YEAR',
@@ -48,6 +48,7 @@ def pro_bar(ts_code='', api=None, start_date='', end_date='', freq='D', asset='E
48
48
  adjfactor = False,
49
49
  offset = None,
50
50
  limit = None,
51
+ fields = '',
51
52
  contract_type = '',
52
53
  retry_count = 3):
53
54
  """
@@ -143,6 +144,11 @@ def pro_bar(ts_code='', api=None, start_date='', end_date='', freq='D', asset='E
143
144
  data['pct_chg'] = data['pct_chg'].map(lambda x: FORMAT(x)).astype(float)
144
145
  else:
145
146
  data = data.drop(['trade_date', 'pre_close'], axis=1)
147
+ else:
148
+ data['pre_close'] = data['close'].shift(-1)
149
+ data['change'] = data['close'] - data['pre_close']
150
+ data['pct_chg'] = data['change'] / data['pre_close'] * 100
151
+ data['pct_chg'] = data['pct_chg'].map(lambda x: FORMAT(x)).astype(float)
146
152
  elif asset == 'I':
147
153
  if freq == 'D':
148
154
  data = api.index_daily(ts_code=ts_code, start_date=start_date, end_date=end_date, offset=offset, limit=limit)
@@ -161,7 +167,7 @@ def pro_bar(ts_code='', api=None, start_date='', end_date='', freq='D', asset='E
161
167
  if freq == 'D':
162
168
  data = api.opt_daily(ts_code=ts_code, start_date=start_date, end_date=end_date, exchange=exchange, offset=offset, limit=limit)
163
169
  if 'min' in freq:
164
- data = api.stk_mins(ts_code=ts_code, start_date=start_date, end_date=end_date, freq=freq, offset=offset, limit=limit)
170
+ data = api.opt_mins(ts_code=ts_code, start_date=start_date, end_date=end_date, freq=freq, offset=offset, limit=limit)
165
171
  elif asset == 'CB':
166
172
  if freq == 'D':
167
173
  data = api.cb_daily(ts_code=ts_code, start_date=start_date, end_date=end_date, offset=offset, limit=limit)
@@ -175,11 +181,8 @@ def pro_bar(ts_code='', api=None, start_date='', end_date='', freq='D', asset='E
175
181
  freq = 'daily'
176
182
  elif freq == 'w':
177
183
  freq = 'week'
178
- data = api.coinbar(
179
- exchange=exchange, symbol=ts_code, freq=freq,
180
- start_dae=start_date, end_date=end_date,
181
- contract_type=contract_type
182
- )
184
+ data = api.coinbar(exchange=exchange, symbol=ts_code, freq=freq, start_dae=start_date, end_date=end_date,
185
+ contract_type=contract_type)
183
186
  if ma is not None and len(ma) > 0:
184
187
  for a in ma:
185
188
  if isinstance(a, int):
@@ -191,6 +194,9 @@ def pro_bar(ts_code='', api=None, start_date='', end_date='', freq='D', asset='E
191
194
  except Exception as e:
192
195
  print(e)
193
196
  else:
197
+ if fields is not None and fields != '':
198
+ f_list = [col.strip() for col in fields.split(',')]
199
+ data = data[f_list]
194
200
  return data
195
201
  raise IOError('ERROR.')
196
202
 
@@ -211,5 +217,7 @@ def ht_subs(username, password):
211
217
 
212
218
 
213
219
  if __name__ == '__main__':
214
- # upass.set_token('')
220
+ # upass.set_token('')
215
221
  pro = pro_api()
222
+ df = pro_bar(ts_code='688539.SH', adj='qfq')
223
+ print(df)
tushare/stock/rtq.py CHANGED
@@ -563,10 +563,10 @@ def get_realtime_quotes_dc(symbols="688553"):
563
563
  if not data_info:
564
564
  return pd.DataFrame()
565
565
  name = data_info["f58"]
566
- open = data_info["f45"] # / 100
566
+ open = data_info["f46"] # / 100
567
567
  high = data_info["f44"] # / 100
568
568
  pre_close = data_info["f60"] # / 100
569
- low = data_info["f46"] # / 100
569
+ low = data_info["f45"] # / 100
570
570
  price = data_info["f43"] # / 100 if data_info["f43"] != "-" else ""
571
571
  b5_v = format_str_to_float(data_info["f12"])
572
572
  b5_p = data_info["f11"] # / 100 if data_info["f11"] != "-" else ""
@@ -636,8 +636,8 @@ def format_str_to_float(x):
636
636
 
637
637
  if __name__ == '__main__':
638
638
  # df = realtime_quote(ts_code="000688.SH,000010.SH,000012.SH,399005.SZ", src="sina")
639
- df = realtime_list(src="sina", page_count=1)
640
- print(df)
639
+ # df = realtime_list(src="sina", page_count=1)
640
+ # print(df)
641
641
  ts_code = '399005.SZ'
642
642
  ts_code = '000001.SZ'
643
643
  # ts_code = '836149.BJ'
@@ -647,3 +647,5 @@ if __name__ == '__main__':
647
647
  ts_code = '688111.SH'
648
648
  df = realtime_quote(src="dc", ts_code=ts_code)
649
649
  print(df)
650
+
651
+
@@ -1,13 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tushare
3
- Version: 1.4.5
3
+ Version: 1.4.7
4
4
  Summary: A utility for crawling historical and Real-time Quotes data of China stocks
5
5
  Home-page: https://tushare.pro
6
6
  Author: Jimmy Liu
7
7
  Author-email: waditu@163.com
8
8
  License: BSD
9
9
  Keywords: Global Financial Data
10
- Platform: UNKNOWN
11
10
  Classifier: Development Status :: 4 - Beta
12
11
  Classifier: Programming Language :: Python :: 3.6
13
12
  Classifier: Programming Language :: Python :: 3.7
@@ -16,17 +15,13 @@ Classifier: Programming Language :: Python :: 3.9
16
15
  Classifier: Programming Language :: Python :: 3.10
17
16
  Classifier: License :: OSI Approved :: BSD License
18
17
  Description-Content-Type: text/plain
18
+ License-File: LICENSE
19
19
  Requires-Dist: pandas
20
20
  Requires-Dist: requests
21
21
  Requires-Dist: lxml
22
22
  Requires-Dist: simplejson
23
- Requires-Dist: bs4 ==0.0.1
23
+ Requires-Dist: bs4
24
24
  Requires-Dist: websocket-client ==0.57.0
25
- Requires-Dist: pytdx
26
- Requires-Dist: protobuf
27
- Requires-Dist: grpcio
28
- Requires-Dist: pycryptodome
29
- Requires-Dist: pydantic
30
25
  Requires-Dist: tqdm
31
26
 
32
27
 
@@ -54,21 +49,21 @@ Installation
54
49
  --------------
55
50
 
56
51
  pip install tushare
57
-
52
+
58
53
  Upgrade
59
54
  ---------------
60
55
 
61
56
  pip install tushare --upgrade
62
-
57
+
63
58
  Quick Start
64
59
  --------------
65
60
 
66
61
  ::
67
62
 
68
63
  import tushare as ts
69
-
64
+
70
65
  ts.get_hist_data('600848')
71
-
66
+
72
67
  return::
73
68
 
74
69
  open high close low volume p_change ma5
@@ -81,10 +76,14 @@ return::
81
76
  2012-01-18 7.000 7.300 6.890 6.880 13075.40 0.44 6.788
82
77
  2012-01-19 6.690 6.950 6.890 6.680 6117.32 0.00 6.770
83
78
  2012-01-20 6.870 7.080 7.010 6.870 6813.09 1.74 6.832
84
-
85
-
79
+
80
+
86
81
  Log
87
82
  --------------
83
+ 1.4.6
84
+ -------
85
+ - 修复 realtime_quote 实时盘口TICK快照(爬虫版)
86
+ - 修复dc OPEN和LOW 值相反问题
88
87
  1.4.0
89
88
  -------
90
89
  - 增加 银河证券实时行情数据入口
@@ -96,6 +95,4 @@ Log
96
95
  1.2.73
97
96
  -------
98
97
  - 支持华泰实时数据15SECOND
99
-
100
-
101
-
98
+
@@ -1,4 +1,4 @@
1
- tushare/__init__.py,sha256=BRDLaOC6I6WPuhh1rcVboWFcUF-uGxw0F8Sbqxj3EOQ,4764
1
+ tushare/__init__.py,sha256=psVu0ZLbywMr4wTiS7FWfrPJWsW7ks8EpgXY2qREgng,4764
2
2
  tushare/bond/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  tushare/bond/bonds.py,sha256=PJM0xDiWZDpOPwDtbEU9PdP0M_Gu0c599YuB1rbZ3r8,232
4
4
  tushare/coins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -18,7 +18,7 @@ tushare/internet/caixinnews.py,sha256=IwNOB5F1q_CxfuP93-jgUpTW5yY5NANPRJXySm_bj2
18
18
  tushare/internet/indexes.py,sha256=oteQCv0k2X0pbhXRHwMSviD1AowJWE6xRjKkqr5RNCo,3595
19
19
  tushare/pro/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  tushare/pro/client.py,sha256=91jKHO9OPrNWPp3193edresGg6UoX0NlmOqAdf0mX4A,1312
21
- tushare/pro/data_pro.py,sha256=Aej_6I0JkA2Evih4O8GDheTity2GgBPvIucLgfHS9js,10332
21
+ tushare/pro/data_pro.py,sha256=SOHbK-j9CmZguuv0CLIT-Z3hUynEy96mbvvhrGN6y9I,10883
22
22
  tushare/stock/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  tushare/stock/billboard.py,sha256=vCrbN7-NGXSpXMc8jq7NcjjHyu9pTcr4uXp559iA1wA,12833
24
24
  tushare/stock/classifying.py,sha256=3yWqlLhgj2irk-9ksKWFFS5HY-SnjfEr5erwJxBidG8,10539
@@ -34,7 +34,7 @@ tushare/stock/news_vars.py,sha256=CQ18hvyoeScelBCqKgF_rgAufoEALAUT8y_LERvZKHk,45
34
34
  tushare/stock/newsevent.py,sha256=STR7C8MjtZlaXTCG0QNaojBuK4-oxP_8hT7ZIvRpbiI,6944
35
35
  tushare/stock/ref_vars.py,sha256=MIxor-2rISl65I32vUzC-z7ZC_QFzG4sxOKDyjLWuU4,4449
36
36
  tushare/stock/reference.py,sha256=x_HZlrP58T-5OTZ7SLdf2Dh9THj1h7cT4wcIp42IHFI,38227
37
- tushare/stock/rtq.py,sha256=Gd0-DbmFc-QyFfAgKcwkANIlN8lB60TOgY2kPBN5GWk,23115
37
+ tushare/stock/rtq.py,sha256=gMTTv8XOtCgStLa0DhXIXMJhf5jBsZbs_1zzQVugTDc,23123
38
38
  tushare/stock/rtq_vars.py,sha256=V6LeJkSP76z8veRfP_mGiQ63V5YBHoTMaqUA5hSBWh4,4200
39
39
  tushare/stock/shibor.py,sha256=Fx9OUZ429kz6l7ZdaYSD6p_X79ud69PDM9EZogm8xCY,6422
40
40
  tushare/stock/trading.py,sha256=3bvM4pexEYW-uGGEL7g6Vkte4sqGC1iYO6dC8mGLSdM,55619
@@ -71,8 +71,8 @@ tushare/util/verify_token.py,sha256=cuV3RErWbOC318NANCYL6K1LKZ3wSAL2yMwZHA7tD3s,
71
71
  tushare/util/protobuf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
72
  tushare/util/protobuf/funcs.py,sha256=UCdK8FxTyjPZsNzoEeXqYzqrQXUmRMvW5hua6GPA66A,779
73
73
  tushare/util/protobuf/response_pb2.py,sha256=vJH9ONkDuJlg6y-q1PvuDZoviKrK7hzNtMieQHK45DI,11347
74
- tushare-1.4.5.dist-info/LICENSE,sha256=C2j55UI0Ul-1-wA1-rn7OaY6b3vGl4YukiyvYzHsU9o,1503
75
- tushare-1.4.5.dist-info/METADATA,sha256=uDEL9Ina_cYyI8PoPRmUy_pBdrq8mSe9fb183LC-Wb0,2828
76
- tushare-1.4.5.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
77
- tushare-1.4.5.dist-info/top_level.txt,sha256=HHOxMuqc31KuAIcxpE0t5dAPMKbaiRtjsjTMFd7FlXI,8
78
- tushare-1.4.5.dist-info/RECORD,,
74
+ tushare-1.4.7.dist-info/LICENSE,sha256=C2j55UI0Ul-1-wA1-rn7OaY6b3vGl4YukiyvYzHsU9o,1503
75
+ tushare-1.4.7.dist-info/METADATA,sha256=xdDYzUgnrx-NOwrlgXbcFkjdo0_hw5oIDoW7JjCPkQs,2838
76
+ tushare-1.4.7.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
77
+ tushare-1.4.7.dist-info/top_level.txt,sha256=HHOxMuqc31KuAIcxpE0t5dAPMKbaiRtjsjTMFd7FlXI,8
78
+ tushare-1.4.7.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.41.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5