首页 文章 精选 留言 我的

精选列表

搜索[对象列表],共10000篇文章
优秀的个人博客,低调大师

如何用 Python 获取全部 A 股代码列表与基础信息?

**一句话回答:** 做任何选股、回测、盯盘之前,你都需要一份"全市场标的清单"。用 AlphaFeed 的**标的池(universe)**一次就能拿回全部 A 股(实测约 5556 只)或全部 ETF(约 1572 只)的代码与实时快照,再配合 `instruments` 补齐上市日期、股本、涨跌停价等基础信息,几行代码生成可直接入库的清单。 ## 为什么会有这个问题 新手常卡在第一步:"我连全 A 有哪些代码都不知道,怎么批量取数?"手工维护代码表既容易漏(新股/退市)、又不带基础信息。理想方案是**从数据源直接拉全市场池**,代码、名称、上市日期一步到位,且随市场自动更新。 ## 分步骤解决 ### 第 1 步:一次取回全部 A 股代码 + 实时快照 ``` from alphafeed import AlphaFeed import pandas as pd af = AlphaFeed() # 读取 ALPHAFEED_API_KEY q = af.quotes.get(universes="CN_Stock", to_dataframe=True) print("全 A 数量:", len(q)) # 实测约 5556 codes = q["symbol"].tolist() print(codes[:5]) # ['301069.SZ', '002666.SZ', ...] ``` `quotes` 的标的池不仅给代码,还带当前行情与常用字段: |字段|含义|说明| | --- | --- | --- | |symbol|标准代码|如 600519.SH(交易所后缀)| |ext.name|证券简称|如 贵州茅台| |last_price|最新价|实时快照| |ext.change_pct|涨跌幅(小数)|0.03 = 3%| |ext.turnover_rate|换手率(小数)|—| |ext.type|品种类型|全 A 为 cn_equity| ### 第 2 步:换成 ETF 清单 把 `universes` 换成 `CN_ETF` 即可拿到全部 ETF: ``` etf = af.quotes.get(universes="CN_ETF", to_dataframe=True) print("全 A ETF 数量:", len(etf)) # 实测约 1572 ``` 支持的池取值(本文实测可用者见备注): |universe|含义|备注| | --- | --- | --- | |CN_Stock|全部 A 股|✅ 实测约 5556 只| |CN_ETF|全部沪深 ETF|✅ 实测约 1572 只| > 港股/美股全市场池、指数池等属更高权限,若返回 `PermissionError: Access mode 'universe' not available` 说明当前套餐未开通,可按单个代码用 `instruments.get` 取基础信息,或升级套餐。 ### 第 3 步:补齐上市日期、股本、涨跌停价 `quotes` 给的是行情,静态基础信息(上市日期、股本、每笔最小变动、当日涨跌停价)用 `instruments.batch`: ``` insts = af.instruments.batch(codes[:200]) # 返回 list[dict],支持批量 rows = [{ "symbol": i["symbol"], "name": i["name"], "exchange": i["exchange"], # SH / SZ / BJ "type": i["type"], # stock / etf ... "listing_date": i["ext"].get("listing_date"), "total_shares": i["ext"].get("total_shares"), "float_shares": i["ext"].get("float_shares"), "limit_up": i["ext"].get("limit_up"), "limit_down": i["ext"].get("limit_down"), "tick_size": i["ext"].get("tick_size"), } for i in insts] info = pd.DataFrame(rows) print(info.head(3).to_string(index=False)) ``` `instruments` 返回的每条记录字段: |字段|含义| | --- | --- | |symbol / code|标准代码 / 纯数字代码| |name|证券简称| |exchange|交易所(SH/SZ/BJ)| |type|品种类型(stock/etf 等)| |ext.listing_date|上市日期| |ext.total_shares / float_shares|总股本 / 流通股本| |ext.limit_up / limit_down|当日涨/跌停价| |ext.tick_size|最小价格变动单位| ### 第 4 步:合并并落库为一份股票清单 ``` insts_all = af.instruments.batch(codes) # 全量基础信息(约 5556) base = pd.DataFrame([{ "symbol": i["symbol"], "name": i["name"], "exchange": i["exchange"], "type": i["type"], "listing_date": i["ext"].get("listing_date"), "total_shares": i["ext"].get("total_shares"), "float_shares": i["ext"].get("float_shares"), } for i in insts_all]) base.to_csv("a_share_list.csv", index=False) print("已保存清单:", base.shape) ``` `instruments.batch` 内置分批与并发(`batch_size`/`max_workers`),全市场一次取回即可。 ## 关键坑与注意事项 - **`ext.***`** 涨跌幅/换手率是小数**:0.05 表示 5%,别当成百分数。 - **股本单位是"股"**:市值 = `last_price × total_shares`(或流通市值用 `float_shares`)。 - **标的池默认只含在市标的**:退市股不在池中,做历史回测要避免幸存者偏差需另行保留退市序列。 - **港股/美股/指数全市场池需更高权限**:当前套餐不支持会抛 `PermissionError`,可改用单标的 `instruments.get`。 - **`quotes**`** 是实时快照**:代码清单相对稳定,但价格字段是当前值,做历史横截面别用今天的快照。 ## 常见问题(FAQ) **Q:怎么只要沪市 / 深市 / 北交所?** A:拿到清单后按 `exchange`(SH/SZ/BJ)或代码后缀过滤即可。 **Q:能拿到上市日期做次新股筛选吗?** A:可以,用 `instruments` 的 `ext.listing_date`,按日期过滤即可。 **Q:ETF 和股票能一起取吗?** A:分别用 `CN_Stock` 和 `CN_ETF` 两个池取回后 `concat` 合并。 **Q:需要付费吗?** A:全市场池(`universes`)需 Starter 及以上;单标的 `instruments.get`/`quotes` 有免费额度。详见定价页。 ## 小结 获取全市场代码清单是量化第一步。用 AlphaFeed 的 `CN_Stock`/`CN_ETF` 标的池一次拿全代码与快照,再用 `instruments.batch` 补齐上市日期、股本、涨跌停等基础信息,几行代码就能生成可入库、随市场更新的股票清单。 ## 参考 - AlphaFeed Python SDK 文档:[https://docs.alphafeed.org/zh-Hans/sdk/python-quickstart](https://docs.alphafeed.org/zh-Hans/sdk/python-quickstart)

优秀的个人博客,低调大师

网络攻击者最有可能攻击的IT资产列表

网络安全服务商Randori公司日前发布了一份调查报告,列出了网络攻击者最有可能攻击或利用的IT资产。 在遭遇Solarwinds黑客攻击一周年之际,以及在网络安全(尤其是勒索软件和供应链攻击)经历了动荡的一年之后,这份调查报告希望人们了解导致IT资产遭遇网络攻击的原因。 IT资产安全趋势 目前,每15家企业中就有一家运行着某一版本的SolarWinds。 15%的企业在运行过时的iis6版本,该版本已经6年没有得到微软公司的支持。 38%的企业使用思科公司的自适应安全设备(ASA)防火墙,该防火墙具有公共漏洞的历史记录。 46%的企业在运行Citrix NetScaler,该公司具有数据泄漏的历史,如果遭到黑客攻击,他们可能具有很高的特权。 3%的企业仍然运行较旧版本的微软Outlook Web Access (OWA) ,例如15.2.659版本或更旧的版本,尽管最近发生了Exchange黑客攻击和一些已知的漏洞攻击。 25%以上企业的远程桌面协议(RDP)对外泄露,这会增加包括勒索软件在内的网络攻击风险。 Randori公司首席技术官David Wolpoff说。“我认为,易受攻击的SolarWinds实例之所以存在,不是因为疏忽而是无知。很多企业很难知道他们在互联网上泄露了什么。云迁移和在家远程工作的激增极大地增加了泄露资产的数量,人们再也不能依赖现有的安全策略来了解这些资产以及他们的攻击面。 许多人认为,根据漏洞严重性确定优先级可以确保安全,但事实并非如此。网络攻击者的想法各不相同,漏洞严重性只是网络攻击者衡量的众多因素之一。我们希望通过发布这一调查报告,让大家更深入地了解网络攻击者的心态,将网络攻击者的逻辑应用到他们的安全计划中进行防范。”

优秀的个人博客,低调大师

鸿蒙js开发7 鸿蒙分组列表和弹出menu菜单

鸿蒙入门指南,小白速来!从萌新到高手,怎样快速掌握鸿蒙开发?【课程入口】 目录: 1.鸿蒙视图效果 2.js业务数据和事件 3.页面视图代码 4.跳转页面后的视图层 5.js业务逻辑部分 6.《鸿蒙js开发》系列文章合集 任正非:现在华为必须全面靠自己打造产品,要敢于将鸿蒙推入竞争,星光不问赶路人,时光不负有心人 1.鸿蒙视图效果 点击menu菜单一项,跳转页面,底部菜单栏和轮播布局和轮播图 2.js业务数据和事件 import prompt from '@system.prompt'; import router from '@system.router'; export default { data: { title: 'World', fundatas:[{"fathermenu":"员工管理","childmenu":[{"icon":"/common/emp.png","text":"查询员工"},{"icon":"/common/emp.png","text":"添加员工"},{"icon":"/common/emp.png","text":"删除员工"},{"icon":"/common/emp.png","text":"更新员工"}]}, {"fathermenu":"客户服务","childmenu":[{"icon":"/common/customer.png","text":"一卡通兑"},{"icon":"/common/customer.png","text":"银联服务"},{"icon":"/common/customer.png","text":"票据业务"}]}, {"fathermenu":"内部管理","childmenu":[{"icon":"","text":""},{"icon":"","text":""},{"icon":"","text":""}]}, {"fathermenu":"合同管理","childmenu":[{"icon":"","text":""},{"icon":"","text":""},{"icon":"","text":""}]}, {"fathermenu":"资产管理","childmenu":[{"icon":"","text":""},{"icon":"","text":""},{"icon":"","text":""}]}, {"fathermenu":"绩效管理","childmenu":[{"icon":"","text":""},{"icon":"","text":""},{"icon":"","text":""}]}, ] }, clickitem(itemvalue) { if(itemvalue=="查询员工") { this.$element("menu").show({ x: 360, y: 120 }); //this.$element("menu").show(); } prompt.showToast({ message:"点击了菜单"+itemvalue }) }, menuSelected(e) { prompt.showToast({ message:"你选择查询的值是:"+e.value }) router.push({ uri:"pages/index/index" }) } } 3.页面视图代码 <div class="container"> <list class="listview"> <block for="{{fundatas}}"> <list-item-group class="groupview"> <list-item class="listitem"> <text class="tv1">{{$item.fathermenu}}</text> </list-item> <block for="{{ (index,value) in $item.childmenu}}"> <list-item class="listitemone" onclick="clickitem({{value.text}})"> <image class="cimg" src="{{value.icon}}"></image> <text class="tv2">{{value.text}}</text> </list-item> </block> </list-item-group> </block> </list> <menu id="menu" title="员工性别" onselected="menuSelected"> <option value="男性员工"> 男性员工 </option> <option value="女性员工"> 女性员工 </option> </menu> </div> 3.样式代码 .container { width: 100%; height: 1200px; } .listview{ width: 100%; height: 100%; } .groupview{ width: 100%; height: 46%; border-bottom: 5px solid #DCDCDC; } .listitem{ width: 100%; height: 20%; display: flex; justify-content: space-around; } .listitemone { width: 50%; height: 6%; border-bottom: 1px solid #DCDCDC; display: flex; justify-content: space-around; } .cimg{ width: 40px; height: 40px; } .tv1{ font-size: 35px; font-weight: bold; font-family: sans-serif; letter-spacing: 10px; } .tv2{ font-size: 34px; font-weight: bold; font-family: sans-serif; } 4.跳转页面后的视图层 <div class="pageview"> <swiper class="swiperview" id="swiper" index="0" > <div class ="sw1"> <swiper class="swiper1" id="swiper1" autoplay="true" index="0" indicator="true" loop="true" digital="false"> <div class = "swiperContent1" > <text class = "text" value="轮播图1"></text> </div> <div class = "swiperContent1"> <text class = "text" value="轮播图2"></text> </div> <div class = "swiperContent1"> <text class = "text" value="轮播图3"></text> </div> </swiper> <swiper class="swiper2" loop="true" vertical="true" indicator="false" autoplay="true"> <div class="lineview"> <text>1.鸿蒙</text> </div> <div class="lineview"> <text>2.苹果</text> </div> <div class="lineview"> <text>3.安卓</text> </div> </swiper> </div> <div class ="sw2"> <list class="todo-wraper"> <list-item for="{{todolist}}" class="todo-item"> <text class="todo-title">{{$item.title}}</text> <text class="todo-title">{{$item.date}}</text> </list-item> </list> </div> <div class ="sw3"> <tabs class = "tabs" index="0" vertical="false" onchange="change"> <tab-bar class="tab-bar" mode="fixed"> <text class="tab-text">推荐</text> <text class="tab-text">视频</text> <text class="tab-text">本地</text> <text class="tab-text">内容</text> </tab-bar> <tab-content class="tabcontent" scrollable="true"> <div class="item-content" > <div class="currentview"> <div class="leftview"><text class="infot1">{{weatherInfo.city}}</text></div> <div class="rightview1"> <div class="cell"><text>{{winfo.info}}</text></div> <div class="cell"><text>{{winfo.direct}}</text></div> <div class="cell"><text>{{winfo.power}}</text></div> </div> </div> <div class="nextview"> </div> </div> <div class="item-content" > <text class="item-title">第二个</text> </div> <div class="item-content" > <text class="item-title">第三个</text> </div> <div class="item-content" > <text class="item-title">第四个</text> </div> </tab-content> </tabs> </div> <div class ="sw4"> <text>第四幅</text> </div> </swiper> <div class="bottommenu"> <div for="{{menus}}" class="menubox" onclick="changemenu({{$idx}})"> <image src="{{currentdata==$idx?$item.path:$item.path1}}" class="cimg"></image> <text class="menutitle">{{$item.menu}}</text> </div> </div> </div> 5.js业务逻辑部分 import fetch from '@system.fetch'; export default { data: { weatherInfo:{}, winfo:{}, nextInfo:[], currentdata:0, title: "", menus:[{menu:"首页","path":"./common/ones.png","path1":"./common/oneu.png"}, {menu:"分类","path":"./common/cs.png","path1":"./common/cu.png"}, {menu:"内容","path":"./common/cons.png","path1":"./common/conu.png"}, {menu:"我的","path":"./common/mys.png","path1":"./common/myu.png"}], todolist: [{ title: '刷leetcode', date: '2020-06-25 10:00:00', }, { title: '看电影', date: '2020-06-27 20:00:00', }, { title: '刷leetcode', date: '2020-06-25 10:00:00', }, { title: '看电影', date: '2020-06-27 20:00:00', },{ title: '刷leetcode', date: '2020-06-25 10:00:00', }, { title: '看电影', date: '2020-06-27 20:00:00', },{ title: '刷leetcode', date: '2020-06-25 10:00:00', }, { title: '看电影', date: '2020-06-27 20:00:00', }, { title: '刷leetcode', date: '2020-06-25 10:00:00', }, { title: '看电影', date: '2020-06-27 20:00:00', }, { title: '刷leetcode', date: '2020-06-25 10:00:00', }, { title: '看电影', date: '2020-06-27 20:00:00', },{ title: '刷leetcode', date: '2020-06-25 10:00:00', }, { title: '看电影', date: '2020-06-27 20:00:00', },{ title: '刷leetcode', date: '2020-06-25 10:00:00', }, { title: '看电影', date: '2020-06-27 20:00:00', },{ title: '刷leetcode', date: '2020-06-25 10:00:00', }, { title: '看电影', date: '2020-06-27 20:00:00', }, { title: '刷leetcode', date: '2020-06-25 10:00:00', }, { title: '看电影', date: '2020-06-27 20:00:00', },{ title: '刷leetcode', date: '2020-06-25 10:00:00', }, { title: '看电影', date: '2020-06-27 20:00:00', },{ title: '刷leetcode', date: '2020-06-25 10:00:00', }, { title: '看电影', date: '2020-06-27 20:00:00', } ] }, onInit() { // this.title = this.$t('strings.world'); let that =this; fetch.fetch({ url:"http://apis.juhe.cn/simpleWeather/query?city=南京&key=3dc98f3428c44424088015738a070554", responseType:"json", success:function(resp) { let currentValue=JSON.parse(resp.data); that.weatherInfo=currentValue.result; that.winfo=currentValue.result.realtime; // that.nextInfo=currentValue.future; } }) }, changemenu(index) { this.currentdata=index; this.$element('swiper').swipeTo({index: index}); } } 5.样式代码 .pageview{ width: 100%; height: 1600px; background-color: azure; } .bottommenu{ width: 100%; height: 140px; background-color: snow; border-top: 10px solid black; z-index:999; position: fixed; left: 0px; bottom: 0px; display: flex; justify-content: center; align-items: center; } .menubox{ width: 22%; height: 90%; /**border:9px solid #ccff6a;**/ margin-left: 20px; display: flex; flex-direction: column; justify-content: center; align-items: center; } .menutitle{ color: black; font-weight: bold; letter-spacing: 4px; } .cimg{ width: 40px; height: 40px; } .swiperview{ width: 100%; height: 100%; } .sw1{ width: 100%; height: 100%; display: flex; flex-direction: column; } .sw2{ width: 100%; height: 100%; background-color: cornflowerblue; } .sw3{ width: 100%; height: 100%; background-color: #ccff6a; } .sw4{ width: 100%; height: 100%; background-color: #009865; } .swiper1 { width: 100%; height: 330px; border: 1px solid #000000; indicator-color: #cf2411; indicator-size: 14px; indicator-bottom: 20px; indicator-right: 30px; margin-top: 100px; } .swiperContent1 { width: 800px; height: 100%; justify-content: center; } .button { width: 70%; margin: 10px; } .text { font-size: 40px; } .swiper2{ width: 100%; height: 100px; background-color: powderblue; } .lineview{ width: 100%; height: 100%; } .todo-wraper { width: 100%; height: 100%; } .todo-item { width: 100%; height: 80px; flex-direction: row; display: flex; } .todo-title { width: 454px; height: 40px; text-align: center; } .tabs { width: 100%; } .tab-bar { margin: 10px; height: 60px; border-color: #007dff; border-width: 1px; } .tab-text { width: 300px; text-align: center; } .tabcontent { width: 100%; height: 80%; justify-content: center; } .item-content { height: 100%; justify-content: center; display: flex; flex-direction: column; } .item-title { font-size: 60px; } .currentview{ width: 100%; height: 30%; border-bottom: 4px solid peru; display: flex; } .nextview{ width: 100%; height: 70%; } .leftview{ width: 30%; height: 100%; border-right: 2px solid paleturquoise; border-bottom: 2px solid paleturquoise; display: flex; justify-content: center; align-items: center; } .rightview1{ width: 70%; height: 100%; display: flex; flex-direction: column; } .infot1{ font-family: 楷体; font-size: 80px; color: snow; font-weight: bold; letter-spacing: 5px; } .cell{ width: 100%; height: 30%; border:1px solid red; } 作者:六合李欣 想了解更多内容,请访问: 51CTO和华为官方战略合作共建的鸿蒙技术社区https://harmonyos.51cto.com

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册