tushare 1.4.13__py3-none-any.whl → 1.4.15__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 +1 -1
- tushare/pro/data_pro.py +179 -7
- tushare/pro/llm.py +4 -2
- tushare/stock/rtq.py +22 -22
- tushare/subs/model/tick.py +128 -128
- tushare/subs/ts_subs/subscribe.py +19 -3
- {tushare-1.4.13.dist-info → tushare-1.4.15.dist-info}/METADATA +6 -1
- {tushare-1.4.13.dist-info → tushare-1.4.15.dist-info}/RECORD +11 -11
- {tushare-1.4.13.dist-info → tushare-1.4.15.dist-info}/LICENSE +0 -0
- {tushare-1.4.13.dist-info → tushare-1.4.15.dist-info}/WHEEL +0 -0
- {tushare-1.4.13.dist-info → tushare-1.4.15.dist-info}/top_level.txt +0 -0
tushare/__init__.py
CHANGED
tushare/pro/data_pro.py
CHANGED
@@ -26,7 +26,6 @@ FACT_LIST = {
|
|
26
26
|
'pe': 'pe',
|
27
27
|
'pe_ttm': 'pe_ttm',
|
28
28
|
}
|
29
|
-
|
30
29
|
def pro_api(token='', timeout=30):
|
31
30
|
"""
|
32
31
|
初始化pro API,第一次可以通过ts.set_token('your token')来记录自己的token凭证,临时token可以通过本参数传入
|
@@ -37,10 +36,10 @@ def pro_api(token='', timeout=30):
|
|
37
36
|
pro = client.DataApi(token=token, timeout=timeout)
|
38
37
|
return pro
|
39
38
|
else:
|
40
|
-
raise Exception('api init error.')
|
41
|
-
|
39
|
+
raise Exception('api init error.')
|
42
40
|
|
43
|
-
|
41
|
+
|
42
|
+
def pro_bar(ts_code='', api=None, start_date='', end_date='', freq='D', asset='E',
|
44
43
|
exchange='',
|
45
44
|
adj = None,
|
46
45
|
ma = [],
|
@@ -70,13 +69,13 @@ def pro_bar(ts_code='', api=None, start_date='', end_date='', freq='D', asset='E
|
|
70
69
|
tor:换手率,默认不返回,返回需指定:factor=['tor']
|
71
70
|
以上两种都需要:factor=['vr', 'tor']
|
72
71
|
retry_count:网络重试次数
|
73
|
-
|
72
|
+
|
74
73
|
Return
|
75
74
|
----------
|
76
75
|
DataFrame
|
77
76
|
code:代码
|
78
77
|
open:开盘close/high/low/vol成交量/amount成交额/maN均价/vr量比/tor换手率
|
79
|
-
|
78
|
+
|
80
79
|
期货(asset='FT')
|
81
80
|
code/open/close/high/low/avg_price:均价 position:持仓量 vol:成交总量
|
82
81
|
"""
|
@@ -87,7 +86,7 @@ def pro_bar(ts_code='', api=None, start_date='', end_date='', freq='D', asset='E
|
|
87
86
|
freq = freq.strip().lower()
|
88
87
|
else:
|
89
88
|
freq = freq.strip().upper() if asset != 'C' else freq.strip().lower()
|
90
|
-
|
89
|
+
|
91
90
|
if 'min' not in freq:
|
92
91
|
today= datetime.datetime.today().date()
|
93
92
|
today = str(today)[0:10]
|
@@ -200,6 +199,179 @@ def pro_bar(ts_code='', api=None, start_date='', end_date='', freq='D', asset='E
|
|
200
199
|
return data
|
201
200
|
raise IOError('ERROR.')
|
202
201
|
|
202
|
+
def pro_api(token='', timeout=30):
|
203
|
+
"""
|
204
|
+
初始化pro API,第一次可以通过ts.set_token('your token')来记录自己的token凭证,临时token可以通过本参数传入
|
205
|
+
"""
|
206
|
+
if token == '' or token is None:
|
207
|
+
token = upass.get_token()
|
208
|
+
if token is not None and token != '':
|
209
|
+
pro = client.DataApi(token=token, timeout=timeout)
|
210
|
+
return pro
|
211
|
+
else:
|
212
|
+
raise Exception('api init error.')
|
213
|
+
|
214
|
+
|
215
|
+
def pro_bar_vip(ts_code='', api=None, start_date='', end_date='', freq='D', asset='E',
|
216
|
+
exchange='',
|
217
|
+
adj = None,
|
218
|
+
ma = [],
|
219
|
+
factors = None,
|
220
|
+
adjfactor = False,
|
221
|
+
offset = None,
|
222
|
+
limit = None,
|
223
|
+
fields = '',
|
224
|
+
contract_type = '',
|
225
|
+
retry_count = 3):
|
226
|
+
"""
|
227
|
+
BAR数据
|
228
|
+
Parameters:
|
229
|
+
------------
|
230
|
+
ts_code:证券代码,支持股票,ETF/LOF,期货/期权,港股,数字货币
|
231
|
+
start_date:开始日期 YYYYMMDD
|
232
|
+
end_date:结束日期 YYYYMMDD
|
233
|
+
freq:支持1/5/15/30/60分钟,周/月/季/年
|
234
|
+
asset:证券类型 E:股票和交易所基金,I:沪深指数,C:数字货币,FT:期货 FD:基金/O期权/H港股/CB可转债
|
235
|
+
exchange:市场代码,用户数字货币行情
|
236
|
+
adj:复权类型,None不复权,qfq:前复权,hfq:后复权
|
237
|
+
ma:均线,支持自定义均线频度,如:ma5/ma10/ma20/ma60/maN
|
238
|
+
offset:开始行数(分页功能,从第几行开始取数据)
|
239
|
+
limit: 本次提取数据行数
|
240
|
+
factors因子数据,目前支持以下两种:
|
241
|
+
vr:量比,默认不返回,返回需指定:factor=['vr']
|
242
|
+
tor:换手率,默认不返回,返回需指定:factor=['tor']
|
243
|
+
以上两种都需要:factor=['vr', 'tor']
|
244
|
+
retry_count:网络重试次数
|
245
|
+
|
246
|
+
Return
|
247
|
+
----------
|
248
|
+
DataFrame
|
249
|
+
code:代码
|
250
|
+
open:开盘close/high/low/vol成交量/amount成交额/maN均价/vr量比/tor换手率
|
251
|
+
|
252
|
+
期货(asset='FT')
|
253
|
+
code/open/close/high/low/avg_price:均价 position:持仓量 vol:成交总量
|
254
|
+
"""
|
255
|
+
if (ts_code=='' or ts_code is None) and (adj is not None):
|
256
|
+
print('提取复权行情必须输入ts_code参数')
|
257
|
+
return
|
258
|
+
if len(freq.strip())>=3:
|
259
|
+
freq = freq.strip().lower()
|
260
|
+
else:
|
261
|
+
freq = freq.strip().upper() if asset != 'C' else freq.strip().lower()
|
262
|
+
|
263
|
+
if 'min' not in freq:
|
264
|
+
today= datetime.datetime.today().date()
|
265
|
+
today = str(today)[0:10]
|
266
|
+
start_date = '' if start_date is None else start_date
|
267
|
+
end_date = today if end_date == '' or end_date is None else end_date
|
268
|
+
start_date = start_date.replace('-', '')
|
269
|
+
end_date = end_date.replace('-', '')
|
270
|
+
ts_code = ts_code.strip().upper() if asset != 'C' else ts_code.strip().lower()
|
271
|
+
asset = asset.strip().upper()
|
272
|
+
api = api if api is not None else pro_api()
|
273
|
+
for _ in range(retry_count):
|
274
|
+
try:
|
275
|
+
if asset == 'E':
|
276
|
+
if freq == 'D':
|
277
|
+
data = api.daily_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, offset=offset, limit=limit)
|
278
|
+
if factors is not None and len(factors) >0 :
|
279
|
+
ds = api.daily_basic_vip(ts_code=ts_code, start_date=start_date, end_date=end_date)[['trade_date', 'turnover_rate', 'volume_ratio']]
|
280
|
+
ds = ds.set_index('trade_date')
|
281
|
+
data = data.set_index('trade_date')
|
282
|
+
data = data.merge(ds, left_index=True, right_index=True)
|
283
|
+
data = data.reset_index()
|
284
|
+
if ('tor' in factors) and ('vr' not in factors):
|
285
|
+
data = data.drop('volume_ratio', axis=1)
|
286
|
+
if ('vr' in factors) and ('tor' not in factors):
|
287
|
+
data = data.drop('turnover_rate', axis=1)
|
288
|
+
if freq == 'W':
|
289
|
+
data = api.weekly_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, offset=offset, limit=limit)
|
290
|
+
if freq == 'M':
|
291
|
+
data = api.monthly_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, offset=offset, limit=limit)
|
292
|
+
if 'min' in freq:
|
293
|
+
data = api.stk_mins_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, freq=freq, offset=offset, limit=limit)
|
294
|
+
data['trade_date'] = data['trade_time'].map(lambda x: x.replace('-', '')[0:8])
|
295
|
+
data['pre_close'] = data['close'].shift(-1)
|
296
|
+
if adj is not None:
|
297
|
+
fcts = api.adj_factor_vip(ts_code=ts_code, start_date=start_date, end_date=end_date)[['trade_date', 'adj_factor']]
|
298
|
+
if fcts.shape[0] == 0:
|
299
|
+
return None
|
300
|
+
data = data.set_index('trade_date', drop=False).merge(fcts.set_index('trade_date'), left_index=True, right_index=True, how='left')
|
301
|
+
if 'min' in freq:
|
302
|
+
data = data.sort_values('trade_time', ascending=False)
|
303
|
+
data['adj_factor'] = data['adj_factor'].fillna(method='bfill')
|
304
|
+
for col in PRICE_COLS:
|
305
|
+
if adj == 'hfq':
|
306
|
+
data[col] = data[col] * data['adj_factor']
|
307
|
+
if adj == 'qfq':
|
308
|
+
data[col] = data[col] * data['adj_factor'] / float(fcts['adj_factor'][0])
|
309
|
+
data[col] = data[col].map(FORMAT)
|
310
|
+
data[col] = data[col].astype(float)
|
311
|
+
if adjfactor is False:
|
312
|
+
data = data.drop('adj_factor', axis=1)
|
313
|
+
if 'min' not in freq:
|
314
|
+
data['change'] = data['close'] - data['pre_close']
|
315
|
+
data['pct_chg'] = data['change'] / data['pre_close'] * 100
|
316
|
+
data['pct_chg'] = data['pct_chg'].map(lambda x: FORMAT(x)).astype(float)
|
317
|
+
else:
|
318
|
+
data = data.drop(['trade_date', 'pre_close'], axis=1)
|
319
|
+
else:
|
320
|
+
data['pre_close'] = data['close'].shift(-1)
|
321
|
+
data['change'] = data['close'] - data['pre_close']
|
322
|
+
data['pct_chg'] = data['change'] / data['pre_close'] * 100
|
323
|
+
data['pct_chg'] = data['pct_chg'].map(lambda x: FORMAT(x)).astype(float)
|
324
|
+
elif asset == 'I':
|
325
|
+
if freq == 'D':
|
326
|
+
data = api.index_daily_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, offset=offset, limit=limit)
|
327
|
+
if freq == 'W':
|
328
|
+
data = api.index_weekly_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, offset=offset, limit=limit)
|
329
|
+
if freq == 'M':
|
330
|
+
data = api.index_monthly_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, offset=offset, limit=limit)
|
331
|
+
if 'min' in freq:
|
332
|
+
data = api.stk_mins_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, freq=freq, offset=offset, limit=limit)
|
333
|
+
elif asset == 'FT':
|
334
|
+
if freq == 'D':
|
335
|
+
data = api.fut_daily_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, exchange=exchange, offset=offset, limit=limit)
|
336
|
+
if 'min' in freq:
|
337
|
+
data = api.ft_mins_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, freq=freq, offset=offset, limit=limit)
|
338
|
+
elif asset == 'O':
|
339
|
+
if freq == 'D':
|
340
|
+
data = api.opt_daily_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, exchange=exchange, offset=offset, limit=limit)
|
341
|
+
if 'min' in freq:
|
342
|
+
data = api.opt_mins_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, freq=freq, offset=offset, limit=limit)
|
343
|
+
elif asset == 'CB':
|
344
|
+
if freq == 'D':
|
345
|
+
data = api.cb_daily_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, offset=offset, limit=limit)
|
346
|
+
elif asset == 'FD':
|
347
|
+
if freq == 'D':
|
348
|
+
data = api.fund_daily_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, offset=offset, limit=limit)
|
349
|
+
if 'min' in freq:
|
350
|
+
data = api.stk_mins_vip(ts_code=ts_code, start_date=start_date, end_date=end_date, freq=freq, offset=offset, limit=limit)
|
351
|
+
if asset == 'C':
|
352
|
+
if freq == 'd':
|
353
|
+
freq = 'daily'
|
354
|
+
elif freq == 'w':
|
355
|
+
freq = 'week'
|
356
|
+
data = api.coinbar(exchange=exchange, symbol=ts_code, freq=freq, start_dae=start_date, end_date=end_date,
|
357
|
+
contract_type=contract_type)
|
358
|
+
if ma is not None and len(ma) > 0:
|
359
|
+
for a in ma:
|
360
|
+
if isinstance(a, int):
|
361
|
+
data['ma%s'%a] = MA(data['close'], a).map(FORMAT).shift(-(a-1))
|
362
|
+
data['ma%s'%a] = data['ma%s'%a].astype(float)
|
363
|
+
data['ma_v_%s'%a] = MA(data['vol'], a).map(FORMAT).shift(-(a-1))
|
364
|
+
data['ma_v_%s'%a] = data['ma_v_%s'%a].astype(float)
|
365
|
+
data = data.reset_index(drop=True)
|
366
|
+
except Exception as e:
|
367
|
+
print(e)
|
368
|
+
else:
|
369
|
+
if fields is not None and fields != '':
|
370
|
+
f_list = [col.strip() for col in fields.split(',')]
|
371
|
+
data = data[f_list]
|
372
|
+
return data
|
373
|
+
raise IOError('ERROR.')
|
374
|
+
|
203
375
|
|
204
376
|
def subs(token=''):
|
205
377
|
if token == '' or token is None:
|
tushare/pro/llm.py
CHANGED
@@ -10,7 +10,7 @@ except:
|
|
10
10
|
from tushare import get_token
|
11
11
|
|
12
12
|
BASE_URL = "http://api.waditu.com/dataapi"
|
13
|
-
# BASE_URL = "http://
|
13
|
+
# BASE_URL = "http://10.255.255.205:8083/dataapi"
|
14
14
|
API_KEY_PREFIX = "tsgpt-"
|
15
15
|
|
16
16
|
|
@@ -52,7 +52,7 @@ class GPTClient:
|
|
52
52
|
resp = self._request(model, messages, temperature, max_tokens, False, pretty)
|
53
53
|
resp_data = resp.json()
|
54
54
|
if resp_data.get('code') not in (0, None):
|
55
|
-
raise Exception(resp_data
|
55
|
+
raise Exception(resp_data.get('msg') or resp_data)
|
56
56
|
if pretty:
|
57
57
|
return resp_data['choices'][0]["message"]["content"]
|
58
58
|
else:
|
@@ -61,6 +61,8 @@ class GPTClient:
|
|
61
61
|
def gpt_stream(self, model, messages, temperature=None, max_tokens=None, pretty=False):
|
62
62
|
resp = self._request(model, messages, temperature, max_tokens, True, pretty)
|
63
63
|
for e in sseclient.SSEClient(resp).events():
|
64
|
+
if '[DONE]' in e.data.upper():
|
65
|
+
break
|
64
66
|
e_data = json.loads(e.data)
|
65
67
|
if pretty:
|
66
68
|
yield e_data["choices"][0]["delta"]["content"]
|
tushare/stock/rtq.py
CHANGED
@@ -173,7 +173,7 @@ def realtime_list(src: Optional[str] = None, interval: Optional[int] = 3,
|
|
173
173
|
东方财富:
|
174
174
|
2、代码:TS_CODE
|
175
175
|
3、名称:NAME
|
176
|
-
4、最新价:
|
176
|
+
4、最新价:CLOSE
|
177
177
|
5、涨跌幅:PCT_CHANGE
|
178
178
|
6、涨跌额:CHANGE
|
179
179
|
7、成交量:VOLUME
|
@@ -182,7 +182,7 @@ def realtime_list(src: Optional[str] = None, interval: Optional[int] = 3,
|
|
182
182
|
10、最高:HIGH
|
183
183
|
11、最低:LOW
|
184
184
|
12、今开:OPEN
|
185
|
-
13、昨收:
|
185
|
+
13、昨收:PRE_CLOSE
|
186
186
|
14、量比:VOL_RATIO
|
187
187
|
15、换手率:TURNOVER_RATE
|
188
188
|
16、市盈率-动态:PE
|
@@ -196,12 +196,12 @@ def realtime_list(src: Optional[str] = None, interval: Optional[int] = 3,
|
|
196
196
|
新浪财经:
|
197
197
|
1、代码:TS_CODE
|
198
198
|
2、名称:NAME
|
199
|
-
3、最新价:
|
199
|
+
3、最新价:CLOSE
|
200
200
|
4、涨跌额:CHANGE
|
201
201
|
5、涨跌幅:PCT_CHANGE
|
202
202
|
6、买入:BUY
|
203
203
|
7、卖出:SALE
|
204
|
-
8、昨收:
|
204
|
+
8、昨收:PRE_CLOSE
|
205
205
|
9、今开:OPEN
|
206
206
|
10、最高:HIGH
|
207
207
|
11、最低:LOW
|
@@ -359,7 +359,7 @@ def get_stock_all_a_dc(page_count: Optional[int] = None,
|
|
359
359
|
# "RANK",
|
360
360
|
"TS_CODE",
|
361
361
|
"NAME",
|
362
|
-
"
|
362
|
+
"CLOSE",
|
363
363
|
"PCT_CHANGE",
|
364
364
|
"CHANGE",
|
365
365
|
"VOLUME",
|
@@ -368,7 +368,7 @@ def get_stock_all_a_dc(page_count: Optional[int] = None,
|
|
368
368
|
"HIGH",
|
369
369
|
"LOW",
|
370
370
|
"OPEN",
|
371
|
-
"
|
371
|
+
"PRE_CLOSE",
|
372
372
|
"VOL_RATIO",
|
373
373
|
"TURNOVER_RATE",
|
374
374
|
"PE",
|
@@ -381,8 +381,8 @@ def get_stock_all_a_dc(page_count: Optional[int] = None,
|
|
381
381
|
"1YEAR",
|
382
382
|
]
|
383
383
|
# 指定要转换为 float 类型的列
|
384
|
-
cols_to_convert = ['
|
385
|
-
'HIGH', "LOW", "OPEN", "
|
384
|
+
cols_to_convert = ['CLOSE', 'PCT_CHANGE', 'CHANGE', "VOLUME", "AMOUNT", "SWING",
|
385
|
+
'HIGH', "LOW", "OPEN", "PRE_CLOSE", "VOL_RATIO", "TURNOVER_RATE", "PE", "PB", "TOTAL_MV", "FLOAT_MV",
|
386
386
|
"RISE", "5MIN", "60DAY", "1YEAR"
|
387
387
|
]
|
388
388
|
# 使用 to_numeric() 方法将指定的列转换为 float 类型,并将非数值类型的数据转换为 NaN
|
@@ -420,12 +420,12 @@ def get_stock_all_a_sina(interval: Optional[int] = 3, page_count: Optional[int]
|
|
420
420
|
:rtype: pandas.DataFrame
|
421
421
|
1、代码:TS_CODE
|
422
422
|
2、名称:NAME
|
423
|
-
3、最新价:
|
423
|
+
3、最新价:CLOSE
|
424
424
|
4、涨跌额:CHANGE
|
425
425
|
5、涨跌幅:PCT_CHANGE
|
426
426
|
6、买入:BUY
|
427
427
|
7、卖出:SALE
|
428
|
-
8、昨收:
|
428
|
+
8、昨收:PRE_CLOSE
|
429
429
|
9、今开:OPEN
|
430
430
|
10、最高:HIGH
|
431
431
|
11、最低:LOW
|
@@ -519,12 +519,12 @@ def get_stock_all_a_sina(interval: Optional[int] = 3, page_count: Optional[int]
|
|
519
519
|
big_df.columns = [
|
520
520
|
"TS_CODE",
|
521
521
|
"NAME",
|
522
|
-
"
|
522
|
+
"CLOSE",
|
523
523
|
"CHANGE",
|
524
524
|
"PCT_CHANGE",
|
525
525
|
"BUY",
|
526
526
|
"SALE",
|
527
|
-
"
|
527
|
+
"PRE_CLOSE",
|
528
528
|
"OPEN",
|
529
529
|
"HIGH",
|
530
530
|
"LOW",
|
@@ -636,16 +636,16 @@ 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
|
-
|
640
|
-
# print(df)
|
641
|
-
ts_code = '399005.SZ'
|
642
|
-
ts_code = '000001.SZ'
|
643
|
-
# ts_code = '836149.BJ'
|
644
|
-
# ts_code = '600000.SH'
|
645
|
-
# ts_code = '000001.SH'
|
646
|
-
# ts_code = '000010.SH'
|
647
|
-
ts_code = '688111.SH'
|
648
|
-
df = realtime_quote(src="dc", ts_code=ts_code)
|
639
|
+
df = realtime_list(src="sina", page_count=1)
|
649
640
|
print(df)
|
641
|
+
# ts_code = '399005.SZ'
|
642
|
+
# ts_code = '000001.SZ'
|
643
|
+
# # ts_code = '836149.BJ'
|
644
|
+
# # ts_code = '600000.SH'
|
645
|
+
# # ts_code = '000001.SH'
|
646
|
+
# # ts_code = '000010.SH'
|
647
|
+
# ts_code = '688111.SH'
|
648
|
+
# df = realtime_quote(src="dc", ts_code=ts_code)
|
649
|
+
# print(df)
|
650
650
|
|
651
651
|
|
tushare/subs/model/tick.py
CHANGED
@@ -1,128 +1,128 @@
|
|
1
|
-
from datetime import datetime
|
2
|
-
from typing import Optional
|
3
|
-
|
4
|
-
from pydantic import BaseModel
|
5
|
-
|
6
|
-
|
7
|
-
class TsTick(BaseModel):
|
8
|
-
ts_code: str
|
9
|
-
name: Optional[str]
|
10
|
-
trade_time: Optional[datetime]
|
11
|
-
pre_close_price: Optional[float]
|
12
|
-
last_price: Optional[float]
|
13
|
-
open_price: Optional[float]
|
14
|
-
high_price: Optional[float]
|
15
|
-
low_price: Optional[float]
|
16
|
-
close_price: Optional[float]
|
17
|
-
volume: Optional[int] # 成交量
|
18
|
-
amount: Optional[int] # 成交金额
|
19
|
-
count: Optional[int] # 交易数量
|
20
|
-
ask_price1: Optional[float] # 申卖价, 委托档位卖1档价格
|
21
|
-
ask_volume1: Optional[int] # 申卖量
|
22
|
-
bid_price1: Optional[float] # 申买价, 委托档位买1档价格
|
23
|
-
bid_volume1: Optional[int] # 申买量
|
24
|
-
ask_price2: Optional[float]
|
25
|
-
ask_volume2: Optional[int]
|
26
|
-
bid_price2: Optional[float]
|
27
|
-
bid_volume2: Optional[int]
|
28
|
-
ask_price3: Optional[float]
|
29
|
-
ask_volume3: Optional[int]
|
30
|
-
bid_price3: Optional[float]
|
31
|
-
bid_volume3: Optional[int]
|
32
|
-
ask_price4: Optional[float]
|
33
|
-
ask_volume4: Optional[int]
|
34
|
-
bid_price4: Optional[float]
|
35
|
-
bid_volume4: Optional[int]
|
36
|
-
ask_price5: Optional[float]
|
37
|
-
ask_volume5: Optional[int]
|
38
|
-
bid_price5: Optional[float]
|
39
|
-
bid_volume5: Optional[int]
|
40
|
-
ask_price6: Optional[float]
|
41
|
-
ask_volume6: Optional[int]
|
42
|
-
bid_price6: Optional[float]
|
43
|
-
bid_volume6: Optional[int]
|
44
|
-
ask_price7: Optional[float]
|
45
|
-
ask_volume7: Optional[int]
|
46
|
-
bid_price7: Optional[float]
|
47
|
-
bid_volume7: Optional[int]
|
48
|
-
ask_price8: Optional[float]
|
49
|
-
ask_volume8: Optional[int]
|
50
|
-
bid_price8: Optional[float]
|
51
|
-
bid_volume8: Optional[int]
|
52
|
-
ask_price9: Optional[float]
|
53
|
-
ask_volume9: Optional[int]
|
54
|
-
bid_price9: Optional[float]
|
55
|
-
bid_volume9: Optional[int]
|
56
|
-
ask_price10: Optional[float]
|
57
|
-
ask_volume10: Optional[int]
|
58
|
-
bid_price10: Optional[float]
|
59
|
-
bid_volume10: Optional[int]
|
60
|
-
|
61
|
-
|
62
|
-
class TsTickIdx(BaseModel):
|
63
|
-
ts_code: str
|
64
|
-
name: Optional[str]
|
65
|
-
trade_time: Optional[datetime]
|
66
|
-
last_price: Optional[float] # last_price 单位元
|
67
|
-
pre_close_price: Optional[float] # pre_close_price
|
68
|
-
high_price: Optional[float] # high_price
|
69
|
-
open_price: Optional[float] # open_price
|
70
|
-
low_price: Optional[float] # low_price
|
71
|
-
close_price: Optional[float] # close_price
|
72
|
-
volume: Optional[int] # volume, 成交总量
|
73
|
-
amount: Optional[float] # amount, 成交总金额
|
74
|
-
|
75
|
-
|
76
|
-
class TsTickOpt(BaseModel):
|
77
|
-
ts_code: str
|
78
|
-
instrument_id: str
|
79
|
-
trade_time: Optional[datetime]
|
80
|
-
pre_price: Optional[float] # 单位元
|
81
|
-
price: Optional[float]
|
82
|
-
open: Optional[float]
|
83
|
-
high: Optional[float]
|
84
|
-
low: Optional[float]
|
85
|
-
close: Optional[float]
|
86
|
-
open_int: Optional[int]
|
87
|
-
vol: Optional[float]
|
88
|
-
amount: Optional[float]
|
89
|
-
num: Optional[int]
|
90
|
-
ask_price1: Optional[float]
|
91
|
-
ask_volume1: Optional[int]
|
92
|
-
bid_price1: Optional[float]
|
93
|
-
bid_volume1: Optional[int]
|
94
|
-
pre_delta: Optional[float] # 昨虚实度,暂未提供
|
95
|
-
dif_price1: Optional[float]
|
96
|
-
dif_price2: Optional[float]
|
97
|
-
high_limit_price: Optional[float]
|
98
|
-
low_limit_price: Optional[float]
|
99
|
-
refer_price: Optional[float] # 参考价,港股使用
|
100
|
-
|
101
|
-
|
102
|
-
class TsTickFuture(BaseModel):
|
103
|
-
ts_code: str
|
104
|
-
instrument_id: Optional[str]
|
105
|
-
trade_time: Optional[datetime]
|
106
|
-
pre_price: Optional[float]
|
107
|
-
price: Optional[float]
|
108
|
-
open: Optional[float]
|
109
|
-
high: Optional[float]
|
110
|
-
low: Optional[float]
|
111
|
-
close: Optional[float]
|
112
|
-
open_int: Optional[int]
|
113
|
-
vol: Optional[int]
|
114
|
-
amount: Optional[int] # 单数量
|
115
|
-
num: Optional[int]
|
116
|
-
ask_price1: Optional[float]
|
117
|
-
ask_volume1: Optional[int]
|
118
|
-
bid_price1: Optional[float]
|
119
|
-
bid_volume1: Optional[int]
|
120
|
-
pre_delta: Optional[float]
|
121
|
-
curr_delta: Optional[float]
|
122
|
-
dif_price1: Optional[float]
|
123
|
-
dif_price2: Optional[float]
|
124
|
-
high_limit_price: Optional[float]
|
125
|
-
low_limit_price: Optional[float]
|
126
|
-
refer_price: Optional[float]
|
127
|
-
pre_settle_price: Optional[float]
|
128
|
-
settle_price: Optional[float]
|
1
|
+
from datetime import datetime
|
2
|
+
from typing import Optional
|
3
|
+
|
4
|
+
from pydantic import BaseModel
|
5
|
+
|
6
|
+
|
7
|
+
class TsTick(BaseModel):
|
8
|
+
ts_code: str
|
9
|
+
name: Optional[str]
|
10
|
+
trade_time: Optional[datetime]
|
11
|
+
pre_close_price: Optional[float]
|
12
|
+
last_price: Optional[float]
|
13
|
+
open_price: Optional[float]
|
14
|
+
high_price: Optional[float]
|
15
|
+
low_price: Optional[float]
|
16
|
+
close_price: Optional[float]
|
17
|
+
volume: Optional[int] # 成交量
|
18
|
+
amount: Optional[int] # 成交金额
|
19
|
+
count: Optional[int] # 交易数量
|
20
|
+
ask_price1: Optional[float] # 申卖价, 委托档位卖1档价格
|
21
|
+
ask_volume1: Optional[int] # 申卖量
|
22
|
+
bid_price1: Optional[float] # 申买价, 委托档位买1档价格
|
23
|
+
bid_volume1: Optional[int] # 申买量
|
24
|
+
ask_price2: Optional[float]
|
25
|
+
ask_volume2: Optional[int]
|
26
|
+
bid_price2: Optional[float]
|
27
|
+
bid_volume2: Optional[int]
|
28
|
+
ask_price3: Optional[float]
|
29
|
+
ask_volume3: Optional[int]
|
30
|
+
bid_price3: Optional[float]
|
31
|
+
bid_volume3: Optional[int]
|
32
|
+
ask_price4: Optional[float]
|
33
|
+
ask_volume4: Optional[int]
|
34
|
+
bid_price4: Optional[float]
|
35
|
+
bid_volume4: Optional[int]
|
36
|
+
ask_price5: Optional[float]
|
37
|
+
ask_volume5: Optional[int]
|
38
|
+
bid_price5: Optional[float]
|
39
|
+
bid_volume5: Optional[int]
|
40
|
+
ask_price6: Optional[float]
|
41
|
+
ask_volume6: Optional[int]
|
42
|
+
bid_price6: Optional[float]
|
43
|
+
bid_volume6: Optional[int]
|
44
|
+
ask_price7: Optional[float]
|
45
|
+
ask_volume7: Optional[int]
|
46
|
+
bid_price7: Optional[float]
|
47
|
+
bid_volume7: Optional[int]
|
48
|
+
ask_price8: Optional[float]
|
49
|
+
ask_volume8: Optional[int]
|
50
|
+
bid_price8: Optional[float]
|
51
|
+
bid_volume8: Optional[int]
|
52
|
+
ask_price9: Optional[float]
|
53
|
+
ask_volume9: Optional[int]
|
54
|
+
bid_price9: Optional[float]
|
55
|
+
bid_volume9: Optional[int]
|
56
|
+
ask_price10: Optional[float]
|
57
|
+
ask_volume10: Optional[int]
|
58
|
+
bid_price10: Optional[float]
|
59
|
+
bid_volume10: Optional[int]
|
60
|
+
|
61
|
+
|
62
|
+
class TsTickIdx(BaseModel):
|
63
|
+
ts_code: str
|
64
|
+
name: Optional[str]
|
65
|
+
trade_time: Optional[datetime]
|
66
|
+
last_price: Optional[float] # last_price 单位元
|
67
|
+
pre_close_price: Optional[float] # pre_close_price
|
68
|
+
high_price: Optional[float] # high_price
|
69
|
+
open_price: Optional[float] # open_price
|
70
|
+
low_price: Optional[float] # low_price
|
71
|
+
close_price: Optional[float] # close_price
|
72
|
+
volume: Optional[int] # volume, 成交总量
|
73
|
+
amount: Optional[float] # amount, 成交总金额
|
74
|
+
|
75
|
+
|
76
|
+
class TsTickOpt(BaseModel):
|
77
|
+
ts_code: str
|
78
|
+
instrument_id: str
|
79
|
+
trade_time: Optional[datetime]
|
80
|
+
pre_price: Optional[float] # 单位元
|
81
|
+
price: Optional[float]
|
82
|
+
open: Optional[float]
|
83
|
+
high: Optional[float]
|
84
|
+
low: Optional[float]
|
85
|
+
close: Optional[float]
|
86
|
+
open_int: Optional[int]
|
87
|
+
vol: Optional[float]
|
88
|
+
amount: Optional[float]
|
89
|
+
num: Optional[int]
|
90
|
+
ask_price1: Optional[float]
|
91
|
+
ask_volume1: Optional[int]
|
92
|
+
bid_price1: Optional[float]
|
93
|
+
bid_volume1: Optional[int]
|
94
|
+
pre_delta: Optional[float] # 昨虚实度,暂未提供
|
95
|
+
dif_price1: Optional[float]
|
96
|
+
dif_price2: Optional[float]
|
97
|
+
high_limit_price: Optional[float]
|
98
|
+
low_limit_price: Optional[float]
|
99
|
+
refer_price: Optional[float] # 参考价,港股使用
|
100
|
+
|
101
|
+
|
102
|
+
class TsTickFuture(BaseModel):
|
103
|
+
ts_code: str
|
104
|
+
instrument_id: Optional[str]
|
105
|
+
trade_time: Optional[datetime]
|
106
|
+
pre_price: Optional[float]
|
107
|
+
price: Optional[float]
|
108
|
+
open: Optional[float]
|
109
|
+
high: Optional[float]
|
110
|
+
low: Optional[float]
|
111
|
+
close: Optional[float]
|
112
|
+
open_int: Optional[int]
|
113
|
+
vol: Optional[int]
|
114
|
+
amount: Optional[int] # 单数量
|
115
|
+
num: Optional[int]
|
116
|
+
ask_price1: Optional[float]
|
117
|
+
ask_volume1: Optional[int]
|
118
|
+
bid_price1: Optional[float]
|
119
|
+
bid_volume1: Optional[int]
|
120
|
+
pre_delta: Optional[float]
|
121
|
+
curr_delta: Optional[float]
|
122
|
+
dif_price1: Optional[float]
|
123
|
+
dif_price2: Optional[float]
|
124
|
+
high_limit_price: Optional[float]
|
125
|
+
low_limit_price: Optional[float]
|
126
|
+
refer_price: Optional[float]
|
127
|
+
pre_settle_price: Optional[float]
|
128
|
+
settle_price: Optional[float]
|
@@ -176,11 +176,27 @@ class TsSubscribe(object):
|
|
176
176
|
p.start()
|
177
177
|
|
178
178
|
|
179
|
-
def
|
179
|
+
def test_min():
|
180
|
+
app = TsSubscribe("xxx")
|
181
|
+
|
182
|
+
# code 可以包含 * (通配符)
|
183
|
+
@app.register(topic='HQ_STK_MIN', codes=["1MIN:*.SH"])
|
184
|
+
def print_message(record):
|
185
|
+
"""
|
186
|
+
订阅主题topic,并指定codes列表,在接收到topic的推送消息时,符合code条件,就会执行回调
|
187
|
+
:param record:
|
188
|
+
:return:
|
189
|
+
"""
|
190
|
+
print('用户定义业务代码输出 print_message(%s)' % str(record))
|
191
|
+
|
192
|
+
app.run()
|
193
|
+
|
194
|
+
|
195
|
+
def test_tick():
|
180
196
|
app = TsSubscribe(token='xxx')
|
181
197
|
|
182
198
|
# code 可以包含 * (通配符)
|
183
|
-
@app.register(topic='
|
199
|
+
@app.register(topic='HQ_STK_TICK', codes=["*.SH"])
|
184
200
|
def print_message(record):
|
185
201
|
"""
|
186
202
|
订阅主题topic,并指定codes列表,在接收到topic的推送消息时,符合code条件,就会执行回调
|
@@ -193,4 +209,4 @@ def test():
|
|
193
209
|
|
194
210
|
|
195
211
|
if __name__ == '__main__':
|
196
|
-
|
212
|
+
test_min()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: tushare
|
3
|
-
Version: 1.4.
|
3
|
+
Version: 1.4.15
|
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
|
@@ -80,6 +80,11 @@ return::
|
|
80
80
|
|
81
81
|
Log
|
82
82
|
--------------
|
83
|
+
1.4.14
|
84
|
+
-------
|
85
|
+
- 修复 realtime_list (爬虫版)
|
86
|
+
- 修复dc CLOSE和PRE_CLOSE收盘和昨收 字段命名问题
|
87
|
+
-------
|
83
88
|
1.4.6
|
84
89
|
-------
|
85
90
|
- 修复 realtime_quote 实时盘口TICK快照(爬虫版)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
tushare/__init__.py,sha256=
|
1
|
+
tushare/__init__.py,sha256=D2GYf-e9mmFqKrbMCS_M20Q3dRhai81uncRRRSHb3GE,4765
|
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,8 +18,8 @@ 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=w7LfXtlmSd4Aiq7Bz5-tPFfkfjrPS_7jroUiRs7BUWw,1388
|
21
|
-
tushare/pro/data_pro.py,sha256=
|
22
|
-
tushare/pro/llm.py,sha256=
|
21
|
+
tushare/pro/data_pro.py,sha256=3ZVaHCsHqJlMouXsqgAeayqD9rThX-EGZ_REOYsAWbs,20568
|
22
|
+
tushare/pro/llm.py,sha256=Zdb81mhr9lQKX6p-JDml7THSbmBm8NmFQT54B8FkgvI,3444
|
23
23
|
tushare/stock/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
24
24
|
tushare/stock/billboard.py,sha256=vCrbN7-NGXSpXMc8jq7NcjjHyu9pTcr4uXp559iA1wA,12833
|
25
25
|
tushare/stock/classifying.py,sha256=3yWqlLhgj2irk-9ksKWFFS5HY-SnjfEr5erwJxBidG8,10539
|
@@ -35,7 +35,7 @@ tushare/stock/news_vars.py,sha256=CQ18hvyoeScelBCqKgF_rgAufoEALAUT8y_LERvZKHk,45
|
|
35
35
|
tushare/stock/newsevent.py,sha256=STR7C8MjtZlaXTCG0QNaojBuK4-oxP_8hT7ZIvRpbiI,6944
|
36
36
|
tushare/stock/ref_vars.py,sha256=MIxor-2rISl65I32vUzC-z7ZC_QFzG4sxOKDyjLWuU4,4449
|
37
37
|
tushare/stock/reference.py,sha256=x_HZlrP58T-5OTZ7SLdf2Dh9THj1h7cT4wcIp42IHFI,38227
|
38
|
-
tushare/stock/rtq.py,sha256=
|
38
|
+
tushare/stock/rtq.py,sha256=28HBzyrJ2VwP93_9edkLBWgllezgrUJoS_WZc6RYFgA,23161
|
39
39
|
tushare/stock/rtq_vars.py,sha256=V6LeJkSP76z8veRfP_mGiQ63V5YBHoTMaqUA5hSBWh4,4200
|
40
40
|
tushare/stock/shibor.py,sha256=Fx9OUZ429kz6l7ZdaYSD6p_X79ud69PDM9EZogm8xCY,6422
|
41
41
|
tushare/stock/trading.py,sha256=3bvM4pexEYW-uGGEL7g6Vkte4sqGC1iYO6dC8mGLSdM,55619
|
@@ -45,13 +45,13 @@ tushare/subs/ht_subs/covert.py,sha256=d25f86D_4CHjrX3IGh8JtTSb7VI2Da506FHwlhOhk1
|
|
45
45
|
tushare/subs/ht_subs/subscribe.py,sha256=yYnPeg7c0OHbIJhEf4bXFMLbQ4H1bHhApDPrHeTimuw,8340
|
46
46
|
tushare/subs/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
47
47
|
tushare/subs/model/min.py,sha256=-AYBGOM1U8IB7Q6SPHS0tpoWN3qz1hngCw7k5x2HhUU,375
|
48
|
-
tushare/subs/model/tick.py,sha256=
|
48
|
+
tushare/subs/model/tick.py,sha256=yaYMJY42_IPjViY4v0aMyNahXfpBE_m2dcz3obm8Y94,4339
|
49
49
|
tushare/subs/tgw_subs/__init__.py,sha256=30AFeIgTci0HLNyZTNpr1wRChrVdvpD2dHNKS4Q-fS0,69
|
50
50
|
tushare/subs/tgw_subs/convert.py,sha256=VWsDOv_rmz3a9YjQ-ZThXerc1HqcWPlBYAOF6A9SqjQ,5474
|
51
51
|
tushare/subs/tgw_subs/login.py,sha256=z7laiscTx50LzOB0cM2hypv5E78DvWx-2Ip5kDE7uNk,903
|
52
52
|
tushare/subs/tgw_subs/subscribe.py,sha256=OwLKcSTN2xrge33hBkio_S188viMeGuicDj_x0VaR2A,3336
|
53
53
|
tushare/subs/ts_subs/__init__.py,sha256=AyX957j8DDjdpIYcNR7dyRaMfxusa6d2VeunMEB6RAc,107
|
54
|
-
tushare/subs/ts_subs/subscribe.py,sha256=
|
54
|
+
tushare/subs/ts_subs/subscribe.py,sha256=3akQj5IDANatYOBFYSKotigKviAf5N8SNO_ZVx8pBR0,6701
|
55
55
|
tushare/trader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
56
56
|
tushare/trader/trader.py,sha256=O2WJkIKGuUFK_hiQj83N5j971VW-TNAgKaCE0O4oFwg,11360
|
57
57
|
tushare/trader/utils.py,sha256=CG-TCyeu5WqYjnBARxft2lEnLD3xvhHLU40hPSL_CCw,752
|
@@ -72,8 +72,8 @@ tushare/util/verify_token.py,sha256=cuV3RErWbOC318NANCYL6K1LKZ3wSAL2yMwZHA7tD3s,
|
|
72
72
|
tushare/util/protobuf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
73
73
|
tushare/util/protobuf/funcs.py,sha256=UCdK8FxTyjPZsNzoEeXqYzqrQXUmRMvW5hua6GPA66A,779
|
74
74
|
tushare/util/protobuf/response_pb2.py,sha256=vJH9ONkDuJlg6y-q1PvuDZoviKrK7hzNtMieQHK45DI,11347
|
75
|
-
tushare-1.4.
|
76
|
-
tushare-1.4.
|
77
|
-
tushare-1.4.
|
78
|
-
tushare-1.4.
|
79
|
-
tushare-1.4.
|
75
|
+
tushare-1.4.15.dist-info/LICENSE,sha256=C2j55UI0Ul-1-wA1-rn7OaY6b3vGl4YukiyvYzHsU9o,1503
|
76
|
+
tushare-1.4.15.dist-info/METADATA,sha256=zCdNZd91LalPVVUE_c_0Jci20wYeISLM7MDmOEyl_eg,2965
|
77
|
+
tushare-1.4.15.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
78
|
+
tushare-1.4.15.dist-info/top_level.txt,sha256=HHOxMuqc31KuAIcxpE0t5dAPMKbaiRtjsjTMFd7FlXI,8
|
79
|
+
tushare-1.4.15.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|