python:baostock 企业季频盈利能力

该博客介绍了如何使用Python库baostock抓取并分析上海和深圳上市公司的季频盈利能力数据,通过'query_profit_data.py'脚本,获取净资产收益率、销售净利率等关键指标,保存为CSV文件。

query_profit_data.py

sh:上海,sz: 深圳 ,

# -*- coding: utf-8 -*-
import os, sys
import baostock as bs
import pandas as pd

if len(sys.argv) ==3:
    sz = sys.argv[1]
    code = sys.argv[2]
else:
    print('usage: python query_profit_data.py sh stockcode ')
    print('usage: python query_profit_data.py sz stockcode ')
    sys.exit(1)

if len(code) !=6:
    print('stock code length: 6')
    sys.exit(2)

# 登入系统
lg = bs.login()

# 显示登陆返回信息
print('login respond error_code:'+lg.error_code)
#print('login respond error_msg:'+lg.error_msg)

stockcode = sz+'.'+code
print(stockcode)
# 中文字段名
pro_fields =['证券代码','发布财报的日期','财报统计的季度日期','净资产收益率(平均)(%)','销售净利率(%)','销售毛利率(%)','净利润(元)','每股收益','主营营业收入(元)','总股本','流通股本']
# 季频盈利能力
profit_list = []
for q in range(1,5):
	rs_profit = bs.query_profit_data(code=stockcode, year=2021, quarter=q)
	while (rs_profit.error_code == '0') & rs_profit.next():
		profit_list.append(rs_profit.get_row_data())
# 今年4个季度
for q in 
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值