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.
- tushare/__init__.py +1 -1
- tushare/pro/data_pro.py +18 -10
- tushare/subs/model/tick.py +128 -128
- tushare/subs/tgw_subs/convert.py +20 -20
- {tushare-1.4.6.dist-info → tushare-1.4.7.dist-info}/METADATA +98 -101
- {tushare-1.4.6.dist-info → tushare-1.4.7.dist-info}/RECORD +9 -46
- {tushare-1.4.6.dist-info → tushare-1.4.7.dist-info}/WHEEL +1 -1
- {tushare-1.4.6.dist-info → tushare-1.4.7.dist-info}/top_level.txt +0 -1
- baks/__init__.py +0 -0
- baks/demo.py +0 -184
- baks/rtqc.py +0 -612
- baks/setup.py +0 -15
- baks/sss.py +0 -56
- test/__init__.py +0 -0
- test/bar_test.py +0 -23
- test/billboard_test.py +0 -35
- test/build_pyd/__init__.py +0 -8
- test/build_pyd/rtqc.py +0 -612
- test/build_pyd/setup.py +0 -15
- 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
- test/classifying_test.py +0 -50
- test/dateu_test.py +0 -19
- test/fund_test.py +0 -43
- test/indictor_test.py +0 -23
- test/macro_test.py +0 -50
- test/nav_test.py +0 -104
- test/news_test.py +0 -38
- test/pro_test.py +0 -11
- test/ref_test.py +0 -57
- test/shibor_test.py +0 -33
- test/storing_test.py +0 -61
- test/test_query.py +0 -16
- test/test_realtime.py +0 -24
- test/test_realtime_quote.py +0 -13
- test/test_sdk_event.py +0 -21
- test/test_stk_mins.py +0 -16
- test/test_stock_basic.py +0 -16
- test/test_tgw_subscribe.py +0 -28
- test/test_ts_subscribe.py +0 -22
- test/test_websocket.py +0 -52
- test/trading_test.py +0 -43
- tushare/stock/rtqc.pyd +0 -0
- tushare/subs/ht_subs/service/__init__.py +0 -0
- tushare/subs/ht_subs/service/covert.py +0 -189
- tushare/subs/ts_subs.py +0 -192
- {tushare-1.4.6.dist-info → tushare-1.4.7.dist-info}/LICENSE +0 -0
test/classifying_test.py
DELETED
@@ -1,50 +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.classifying as fd
|
8
|
-
|
9
|
-
class Test(unittest.TestCase):
|
10
|
-
|
11
|
-
def set_data(self):
|
12
|
-
self.code = '600848'
|
13
|
-
self.start = '2015-01-03'
|
14
|
-
self.end = '2015-04-07'
|
15
|
-
self.year = 2014
|
16
|
-
self.quarter = 4
|
17
|
-
|
18
|
-
def test_get_industry_classified(self):
|
19
|
-
print(fd.get_industry_classified())
|
20
|
-
|
21
|
-
def test_get_concept_classified(self):
|
22
|
-
print(fd.get_concept_classified())
|
23
|
-
|
24
|
-
def test_get_area_classified(self):
|
25
|
-
print(fd.get_area_classified())
|
26
|
-
|
27
|
-
def test_get_gem_classified(self):
|
28
|
-
print(fd.get_gem_classified())
|
29
|
-
|
30
|
-
def test_get_sme_classified(self):
|
31
|
-
print(fd.get_sme_classified())
|
32
|
-
|
33
|
-
def test_get_st_classified(self):
|
34
|
-
print(fd.get_st_classified())
|
35
|
-
|
36
|
-
def test_get_hs300s(self):
|
37
|
-
print(fd.get_hs300s())
|
38
|
-
|
39
|
-
def test_get_sz50s(self):
|
40
|
-
print(fd.get_sz50s())
|
41
|
-
|
42
|
-
def test_get_zz500s(self):
|
43
|
-
print(fd.get_zz500s())
|
44
|
-
|
45
|
-
if __name__ == "__main__":
|
46
|
-
unittest.main()
|
47
|
-
|
48
|
-
# suite = unittest.TestSuite()
|
49
|
-
# suite.addTest(Test('test_get_gem_classified'))
|
50
|
-
# unittest.TextTestRunner(verbosity=2).run(suite)
|
test/dateu_test.py
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# -*- coding:utf-8 -*-
|
2
|
-
"""
|
3
|
-
@author: ZackZK
|
4
|
-
"""
|
5
|
-
|
6
|
-
from unittest import TestCase
|
7
|
-
|
8
|
-
from tushare.util import dateu
|
9
|
-
from tushare.util.dateu import is_holiday
|
10
|
-
|
11
|
-
|
12
|
-
class Test_Is_holiday(TestCase):
|
13
|
-
def test_is_holiday(self):
|
14
|
-
dateu.holiday = ['2016-01-04'] # holiday stub for later test
|
15
|
-
self.assertTrue(is_holiday('2016-01-04')) # holiday
|
16
|
-
self.assertFalse(is_holiday('2016-01-01')) # not holiday
|
17
|
-
self.assertTrue(is_holiday('2016-01-09')) # Saturday
|
18
|
-
self.assertTrue(is_holiday('2016-01-10')) # Sunday
|
19
|
-
|
test/fund_test.py
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# -*- coding:utf-8 -*-
|
2
|
-
|
3
|
-
import unittest
|
4
|
-
import tushare.stock.fundamental as fd
|
5
|
-
|
6
|
-
class Test(unittest.TestCase):
|
7
|
-
|
8
|
-
def set_data(self):
|
9
|
-
self.code = '600848'
|
10
|
-
self.start = '2015-01-03'
|
11
|
-
self.end = '2015-04-07'
|
12
|
-
self.year = 2014
|
13
|
-
self.quarter = 4
|
14
|
-
|
15
|
-
def test_get_stock_basics(self):
|
16
|
-
print(fd.get_stock_basics())
|
17
|
-
|
18
|
-
# def test_get_report_data(self):
|
19
|
-
# self.set_data()
|
20
|
-
# print(fd.get_report_data(self.year, self.quarter))
|
21
|
-
#
|
22
|
-
# def test_get_profit_data(self):
|
23
|
-
# self.set_data()
|
24
|
-
# print(fd.get_profit_data(self.year, self.quarter))
|
25
|
-
#
|
26
|
-
# def test_get_operation_data(self):
|
27
|
-
# self.set_data()
|
28
|
-
# print(fd.get_operation_data(self.year, self.quarter))
|
29
|
-
#
|
30
|
-
# def test_get_growth_data(self):
|
31
|
-
# self.set_data()
|
32
|
-
# print(fd.get_growth_data(self.year, self.quarter))
|
33
|
-
#
|
34
|
-
# def test_get_debtpaying_data(self):
|
35
|
-
# self.set_data()
|
36
|
-
# print(fd.get_debtpaying_data(self.year, self.quarter))
|
37
|
-
#
|
38
|
-
# def test_get_cashflow_data(self):
|
39
|
-
# self.set_data()
|
40
|
-
# print(fd.get_cashflow_data(self.year, self.quarter))
|
41
|
-
|
42
|
-
if __name__ == '__main__':
|
43
|
-
unittest.main()
|
test/indictor_test.py
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# -*- coding:utf-8 -*-
|
2
|
-
'''
|
3
|
-
Created on 2018/05/26
|
4
|
-
@author: Jackie Liao
|
5
|
-
'''
|
6
|
-
import unittest
|
7
|
-
import tushare.stock.indictor as idx
|
8
|
-
import tushare as ts
|
9
|
-
|
10
|
-
|
11
|
-
class Test(unittest.TestCase):
|
12
|
-
|
13
|
-
def test_plot_all(self):
|
14
|
-
data = ts.get_k_data("601398", start="2018-01-01", end="2018-05-27")
|
15
|
-
|
16
|
-
data = data.sort_values(by=["date"], ascending=True)
|
17
|
-
|
18
|
-
idx.plot_all(data, is_show=True, output=None)
|
19
|
-
|
20
|
-
|
21
|
-
if __name__ == "__main__":
|
22
|
-
# import sys;sys.argv = ['', 'Test.testName']
|
23
|
-
unittest.main()
|
test/macro_test.py
DELETED
@@ -1,50 +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.macro as fd
|
8
|
-
|
9
|
-
class Test(unittest.TestCase):
|
10
|
-
|
11
|
-
def test_get_gdp_year(self):
|
12
|
-
print(fd.get_gdp_year())
|
13
|
-
|
14
|
-
def test_get_gdp_quarter(self):
|
15
|
-
print(fd.get_gdp_quarter())
|
16
|
-
|
17
|
-
def test_get_gdp_for(self):
|
18
|
-
print(fd.get_gdp_for())
|
19
|
-
|
20
|
-
def test_get_gdp_pull(self):
|
21
|
-
print(fd.get_gdp_pull())
|
22
|
-
|
23
|
-
def test_get_gdp_contrib(self):
|
24
|
-
print(fd.get_gdp_contrib())
|
25
|
-
|
26
|
-
def test_get_cpi(self):
|
27
|
-
print(fd.get_cpi())
|
28
|
-
|
29
|
-
def test_get_ppi(self):
|
30
|
-
print(fd.get_ppi())
|
31
|
-
|
32
|
-
def test_get_deposit_rate(self):
|
33
|
-
print(fd.get_deposit_rate())
|
34
|
-
|
35
|
-
def test_get_loan_rate(self):
|
36
|
-
print(fd.get_loan_rate())
|
37
|
-
|
38
|
-
def test_get_rrr(self):
|
39
|
-
print(fd.get_rrr())
|
40
|
-
|
41
|
-
def test_get_money_supply(self):
|
42
|
-
print(fd.get_money_supply())
|
43
|
-
|
44
|
-
def test_get_money_supply_bal(self):
|
45
|
-
print(fd.get_money_supply_bal())
|
46
|
-
|
47
|
-
|
48
|
-
if __name__ == "__main__":
|
49
|
-
#import sys;sys.argv = ['', 'Test.testName']
|
50
|
-
unittest.main()
|
test/nav_test.py
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
# -*- coding:utf-8 -*-
|
2
|
-
'''
|
3
|
-
Created on 2016/5/26
|
4
|
-
@author: leo
|
5
|
-
'''
|
6
|
-
import unittest
|
7
|
-
import tushare.fund.nav as nav
|
8
|
-
|
9
|
-
|
10
|
-
class Test(unittest.TestCase):
|
11
|
-
|
12
|
-
def set_data(self):
|
13
|
-
self.symbol = '600848'
|
14
|
-
self.start = '2014-11-24'
|
15
|
-
self.end = '2016-02-29'
|
16
|
-
self.disp = 5
|
17
|
-
|
18
|
-
def test_get_nav_open(self):
|
19
|
-
self.set_data()
|
20
|
-
lst = ['all', 'equity', 'mix', 'bond', 'monetary', 'qdii']
|
21
|
-
print('get nav open................\n')
|
22
|
-
for item in lst:
|
23
|
-
print('=============\nget %s nav\n=============' % item)
|
24
|
-
fund_df = nav.get_nav_open(item)
|
25
|
-
print('\nnums=%d' % len(fund_df))
|
26
|
-
print(fund_df[:self.disp])
|
27
|
-
|
28
|
-
def test_get_nav_close(self):
|
29
|
-
self.set_data()
|
30
|
-
type2 = ['all', 'fbqy', 'fbzq']
|
31
|
-
qy_t3 = ['all', 'ct', 'cx']
|
32
|
-
zq_t3 = ['all', 'wj', 'jj', 'cz']
|
33
|
-
|
34
|
-
print('\nget nav closed................\n')
|
35
|
-
fund_df = None
|
36
|
-
for item in type2:
|
37
|
-
if item == 'fbqy':
|
38
|
-
for t3i in qy_t3:
|
39
|
-
print('\n=============\nget %s-%s nav\n=============' %
|
40
|
-
(item, t3i))
|
41
|
-
fund_df = nav.get_nav_close(item, t3i)
|
42
|
-
print('\nnums=%d' % len(fund_df))
|
43
|
-
print(fund_df[:self.disp])
|
44
|
-
elif item == 'fbzq':
|
45
|
-
for t3i in zq_t3:
|
46
|
-
print('\n=============\nget %s-%s nav\n=============' %
|
47
|
-
(item, t3i))
|
48
|
-
fund_df = nav.get_nav_close(item, t3i)
|
49
|
-
print('\nnums=%d' % len(fund_df))
|
50
|
-
print(fund_df[:self.disp])
|
51
|
-
else:
|
52
|
-
print('\n=============\nget %s nav\n=============' % item)
|
53
|
-
fund_df = nav.get_nav_close(item)
|
54
|
-
print('\nnums=%d' % len(fund_df))
|
55
|
-
print(fund_df[:self.disp])
|
56
|
-
|
57
|
-
def test_get_nav_grading(self):
|
58
|
-
self.set_data()
|
59
|
-
t2 = ['all', 'fjgs', 'fjgg']
|
60
|
-
t3 = {'all': '0', 'wjzq': '13', 'gp': '14',
|
61
|
-
'zs': '15', 'czzq': '16', 'jjzq': '17'}
|
62
|
-
|
63
|
-
print('\nget nav grading................\n')
|
64
|
-
fund_df = None
|
65
|
-
for item in t2:
|
66
|
-
if item == 'all':
|
67
|
-
print('\n=============\nget %s nav\n=============' % item)
|
68
|
-
fund_df = nav.get_nav_grading(item)
|
69
|
-
print('\nnums=%d' % len(fund_df))
|
70
|
-
print(fund_df[:self.disp])
|
71
|
-
else:
|
72
|
-
for t3i in t3.keys():
|
73
|
-
print('\n=============\nget %s-%s nav\n=============' %
|
74
|
-
(item, t3i))
|
75
|
-
fund_df = nav.get_nav_grading(item, t3i)
|
76
|
-
print('\nnums=%d' % len(fund_df))
|
77
|
-
print(fund_df[:self.disp])
|
78
|
-
|
79
|
-
def test_nav_history(self):
|
80
|
-
self.set_data()
|
81
|
-
lst = ['164905', '161005', '380007', '000733', '159920', '164902',
|
82
|
-
'184721', '165519', '164302', '519749', '150275', '150305',
|
83
|
-
'150248']
|
84
|
-
for _, item in enumerate(lst):
|
85
|
-
print('\n=============\nget %s nav\n=============' % item)
|
86
|
-
fund_df = nav.get_nav_history(item, self.start, self.end)
|
87
|
-
if fund_df is not None:
|
88
|
-
print('\nnums=%d' % len(fund_df))
|
89
|
-
print(fund_df[:self.disp])
|
90
|
-
|
91
|
-
def test_get_fund_info(self):
|
92
|
-
self.set_data()
|
93
|
-
lst = ['164905', '161005', '380007', '000733', '159920', '164902',
|
94
|
-
'184721', '165519', '164302', '519749', '150275', '150305',
|
95
|
-
'150248']
|
96
|
-
for item in lst:
|
97
|
-
print('\n=============\nget %s nav\n=============' % item)
|
98
|
-
fund_df = nav.get_fund_info(item)
|
99
|
-
if fund_df is not None:
|
100
|
-
print('%s fund info' % item)
|
101
|
-
print(fund_df)
|
102
|
-
|
103
|
-
if __name__ == '__main__':
|
104
|
-
unittest.main()
|
test/news_test.py
DELETED
@@ -1,38 +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.newsevent as fd
|
8
|
-
|
9
|
-
class Test(unittest.TestCase):
|
10
|
-
|
11
|
-
def set_data(self):
|
12
|
-
self.code = '600848'
|
13
|
-
self.start = '2015-01-03'
|
14
|
-
self.end = '2015-04-07'
|
15
|
-
self.year = 2014
|
16
|
-
self.quarter = 4
|
17
|
-
self.top = 60
|
18
|
-
self.show_content = True
|
19
|
-
|
20
|
-
|
21
|
-
def test_get_latest_news(self):
|
22
|
-
self.set_data()
|
23
|
-
print(fd.get_latest_news(self.top, self.show_content))
|
24
|
-
|
25
|
-
|
26
|
-
def test_get_notices(self):
|
27
|
-
self.set_data()
|
28
|
-
df = fd.get_notices(self.code)
|
29
|
-
print(fd.notice_content(df.ix[0]['url']))
|
30
|
-
|
31
|
-
|
32
|
-
def test_guba_sina(self):
|
33
|
-
self.set_data()
|
34
|
-
print(fd.guba_sina(self.show_content))
|
35
|
-
|
36
|
-
|
37
|
-
if __name__ == "__main__":
|
38
|
-
unittest.main()
|
test/pro_test.py
DELETED
test/ref_test.py
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
# -*- coding:utf-8 -*-
|
2
|
-
'''
|
3
|
-
Created on 2015/3/14
|
4
|
-
@author: Jimmy Liu
|
5
|
-
'''
|
6
|
-
import unittest
|
7
|
-
from tushare.stock import reference as fd
|
8
|
-
|
9
|
-
class Test(unittest.TestCase):
|
10
|
-
|
11
|
-
def set_data(self):
|
12
|
-
self.code = '600848'
|
13
|
-
self.start = '2015-01-03'
|
14
|
-
self.end = '2015-04-07'
|
15
|
-
self.year = 2014
|
16
|
-
self.quarter = 4
|
17
|
-
self.top = 60
|
18
|
-
self.show_content = True
|
19
|
-
|
20
|
-
def test_profit_data(self):
|
21
|
-
self.set_data()
|
22
|
-
print(fd.profit_data(top=self.top))
|
23
|
-
|
24
|
-
def test_forecast_data(self):
|
25
|
-
self.set_data()
|
26
|
-
print(fd.forecast_data(self.year, self.quarter))
|
27
|
-
|
28
|
-
def test_xsg_data(self):
|
29
|
-
print(fd.xsg_data())
|
30
|
-
|
31
|
-
def test_fund_holdings(self):
|
32
|
-
self.set_data()
|
33
|
-
print(fd.fund_holdings(self.year, self.quarter))
|
34
|
-
|
35
|
-
def test_new_stocksa(self):
|
36
|
-
print(fd.new_stocks())
|
37
|
-
|
38
|
-
|
39
|
-
def test_sh_margin_details(self):
|
40
|
-
self.set_data()
|
41
|
-
print(fd.sh_margin_details(self.start, self.end, self.code))
|
42
|
-
|
43
|
-
def test_sh_margins(self):
|
44
|
-
self.set_data()
|
45
|
-
print(fd.sh_margins(self.start, self.end))
|
46
|
-
|
47
|
-
def test_sz_margins(self):
|
48
|
-
self.set_data()
|
49
|
-
print(fd.sz_margins(self.start, self.end))
|
50
|
-
|
51
|
-
def test_sz_margin_details(self):
|
52
|
-
self.set_data()
|
53
|
-
print(fd.sz_margin_details(self.end))
|
54
|
-
|
55
|
-
|
56
|
-
if __name__ == "__main__":
|
57
|
-
unittest.main()
|
test/shibor_test.py
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# -*- coding:utf-8 -*-
|
2
|
-
|
3
|
-
import unittest
|
4
|
-
import tushare.stock.shibor as fd
|
5
|
-
|
6
|
-
class Test(unittest.TestCase):
|
7
|
-
|
8
|
-
def set_data(self):
|
9
|
-
self.year = 2014
|
10
|
-
# self.year = None
|
11
|
-
|
12
|
-
def test_shibor_data(self):
|
13
|
-
self.set_data()
|
14
|
-
fd.shibor_data(self.year)
|
15
|
-
|
16
|
-
def test_shibor_quote_data(self):
|
17
|
-
self.set_data()
|
18
|
-
fd.shibor_quote_data(self.year)
|
19
|
-
|
20
|
-
def test_shibor_ma_data(self):
|
21
|
-
self.set_data()
|
22
|
-
fd.shibor_ma_data(self.year)
|
23
|
-
|
24
|
-
def test_lpr_data(self):
|
25
|
-
self.set_data()
|
26
|
-
fd.lpr_data(self.year)
|
27
|
-
|
28
|
-
def test_lpr_ma_data(self):
|
29
|
-
self.set_data()
|
30
|
-
fd.lpr_ma_data(self.year)
|
31
|
-
|
32
|
-
if __name__ == '__main__':
|
33
|
-
unittest.main()
|
test/storing_test.py
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# -*- coding:utf-8 -*-
|
2
|
-
|
3
|
-
import os
|
4
|
-
from sqlalchemy import create_engine
|
5
|
-
from pandas.io.pytables import HDFStore
|
6
|
-
import tushare as ts
|
7
|
-
|
8
|
-
def csv():
|
9
|
-
df = ts.get_hist_data('000875')
|
10
|
-
df.to_csv('c:/day/000875.csv',columns=['open','high','low','close'])
|
11
|
-
|
12
|
-
def xls():
|
13
|
-
df = ts.get_hist_data('000875')
|
14
|
-
#直接保存
|
15
|
-
df.to_excel('c:/day/000875.xlsx', startrow=2,startcol=5)
|
16
|
-
|
17
|
-
def hdf():
|
18
|
-
df = ts.get_hist_data('000875')
|
19
|
-
# df.to_hdf('c:/day/store.h5','table')
|
20
|
-
|
21
|
-
store = HDFStore('c:/day/store.h5')
|
22
|
-
store['000875'] = df
|
23
|
-
store.close()
|
24
|
-
|
25
|
-
def json():
|
26
|
-
df = ts.get_hist_data('000875')
|
27
|
-
df.to_json('c:/day/000875.json',orient='records')
|
28
|
-
|
29
|
-
#或者直接使用
|
30
|
-
print(df.to_json(orient='records'))
|
31
|
-
|
32
|
-
def appends():
|
33
|
-
filename = 'c:/day/bigfile.csv'
|
34
|
-
for code in ['000875', '600848', '000981']:
|
35
|
-
df = ts.get_hist_data(code)
|
36
|
-
if os.path.exists(filename):
|
37
|
-
df.to_csv(filename, mode='a', header=None)
|
38
|
-
else:
|
39
|
-
df.to_csv(filename)
|
40
|
-
|
41
|
-
def db():
|
42
|
-
df = ts.get_tick_data('600848',date='2014-12-22')
|
43
|
-
engine = create_engine('mysql://root:jimmy1@127.0.0.1/mystock?charset=utf8')
|
44
|
-
# db = MySQLdb.connect(host='127.0.0.1',user='root',passwd='jimmy1',db="mystock",charset="utf8")
|
45
|
-
# df.to_sql('TICK_DATA',con=db,flavor='mysql')
|
46
|
-
# db.close()
|
47
|
-
df.to_sql('tick_data',engine,if_exists='append')
|
48
|
-
|
49
|
-
def nosql():
|
50
|
-
import pymongo
|
51
|
-
import json
|
52
|
-
conn = pymongo.Connection('127.0.0.1', port=27017)
|
53
|
-
df = ts.get_tick_data('600848',date='2014-12-22')
|
54
|
-
print(df.to_json(orient='records'))
|
55
|
-
|
56
|
-
conn.db.tickdata.insert(json.loads(df.to_json(orient='records')))
|
57
|
-
|
58
|
-
# print conn.db.tickdata.find()
|
59
|
-
|
60
|
-
if __name__ == '__main__':
|
61
|
-
nosql()
|
test/test_query.py
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
作 者:lidy
|
3
|
-
时 间:2023/8/22 22:00
|
4
|
-
项目名:tsdpsdk
|
5
|
-
"""
|
6
|
-
|
7
|
-
import tushare
|
8
|
-
|
9
|
-
def test_query():
|
10
|
-
api = tushare.pro_api('75e70c1ef4bd1a14e2301cbf20ec35e1045971c104ab02853e375284')
|
11
|
-
df = api.query('stock_basic', fields='ts_code,symbol')
|
12
|
-
print(df)
|
13
|
-
|
14
|
-
|
15
|
-
if __name__ == '__main__':
|
16
|
-
test_query()
|
test/test_realtime.py
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
from tushare.subs.ts_subs import Subs
|
4
|
-
|
5
|
-
|
6
|
-
def test_realtime():
|
7
|
-
# 75e70c1ef4bd1a14e2301cbf20ec35e1045971c104ab02853e375284
|
8
|
-
app = Subs(token='75e70c1ef4bd1a14e2301cbf20ec35e1045971c104ab02853e375284')
|
9
|
-
|
10
|
-
# code 可以包含 * (通配符)
|
11
|
-
@app.register(topic='HQ_FUT_MIN', codes=["5MIN:*"])
|
12
|
-
def print_message(record):
|
13
|
-
"""
|
14
|
-
订阅主题topic,并指定codes列表,在接收到topic的推送消息时,符合code条件,就会执行回调
|
15
|
-
:param record:
|
16
|
-
:return:
|
17
|
-
"""
|
18
|
-
print('用户定义业务代码输出 print_message(%s)' % str(record))
|
19
|
-
|
20
|
-
app.run()
|
21
|
-
|
22
|
-
|
23
|
-
if __name__ == '__main__':
|
24
|
-
test_realtime()
|
test/test_realtime_quote.py
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
作 者:lidy
|
3
|
-
时 间:2023/12/30 17:36
|
4
|
-
项目名:tsdpsdk
|
5
|
-
"""
|
6
|
-
import tushare
|
7
|
-
|
8
|
-
if __name__ == '__main__':
|
9
|
-
api = tushare.set_token('75e70c1ef4bd1a14e2301cbf20ec35e1045971c104ab02853e375284')
|
10
|
-
dd = tushare.realtime_quote(
|
11
|
-
ts_code="688553.SH", src="sina"
|
12
|
-
)
|
13
|
-
print(dd)
|
test/test_sdk_event.py
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
# 作 者:84028
|
3
|
-
# 时 间:2024/1/9 13:29
|
4
|
-
# tsdpsdk
|
5
|
-
"""
|
6
|
-
import time
|
7
|
-
|
8
|
-
import requests
|
9
|
-
|
10
|
-
if __name__ == '__main__':
|
11
|
-
for i in range(200):
|
12
|
-
start = time.time()
|
13
|
-
resp = requests.post(
|
14
|
-
'http://127.0.0.1:8081/dataapi/sdk-event',
|
15
|
-
json={
|
16
|
-
"user_token": "af4c3a76ff14972b3467d8950dd1587bb3d4b6b2dc9cd94093910795",
|
17
|
-
"event_name": "test",
|
18
|
-
"event_detail": "测试"
|
19
|
-
}
|
20
|
-
)
|
21
|
-
print(time.time()-start, resp)
|