摘要:TuShare大數(shù)據(jù)社區(qū)(https://),提供了專門針對(duì)股票,、期貨,、經(jīng)濟(jì)發(fā)展等相關(guān)的數(shù)據(jù)整理接口。開發(fā)者通過直接調(diào)用第三方接口可以輕松的獲取交易數(shù)據(jù),,開發(fā)者可以使用這些數(shù)據(jù)進(jìn)行進(jìn)一步分析得出結(jié)論等再可以結(jié)合可視化展示出交易數(shù)據(jù),、K線圖等等。說明:社區(qū)注冊(cè)并登錄,,使用手機(jī)號(hào)注冊(cè)登錄即可,,完成后需要獲取token這是后面調(diào)用三方接口用于驗(yàn)證調(diào)用者身份的。在數(shù)據(jù)接口模塊選擇需要調(diào)用的數(shù)據(jù)的接口,,按照參數(shù)請(qǐng)求發(fā)送后獲取響應(yīng)結(jié)果。 1import tushare as ts 2 3import pandas as pd 4 5# 設(shè)置pandas最大列數(shù) 6 7pd.set_option('display.max_columns', 600) 8 9# 設(shè)置pandas最大行數(shù) 10 11pd.set_option('display.max_rows', 20000) 12 13# 設(shè)置pandas每一列的最大寬度 14 15pd.set_option('display.max_colwidth', 30) 16 17# 定義token信息 18 19token = '*****************' 20 21# 接口調(diào)用參數(shù)初始化 22 23pro = ts.pro_api(token) 24 25# 獲取股票交易數(shù)據(jù) 26 27res_data = pro.daily(ts_code='000651.sz', start_date='20210101', end_date='20210501') 28 29print(res_data)
展示部分股票數(shù)據(jù)讀取結(jié)果
1 ts_code trade_date open high low close pre_close change \ 20 000651.SZ 20210430 60.25 60.60 59.32 59.91 59.51 0.40 31 000651.SZ 20210429 59.51 60.67 58.21 59.51 58.06 1.45 42 000651.SZ 20210428 58.50 58.66 57.39 58.06 57.98 0.08 53 000651.SZ 20210427 58.50 58.73 57.52 57.98 58.50 -0.52 64 000651.SZ 20210426 59.97 59.99 58.45 58.50 59.81 -1.31 75 000651.SZ 20210423 59.30 60.20 59.06 59.81 59.11 0.70 86 000651.SZ 20210422 59.71 59.90 58.76 59.11 59.62 -0.51 97 000651.SZ 20210421 59.50 59.98 59.07 59.62 59.98 -0.36 108 000651.SZ 20210420 60.81 60.82 59.65 59.98 60.88 -0.90 119 000651.SZ 20210419 60.90 61.36 60.35 60.88 60.88 0.00 1210 000651.SZ 20210416 61.70 61.88 60.02 60.88 60.53 0.35 1311 000651.SZ 20210415 61.00 62.33 60.38 60.53 59.92 0.61 1412 000651.SZ 20210414 59.51 60.15 59.31 59.92 59.17 0.75 1513 000651.SZ 20210413 60.40 60.50 58.71 59.17 60.20 -1.03 1614 000651.SZ 20210412 61.55 61.83 59.68 60.20 61.65 -1.45 1715 000651.SZ 20210409 62.09 62.18 60.69 61.65 61.85 -0.20 1816 000651.SZ 20210408 61.65 61.98 61.15 61.85 61.68 0.17 1917 000651.SZ 20210407 61.99 62.10 60.88 61.68 61.33 0.35 2018 000651.SZ 20210406 62.45 62.69 61.00 61.33 62.44 -1.11 2119 000651.SZ 20210402 62.98 63.50 62.20 62.44 62.73 -0.29 2220 000651.SZ 20210401 62.69 63.00 61.98 62.73 62.70 0.03
1http://pandas./pandas-docs/stable/visualization.html 2 3http://pandas./pandas-docs/stable/generated/pandas.DataFrame.plot.html?highlight=plot 4 5http://pandas./pandas-docs/stable/generated/pandas.Series.plot.html?highlight=series
|