pysnowball
雪球APP Python API (需要自取token)
快速指引
安装
pip install pysnowball
示例
>>> import pysnowball as ball
>>> ball.set_token('xq_a_token=651af***************031c96a315c;')
'xq_a_token=651af***************031c96a315c;'
>>> ball.cash_flow('SH600000')
调用API前需要手动获取雪球网站的token,使用set_token设置token后才能访问雪球的API。
联系作者
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.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
}
业绩预告
按年度获取业绩预告数据
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": ""
}
<