This commit is contained in:
guanjihuan 2024-01-29 21:15:33 +08:00
parent eb40eb4238
commit 2602518fed
3 changed files with 13 additions and 6 deletions

View File

@ -1,7 +1,7 @@
[metadata] [metadata]
# replace with your username: # replace with your username:
name = guan name = guan
version = 0.1.81 version = 0.1.82
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.1.81 Version: 0.1.82
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

@ -318,15 +318,22 @@ def sorted_market_capitalization(num=10):
import numpy as np import numpy as np
import guan import guan
title, stock_data = guan.all_stocks() title, stock_data = guan.all_stocks()
list_index = np.argsort(stock_data[:, 17]) 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[:, 17])
list_index = list_index[::-1] list_index = list_index[::-1]
if num == None: if num == None:
num = len(list_index) num = len(list_index)
sorted_array = [] sorted_array = []
for i0 in range(num): for i0 in range(num):
stock_symbol = stock_data[list_index[i0], 1] stock_symbol = new_stock_data[list_index[i0], 1]
stock_name = stock_data[list_index[i0], 2] stock_name = new_stock_data[list_index[i0], 2]
market_capitalization = stock_data[list_index[i0], 17]/1e8 market_capitalization = new_stock_data[list_index[i0], 17]/1e8
sorted_array.append([i0+1, stock_symbol, stock_name, market_capitalization]) sorted_array.append([i0+1, stock_symbol, stock_name, market_capitalization])
return sorted_array return sorted_array