Pysnowball
雪球股票数据接口 python edition
Install / Use
/learn @uname-yang/PysnowballREADME
pysnowball
雪球APP Python API (需要自取token)
快速指引
安装
pip install pysnowball
示例
>>> import pysnowball as ball
>>> ball.set_token("xq_a_token=662745a236*****;u=909119****")
>>> ball.cash_flow('SH600000')
调用API前需要手动获取雪球网站的token,使用set_token设置token后才能访问雪球的API。s(xq_a_token & u)
传送门 === 如何获取雪球token
联系作者
欢迎加入Users微信群,方便讨论使用方面的问题,新需求,以及量化交易相关的内容。 共同进步!


APIs
实时行情
获取某支股票的行情数据
import pysnowball as ball
ball.quotec('SZ002027')
结果显示:
{
"data": [
{
"symbol": "SZ002027",
"current": 1.341,
"percent": -0.89,
"chg": -0.012,
"timestamp": 1541486940000,
"volume": 2695183,
"amount": 3605340,
"market_capital": 9835440347.54,
"float_market_capital": null,
"turnover_rate": null,
"amplitude": 1.4,
"open": 1.351,
"last_close": 1.353,
"high": 1.351,
"low": 1.332,
"avg_price": 1.338,
"trade_volume": 22100,
"side": 1,
"is_trade": true,
"level": 1,
"trade_session": null,
"trade_type": null,
"current_year_percent": -35.84
}
],
"error_code": 0,
"error_description": null
}
获取某支股票的行情数据-详细
import pysnowball as ball
ball.quote_detail("SH600104")
结果显示:
{
"data": {
"market": {
"status_id": 7,
"region": "CN",
"status": "已收盘",
"time_zone": "Asia/Shanghai",
"time_zone_desc": null,
"delay_tag": 0
},
"quote": {
"current_ext": null,
"symbol": "SH600104",
"volume_ext": null,
"high52w": 26.4319,
"delayed": 0,
"type": 11,
"tick_size": 0.01,
"float_shares": 11683461365,
"limit_down": 18.23,
"no_profit": null,
"high": 20.96,
"float_market_capital": 2.43717004074E11,
"timestamp_ext": null,
"lot_size": 100,
"lock_set": null,
"weighted_voting_rights": null,
"chg": 0.61,
"eps": 2.07,
"last_close": 20.25,
"profit_four": 2.413305412205E10,
"volume": 65949501,
"volume_ratio": 1.73,
"profit_forecast": 2.7133061018E10,
"turnover_rate": 0.56,
"low52w": 18.03,
"name": "上汽集团",
"exchange": "SH",
"pe_forecast": 8.982,
"total_shares": 11683461365,
"status": 1,
"is_vie_desc": null,
"security_status": null,
"code": "600104",
"goodwill_in_net_assets": 0.5219986746082667,
"avg_price": 20.698,
"percent": 3.01,
"weighted_voting_rights_desc": null,
"amplitude": 3.51,
"current": 20.86,
"is_vie": null,
"current_year_percent": -11.78,
"issue_date": 880387200000,
"sub_type": "ASH",
"low": 20.25,
"is_registration_desc": null,
"no_profit_desc": null,
"market_capital": 2.43717004074E11,
"dividend": 0.62,
"dividend_yield": 2.972,
"currency": "CNY",
"navps": 23.18,
"profit": 2.043103747976E10,
"timestamp": 1638860400000,
"pe_lyr": 11.929,
"amount": 1.365040096E9,
"pledge_ratio": null,
"traded_amount_ext": null,
"is_registration": null,
"pb": 0.9,
"limit_up": 22.28,
"pe_ttm": 10.099,
"time": 1638860400000,
"open": 20.33
},
"others": {
"pankou_ratio": -29.27,
"cyb_switch": true
},
"tags": [
{
"description": "沪股通",
"value": 1
},
{
"description": "融",
"value": 6
},
{
"description": "空",
"value": 7
}
]
},
"error_code": 0,
"error_description": ""
}
实时分笔
获取实时分笔数据,可以实时取得股票当前报价和成交信息
import pysnowball as ball
ball.pankou('SZ002027')
结果显示:
{
"symbol": "SZ002027",
"time": "Nov 6, 2018 2:59:15 PM",
"timestamp": 1541487555000,
"bp1": 6.56,
"bc1": 502,
"bp2": 0,
"bc2": 0,
"bp3": 0,
"bc3": 0,
"bp4": 0,
"bc4": 0,
"bp5": 0,
"bc5": 0,
"bp6": 0,
"bc6": 0,
"bp7": 0,
"bc7": 0,
"bp8": 0,
"bc8": 0,
"bp9": 0,
"bc9": 0,
"bp10": 0,
"bc10": 0,
"current": 6.55,
"sp1": 6.56,
"sc1": 502,
"sp2": 0,
"sc2": 2796,
"sp3": 0,
"sc3": 0,
"sp4": 0,
"sc4": 0,
"sp5": 0,
"sc5": 0,
"sp6": 0,
"sc6": 0,
"sp7": 0,
"sc7": 0,
"sp8": 0,
"sc8": 0,
"sp9": 0,
"sc9": 0,
"sp10": 0,
"sc10": 0,
"buypct": 13.21,
"sellpct": 86.79,
"diff": -2796,
"ratio": -73.58
}
K线
获取K线数据。
第二参数可指定period,默认day;第三参数可指定count,默认284。
原K线接口中 https://stock.xueqiu.com/v5/stock/chart/kline.json?symbol=SH600219&begin=1747625277024&period=day&type=before&count=-284&indicator=kline,pe,pb,ps,pcf,market_capital,agt,ggt,balance 的 period 会根据不同的类型返回不同周期的K线
日K:day
周K:week
月K:month
60分K:60m
30分K:30m
1分K:1m
import pysnowball as ball
ball.kline('SZ002027')
ball.kline('SZ002027','day', 30)
业绩预告
按年度获取业绩预告数据
import pysnowball as ball
ball.earningforecast('SZ002027')
结果显示:
{
"list": [
{
"eps": 4.78,
"roe": null,
"pb": null,
"pe": 8.4,
"forecast_year": "2018"
},
{
"eps": 5.49,
"roe": null,
"pb": null,
"pe": 7.32,
"forecast_year": "2019"
},
{
"eps": 6.12,
"roe": null,
"pb": null,
"pe": 6.56,
"forecast_year": "2020"
}
]
}
机构评级
获取机构评级数据
import pysnowball as ball
ball.report('SZ002027')
结果显示:
{
"list": [
{
"title": "2018年三季报点评:业绩确定性最强 新冷年预收款下降",
"rpt_comp": "申万宏源",
"rating_desc": "买入",
"target_price_min": null,
"target_price_max": null,
"pub_date": 1541088000000,
"status_id": 116200430,
"retweet_count": 0,
"reply_count": 4,
"like_count": 4,
"liked": false
},
{
"title": "2018年三季报点评:业绩表现优异 现金流增长亮眼(",
"rpt_comp": "海通证券",
"rating_desc": "增持",
"target_price_min": 50.3,
"target_price_max": 60.4,
"pub_date": 1541088000000,
"status_id": 116196608,
"retweet_count": 0,
"reply_count": 0,
"like_count": 0,
"liked": false
}...
]
}
资金流向趋势
获取当日资金流如流出数据,每分钟数据
import pysnowball as ball
ball.capital_flow('SZ002027')
结果显示:
{
"data": {
"symbol": "SZ002027",
"items": [
{
"timestamp": 1541467800000,
"amount": -12323447,
"type": null
},
{
"timestamp": 1541467860000,
"amount": -12940471,
"type": null
},
{
"timestamp": 1541467920000,
"amount": -18710425,
"type": null
},
...
]
}
资金流向历史
获取历史资金流如流出数据,每日数据
import pysnowball as ball
ball.capital_history('SZ002027')
结果显示:
{
"data": {
"sum3": -152759438,
"sum5": -332530425,
"sum10": -362575240.15999997,
"sum20": -162580140.64,
"items": [
{
"amount": 1232691,
"timestamp": 1539100800000
},
{
"amount": -65392886,
"timestamp": 1539187200000
},
...
{
"amount": -4122992,
"timestamp": 1541433600000
}
]
},
"error_code": 0,
"error_description": ""
}
资金成交分布
获取资金成交分布数据
import pysnowball as ball
ball.capital_assort('SZ002027')
结果显示:
{
"data": {
"sell_large": 21922533,
"sell_medium": 353650388,
"sell_small": 225596826,
"sell_total": 601169747,
"buy_large": 14298615,
"buy_medium": 317379444,
"buy_small": 265530036,
"buy_total": 597208095,
"timestamp": 1541433600000,
"created_at": null,
"updated_at": null
},
"error_code": 0,
"error_description": ""
}
大宗交易
大宗交易数据
import pysnowball as ball
ball.blocktrans('SZ002027')
结果显示:
{
"data": {
"items": [
{
"vol": 780200,
"sell_branch_org_name": "机构专用",
"premium_rat": 0,
"trans_amt": 30193700,
"td_date": 1541001600000,
"buy_branch_org_name": "机构专用",
"trans_price": 38.7
},
{
"vol": 774200,
"sell_branch_org_name": "机构专用",
"premium_rat": 0,
"trans_amt": 29961500,
"td_date": 1541001600000,
"buy_branc
Related Skills
gh-issues
351.8kFetch GitHub issues, spawn sub-agents to implement fixes and open PRs, then monitor and address PR review comments. Usage: /gh-issues [owner/repo] [--label bug] [--limit 5] [--milestone v1.0] [--assignee @me] [--fork user/repo] [--watch] [--interval 5] [--reviews-only] [--cron] [--dry-run] [--model glm-5] [--notify-channel -1002381931352]
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
oracle
351.8kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
taskflow-inbox-triage
351.8kname: taskflow-inbox-triage description: Example TaskFlow authoring pattern for inbox triage. Use when messages need different treatment based on intent, with some routes notifying immediately, some w
