From 5f325109147e209f8c90a965585c6b258563744c Mon Sep 17 00:00:00 2001 From: guanjihuan Date: Tue, 5 Sep 2023 15:10:13 +0800 Subject: [PATCH] 0.0.175 --- API_Reference/API_Reference.py | 12 +++++++ Source_Code/PyPI/setup.cfg | 2 +- Source_Code/PyPI/src/guan.egg-info/PKG-INFO | 2 +- Source_Code/PyPI/src/guan/__init__.py | 37 ++++++++++++++++++++- 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/API_Reference/API_Reference.py b/API_Reference/API_Reference.py index 27175ac..b1e91ef 100644 --- a/API_Reference/API_Reference.py +++ b/API_Reference/API_Reference.py @@ -523,6 +523,18 @@ guan.change_directory_by_replacement(current_key_word='code', new_key_word='data # Module 14: others +# 获取所有股票 +title, stock_data = guan.all_stocks() + +# 获取所有股票的代码 +stock_symbols = guan.all_stock_symbols() + +# 从股票代码获取股票名称 +stock_name = guan.find_stock_name_from_symbol(symbol='000002') + +# 获取单个股票的历史数据 +title, stock_data = guan.history_data_of_one_stock(symbol='000002', period='daily', start_date="19000101", end_date='21000101') + # 拼接两个PDF文件 guan.combine_two_pdf_files(input_file_1='a.pdf', input_file_2='b.pdf', output_file='combined_file.pdf') diff --git a/Source_Code/PyPI/setup.cfg b/Source_Code/PyPI/setup.cfg index b6ed955..d992cd3 100644 --- a/Source_Code/PyPI/setup.cfg +++ b/Source_Code/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.0.173 +version = 0.0.175 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/Source_Code/PyPI/src/guan.egg-info/PKG-INFO b/Source_Code/PyPI/src/guan.egg-info/PKG-INFO index b0e59ed..da34804 100644 --- a/Source_Code/PyPI/src/guan.egg-info/PKG-INFO +++ b/Source_Code/PyPI/src/guan.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: guan -Version: 0.0.173 +Version: 0.0.175 Summary: An open source python package Home-page: https://py.guanjihuan.com Author: guanjihuan diff --git a/Source_Code/PyPI/src/guan/__init__.py b/Source_Code/PyPI/src/guan/__init__.py index d85b778..2d29cc4 100644 --- a/Source_Code/PyPI/src/guan/__init__.py +++ b/Source_Code/PyPI/src/guan/__init__.py @@ -2,7 +2,7 @@ # With this package, you can calculate band structures, density of states, quantum transport and topological invariant of tight-binding models by invoking the functions you need. Other frequently used functions are also integrated in this package, such as file reading/writing, figure plotting, data processing. -# The current version is guan-0.0.173, updated on July 12, 2023. +# The current version is guan-0.0.175, updated on September 05, 2023. # Installation: pip install --upgrade guan @@ -3096,6 +3096,41 @@ def change_directory_by_replacement(current_key_word='code', new_key_word='data' # Module 14: others +## stocks + +# 获取所有股票 +def all_stocks(): + import akshare as ak + stocks = ak.stock_zh_a_spot_em() + title = np.array(stocks.columns) + stock_data = stocks.values + return title, stock_data + +# 获取所有股票的代码 +def all_stock_symbols(): + title, stock_data = guan.all_stocks() + stock_symbols = stock_data[:, 1] + return stock_symbols + +# 从股票代码获取股票名称 +def find_stock_name_from_symbol(symbol='000002'): + title, stock_data = guan.all_stocks() + for stock in stock_data: + if symbol in stock: + stock_name = stock[2] + return stock_name + +# 获取单个股票的历史数据 +def history_data_of_one_stock(symbol='000002', period='daily', start_date="19000101", end_date='21000101'): + # period = 'daily' + # period = 'weekly' + # period = 'monthly' + import akshare as ak + stock = ak.stock_zh_a_hist(symbol=symbol, period=period, start_date=start_date, end_date=end_date) + title = np.array(stock.columns) + stock_data = stock.values[::-1] + return title, stock_data + ## download # 通过Sci-Hub网站下载文献