From eb40eb423830a39856638e3c8500da90dbc6a3b4 Mon Sep 17 00:00:00 2001 From: guanjihuan Date: Sun, 28 Jan 2024 04:21:34 +0800 Subject: [PATCH] 0.1.81 --- PyPI/setup.cfg | 2 +- PyPI/src/guan.egg-info/PKG-INFO | 2 +- PyPI/src/guan/others.py | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index f5a0437..5c4e340 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.1.80 +version = 0.1.81 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/PyPI/src/guan.egg-info/PKG-INFO b/PyPI/src/guan.egg-info/PKG-INFO index 71e1af2..f0d697c 100644 --- a/PyPI/src/guan.egg-info/PKG-INFO +++ b/PyPI/src/guan.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: guan -Version: 0.1.80 +Version: 0.1.81 Summary: An open source python package Home-page: https://py.guanjihuan.com Author: guanjihuan diff --git a/PyPI/src/guan/others.py b/PyPI/src/guan/others.py index 8f21064..ba74ddd 100644 --- a/PyPI/src/guan/others.py +++ b/PyPI/src/guan/others.py @@ -330,6 +330,32 @@ def sorted_market_capitalization(num=10): sorted_array.append([i0+1, stock_symbol, stock_name, market_capitalization]) return sorted_array +# 美股市值排序 +@guan.statistics_decorator +def sorted_market_capitalization_us(num=10): + import akshare as ak + import numpy as np + stocks = ak.stock_us_spot_em() + stock_data = stocks.values + new_stock_data = [] + for stock in stock_data: + if np.isnan(float(stock[9])): + continue + else: + new_stock_data.append(stock) + new_stock_data = np.array(new_stock_data) + list_index = np.argsort(new_stock_data[:, 9]) + list_index = list_index[::-1] + if num == None: + num = len(list_index) + sorted_array = [] + for i0 in range(num): + stock_symbol = new_stock_data[list_index[i0], 15] + stock_name = new_stock_data[list_index[i0], 1] + market_capitalization = new_stock_data[list_index[i0], 9]/1e8 + sorted_array.append([i0+1, stock_symbol, stock_name, market_capitalization]) + return sorted_array + # 获取单个股票的历史数据 @guan.statistics_decorator def history_data_of_one_stock(symbol='000002', period='daily', start_date="19000101", end_date='21000101'):