Financial data reading and analysis of big data (1)

Due to the consideration of commercial data issues, we use open source data for demonstration

1. tushare open source data

Tushare is a free, open source Python financial data interface package. It mainly realizes the process of financial data such as stocks from data collection, cleaning and processing to data storage, and can provide financial analysts with fast, clean, and diverse data that is easy to analyze, greatly reducing the workload in terms of data acquisition and focusing more energy Focus on the research and implementation of strategies and models.

The standard data format used by Tushare is the DataFrame type, and the data storage function of Tushare can also be used to store all the data locally for analysis.

1. Register a Tushare account and get the interface

Tushare data https://tushare.pro/   and https://tu.share.org (update has been stopped)

2. Tushare is a third-party library, so we need to install it. The method of installation is to open the command prompt tool (search for "cmd" in the "Start" menu and open it), enter 'pip install tushare', and the automatic download and installation will begin.
After the installation is complete, you need to update the version of tushare, enter 'pip install tushare-upgrade'
to update.

 

import tushare as ts

pro = ts.pro_api('1e15bc4b19c9d9803fb6b53a2e3e23c3b7ceab364f4637deca6ccb9a')
# tushare version
print(ts.__version__)
# Get historical data of stock code 000001
print(ts.get_hist_data('000001'))
# Restricted sales of unlocked stock information Note that only those who have tushare 300 points or more have permission to read
# print(ts.pro_bar(ts_code='000002.sz', adj='qfq', start_date='20230101', end_date='20230331'))
df = ts.pro_bar(ts_code='600000.SH',
                start_date='2023-01-07 09:00:00',
                end_date='2023-01-08 17:00:00')

print(df)

 Share data analysis in the next issue

Guess you like

Origin blog.csdn.net/swebin/article/details/131451311