Package: xueqiu
xueqiua humanize XueQiu API wrappers.Installation1.First, you need to install some basic components.git-scmpython3nodejs(needsnodecommand in the PATH variable)2.And then, installGoogle Chrome BrowserandChrome Driver.>copychromedriver.exe%LOCALAPPDATA%\Programs\Python\Python37-32\3.Finally, installxueqiuviapip.$pipinstallxueqiu# OR git+https://github.com/1dot75cm/xueqiu@master$pipinstallgit+https://github.com/1dot75cm/browsercookie@master
$python3-mxueqiu
xueqiux.y.z-AhumanizeXueQiuAPIwrappers.

:copyright:(c)2019by1dot75cm.
:license:MIT,seeLICENSEformoredetails.enjoy!!!Quick startExample:>>>news=xueqiu.news()# watch the news>>>news{'list':[<xueqiu.Post为何价值投资长期有效[https://xueqiu.com/8291461932/120351059]>,<xueqiu.Post韬蕴资本CEO温晓东怒斥贾跃亭：怎就一个[https://xueqiu.com/2095268812/120483699]>,<xueqiu.Post增持与回购20190122-201901[https://xueqiu.com/9206540776/120458648]>,<xueqiu.Post医药研发外包为什么这么红?(上)[https://xueqiu.com/1472391509/120481662]>,<xueqiu.Post医药大赛道之大分子生物药（下）[https://xueqiu.com/1472391509/120482094]>,<xueqiu.Post增强型指数基金，到底“强”在哪里？[https://xueqiu.com/8082119199/120480761]>,<xueqiu.Post价值投资不需要概率思维吗？—与董宝珍先生[https://xueqiu.com/3555476733/120245234]>,<xueqiu.Post邓晓峰的投资观[https://xueqiu.com/7649503965/120430145]>,<xueqiu.Post复利无敌：买入一只股票看这四点[https://xueqiu.com/1876906471/120479202]>,<xueqiu.Post再论安全边际[https://xueqiu.com/4465952737/120453192]>],'next_max_id':20323343}>>>p=news['list'][0]>>>"{}{}赞{}评论{}转发{}{}".format(p.title,p.user.name,p.like_count,p.reply_count,p.retweet_count,p.target)'为何价值投资长期有效 房杨凯的投资世界 赞9 评论11 转发9 https://xueqiu.com/8291461932/120351059'>>>p.user.get_posts()# get user's article>>>p.user.posts{'count':622,'page':1,'maxpage':63,'list':[<xueqiu.Post[https://xueqiu.com/8291461932/120497097]>,<xueqiu.Post[https://xueqiu.com/8291461932/120491351]>,<xueqiu.Post[https://xueqiu.com/8291461932/120487476]>,<xueqiu.Post[https://xueqiu.com/8291461932/120487448]>,<xueqiu.Post[https://xueqiu.com/8291461932/120486037]>,<xueqiu.Post腾讯游戏帝国的护城河还在吗？[https://xueqiu.com/8291461932/120485596]>,<xueqiu.Post[https://xueqiu.com/8291461932/120473933]>,<xueqiu.Post[https://xueqiu.com/8291461932/120434054]>,<xueqiu.Post[https://xueqiu.com/8291461932/120434037]>,<xueqiu.Post[https://xueqiu.com/8291461932/120434020]>]}>>>p.user.posts['list'][0].text# content'回复@A8天道酬勤: 这个问题应该放在买之前。//@A8天道酬勤:回复@房杨凯的投资世界:假如花旗银行做假账，聂夫还会不会持有？'>>>p.user.posts['list'][0].like()# like this (need login)APIUser classA user class that contains user-related methods.User object attributes:id- user id.profile- user's profile url.name- user name.city- city, for example '上海'.description- user description.friends_count- the number of user's friends.followers_count- the number of user's fans.posts_count- the number of user's post.stocks_count- the number of stocks.friends- use to saveUserobject for friends.followers- use the saveUserobject for fans.posts- use the savePostobject for post.articles- use the savePostobject for user's article.favorites- use the savePostobject for favorite articles.stocks- use the saveStockobject for favorite stocks.hot_stocks- use the saveStockobject for the current hot stocks.User object methods:get_friends(page: int = 1)- get your friends and save toself.friends.get_followers(page: int = 1)- get your fans and save toself.followers.get_posts(page: int = 1, count: int = 10)- get your posts and save toself.posts.get_articles(page: int = 1, count: int = 10)- get your articles and save toself.articles.get_favorites(page: int = 1, count: int = 20)- get your favorite posts and save toself.favorites.get_stocks(mkt: int = 1, count: int = 1000)- get your stocks and save toself.stocks.get_hot_stocks(mkt: int = 10, time_range: str = "hour", count: int = 10)- get hottest stocks.:parammkt: (optional) market type, default is10.value: 全球10沪深12港股13美股11:paramtime_range: (optional) hottest stocks by time range, default ishour.value:hour,day:paramcount: (optional) the number of results, default is10.send_verification_code(phone: int)- send verification code to your phone.Note: only 5 times a day.login(uid: str = '', passwd: str = '', login_type: str = 'phone')- user login by password or verification code. If the cookie cache exists, load it first and return. Otherwise, login and save the cookie to file (Linux~/.xueqiu/cookieor Windows).:paramuid: your username or phone number.:parampasswd: your password or verification code.:paramlogin_type: (optional) login type, default isphone.value:password,phoneload_cookie()- load cookies from local file or browser(chrome or firefox). You can login your account on the chrome browser, then executeload_cookie(), and now login successfully.Example:>>>u=User(2478797769)>>>u.name"红利基金">>>u.get_posts()>>>u.posts['list'][0].title'【你了解红利基金吗】红利基金（501029）热问快答！（12.31）'>>>u.get_favorites()>>>u.favorites['list'][0].title'2018年A股大数据盘点：30张图尽览市场热点'Post classA post class that contains post-related methods.Post object attributes:id- post id.user- post authors. aUserclass object.created_at- created time. aArrowclass object.target- post url.view_count- view count.reply_count- reply count.retweet_count- retweet count.fav_count- favorites count.like_count- like count.title- post title.text- post content.full_text- the full content of the article.comments- use the saveCommentobject for post.Post object methods:get_content()- get article content and save toself.full_text.get_comments(page: int = 1, count: int = 20, asc: str = 'false')- get article comments and save toself.comments.like()- like the article. (require login)unlike()- unlike the article. (require login)favorite()- favorite the article. (require login)unfavorite()- unfavorite the article. (require login)Example:>>>p=Post('2478797769/78869335')>>>p.user.name"红利基金">>>p.created_at.format("YYYY-MM-DD")"2016-12-13">>>p.title'【你了解红利基金吗】红利基金（501029）热问快答！（12.31）'>>>p.target"https://xueqiu.com/2478797769/78869335">>>p.get_content()>>>p.full_text'目录：\n一、\n华宝标普中国A股红利机会指数证券投资基金\n......'>>>p.get_comments()>>>p.comments['list'][-1].text'为什么成份股中有很多次新股？百思不得其解'Comment classA comment class that contains comment-related methods.Comment object attributes:id- comment id.user- comment authors. aUserclass object.post- comment on an article. aPostclass object.created_at- created time. aArrowclass object.like_count- like count.text- comment content.Comment object methods:like()- like the comment. (require login)unlike()- unlike the comment. (require login)Example:>>>p=Post('2478797769/78869335')>>>p.get_comments()>>>c=p.comments['list'][0]>>>c.user.name'红利基金'>>>c.text'回复@孙浩云: 怎么可能....2018年跌幅为24.54%，较主流指数跌幅较小。不知道您50%多是哪儿看来的呢'Selector classTheSelectorclass implements a stock filter.Selector object attributes:market- market string, default isSH.value:SH,HK,USqueries- include default parameters with selector.Selector object methods:url()- return a selector url string.help(range: str = "base", show: str = "text")- show selector parameters.:paramrange: (optional) parameters range, default isbase.
value:SH: industries, areas, base, ball, quota, finan_rate, stock_data,
profit_sheet, balance_sheet, cash_sheetHK: industries, base, ball, quotaUS: industries, base, ball, quota, grow,
profit_sheet, balance_sheet, cash_sheet:paramshow: (optional) output help or return generator, default istext.value:text,keysscope(exchange: str = '', indcode: str = '', areacode: str = '')- set stock selector scope.:paramexchange: (optional) set A-share exchange market, default isNone.value:SH,SZorNone:paramindcode: (optional) set industry code, default isNone. please seeself.help('industries'):paramareacode: (optional) set area code, default isNone. please seeself.help('areas')param(*args, **kwargs)- set stock selector paramters.:param*args: (optional) set parameters key, default value isALL.
for example, theself.param('pb', 'mc')will be setpb=ALL&mc=ALLparams.:param**kwargs: (optional) set parameters key and value.
for example, theself.param('pettm'=0_30)will be setpettm=0_30param.orderby(key: str = 'symbol')- stock selector results are sorted by field.:paramkey: the results are sorted by thekey, default issymbol.
the key parameters can be viewed throughself.help('base').order(ord: str = 'desc')- set stock selector results are sorted.:paramord: the ascending and descending order, default isdesc.value:asc,descpage(page: int = 1)- set stock selector results page number.count(size: int = 10)- the number of stock selector results.run()- sends a stock screener request and return[Stock class]list.Example:>>>s=Selector("SH")# scope 深市，房地产，浙江地区# param 筛选总市值，18年3季度ROE 0-30%# orderby 按市值排序# order 升序排列# page 第2页# count 每页2个>>>result=s.scope('SZ','K70','CN330000').param('mc',roediluted_20180930='0_30').orderby('mc').order('asc').page(2).count(2).run()>>>result['list'][<xueqiu.Stock荣安地产[SZ000517]>,<xueqiu.Stock滨江集团[SZ002244]>]Stock classA stock class that contains stock-related methods.Stock object attributes:basesymbol- stock symbol.code- stock code.name- stock name.current- current price.current_year_percent- current year return.percent- change rate.chg- change amount.open- price today.last_close- last close.high- highest.low- lowest.avg_price- average price.volume- trading volume.amount- amount.turnover_rate- turnover rate.amplitude- amplitude.market_capital- market capital.float_market_capital- float market capital.total_shares- total shares.float_shares- float shares.currency- currency unit.exchange- stock exchange.issue_date- launch date. aArrowclass object.extendlimit_up- stock limit up.limit_down- stock limit down.high52w- the highest of the fifty-two weeks.low52w- the lowest of the fifty-two weeks.volume_ratio- volume ratio.pe_lyr- pe lyr.pe_ttm- pe ttm.pe_forecast- pe forecast.pb- price/book value ratio.eps- earnings per share.bps- net asset value per share.dividend- stock dividend.dividend_yield- stock dividend yield.profit- net profit.profit_forecast- profit forecast.profit_four- profit last four quarters.otherstime- current time. aArrowclass object.posts- used to the savePostobject for stock.followers- used to the saveUserobject for stock's fans.prousers- used to the saveUserobject for stock's professional users.popstocks- pop stocks.industries- industry stocks.history- stock history.Stock object methods:refresh(dt: dict = {})- get current stock data and updateself.time.get_posts(page: int = 1, count: int = 20, sort: str = "time", source: str = "all")- get stock posts and save toself.posts.:parampage: (optional) page number, default is1.:paramcount: (optional) the number of results, default is20.:paramsort: (optional) order type, default istime.value:time最新,reply评论,relevance默认:paramsource: (optional) source of the results, default isall.value:all,user讨论,news新闻,notice公告,trans交易get_followers(page: int = 1, count: int = 15)- get stock fans and save toself.followers.:parampage: (optional) page number, default is1.:paramcount: (optional) the number of results, default is15.get_prousers(count: int = 5)- get stock professional users and save toself.prousers.get_popstocks(count: int = 8)- get pop stocks and save toself.popstocks.get_industry_stocks(count: int = 8)- get industry stocks and save toself.industries.get_histories(begin: str = '-1m', end: str = arrow.now(), period: str = 'day')- get stock history data and save toself.history.:parambegin: the start date of the results.value: -1w -2w -1m -3m -6m -1y -2y -3y -5y cyear issue or YYYY-MM-DD:paramend: (optional) the end date of the results, default isnow.:paramperiod: (optional) set date period, default isday.value: day week month quarter year 120m 60m 30m 15m 5m 1mincome(quarter: str = 'all', count: int = 12, lang: str = 'cn')- get stock income sheet.balance(quarter: str = 'all', count: int = 12, lang: str = 'cn')- get stock balance sheet.cash_flow(quarter: str = 'all', count: int = 12, lang: str = 'cn')- get stock cash flow sheet.Example:>>>s=Stock("SH601318")>>>s.symbol"SH601318">>>s.name"中国平安">>>s.market_capital1119664786363.0>>>s.issue_date.format("YYYY-MM-DD")"2007-02-28">>>s.refresh()# update stock data>>>s.get_posts(){'count':188745,'page':1,'maxpage':100,'list':[<xueqiu.Post[https://xueqiu.com/1566609429/120543602]>,<xueqiu.Post[https://xueqiu.com/1083048635/120542397]>,<xueqiu.Post[https://xueqiu.com/6376335219/120542355]>,<xueqiu.Post[https://xueqiu.com/8335420516/120542213]>,<xueqiu.Post[https://xueqiu.com/2706248223/120542082]>,<xueqiu.Post[https://xueqiu.com/4298761680/120542015]>,<xueqiu.Post[https://xueqiu.com/2856403580/120541995]>,<xueqiu.Post[https://xueqiu.com/6122867052/120541786]>,<xueqiu.Post[https://xueqiu.com/1083048635/120541288]>,<xueqiu.Post[https://xueqiu.com/9598902646/120541255]>]}>>>s.get_popstocks()>>>s.popstocks[<xueqiu.Stock招商银行[SH600036]>,<xueqiu.Stock兴业银行[SH601166]>,<xueqiu.Stock民生银行[SH600016]>,<xueqiu.Stock贵州茅台[SH600519]>,<xueqiu.Stock苏宁易购[SZ002024]>,<xueqiu.Stock万科A[SZ000002]>,<xueqiu.Stock腾讯控股[00700]>,<xueqiu.Stock中绿[02988]>]>>>s.get_industry_stocks()>>>s.industries{'industryname':'非银金融','list':[<xueqiu.Stock九鼎投资[SH600053]>,<xueqiu.Stock华林证券[SZ002945]>,<xueqiu.Stock爱建集团[SH600643]>,<xueqiu.Stock中航资本[SH600705]>,<xueqiu.Stock华铁科技[SH603300]>,<xueqiu.Stock民生控股[SZ000416]>,<xueqiu.Stock熊猫金控[SH600599]>,<xueqiu.Stock宏源证券[SZ000562]>]}>>>s.get_histories('2019-01-07','2019-01-11')>>>s.history.iloc[:,0:8]datevolumeopenhighlowclosechgpercentturnoverrate2019-01-077659300757.0957.1755.9056.30-0.29-0.510.702019-01-085599209256.0556.0955.2055.80-0.50-0.890.512019-01-098191461356.2057.6055.9656.951.152.060.752019-01-106732822356.8757.8256.5557.500.550.970.612019-01-114575697358.0058.2957.5058.070.570.990.42>>>s.history.iloc[:,8:17]datema5ma10ma20ma30pepbpspcfmarket_capital2019-01-0755.97056.88559.252060.714310.0731.9491.0519723.5360001.029178e+122019-01-0855.91056.63158.892060.48639.9841.9321.0426293.5045971.020037e+122019-01-0956.26456.50158.630560.278010.1901.9721.0641173.5768241.041060e+122019-01-1056.62856.43058.397060.091010.2881.9911.0743943.6113681.051114e+122019-01-1156.92456.50758.177559.901010.3902.0111.0850443.6471671.061534e+12>>>s.get_histories('-1w')>>>s.history.iloc[:,0:8]datevolumeopenhighlowclosechgpercentturnoverrate2019-01-244494061859.6160.5259.2260.430.941.580.412019-01-256724591160.5061.7860.4361.290.861.420.622019-01-285816488461.8062.4161.2061.520.230.380.532019-01-293951929461.3861.9060.9861.650.130.210.362019-01-303100032360.8861.8660.7861.25-0.40-0.650.27>>>s.get_histories('-1y')>>>s.history[['pe','pb','ps']].describe()pepbpscount243.000000243.000000243.000000mean11.8405882.2739961.217041std1.3574890.2152170.110052min9.7289001.9110001.03104425%10.8494502.1432001.15055450%11.5049002.2373001.19770075%12.6286002.3452001.251150max15.5967002.9354001.559700>>>s.income()[['净利润','营业总收入']]report_name净利润营业总收入2018Q38.948900e+107.504560e+112018Q26.477000e+105.348140e+112018Q12.895100e+103.104520e+112017Q49.997800e+108.908820e+11...>>>s.balance()[['资产合计','负债合计']]report_name资产合计负债合计2018Q36.910935e+126.260499e+122018Q26.851431e+126.216339e+122018Q16.725766e+126.108353e+122017Q46.493075e+125.905158e+12...>>>s.cash_flow()['经营活动现金流量净额']report_name经营活动现金流量净额2018Q31.775950e+112018Q21.616070e+112018Q11.398670e+112017Q41.212830e+11...Fund classA fund class that contains fund-related methods.Fund object attributes:fund_nav- fund net value.fund_nav_guess- estimate value.fund_nav_premium- fund nav premium rate.fund_history- fund history.fund_stocks- component stocks.fund_weight- stocks weight.Fund object methods:get_fund_stocks(year: str = "", mouth: str = "12")- get fund's stocks from天天基金.get_fund_nav()- get fund nav.get_fund_histories(page: int = 1, size: int = 90)- get history fund nav.calc_premium()- calculate fund premium.refresh_all()- refresh all of the fund stock objects.Example:>>>f=Fund('501301')>>>f.symbol"SH501301">>>f.fund_nav['2019-01-29',1.1311,1.1311,'-0.47%']>>>f.get_fund_stocks()>>>f.fund_stocksstocksweight0中国移动[00941]0.10821工商银行[01398]0.09752腾讯控股[00700]0.09703建设银行[00939]0.09324中国平安[02318]0.09225中国银行[03988]0.06426中国海洋石油[00883]0.05227中国石化[00386]0.03438中国人寿[02628]0.02979招商银行[03968]0.0267>>>list(f.fund_stocks.weight)[0.1082,0.0975,0.097,0.0932,0.0922,0.0642,0.0522,0.0343,0.0297,0.0267]>>>f.get_fund_histories('2019-01-07','2019-01-11')>>>f.fund_historydatenavcnavpercent2019-01-071.07431.07430.702019-01-081.06791.0679-0.602019-01-091.09491.09492.532019-01-101.09441.0944-0.052019-01-111.09641.09640.18>>>f.get_fund_histories('-1w')datenavcnavpercent2019-01-251.14131.14132.022019-01-281.13641.1364-0.432019-01-291.13111.1311-0.472019-01-301.13791.13790.602019-01-311.14751.14750.84get_all_funds functionExample:>>>df=get_all_funds()>>>df.groupby(by='type').count()typecodenameETF-场内171171QDII171171QDII-ETF1010QDII-指数8383保本型5252债券型16131613债券指数6969其他创新22分级杠杆132132固定收益132132定开债券657657混合-FOF4040混合型31673167理财型116116联接基金194194股票型373373股票指数462462货币型665665>>>df[df['code'].str.contains('^510')].head()codenametype7319510010交银上证180治理ETFETF-场内7320510020博时上证超大盘ETFETF-场内7321510030华宝上证180价值ETFETF-场内7322510050华夏上证50ETFETF-场内7323510060工银上证央企50ETFETF-场内>>>df[df['name'].str.contains('恒生')].head()codenametype54000071华夏恒生ETF联接AQDII-指数58000075华夏恒生ETF联接现汇QDII-指数59000076华夏恒生ETF联接现钞QDII-指数761000948华夏沪港通恒生ETF联接AQDII-指数919001149汇丰晋信恒生龙头指数C股票指数get_all_funds_ranking functionExample:>>>df=get_all_funds_ranking(fund_type='fof')# 开放式基金排行>>>df.head()[['code','name','issue_date','nav','current_year']]codenameissue_datenavcurrent_year0005220海富通聚优精选混合(FOF)2017-11-060.82770.0507811006306泰达宏利泰和平衡养老(FOF)2018-10-251.00990.0205132006042上投摩根尚睿混合(FOF)2018-08-150.99310.0116133005222泰达宏利全能混合(FOF)C2017-11-020.98030.0156444005221泰达宏利全能混合(FOF)A2017-11-020.98500.015883>>>df=get_all_funds_ranking(fund_type='ct')# 场内基金排行>>>df.tail()[['code','name','issue_date','nav','-1year','current_year']]codenameissue_datenav-1yearcurrent_year419150197国泰国证有色金属行业分级B2015-03-300.3411-0.715443-0.038349420150294南方中证高铁产业指数分级B2015-06-100.4018-0.543043-0.057697421150308富国中证体育产业指数分级B2015-06-250.8470-0.663614-0.055753422150264华宝中证1000指数分级B2015-06-040.3436-0.6616960.031840423512590浦银安盛中证高股息ETF2019-01-291.0032NaNNaNget_economic functionExample:>>>get_economic()# 获取经济指标{'中国人民银行利率':'1083','中国季度国内生产总值(GDP)年率':'461','中国规模以上工业增加值年率':'462','中国官方制造业采购经理人指数(PMI)':'594','中国财新制造业采购经理人指数(PMI)':'753','中国失业率':'1793','中国贸易帐 (美元)':'466','中国台湾利率决议':'1117',......>>>get_economic(search='美国')# 获取经济指标 - 美国{'美国失业率':'300','美国总统选举':'371','美国ADP就业人数':'1','美国ISM制造业PMI':'173','美国零售销售月率':'256','美国营建许可总数':'25','美国ISM非制造业PMI':'176','美国核心零售销售月率':'63',......>>>df=get_economic('中国财新制造业采购经理人指数(PMI)')# 获取财新PMI>>>df.tail()dateactualactual_stateforecastrevised2018-09-3050.0down50.5NaN2018-11-0150.1up49.9NaN2018-12-0350.2up50.1NaN2019-01-0249.7down50.3NaN2019-02-0148.3down49.5NaN>>>df.to_excel('output.xls')# 导出excelget_economic_of_china functionExample:>>>get_economic_of_china(search='总人口')[{'id':'A01050201','name':'民族自治地方总人口数'},{'id':'A030301','name':'年末总人口'},{'id':'A030501','name':'人口普查总人口'},{'id':'A030508','name':'人口普查0-14岁人口占总人口比重'},......>>>df=get_economic_of_china('A030101,A030102,A030103',time_period='1949-')>>>df.to_period('A').tail()年末总人口男性人口女性人口195358796.030468.028328.0195257482.029833.027649.0195156300.029231.027069.0195055196.028669.026527.0194954167.028145.026022.0>>>get_economic_of_china(category='month',search='居民消费价格指数')[{'id':'A01010101','name':'居民消费价格指数(上年同月=100)'},{'id':'A01010102','name':'食品烟酒类居民消费价格指数(上年同月=100)'},{'id':'A01010103','name':'衣着类居民消费价格指数(上年同月=100)'},{'id':'A01010104','name':'居住类居民消费价格指数(上年同月=100)'},......>>>get_economic_of_china("A01010101",category='month').to_period('M')居民消费价格指数(上年同月=100)2018-12101.8606982018-11102.1750412018-10102.5431512018-09102.472394......>>>get_economic_of_china(category='month_by_state',search='region')[{'id':'110000','name':'北京市'},{'id':'120000','name':'天津市'},{'id':'130000','name':'河北省'},{'id':'140000','name':'山西省'},......>>>get_economic_of_china("A03010101",region='210000,130000',category='month_by_state').to_period('M')辽宁省河北省2018-12333.6381.02018-11311.0398.32018-10274.3429.22018-09273.5456.2......get_data_invest functionExample:>>>get_data_invest(query='BABA')[['941155','阿里巴巴','BABA','纽约'],['940993','Baba Farid Sugar Mills Ltd','BABA','巴基斯坦卡拉奇'],['986306','阿里巴巴','BABAUSD','瑞士'],['987353','Baba Arts Ltd','BART','孟买BSE'],>>>get_data_invest('941155','-1y').head()datecloseopenhighlowvol2018-03-05181.60179.41181.95177.0715656661.02018-03-06187.37185.19188.01184.8217856088.02018-03-07189.05184.37189.07184.3213728910.02018-03-08187.18189.05190.23186.5714331400.02018-03-09190.55189.64190.70188.0114208356.0get_data_yahoo functionExample:>>>get_data_yahoo('BABA','-1y').head()DateHighLowOpenCloseVolumeAdjClose2018-02-22190.740005187.770004190.199997188.75000012282800188.7500002018-02-23193.404999189.949997190.179993193.28999316937300193.2899932018-02-26195.149994190.649994194.460007194.19000219463100194.1900022018-02-27193.567001187.210007192.589996188.25999523218500188.2599952018-02-28188.240005185.000000187.250000186.13999919367600186.139999get_quota_yahoo functionExample:>>>get_quote_yahoo('BABA')[['marketCap','price']]marketCappriceBABA458608476160176.92get_stock_margin functionExample:>>>get_stock_margin()[['收盘-沪深300','涨跌幅','融资余额','融资净买入额']]tdate收盘-沪深300涨跌幅融资余额融资净买入额2019-02-213442.7056-0.26714675177047759637512306462019-02-203451.92730.35816674801924695045336292892019-02-193439.6078-0.17810474348561766159982805112019-02-183445.74483.2060377374873371505113256902...>>>get_stock_margin(mkt_type='sh')[['收盘-沪深300','涨跌幅','融资余额','融资净买入额']]tdate收盘-沪深300涨跌幅融资余额融资净买入额2019-02-222804.22621.90511646195485962927200504702019-02-212751.8012-0.34107045923480915920499902782019-02-202761.21890.20223945718481888119920748912019-02-192755.64590.0468094551927439903286343033...>>>get_stock_margin(code='601318')[['收盘-沪深300','涨跌幅','融资余额','融资净买入额']]tdate收盘-沪深300涨跌幅融资余额融资净买入额2019-02-2267.022.492719272743520-1596418912019-02-2165.39-0.743819432385411-500541602019-02-2065.880.304519482439571123740392019-02-1965.680.597319470065532169750461get_hsgt_history functionExample:>>>shgt=get_hsgt_history(mkt_type='shgt',begin='-1m')# 沪股通(北) 近1月>>>shgt[['当日资金流入','当日余额','当日成交净买额','领涨股','指数','涨跌幅']]DetailDate当日资金流入当日余额当日成交净买额领涨股指数涨跌幅2019-02-223965.0048035.003589.82华安证券2804.230.0190532019-02-211718.5650281.441473.51豫光金铅2751.80-0.0034122019-02-203228.5748771.432933.49鼎立股份2761.220.0020212019-02-191418.1150581.891259.40宏图高科2755.650.000468...>>>hksh=get_hsgt_history(mkt_type='hksh',begin='-1m')# 港股通(沪) 近1月>>>hksh[['当日资金流入','当日余额','当日成交净买额','领涨股','指数','涨跌幅']]DetailDate当日资金流入当日余额当日成交净买额领涨股指数涨跌幅2019-02-2279841202186.64华虹半导体28816.300.0065102019-02-21-58142581-1122.04南京熊猫28629.920.0040642019-02-20-59942599-1166.03中国燃气28514.050.0101292019-02-19-74142741-1223.02嘉里物流28228.13-0.004194...get_hsgt_top10 functionExample:>>>get_hsgt_top10(mkt_type='shgt',date='2019-02-22')# 沪股通成交额top10RankCodeNameCloseChangePercentHGTJMEHGTMRJEHGTMCJEHGTCJJE1601318中国平安67.022.492735334611173867553138532942011240049512600030中信证券22.4310.0049-2072734533191159305263893838455053133600519贵州茅台726.010.79972541560434482395181940834756423229934600036招商银行30.631.828534614656840232337156176803458500174...get_hsgt_holding functionExample:>>>hold=get_hsgt_holding(mkt_type='north',date='2019-02-22')# 北向持股>>>hold[['代码','名称','持股市值','持股数量','持股占A股比例']]HDDATE代码名称持股市值持股数量持股占A股比例2019-02-22600519贵州茅台8.517306e+101173166449.182019-02-22601318中国平安5.141756e+107671973216.852019-02-22000333美的集团4.714754e+10103371052215.522019-02-22600276恒瑞医药3.194746e+1048186219512.95...>>>hold=get_hsgt_holding(code='601318',date='2019-02-22')# 个股持股，最多近1月数据>>>hold[['代码','名称','持股市值','持股数量','持股占A股比例']]HDDATE代码名称持股市值持股数量持股占A股比例2019-02-22601318中国平安5.141756e+107671973216.852019-02-21601318中国平安4.981185e+107617656286.802019-02-20601318中国平安4.991939e+107577320516.802019-02-19601318中国平安4.943077e+107526000926.72...BaiduIndex classExample:>>>BaiduIndex.cookie="cookie string"# OR load cookie from browsers>>>idx=BaiduIndex()>>>idx.search('股票,基金',begin='-3m',area='上海').tail()date股票基金2019-02-1817227782019-02-1921178372019-02-2018797822019-02-2119337602019-02-222097779>>>idx.search('股票,基金',begin='-2q',index='feed',area='广州').head()date股票基金2018-08-23221807168382018-08-24196099113392018-08-25185960163462018-08-26137134122062018-08-2718002828195>>>idx.region_distribution('股票','-6w')# 地域分布{'股票':{'city':{'514':1000,'57':962,'138':677,'94':663,....},'prov':{'913':1000,'917':693,'916':555,'911':498,....},'period':'2019-01-23|2019-02-22'}}>>>idx.social_attribute('股票','-15d')# 人群属性{'股票':{'age':{'1':'2','2':'11','3':'45','4':'32','5':'10'},'sex':{'F':'23','M':'77'}}}search functionsearch(query: str = "", query_type: str = "stock", symbol: str = "", count: int = 10, page: int = 1, sort: str = "time", source: str = "user")- Sends a search request.:paramquery: query string.:paramquery_type: (optional) type of the query request, default isstock.value: stock, post, user:paramsymbol: (optional) the stock symbol.:paramcount: (optional) the number of results, default is20.:parampage: (optional) page number, default is1.:paramsort: (optional) order type, default istime.value: time最新, reply评论, relevance默认:paramsource: (optional) source of the results, default isuser.value: all, user讨论, news新闻, notice公告, trans交易:return: a list of :class:Object <instance_id>objects. Object class: Stock, Post or User:rtype: list([ins1, ins2, ...])news functionnews(category: int = -1, count: int = 10, max_id: int = -1)- Get news.:paramcategory: (optional) type of the news, default is-1.value: 头条-1, 今日话题0, 直播6, 沪深105, 港股102, 美股101, 基金104, 私募113, 房产111, 汽车114, 保险110:paramcount: (optional) the number of results, default is10.:parammax_id: (optional) the max id of news, default is-1.:return: a list of :class:Post <instance_id>objects.:rtype: list([post1, post2, ...])utils moduleThis module contains some utils.get_cookies()- load cookies from local file, browser and selenium. return aLWPCookieJarclass object.get_session()- get the requests session.clean_html(tree: str)- clean html.check_symbol(code: str)- check stock symbol.exrate(date: str = "", code: str = "USD")- get the monetary exchange rate by date.code:{'USD':'美元','EUR':'欧元','JPY':'日元','HKD':'港元','GBP':'英镑','AUD':'澳大利亚元','NZD':'新西兰元','SGD':'新加坡元','CHF':'瑞士法郎','CAD':'加拿大元','MYR':'马来西亚林吉特','RUB':'俄罗斯卢布','ZAR':'南非兰特','KRW':'韩元','AED':'阿联酋迪拉姆','SAR':'沙特里亚尔','HUF':'匈牙利福林','PLN':'波兰兹罗提','DKK':'丹麦克朗','SEK':'瑞典克朗','NOK':'挪威克朗','TRY':'土耳其里拉','MXN':'墨西哥比索','THB':'泰铢'}exusd(date: str = "")- only forUSD.exhkd(date: str = "")- only forHKD.Example:>>>CJ=get_cookies()>>>sess=get_session()>>>clean_html("<span>hello.</span>")hello.>>>check_symbol(601318)"SH601318">>>exrate("2019-01-10","EUR")[7.8765,7.8443]>>>exusd(date="2019-01-10")[6.816,6.8526]>>>exhkd("2019-01-10")[0.86959,0.87419]