通过miniqmt的财报系统,获得了最新的各种财务数据,然后进行倒序排列,进行下单交易。系统开发成功。
# 设置Pandas显示选项
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
# 获取沪深A股板块的股票列表
sector_stocks = xtdata.get_stock_list_in_sector('沪深A股')
print(f'获取板块合约: {sector_stocks},总个数为:{len(sector_stocks)}')
def calculate_market_values(sector_stocks):
""" 计算并返回沪深A股成分股的市值信息 """
market_values = []
for stock_code in sector_stocks:
instrument_detail = xtdata.get_instrument_detail(stock_code, iscomplete=False)
#print(instrument_detail)
float_volume = instrument_detail.get('FloatVolume')
settlement_price = instrument_detail.get('SettlementPrice')
# 剔除 float_volume和settlement_price异常的标的
if float_volume and settlement_price:
# 将流通股本转换为万为单位,并转换为整数
float_volume_in_wan = int(float_volume / 10000)
# 计算市值,并转换为亿为单位,保留两位小数
market_value_in_yi = round((float_volume * settlement_price) / 100000000, 2)
market_values.append({
'InstrumentID': instrument_detail['InstrumentID'],
'InstrumentName': instrument_detail['InstrumentName'],
'FloatVolume': float_volume_in_wan,
'SettlementPrice': settlement_price,