### Install Tushare Source: https://github.com/waditu/tushare/wiki/Tushare-on-Centos-7安装详解 Installs the Tushare library using pip. This is the main step for getting Tushare functionality. ```bash pip install tushare ``` -------------------------------- ### Install Python Source: https://github.com/waditu/tushare/wiki/Tushare-on-Centos-7安装详解 Installs Python using the zypper package manager. This is a prerequisite for Tushare. ```bash zypper install python ``` -------------------------------- ### Install pip Source: https://github.com/waditu/tushare/wiki/Tushare-on-Centos-7安装详解 Downloads and installs pip, the Python package installer. This is essential for installing Tushare and its dependencies. ```bash wget https://bootstrap.pypa.io/get-pip.py python get-pip.py ``` -------------------------------- ### Install MariaDB and Related Libraries Source: https://github.com/waditu/tushare/wiki/Tushare-on-Centos-7安装详解 Installs MariaDB server and necessary Python/PHP libraries for database integration on CentOS 7. ```bash yum -y mariadb-server yum -y install MySQL-python.x86_64 yum -y install httpd yum -y install php php-mbstring php-pear yum -y install phpMyAdmin php-mysql php-mcrypt ``` -------------------------------- ### Install SQLAlchemy Source: https://github.com/waditu/tushare/wiki/Tushare-on-Centos-7安装详解 Installs SQLAlchemy, a Python SQL toolkit and Object Relational Mapper, required for database interaction. ```bash pip install sqlalchemy ``` -------------------------------- ### Install pandas Source: https://github.com/waditu/tushare/wiki/Tushare-on-Centos-7安装详解 Installs the pandas library, a core dependency for Tushare, using pip. ```bash pip install pandas ``` -------------------------------- ### Install Tushare Dependencies Source: https://github.com/waditu/tushare/wiki/Tushare-on-Centos-7安装详解 Installs essential libraries for Tushare, including lxml, requests, and bs4, using pip. ```bash pip install lxml pip install requests pip install bs4 ``` -------------------------------- ### Get GEM Board Classification Data Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Fetches data for stocks listed on the GEM (Growth Enterprise Market) board, typically identified by codes starting with '300'. An optional 'file_path' can be used for custom stock files. ```python import tushare as ts ts.get_gem_classified() ``` -------------------------------- ### Get SME Board Classification Data Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Retrieves data for stocks listed on the SME (Small and Medium Enterprise) board, typically identified by codes starting with '002'. An optional 'file_path' can be used for custom stock files. ```python import tushare as ts ts.get_sme_classified() ``` -------------------------------- ### Get CSI 300 Component Stocks and Weights Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Retrieves the current component stocks and their respective weights for the CSI 300 index. ```python import tushare as ts ts.get_hs300s() ``` -------------------------------- ### Get SSE 50 Component Stocks Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Fetches the list of component stocks for the Shanghai Stock Exchange 50 index. ```python import tushare as ts ts.get_sz50s() ``` -------------------------------- ### Get Stock Basics Source: https://github.com/waditu/tushare/blob/master/docs/fundamental.rst Retrieves fundamental information for all listed stocks, including industry, area, PE ratio, outstanding shares, and more. Use this to get a general overview of companies. ```python import tushare as ts ts.get_stock_basics() ``` -------------------------------- ### Get Profitability Data Source: https://github.com/waditu/tushare/blob/master/docs/fundamental.rst Retrieves annual or quarterly profitability data, such as ROE, net profit ratio, gross profit margin, and net profits. Use this to assess a company's earning power. ```python # Get profitability data for the 3rd quarter of 2014 ts.get_profit_data(2014,3) ``` -------------------------------- ### Get Industry Classification Data Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Retrieves industry classification for stocks based on Sina Finance categories. This data is fetched online and may have a delay; consider storing it locally after retrieval. ```python import tushare as ts ts.get_industry_classified() ``` -------------------------------- ### Get Risk Alert Board Classification Data Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Retrieves data for stocks on the risk-alert board, commonly known as 'ST' stocks. An optional 'file_path' can be provided for custom stock files. ```python import tushare as ts ts.get_st_classified() ``` -------------------------------- ### Get Historical K-line Data by Type Source: https://github.com/waditu/tushare/blob/master/docs/trading.rst Retrieves historical K-line data for different time intervals (weekly, monthly, 5-minute, 15-minute, 30-minute, 60-minute). This allows for analysis at various granularities. The 'ktype' parameter specifies the desired data frequency. ```python ts.get_hist_data('600848', ktype='W') #获取周k线数据 ``` ```python ts.get_hist_data('600848', ktype='M') #获取月k线数据 ``` ```python ts.get_hist_data('600848', ktype='5') #获取5分钟k线数据 ``` ```python ts.get_hist_data('600848', ktype='15') #获取15分钟k线数据 ``` ```python ts.get_hist_data('600848', ktype='30') #获取30分钟k线数据 ``` ```python ts.get_hist_data('600848', ktype='60') #获取60分钟k线数据 ``` -------------------------------- ### Get Adjusted Historical Data (Forward or Backward) Source: https://github.com/waditu/tushare/blob/master/docs/trading.rst Retrieves historical stock data with adjustments for stock splits and dividends. Supports forward ('fq') and backward ('hfq') adjustments, or no adjustment ('None'). It can fetch data since listing or within a specified date range. For index data, set `index=True` and ignore `autype`. ```python ts.get_h_data('002337') #前复权 ``` ```python ts.get_h_data('002337', autype='hfq') #后复权 ``` ```python ts.get_h_data('002337', autype=None) #不复权 ``` ```python ts.get_h_data('002337', start='2015-01-01', end='2015-03-16') #两个日期之间的前复权数据 ``` ```python ts.get_h_data('399106', index=True) #深圳综合指数 ``` -------------------------------- ### Get Earnings Report Data Source: https://github.com/waditu/tushare/blob/master/docs/fundamental.rst Fetches annual or quarterly earnings report data for a specific year and quarter. This includes EPS, ROE, net profits, and distribution plans. Data retrieval may take time depending on your network speed. ```python # Get earnings report data for the 3rd quarter of 2014 ts.get_report_data(2014,3) ``` -------------------------------- ### Get Regional Classification Data Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Classifies stocks by their geographical region. An optional 'file_path' parameter can be provided to use a custom stock file. ```python import tushare as ts ts.get_area_classified() ``` -------------------------------- ### Get Concept Classification Data Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Fetches stock classification data based on market concepts. This is useful for analyzing 'concept-driven' trading and monitoring fund movements. Data is fetched online and may have a delay. ```python import tushare as ts ts.get_concept_classified() ``` -------------------------------- ### Get Historical K-line Data within a Date Range Source: https://github.com/waditu/tushare/blob/master/docs/trading.rst Fetches historical K-line data for a specified date range. This is useful for analyzing specific periods. The function returns detailed trading information including open, high, close, low prices, volume, price change, and moving averages. ```python ts.get_hist_data('600848',start='2015-01-05',end='2015-01-09') ``` -------------------------------- ### GEM Board Classification Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Retrieves data for stocks listed on the GEM board (Growth Enterprise Market), which typically includes stocks with codes starting with '300'. An optional file path can be provided. ```APIDOC ## get_gem_classified ### Description Retrieves data for stocks listed on the GEM board (Growth Enterprise Market), which typically includes stocks with codes starting with '300'. An optional file path can be provided. ### Method GET ### Endpoint /classification/gem ### Parameters #### Query Parameters - **file_path** (string) - Optional - Path to a custom stock file. Defaults to None, using TuShare's provided data. ### Request Example ```python import tushare as ts ts.get_gem_classified() ``` ### Response #### Success Response (200) - **code** (string) - Stock code - **name** (string) - Stock name #### Response Example ```json { "code": "300001", "name": "特锐德" } ``` ``` -------------------------------- ### Get Index K-line Data Source: https://github.com/waditu/tushare/blob/master/docs/trading.rst Fetches historical K-line data for major stock market indices. The 'code' parameter can be set to 'sh' for Shanghai Composite, 'sz' for Shenzhen Component, 'hs300' for CSI 300, 'sz50' for SSE 50, 'zxb' for SME Board, and 'cyb' for ChiNext. ```python ts.get_hist_data('sh') ``` ```python ts.get_hist_data('sz') ``` ```python ts.get_hist_data('hs300') ``` ```python ts.get_hist_data('sz50') ``` ```python ts.get_hist_data('zxb') ``` ```python ts.get_hist_data('cyb') ``` -------------------------------- ### Get Operational Data Source: https://github.com/waditu/tushare/blob/master/docs/fundamental.rst Fetches annual or quarterly operational efficiency data, including accounts receivable turnover, inventory turnover, and current asset turnover. This helps in evaluating how effectively a company utilizes its assets. ```python # Get operational data for the 3rd quarter of 2014 ts.get_operation_data(2014,3) ``` -------------------------------- ### SME Board Classification Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Retrieves data for stocks listed on the SME board (Small and Medium Enterprise board), which typically includes stocks with codes starting with '002'. An optional file path can be provided. ```APIDOC ## get_sme_classified ### Description Retrieves data for stocks listed on the SME board (Small and Medium Enterprise board), which typically includes stocks with codes starting with '002'. An optional file path can be provided. ### Method GET ### Endpoint /classification/sme ### Parameters #### Query Parameters - **file_path** (string) - Optional - Path to a custom stock file. Defaults to None, using TuShare's provided data. ### Request Example ```python import tushare as ts ts.get_sme_classified() ``` ### Response #### Success Response (200) - **code** (string) - Stock code - **name** (string) - Stock name #### Response Example ```json { "code": "002001", "name": "新 和 成" } ``` ``` -------------------------------- ### Get Historical Daily K-line Data Source: https://github.com/waditu/tushare/blob/master/docs/trading.rst Retrieves historical daily K-line data for a given stock code. This function can fetch up to the last three years of daily data. It includes moving average data (ma5, ma10, ma20) and volume moving averages (v_ma5, v_ma10, v_ma20). ```python import tushare as ts ts.get_hist_data('600848') #一次性获取全部日k线数据 ``` -------------------------------- ### HS300 Constituents and Weights Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Fetches the current constituents and their weights for the CSI 300 index (沪深300). ```APIDOC ## get_hs300s ### Description Fetches the current constituents and their weights for the CSI 300 index (沪深300). ### Method GET ### Endpoint /index/hs300 ### Parameters None ### Request Example ```python import tushare as ts ts.get_hs300s() ``` ### Response #### Success Response (200) - **code** (string) - Stock code - **name** (string) - Stock name - **date** (string) - Date of the data - **weight** (float) - Weight of the stock in the index #### Response Example ```json { "code": "000001", "name": "平安银行", "date": "2015-03-02", "weight": 0.93 } ``` ``` -------------------------------- ### get_h_data Source: https://github.com/waditu/tushare/blob/master/docs/trading.rst Retrieves historical adjusted (front, back, or no adjustment) K-line data for stocks and indices. Provides all historical data since listing for stocks. For indices, it provides all historical data. ```APIDOC ## GET /get_h_data ### Description Retrieves historical adjusted (front, back, or no adjustment) K-line data for stocks and indices. Provides all historical data since listing for stocks. For indices, it provides all historical data. ### Method GET ### Endpoint /get_h_data ### Parameters #### Query Parameters - **code** (string) - Required - Stock code (e.g., '002337') or index code (e.g., '399106'). - **start** (string) - Optional - Start date in 'YYYY-MM-DD' format. If not provided, defaults to approximately one year of data. - **end** (string) - Optional - End date in 'YYYY-MM-DD' format. - **autype** (string) - Optional - Adjustment type: 'qfq' (front adjustment, default), 'hfq' (back adjustment), None (no adjustment). - **index** (boolean) - Optional - Set to True if retrieving data for an index (default: False). - **retry_count** (integer) - Optional - Number of retries on network errors (default: 3). - **pause** (integer) - Optional - Seconds to pause between retries (default: 0). ### Response #### Success Response (200) - **date** (string) - Date - **open** (float) - Opening price - **high** (float) - Highest price - **close** (float) - Closing price - **low** (float) - Lowest price - **volume** (float) - Trading volume - **price_change** (float) - Price change - **p_change** (float) - Percentage change - **ma5** (float) - 5-day moving average - **ma10** (float) - 10-day moving average - **ma20** (float) - 20-day moving average - **v_ma5** (float) - 5-day volume moving average - **v_ma10** (float) - 10-day volume moving average - **v_ma20** (float) - 20-day volume moving average - **turnover** (float) - Turnover rate (not available for indices) ### Request Example ```python import tushare as ts ts.get_h_data('002337') # Front adjustment (default) ts.get_h_data('002337', autype='hfq') # Back adjustment ts.get_h_data('002337', autype=None) # No adjustment ts.get_h_data('002337', start='2015-01-01', end='2015-03-16') # Specific date range ts.get_h_data('399106', index=True) # Shenzhen Component Index ``` ``` -------------------------------- ### SSE 50 Constituents Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Retrieves the constituent stocks for the SSE 50 index (上证50). ```APIDOC ## get_sz50s ### Description Retrieves the constituent stocks for the SSE 50 index (上证50). ### Method GET ### Endpoint /index/sz50 ### Parameters None ### Request Example ```python import tushare as ts ts.get_sz50s() ``` ### Response #### Success Response (200) - **code** (string) - Stock code - **name** (string) - Stock name #### Response Example ```json { "code": "600000", "name": "浦发银行" } ``` ``` -------------------------------- ### Risk Warning Board Classification Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Retrieves data for stocks on the risk warning board, typically including 'ST' stocks. An optional file path can be provided. ```APIDOC ## get_st_classified ### Description Retrieves data for stocks on the risk warning board, typically including 'ST' stocks. An optional file path can be provided. ### Method GET ### Endpoint /classification/st ### Parameters #### Query Parameters - **file_path** (string) - Optional - Path to a custom stock file. Defaults to None, using TuShare's provided data. ### Request Example ```python import tushare as ts ts.get_st_classified() ``` ### Response #### Success Response (200) - **code** (string) - Stock code - **name** (string) - Stock name #### Response Example ```json { "code": "000033", "name": "*ST新都" } ``` ``` -------------------------------- ### Concept Classification Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Returns concept classification data for stocks. This is valuable for monitoring fund movements and identifying investment opportunities based on market concepts. ```APIDOC ## get_concept_classified ### Description Returns concept classification data for stocks. This is valuable for monitoring fund movements and identifying investment opportunities based on market concepts. ### Method GET ### Endpoint /classification/concept ### Parameters None ### Request Example ```python import tushare as ts ts.get_concept_classified() ``` ### Response #### Success Response (200) - **code** (string) - Stock code - **name** (string) - Stock name - **c_name** (string) - Concept name #### Response Example ```json { "code": "600007", "name": "中国国贸", "c_name": "外资背景" } ``` ``` -------------------------------- ### Industry Classification Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Retrieves industry classification for Shanghai and Shenzhen A-shares based on Sina Finance's categorization. This data is useful for analyzing stock performance and fund flows by industry. ```APIDOC ## get_industry_classified ### Description Retrieves industry classification for Shanghai and Shenzhen A-shares based on Sina Finance's categorization. This data is useful for analyzing stock performance and fund flows by industry. ### Method GET ### Endpoint /classification/industry ### Parameters None ### Request Example ```python import tushare as ts ts.get_industry_classified() ``` ### Response #### Success Response (200) - **code** (string) - Stock code - **name** (string) - Stock name - **c_name** (string) - Industry name #### Response Example ```json { "code": "600051", "name": "宁波联合", "c_name": "综合行业" } ``` ``` -------------------------------- ### get_hist_data Source: https://github.com/waditu/tushare/blob/master/docs/trading.rst Retrieves historical K-line data for a given stock code or index. Supports daily, weekly, monthly, and various minute intervals. Can specify date ranges and retry parameters. ```APIDOC ## GET /get_hist_data ### Description Retrieves historical K-line data for a given stock code or index. Supports daily, weekly, monthly, and various minute intervals. Can specify date ranges and retry parameters. ### Method GET ### Endpoint /get_hist_data ### Parameters #### Query Parameters - **code** (string) - Required - Stock code (e.g., '600848') or index code (e.g., 'sh', 'sz', 'hs300', 'sz50', 'zxb', 'cyb'). - **start** (string) - Optional - Start date in 'YYYY-MM-DD' format. - **end** (string) - Optional - End date in 'YYYY-MM-DD' format. - **ktype** (string) - Optional - Data type: 'D' (Day, default), 'W' (Week), 'M' (Month), '5' (5-minute), '15' (15-minute), '30' (30-minute), '60' (60-minute). - **retry_count** (integer) - Optional - Number of retries on network errors (default: 3). - **pause** (integer) - Optional - Seconds to pause between retries (default: 0). ### Response #### Success Response (200) - **date** (string) - Date - **open** (float) - Opening price - **high** (float) - Highest price - **close** (float) - Closing price - **low** (float) - Lowest price - **volume** (float) - Trading volume - **price_change** (float) - Price change - **p_change** (float) - Percentage change - **ma5** (float) - 5-day moving average - **ma10** (float) - 10-day moving average - **ma20** (float) - 20-day moving average - **v_ma5** (float) - 5-day volume moving average - **v_ma10** (float) - 10-day volume moving average - **v_ma20** (float) - 20-day volume moving average - **turnover** (float) - Turnover rate (not available for indices) ### Request Example ```python import tushare as ts ts.get_hist_data('600848') ts.get_hist_data('600848', start='2015-01-05', end='2015-01-09') ts.get_hist_data('sh', ktype='W') ``` ``` -------------------------------- ### Area Classification Source: https://github.com/waditu/tushare/blob/master/docs/classifying.rst Classifies stocks by region, indicating which province each stock belongs to. An optional file path can be provided to use a custom stock file. ```APIDOC ## get_area_classified ### Description Classifies stocks by region, indicating which province each stock belongs to. An optional file path can be provided to use a custom stock file. ### Method GET ### Endpoint /classification/area ### Parameters #### Query Parameters - **file_path** (string) - Optional - Path to a custom stock file. Defaults to None, using TuShare's provided data. ### Request Example ```python import tushare as ts ts.get_area_classified() ``` ### Response #### Success Response (200) - **code** (string) - Stock code - **name** (string) - Stock name - **area** (string) - Region name #### Response Example ```json { "code": "000668", "name": "荣丰控股", "area": "上海" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.