This commit is contained in:
guanjihuan 2023-09-05 15:10:13 +08:00
parent 9182696bd6
commit 5f32510914
4 changed files with 50 additions and 3 deletions

View File

@ -523,6 +523,18 @@ guan.change_directory_by_replacement(current_key_word='code', new_key_word='data
# Module 14: others # 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文件 # 拼接两个PDF文件
guan.combine_two_pdf_files(input_file_1='a.pdf', input_file_2='b.pdf', output_file='combined_file.pdf') guan.combine_two_pdf_files(input_file_1='a.pdf', input_file_2='b.pdf', output_file='combined_file.pdf')

View File

@ -1,7 +1,7 @@
[metadata] [metadata]
# replace with your username: # replace with your username:
name = guan name = guan
version = 0.0.173 version = 0.0.175
author = guanjihuan author = guanjihuan
author_email = guanjihuan@163.com author_email = guanjihuan@163.com
description = An open source python package description = An open source python package

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: guan Name: guan
Version: 0.0.173 Version: 0.0.175
Summary: An open source python package Summary: An open source python package
Home-page: https://py.guanjihuan.com Home-page: https://py.guanjihuan.com
Author: guanjihuan Author: guanjihuan

View File

@ -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. # 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 # 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 # 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 ## download
# 通过Sci-Hub网站下载文献 # 通过Sci-Hub网站下载文献