宽客秀

宽客秀

Quant.Show的Web3站点,Archives from quant.show

【Code Example】获取收益率最高的指数

This code implements the following functionality: Get the yield of several industry indexes (index_list) for the past 20 trading days, and select the index with the highest yield. It mainly uses the functionality of the argmax function in numpy. All code is compiled and tested based on JoinQuant.

import numpy as np

index_list = ['000912.XSHG', #Consumption
'000913.XSHG', #Medical
'000908.XSHG',
'000914.XSHG',
'000915.XSHG',
'000922.XSHG']
return_index = []

for index in index_list:
return_index_his = attribute_history(index, 20, unit='1d',
fields=['close'],skip_paused=True,
df=True, fq='pre')
return_index_his=return_index_his['close'].values
return_index.append(return_index_his[-1] / return_index_his[0] - 1)

sector = index_list[np.argmax(return_index)]

加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。