instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Turn comments into proper docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.utils.cons import headers def index_realtime_fund_sw(symbol: str = "基础一级") -> pd.DataFrame: url = "https://www.swsresearch.com/insWechatSw/fundIndex/pageList" payload = { "pageNo": 1, "pageSize": 50...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/4/11 17:40 +Desc: 申万宏源研究-申万指数-指数发布-基金指数-实时行情 +https://www.swsresearch.com/institute_sw/allIndex/releasedIndex +""" import pandas as pd import requests @@ -8,6 +13,14 @@ def index_realtime_fund_sw(symbol: str = "基础一级") -> pd....
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_research_fund_sw.py
Document my Python code with docstrings
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests def option_daily_stats_sse(date: str = "20240626") -> pd.DataFrame: url = "http://query.sse.com.cn/commonQuery.do" params = { "isPagination": "false", "sqlId": "COMMON_SSE_ZQPZ_YSP_QQ_SJTJ_MRTJ_CX", "tra...
--- +++ @@ -1,11 +1,26 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2024/6/27 22:20 +Desc: 上海证券交易所-产品-股票期权-每日统计 +https://www.sse.com.cn/assortment/options/date/ +深圳证券交易所-市场数据-期权数据-日度概况 +https://investor.szse.cn/market/option/day/index.html +""" import pandas as pd import requests def option_da...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_daily_stats_sse_szse.py
Add well-formatted docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import json import pandas as pd from curl_cffi import requests def stock_news_em(symbol: str = "603777") -> pd.DataFrame: url = "https://search-api-web.eastmoney.com/search/jsonp" inner_param = { "uid": "", "keyword": symbol, "type": ["cms...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/12/23 17:15 +Desc: 个股新闻数据 +https://so.eastmoney.com/news/s?keyword=603777 +""" import json @@ -8,6 +13,14 @@ def stock_news_em(symbol: str = "603777") -> pd.DataFrame: + """ + 东方财富-个股新闻-最近 100 条新闻 + https://so.east...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/news/news_stock.py
Add structured docstrings to improve clarity
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def index_kq_fashion(symbol: str = "时尚创意指数") -> pd.DataFrame: url = "http://api.idx365.com/index/project/34/data" symbol_map = { "柯桥时尚指数": "root", "时尚创意指数": "01", "时尚设计人才数": "0101", "新花型推出数": "010...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/6/13 22:05 +Desc: 柯桥时尚指数 +http://ss.kqindex.cn:9559/rinder_web_kqsszs/index/index_page.do +""" import pandas as pd import requests def index_kq_fashion(symbol: str = "时尚创意指数") -> pd.DataFrame: + """ + 柯桥时尚指数 + htt...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_kq_ss.py
Create documentation strings for testing functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import warnings from io import StringIO import pandas as pd import requests from akshare.option.cons import ( get_calendar, convert_date, CZCE_DAILY_OPTION_URL_3, SHFE_HEADERS, ) def option_hist_dce( symbol: str = "聚丙烯期权", trade_date:...
--- +++ @@ -1,5 +1,18 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/10/17 21:00 +Desc: 商品期权数据 +说明: +(1) 价格:自2019年12月02日起,纤维板报价单位由元/张改为元/立方米 +(2) 价格:元/吨,鸡蛋为元/500千克,纤维板为元/立方米,胶合板为元/张 +(3) 成交量、持仓量:手(按双边计算) +(4) 成交额:万元(按双边计算) +(5) 涨跌=收盘价-前结算价 +(6) 涨跌1=今结算价-前结算价 +(7) 合约系列:具有相同月份标的期货合约的所有期权合约的统称 +(8) 隐含波动...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_commodity.py
Add documentation for all methods
#!/usr/bin/env python # -*- coding:utf-8 -*- import math import pandas as pd import requests from akshare.utils.tqdm import get_tqdm def index_hist_sw(symbol: str = "801030", period: str = "day") -> pd.DataFrame: period_map = { "day": "DAY", "week": "WEEK", "month": "MONTH", } u...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/10/23 13:00 +Desc: 申万宏源研究-指数系列 +https://www.swsresearch.com/institute_sw/allIndex/releasedIndex +""" import math @@ -10,6 +15,16 @@ def index_hist_sw(symbol: str = "801030", period: str = "day") -> pd.DataFrame: + """ + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_research_sw.py
Write clean docstrings for readability
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests def stock_zh_index_hist_csindex( symbol: str = "000928", start_date: str = "20180526", end_date: str = "20240604", ) -> pd.DataFrame: url = "https://www.csindex.com.cn/csindex-home/perf/index-perf" params = { ...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2024/12/23 17:00 +Desc: 中证指数-所有指数-历史行情数据 +https://www.csindex.com.cn/zh-CN/indices/index-detail/H30374#/indices/family/list?index_series=1 +""" import pandas as pd import requests @@ -10,6 +15,19 @@ start_date: str = "20180526",...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_stock_zh_csindex.py
Add clean documentation to messy code
#!/usr/bin/env python # -*- coding:utf-8 -*- import warnings from io import StringIO import pandas as pd import requests def option_hist_yearly_czce(symbol: str = "SR", year: str = "2021") -> pd.DataFrame: symbol_year_dict = { "SR": "2017", "CF": "2019", "TA": "2019", "MA": "2019...
--- +++ @@ -1,5 +1,31 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/10/17 16:30 +Desc: 郑州商品交易所-交易数据-历史行情下载-期权历史行情下载 +http://www.czce.com.cn/cn/jysj/lshqxz/H770319index_1.htm +自 20200101 起,成交量、空盘量、成交额、行权量均为单边计算 +郑州商品交易所-期权上市时间表 +"SR": "20170419" +"CF": "20190410" +"TA": "20191216" +"MA": "20191217" +...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_czce.py
Add docstrings for better understanding
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def option_contract_info_ctp() -> pd.DataFrame: url = "http://dict.openctp.cn/instruments?types=option" r = requests.get(url) data_json = r.json() temp_df = pd.DataFrame(data_json["data"]) # 字段映射:英文字段名 -> 中文字段名 ...
--- +++ @@ -1,11 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/10/30 17:40 +Desc: openctp-合约信息接口 +http://openctp.cn/instruments.html +""" import pandas as pd import requests def option_contract_info_ctp() -> pd.DataFrame: + """ + openctp-合约信息接口-期权合约 + http://openctp.cn/instru...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_contract_info_ctp.py
Add docstrings that explain logic
#!/usr/bin/env python # -*- coding:utf-8 -*- import re import pandas as pd import requests import py_mini_racer from functools import lru_cache from akshare.stock.cons import hk_js_decode from akshare.utils.func import fetch_paginated_data def _replace_comma(x) -> str: if "," in str(x): return str(x)....
--- +++ @@ -1,5 +1,12 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/15 22:30 +Desc: 港股股票指数数据-新浪-东财 +所有指数-实时行情数据和历史行情数据 +https://finance.sina.com.cn/realstock/company/sz399552/nc.shtml +https://quote.eastmoney.com/gb/zsHSTECF2L.html +""" import re @@ -14,6 +21,13 @@ def _replace_comma(x) -...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_stock_hk.py
Generate missing documentation strings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from tqdm import tqdm def index_kq_fz(symbol: str = "价格指数") -> pd.DataFrame: symbol_map = { "价格指数": "1_1", "景气指数": "1_2", "外贸指数": "2", } url = "http://www.kqindex.cn/flzs/table_data" params = { ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/5/18 17:10 +Desc: 中国柯桥纺织指数 +http://www.kqindex.cn/flzs/jiage +""" import pandas as pd import requests @@ -7,6 +12,14 @@ def index_kq_fz(symbol: str = "价格指数") -> pd.DataFrame: + """ + 中国柯桥纺织指数 + http://www.kqindex.cn...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_kq_fz.py
Generate missing documentation strings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests import py_mini_racer from akshare.stock.cons import ( zh_js_decode, ) def index_us_stock_sina(symbol: str = ".INX") -> pd.DataFrame: url = f"https://finance.sina.com.cn/staticdata/us/{symbol}" r = requests.get(url) js_c...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/3/17 18:20 +Desc: 新浪财经-美股指数行情 +https://stock.finance.sina.com.cn/usstock/quotes/.IXIC.html +""" import pandas as pd import requests @@ -11,6 +16,14 @@ def index_us_stock_sina(symbol: str = ".INX") -> pd.DataFrame: + """ +...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_stock_us_sina.py
Add docstrings for utility scripts
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.index.cons import index_global_sina_symbol_map def index_global_name_table() -> pd.DataFrame: temp_df = pd.DataFrame.from_dict( index_global_sina_symbol_map, orient="index", columns=["代码"] ) temp_df.ind...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/7 17:00 +Desc: 新浪财经-行情中心-环球市场 +https://finance.sina.com.cn/stock/globalindex/quotes/UKX +""" import pandas as pd import requests @@ -8,6 +13,12 @@ def index_global_name_table() -> pd.DataFrame: + """ + 新浪财经-行情中心-环球市场...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_global_sina.py
Generate documentation strings for clarity
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from bs4 import BeautifulSoup from akshare.utils import demjson def option_commodity_contract_sina(symbol: str = "玉米期权") -> pd.DataFrame: url = "https://stock.finance.sina.com.cn/futures/view/optionsDP.php/pg_o/dce" r = request...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2022/1/23 10:21 +Desc: 新浪财经-商品期权 +https://stock.finance.sina.com.cn/futures/view/optionsDP.php +""" import pandas as pd import requests @@ -9,6 +14,14 @@ def option_commodity_contract_sina(symbol: str = "玉米期权") -> pd.DataFrame: +...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_commodity_sina.py
Add verbose docstrings with examples
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO import pandas as pd import requests from bs4 import BeautifulSoup from akshare.utils.cons import headers def sw_index_first_info() -> pd.DataFrame: url = "https://legulegu.com/stockdata/sw-industry-overview" r = requests.get(url, headers=...
--- +++ @@ -1,5 +1,11 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/1/24 15:00 +Desc: 申万宏源研究-申万指数-指数发布 +乐咕乐股网 +https://legulegu.com/stockdata/index-composition?industryCode=851921.SI +""" from io import StringIO @@ -11,6 +17,12 @@ def sw_index_first_info() -> pd.DataFrame: + """ + 乐咕乐...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_sw.py
Generate descriptive docstrings automatically
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def spot_goods(symbol: str = "波罗的海干散货指数") -> pd.DataFrame: url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/GoodsIndexService.get_goods_index" symbol_url_dict = { "波罗的海干散货指数": "BDI", "钢坯价格指数": "GP...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/12/26 18:30 +Desc: 商品现货价格指数 +https://finance.sina.com.cn/futuremarket/spotprice.shtml#titlePos_0 +""" import pandas as pd import requests def spot_goods(symbol: str = "波罗的海干散货指数") -> pd.DataFrame: + """ + 新浪财经-商品现货价格...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_spot.py
Write docstrings for this repository
#!/usr/bin/env python # -*- coding:utf-8 -*- from functools import lru_cache from io import StringIO import pandas as pd import requests from bs4 import BeautifulSoup @lru_cache() def option_comm_symbol() -> pd.DataFrame: import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/7/5 15:00 +Desc: 九期网-商品期权手续费 +https://www.9qihuo.com/qiquanshouxufei +""" from functools import lru_cache from io import StringIO @@ -31,6 +36,14 @@ def option_comm_info(symbol: str = "工业硅期权") -> pd.DataFrame: + """ + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_comm_qihuo.py
Document classes and their methods
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def index_hog_spot_price() -> pd.DataFrame: url = "https://hqb.nxin.com/pigindex/getPigIndexChart.shtml" params = {"regionId": "0"} r = requests.get(url, params=params) data_json = r.json() temp_df = pd.DataFrame(dat...
--- +++ @@ -1,11 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/3/21 11:16 +Desc: 行情宝 +https://hqb.nxin.com/pigindex/index.shtml +""" import pandas as pd import requests def index_hog_spot_price() -> pd.DataFrame: + """ + 行情宝-生猪市场价格指数 + https://hqb.nxin.com/pigindex/index.shtm...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_hog.py
Auto-generate documentation strings for this file
#!/usr/bin/env python # -*- coding:utf-8 -*- import re import pandas as pd import requests from bs4 import BeautifulSoup from tqdm import tqdm def news_cctv(date: str = "20240424") -> pd.DataFrame: if int(date) <= int("20130708"): url = f"https://cctv.cntv.cn/lm/xinwenlianbo/{date}.shtml" r = re...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/4/25 17:00 +Desc: 新闻联播文字稿 +https://tv.cctv.com/lm/xwlb +""" import re @@ -10,6 +15,14 @@ def news_cctv(date: str = "20240424") -> pd.DataFrame: + """ + 新闻联播文字稿 + https://tv.cctv.com/lm/xwlb + :param date: 需要获取数据...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/news/news_cctv.py
Write docstrings including parameters and return values
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd from akshare.request import make_request_with_retry_json def qdii_e_index_jsl(cookie: str = "") -> pd.DataFrame: url = "https://www.jisilu.cn/data/qdii/qdii_list/E" params = { "___jsl": "LST___t=1728207798534", "rp": "22", ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/10/6 17:00 +Desc: 集思录-T+0 QDII +集思录:https://www.jisilu.cn/data/qdii/#qdiie +""" import pandas as pd @@ -7,6 +12,12 @@ def qdii_e_index_jsl(cookie: str = "") -> pd.DataFrame: + """ + 集思录-T+0 QDII-欧美市场-欧美指数 + https:/...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/qdii/qdii_jsl.py
Fully document this Python code with docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import json import os import pandas as pd import requests import py_mini_racer def _get_js_path(name: str = "", module_file: str = "") -> str: module_folder = os.path.abspath(os.path.dirname(os.path.dirname(module_file))) module_json_path = os.pat...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/2/20 14:00 +Desc: 电影票房数据 +https://ys.endata.cn/BoxOffice/Movie +""" import datetime import json @@ -11,12 +16,28 @@ def _get_js_path(name: str = "", module_file: str = "") -> str: + """ + get JS file path + :param n...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/movie/movie_yien.py
Document this code for team use
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests def option_current_day_sse() -> pd.DataFrame: url = "http://query.sse.com.cn/commonQuery.do" params = { "isPagination": "false", "expireDate": "", "securityId": "", "sqlId": "SSE_ZQPZ_YSP_GGQQZSX...
--- +++ @@ -1,11 +1,22 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/9/8 16:20 +Desc: 上海证券交易所-产品-股票期权-信息披露-当日合约 +http://www.sse.com.cn/assortment/options/disclo/preinfo/ +""" import pandas as pd import requests def option_current_day_sse() -> pd.DataFrame: + """ + 上海证券交易所-产品-股票期权-信息披...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_current_sse.py
Add docstrings explaining edge cases
#!/usr/bin/env python # -*- coding:utf-8 -*- import json import os import pandas as pd import requests import py_mini_racer def _get_js_path(name: str = "", module_file: str = "") -> str: module_folder = os.path.abspath(os.path.dirname(os.path.dirname(module_file))) module_json_path = os.path.join(module_fo...
--- +++ @@ -1,5 +1,13 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2021/11/15 20:40 +Desc: 艺恩 +视频放映 +电视剧集 +综艺节目 +https://www.endata.com.cn/Video/index.html +""" import json import os @@ -10,12 +18,28 @@ def _get_js_path(name: str = "", module_file: str = "") -> str: + """ + get JS file pat...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/movie/video_yien.py
Add docstrings with type hints explained
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def nlp_ownthink(word: str = "人工智能", indicator: str = "entity") -> pd.DataFrame: url = "https://api.ownthink.com/kg/knowledge" payload = { "entity": word, } r = requests.post(url, data=payload) if not r.json(...
--- +++ @@ -1,11 +1,27 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/7/6 14:02 +Desc: ownthink-knowledge graph +https://ownthink.com/ +https://www.ownthink.com/docs/kg/ +""" import pandas as pd import requests def nlp_ownthink(word: str = "人工智能", indicator: str = "entity") -> pd.DataFrame: ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/nlp/nlp_interface.py
Write Python docstrings for this snippet
# -*- coding:utf-8 -*- # !/usr/bin/env python import math import re import pandas as pd from curl_cffi import requests def _get_baidu_cookie(headers: dict) -> str: try: # 使用Session保持Cookie上下文 with requests.Session() as session: session.headers.update(headers) # 第一步:获取基础C...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/12/1 22:00 +Desc: 百度股市通-经济数据 +https://gushitong.baidu.com/calendar +""" import math import re @@ -9,6 +14,13 @@ def _get_baidu_cookie(headers: dict) -> str: + """ + 安全获取百度股市通所需的Cookie + :param headers: 基础请求头 + :...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/news/news_baidu.py
Add docstrings for internal functions
# -*- coding:utf-8 -*- # !/usr/bin/env python import requests import pandas as pd def index_sugar_msweet() -> pd.DataFrame: url = "https://www.msweet.com.cn/eportal/ui" params = { "struts.portlet.action": "/portlet/price!getSTZSJson.action", "moduleId": "cb752447cfe24b44b18c7a7e9abab048", ...
--- +++ @@ -1,11 +1,22 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2023/6/19 17:00 +Desc: 沐甜科技数据中心-中国食糖指数 +https://www.msweet.com.cn/mtkj/sjzx13/index.html +""" import requests import pandas as pd def index_sugar_msweet() -> pd.DataFrame: + """ + 沐甜科技数据中心-中国食糖指数 + https://www.msweet....
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_sugar.py
Add professional docstrings to my codebase
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import BytesIO import pandas as pd import requests from akshare.option.cons import ( SH_OPTION_PAYLOAD, SH_OPTION_PAYLOAD_OTHER, SH_OPTION_URL_50, SH_OPTION_URL_KING_50, SH_OPTION_URL_300, SH_OPTION_URL_KING_300, SH_OPTION_URL_500, ...
--- +++ @@ -1,5 +1,13 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/2/24 15:18 +Desc: 金融期权数据 +http://www.sse.com.cn/assortment/options/price/ +http://www.szse.cn/market/product/option/index.html +http://www.cffex.com.cn/hs300gzqq/ +http://www.cffex.com.cn/zz1000gzqq/ +""" from io import BytesIO ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_finance.py
Write docstrings for backend logic
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def index_yw(symbol: str = "月景气指数") -> pd.DataFrame: import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) if symbol == "月景气指数": url = "https://apiserver.chinagoods.com/yiwuindex/v1/act...
--- +++ @@ -1,11 +1,29 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/5/3 +Desc: 义乌小商品指数 +目前可以通过这些接口直接请求到 JSON 数据 +周价格指数:https://apiserver.chinagoods.com/yiwuindex/v1/active/industry/class/history/piweek?gcCode= +月价格指数:https://apiserver.chinagoods.com/yiwuindex/v1/active/industry/class/history/month?...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_yw.py
Write docstrings including parameters and return values
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.utils.func import fetch_paginated_data def option_current_em() -> pd.DataFrame: url = "https://23.push2.eastmoney.com/api/qt/clist/get" params = { "pn": "1", "pz": "100", "po": "1", "...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/2/18 16:30 +Desc: 东方财富网-行情中心-期权市场 +https://quote.eastmoney.com/center/qqsc.html +""" import pandas as pd import requests @@ -7,6 +12,12 @@ def option_current_em() -> pd.DataFrame: + """ + 东方财富网-行情中心-期权市场 + https://q...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_em.py
Add well-formatted docstrings
#!/usr/bin/env python import datetime import json from functools import lru_cache from typing import Dict, List, Tuple import pandas as pd import requests from bs4 import BeautifulSoup from akshare.option.option_em import option_current_em from akshare.utils.func import set_df_columns # 期权-中金所-上证50指数 def option_cf...
--- +++ @@ -1,4 +1,15 @@ #!/usr/bin/env python +""" +Date: 2024/6/21 18:00 +Desc: 新浪财经-股票期权 +https://stock.finance.sina.com.cn/option/quotes.html +期权-中金所-沪深 300 指数 +https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php +期权-上交所-50ETF +期权-上交所-300ETF +期权-上交所-500ETF +https://stock.finance.sina.com.cn/option/quo...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_finance_sina.py
Create docstrings for all classes and functions
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests from bs4 import BeautifulSoup def spot_hog_soozhu() -> pd.DataFrame: session = requests.session() url = "https://www.soozhu.com/price/data/center/" r = session.get(url) soup = BeautifulSoup(r.text, features="lxml") ...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2024/8/10 15:30 +Desc: 搜猪-生猪大数据-各省均价实时排行榜 +https://www.soozhu.com/price/data/center/ +""" import pandas as pd import requests @@ -7,6 +12,12 @@ def spot_hog_soozhu() -> pd.DataFrame: + """ + 搜猪-生猪大数据-各省均价实时排行榜 + https:/...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/spot/spot_hog_soozhu.py
Add well-formatted docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- from functools import lru_cache from typing import Dict import pandas as pd import requests @lru_cache() def __reits_code_market_map() -> Dict: url = "https://95.push2.eastmoney.com/api/qt/clist/get" params = { "pn": "1", "pz": "100", "po"...
--- +++ @@ -1,5 +1,11 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/8/26 15:00 +Desc: REITs 行情及信息 +https://quote.eastmoney.com/center/gridlist.html#fund_reits_all +https://www.jisilu.cn/data/cnreits/#CnReits +""" from functools import lru_cache from typing import Dict @@ -10,6 +16,12 @@ @lru_c...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/reits/reits_basic.py
Add detailed docstrings explaining each function
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests def option_lhb_em( symbol: str = "510050", indicator: str = "期权交易情况-认沽交易量", trade_date: str = "20220121", ) -> pd.DataFrame: url = "https://datacenter-web.eastmoney.com/api/data/get" params = { "type": "RPT_...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2024/7/30 17:00 +Desc: 东方财富网-数据中心-特色数据-期权龙虎榜单 +https://data.eastmoney.com/other/qqlhb.html +""" import pandas as pd import requests @@ -10,6 +15,18 @@ indicator: str = "期权交易情况-认沽交易量", trade_date: str = "20220121", ) -> pd....
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_lhb_em.py
Create docstrings for all classes and functions
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd from akshare.utils.func import fetch_paginated_data def option_premium_analysis_em() -> pd.DataFrame: url = "https://push2.eastmoney.com/api/qt/clist/get" params = { "fid": "f250", "po": "1", "pz": "100", "pn":...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/3/11 17:00 +Desc: 东方财富网-数据中心-特色数据-期权折溢价 +https://data.eastmoney.com/other/premium.html +""" import pandas as pd @@ -7,6 +12,12 @@ def option_premium_analysis_em() -> pd.DataFrame: + """ + 东方财富网-数据中心-特色数据-期权折溢价 + h...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_premium_analysis_em.py
Write docstrings for utility functions
# -*- coding:utf-8 -*- # !/usr/bin/env python import json import pandas as pd import requests from bs4 import BeautifulSoup def __get_item_of_spot_price_qh() -> pd.DataFrame: url = "https://www.99qh.com/data/spotTrend" r = requests.get(url) soup = BeautifulSoup(r.text, features="lxml") data_text = s...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2024/5/16 20:00 +Desc: 99 期货-数据-期现-现货走势 +https://www.99qh.com/data/spotTrend +""" import json @@ -9,6 +14,12 @@ def __get_item_of_spot_price_qh() -> pd.DataFrame: + """ + 99 期货-数据-期现-品种和 ID 对应表 + https://www.99qh.com/d...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/spot/spot_price_qh.py
Include argument descriptions in docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import json import os import pandas as pd # type: ignore import requests import py_mini_racer # type: ignore def _get_js_path(name: str = "", module_file: str = "") -> str: module_folder = os.path.abspath(os.path.dirname(os.path.dirname(module_file)...
--- +++ @@ -1,5 +1,12 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2021/11/16 20:40 +Desc: 艺恩-艺人 +艺人商业价值 +艺人流量价值 +https://www.endata.com.cn/Marketing/Artist/business.html +""" import datetime import json @@ -11,12 +18,28 @@ def _get_js_path(name: str = "", module_file: str = "") -> str: + """...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/movie/artist_yien.py
Create structured documentation for my script
#!/usr/bin/env python # -*- coding:utf-8 -*- import requests import pandas as pd from io import StringIO from bs4 import BeautifulSoup from functools import lru_cache @lru_cache() def option_margin_symbol() -> pd.DataFrame: url = "https://www.iweiai.com/qiquan/yuanyou" r = requests.get(url) soup = Beaut...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/6/16 18:00 +Desc: 唯爱期货-期权保证金 +https://www.iweiai.com/qihuo/yuanyou +""" import requests import pandas as pd @@ -11,6 +16,11 @@ @lru_cache() def option_margin_symbol() -> pd.DataFrame: + """ + 获取商品期权品种代码和名称 + :return:...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_margin.py
Add docstrings to improve code quality
import time import requests from requests.exceptions import RequestException from akshare.exceptions import NetworkError, APIError, RateLimitError, DataParsingError from akshare.utils.context import config def make_request_with_retry_json( url, params=None, headers=None, proxies=None, max_retries=3, retry_delay...
--- +++ @@ -10,6 +10,17 @@ def make_request_with_retry_json( url, params=None, headers=None, proxies=None, max_retries=3, retry_delay=1 ): + """ + 发送 HTTP GET 请求,支持重试机制和代理设置。 + + :param url: 请求的 URL + :param params: URL 参数 (可选) + :param headers: 请求头 (可选) + :param proxies: 代理设置 (可选) + :param m...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/request.py
Fully document this Python code with docstrings
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import py_mini_racer import requests from akshare.datasets import get_ths_js def _get_file_content_ths(file: str = "cninfo.js") -> str: setting_file_path = get_ths_js(file) with open(setting_file_path, encoding="utf-8") as f: file_dat...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/11/20 22:00 +Desc: 巨潮资讯-个股-历史分红 +https://webapi.cninfo.com.cn/#/company?companyid=600009 +""" import pandas as pd import py_mini_racer @@ -9,6 +14,13 @@ def _get_file_content_ths(file: str = "cninfo.js") -> str: + """ + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_dividend_cninfo.py
Write docstrings including parameters and return values
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def stock_report_fund_hold( symbol: str = "基金持仓", date: str = "20210331" ) -> pd.DataFrame: symbol_map = { "基金持仓": "1", "QFII持仓": "2", "社保持仓": "3", "券商持仓": "4", "保险持仓": "5", "信托持仓"...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2021/12/19 13:09 +Desc: 东方财富网-数据中心-主力数据-基金持仓 +http://data.eastmoney.com/zlsj/2020-06-30-1-2.html +""" import pandas as pd import requests @@ -8,6 +13,16 @@ def stock_report_fund_hold( symbol: str = "基金持仓", date: str = "20210331"...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_fund_hold.py
Add inline docstrings for readability
#!/usr/bin/env python # -*- coding:utf-8 -*- import math import time from functools import lru_cache import pandas as pd import requests from akshare.utils.func import fetch_paginated_data from akshare.utils.tqdm import get_tqdm def stock_individual_fund_flow( stock: str = "600094", market: str = "sh" ) -> pd....
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/10 19:00 +Desc: 东方财富网-数据中心-资金流向 +https://data.eastmoney.com/zjlx/detail.html +""" import math import time @@ -15,6 +20,16 @@ def stock_individual_fund_flow( stock: str = "600094", market: str = "sh" ) -> pd.DataFrame: + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_fund_em.py
Insert docstrings into my code
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def stock_hk_famous_spot_em() -> pd.DataFrame: url = "https://69.push2.eastmoney.com/api/qt/clist/get" params = { "pn": "1", "pz": "50000", "po": "1", "np": "2", "ut": "bd1d9ddb04089700cf9...
--- +++ @@ -1,11 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/2/24 18:30 +Desc: 东方财富网-行情中心-港股市场-知名港股 +https://quote.eastmoney.com/center/gridlist.html#hk_wellknown +""" import pandas as pd import requests def stock_hk_famous_spot_em() -> pd.DataFrame: + """ + 东方财富网-行情中心-港股市场-知名...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_hk_famous.py
Write docstrings for this repository
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime from typing import AnyStr import pandas as pd import requests from akshare.futures.cons import ( QHKC_FUND_BS_URL, QHKC_FUND_POSITION_URL, QHKC_FUND_POSITION_CHANGE_URL, QHKC_FUND_DEAL_URL, ) def get_qhkc_fund_bs( date: datetime.datet...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/4/10 18:00 +Desc: 奇货可查网站目前已经商业化运营, 特提供奇货可查-资金数据接口, 方便您程序化调用 +注:期货价格为收盘价; 现货价格来自网络; 基差=现货价格-期货价格; 基差率=(现货价格-期货价格)/现货价格 * 100 %. +""" import datetime from typing import AnyStr @@ -18,6 +23,71 @@ def get_qhkc_fund_bs( date: da...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/qhkc_web/qhkc_fund.py
Add documentation for all methods
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def stock_dzjy_sctj() -> pd.DataFrame: url = "https://datacenter-web.eastmoney.com/api/data/v1/get" params = { "sortColumns": "TRADE_DATE", "sortTypes": "-1", "pageSize": "500", "pageNumber": "1",...
--- +++ @@ -1,11 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/1/13 22:30 +Desc: 东方财富网-数据中心-大宗交易-市场统计 +https://data.eastmoney.com/dzjy/ +""" import pandas as pd import requests def stock_dzjy_sctj() -> pd.DataFrame: + """ + 东方财富网-数据中心-大宗交易-市场统计 + https://data.eastmoney.com/dz...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_dzjy_em.py
Auto-generate documentation strings for this file
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import py_mini_racer import requests from akshare.datasets import get_ths_js def _get_file_content_cninfo(file: str = "cninfo.js") -> str: setting_file_path = get_ths_js(file) with open(setting_file_path, encoding="utf-8") as f: file_d...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/10/22 15:00 +Desc: 巨潮资讯-数据浏览器-筹资指标-公司配股实施方案 +https://webapi.cninfo.com.cn/#/dataBrowse +""" import pandas as pd import py_mini_racer @@ -9,6 +14,13 @@ def _get_file_content_cninfo(file: str = "cninfo.js") -> str: + """ + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_allotment_cninfo.py
Add docstrings for utility scripts
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def car_market_total_cpca( symbol: str = "狭义乘用车", indicator: str = "产量" ) -> pd.DataFrame: url = "http://data.cpcadata.com/api/chartlist" params = {"charttype": "1"} r = requests.get(url, params=params) data_json = r...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/8/3 20:00 +Desc: 乘联会 +http://data.cpcadata.com/FuelMarket +""" import pandas as pd import requests @@ -8,6 +13,16 @@ def car_market_total_cpca( symbol: str = "狭义乘用车", indicator: str = "产量" ) -> pd.DataFrame: + """ + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/other/other_car_cpca.py
Create simple docstrings for beginners
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests def option_risk_indicator_sse(date: str = "20240626") -> pd.DataFrame: url = "http://query.sse.com.cn/commonQuery.do" params = { "isPagination": "false", "trade_date": date, "sqlId": "SSE_ZQPZ_YSP_GGQQZS...
--- +++ @@ -1,11 +1,23 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/9/8 16:20 +Desc: 上海证券交易所-产品-股票期权-期权风险指标 +""" import pandas as pd import requests def option_risk_indicator_sse(date: str = "20240626") -> pd.DataFrame: + """ + 上海证券交易所-产品-股票期权-期权风险指标 + http://www.sse.com.cn/assor...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_risk_indicator_sse.py
Add docstrings to make code maintainable
#!/usr/bin/env python # -*- coding:utf-8 -*- from datetime import datetime import pandas as pd import requests def stock_hot_search_baidu( symbol: str = "A股", date: str = "20250616", time: str = "今日" ): hour_str = datetime.now().hour symbol_map = { "全市场": "all", "A股": "ab", "港股":...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/6/16 18:19 +Desc: 百度股市通-热搜股票 +https://gushitong.baidu.com/hotlist?mainTab=hotSearch&market=all +""" from datetime import datetime @@ -10,6 +15,18 @@ def stock_hot_search_baidu( symbol: str = "A股", date: str = "20250616", t...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_hot_search_baidu.py
Provide clean and structured docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd from py_mini_racer import MiniRacer import requests from akshare.stock.cons import ( hk_js_decode, hk_sina_stock_hist_url, hk_sina_stock_hist_hfq_url, hk_sina_stock_hist_qfq_url, ) from akshare.utils.tqdm import get_tqdm def stock_hk_s...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2026/3/15 23:00 +Desc: 新浪财经-港股-实时行情数据和历史行情数据(包含前复权和后复权因子) +https://stock.finance.sina.com.cn/hkstock/quotes/00700.html +""" import pandas as pd from py_mini_racer import MiniRacer @@ -15,6 +20,12 @@ def stock_hk_spot() -> pd.Data...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_hk_sina.py
Document helper functions with docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def stock_gsrl_gsdt_em(date: str = "20230808") -> pd.DataFrame: url = "https://datacenter-web.eastmoney.com/api/data/v1/get" params = { "sortColumns": "SECURITY_CODE", "sortTypes": "1", "pageSize": "5000"...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/8/8 21:30 +Desc: 东方财富网-数据中心-股市日历 +https://data.eastmoney.com/gsrl/gsdt.html +""" import pandas as pd import requests def stock_gsrl_gsdt_em(date: str = "20230808") -> pd.DataFrame: + """ + 东方财富网-数据中心-股市日历-公司动态 + h...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_gsrl_em.py
Create docstrings for reusable components
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import py_mini_racer import requests from akshare.datasets import get_ths_js def _get_file_content_ths(file: str = "cninfo.js") -> str: setting_file_path = get_ths_js(file) with open(setting_file_path, encoding="utf-8") as f: file_data...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/7/24 23:30 +Desc: 巨潮资讯-数据中心-专题统计-股东股本-股东人数及持股集中度 +https://webapi.cninfo.com.cn/#/thematicStatistics +""" import pandas as pd import py_mini_racer @@ -9,6 +14,13 @@ def _get_file_content_ths(file: str = "cninfo.js") -> str: +...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_hold_num_cninfo.py
Generate consistent docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def stock_hk_hot_rank_em() -> pd.DataFrame: url = "https://emappdata.eastmoney.com/stockrank/getAllCurrHkUsList" payload = { "appId": "appId01", "globalId": "786e4c21-70dc-435a-93bb-38", "marketType": "00...
--- +++ @@ -1,11 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/3/25 22:15 +Desc: 东方财富个股人气榜-港股市场 +https://guba.eastmoney.com/rank/ +""" import pandas as pd import requests def stock_hk_hot_rank_em() -> pd.DataFrame: + """ + 东方财富-个股人气榜-人气榜-港股市场 + https://guba.eastmoney.com/rank...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_hk_hot_rank_em.py
Document my Python code with docstrings
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd from akshare.utils.func import fetch_paginated_data def option_value_analysis_em() -> pd.DataFrame: url = "https://push2.eastmoney.com/api/qt/clist/get" params = { "fid": "f301", "po": "1", "pz": "100", "pn": "...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/3/11 17:00 +Desc: 东方财富网-数据中心-特色数据-期权价值分析 +https://data.eastmoney.com/other/valueAnal.html +""" import pandas as pd @@ -7,6 +12,12 @@ def option_value_analysis_em() -> pd.DataFrame: + """ + 东方财富网-数据中心-特色数据-期权价值分析 + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_value_analysis_em.py
Write docstrings for utility functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def stock_hot_rank_em() -> pd.DataFrame: url = "https://emappdata.eastmoney.com/stockrank/getAllCurrentList" payload = { "appId": "appId01", "globalId": "786e4c21-70dc-435a-93bb-38", "marketType": "", ...
--- +++ @@ -1,11 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/7/8 17:15 +Desc: 东方财富个股人气榜 +https://guba.eastmoney.com/rank/ +""" import pandas as pd import requests def stock_hot_rank_em() -> pd.DataFrame: + """ + 东方财富-个股人气榜-人气榜 + https://guba.eastmoney.com/rank/ + :return...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_hot_rank_em.py
Generate docstrings for this script
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import pandas as pd import py_mini_racer import requests from akshare.datasets import get_ths_js def _get_file_content_cninfo(file: str = "cninfo.js") -> str: setting_file_path = get_ths_js(file) with open(setting_file_path, encoding="utf-8") as ...
--- +++ @@ -1,5 +1,13 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/7/24 23:30 +Desc: 巨潮资讯-数据中心-专题统计-股东股本-实际控制人持股变动 +https://webapi.cninfo.com.cn/#/thematicStatistics + +巨潮资讯-数据中心-专题统计-股东股本-高管持股变动明细 +https://webapi.cninfo.com.cn/#/thematicStatistics +""" import datetime @@ -11,6 +19,13 @@ d...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_hold_control_cninfo.py
Document all endpoints with docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.utils import demjson def car_sale_rank_gasgoo(symbol: str = "车企榜", date: str = "202109") -> pd.DataFrame: symbol_map = { "车型榜": "M", "车企榜": "F", "品牌榜": "B", } url = "https://i.gasgoo.com...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/4/3 19:00 +Desc: 汽车行业制造企业数据库 +http://i.gasgoo.com/data/ranking +""" import pandas as pd import requests @@ -8,6 +13,16 @@ def car_sale_rank_gasgoo(symbol: str = "车企榜", date: str = "202109") -> pd.DataFrame: + """ + 盖世汽...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/other/other_car_gasgoo.py
Add detailed docstrings explaining each function
#!/usr/bin/env python # -*- coding:utf-8 -*- from akshare.pro import client from akshare.utils import token_process def pro_api(token=""): if token == "" or token is None: token = token_process.get_token() if token is not None and token != "": pro = client.DataApi(token) return pro ...
--- +++ @@ -1,11 +1,18 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2019/11/10 22:52 +Desc: 数据接口初始化 +""" from akshare.pro import client from akshare.utils import token_process def pro_api(token=""): + """ + 初始化 pro API,第一次可以通过ak.set_token('your token')来记录自己的token凭证,临时token可以通过本参数传入 + "...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/pro/data_pro.py
Write docstrings for this repository
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests import py_mini_racer from akshare.datasets import get_ths_js def _get_file_content_ths(file: str = "cninfo.js") -> str: setting_file_path = get_ths_js(file) with open(setting_file_path, encoding="utf-8") as f: file_data...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/5/19 18:34 +Desc: 巨潮资讯-数据中心-专题统计-公司治理-对外担保 +https://webapi.cninfo.com.cn/#/thematicStatistics +""" import pandas as pd import requests @@ -9,6 +14,13 @@ def _get_file_content_ths(file: str = "cninfo.js") -> str: + """ + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_cg_guarantee.py
Add concise docstrings to each method
#!/usr/bin/env python # -*- coding:utf-8 -*- from typing import AnyStr import pandas as pd import requests from akshare.futures.cons import ( QHKC_INDEX_URL, QHKC_INDEX_TREND_URL, QHKC_INDEX_PROFIT_LOSS_URL, ) def get_qhkc_index(name: AnyStr = "奇货商品", url: AnyStr = QHKC_INDEX_URL): name_id_dict = {...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/4/10 18:00 +Desc: 奇货可查网站目前已经商业化运营, 特提供奇货可查-指数数据接口, 方便您程序化调用 +注:期货价格为收盘价; 现货价格来自网络; 基差=现货价格-期货价格; 基差率=(现货价格-期货价格)/现货价格 * 100 %. +""" from typing import AnyStr @@ -14,6 +19,28 @@ def get_qhkc_index(name: AnyStr = "奇货商品", url:...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/qhkc_web/qhkc_index.py
Add documentation for all methods
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from tqdm import tqdm def stock_hold_management_detail_em() -> pd.DataFrame: url = "https://datacenter-web.eastmoney.com/api/data/v1/get" params = { "reportName": "RPT_EXECUTIVE_HOLD_DETAILS", "columns": "ALL", ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/5/19 18:30 +Desc: 东方财富网-数据中心-特色数据-高管持股 +https://data.eastmoney.com/executive/list.html +""" import pandas as pd import requests @@ -7,6 +12,12 @@ def stock_hold_management_detail_em() -> pd.DataFrame: + """ + 东方财富网-数据中...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_hold_control_em.py
Please document this code using docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO import pandas as pd import requests def stock_hk_fhpx_detail_ths(symbol: str = "0700") -> pd.DataFrame: url = f"https://basic.10jqka.com.cn/176/HK{symbol}/bonus.html" headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/1/16 15:30 +Desc: 同花顺-港股-分红派息 +https://stockpage.10jqka.com.cn/HK0700/bonus/ +""" from io import StringIO @@ -8,6 +13,14 @@ def stock_hk_fhpx_detail_ths(symbol: str = "0700") -> pd.DataFrame: + """ + 同花顺-港股-分红派息 + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_hk_fhpx_ths.py
Generate docstrings for each module
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd from akshare.utils.func import fetch_paginated_data def option_risk_analysis_em() -> pd.DataFrame: url = "https://push2.eastmoney.com/api/qt/clist/get" params = { "fid": "f12", "po": "1", "pz": "100", "pn": "1"...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/3/13 21:50 +Desc: 东方财富网-数据中心-特色数据-期权风险分析 +https://data.eastmoney.com/other/riskanal.html +""" import pandas as pd @@ -7,6 +12,12 @@ def option_risk_analysis_em() -> pd.DataFrame: + """ + 东方财富网-数据中心-特色数据-期权风险分析 + h...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_risk_analysis_em.py
Generate helpful docstrings for debugging
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def stock_hk_growth_comparison_em(symbol: str = "03900") -> pd.DataFrame: url = "https://datacenter.eastmoney.com/securities/api/data/v1/get" params = { "reportName": "RPT_PCF10_INDUSTRY_HKGROWTH", "columns": "SE...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/9/24 15:00 +Desc: 东方财富-港股-行业对比 +https://emweb.securities.eastmoney.com/PC_HKF10/pages/home/index.html?code=03900&type=web&color=w#/IndustryComparison +""" import pandas as pd import requests def stock_hk_growth_comparison_...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_hk_comparison_em.py
Add docstrings to improve readability
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def repo_rate_query(symbol: str = "回购定盘利率") -> pd.DataFrame: if symbol == "回购定盘利率": url = "https://www.chinamoney.com.cn/r/cms/www/chinamoney/data/currency/frr-chrt.csv" temp_df = pd.read_csv(url, header=None) ...
--- +++ @@ -1,11 +1,23 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/1/20 23:04 +Desc: 中国外汇交易中心暨全国银行间同业拆借中心-回购定盘利率-历史数据 +""" import pandas as pd import requests def repo_rate_query(symbol: str = "回购定盘利率") -> pd.DataFrame: + """ + 中国外汇交易中心暨全国银行间同业拆借中心-回购定盘利率-历史数据 + https://www.china...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/rate/repo_rate.py
Document classes and their methods
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests from akshare.utils.cons import headers def spot_symbol_table_sge() -> pd.DataFrame: temp_list = [ "Au99.99", "Au99.95", "Au100g", "Pt99.95", "Ag(T+D)", "Au(T+D)", "mAu(T+D)",...
--- +++ @@ -1,5 +1,12 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/4/11 22:00 +Desc: 上海黄金交易所-数据资讯-行情走势 +https://www.sge.com.cn/sjzx/mrhq +上海黄金交易所-数据资讯-上海金基准价-历史数据 +上海黄金交易所-数据资讯-上海银基准价-历史数据 +""" import pandas as pd import requests @@ -8,6 +15,12 @@ def spot_symbol_table_sge() -> pd.DataFram...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/spot/spot_sge.py
Add docstrings including usage examples
#!/usr/bin/env python # -*- coding:utf-8 -*- from typing import AnyStr import pandas as pd import requests from akshare.futures.cons import QHKC_TOOL_FOREIGN_URL, QHKC_TOOL_GDP_URL def qhkc_tool_foreign(url: AnyStr = QHKC_TOOL_FOREIGN_URL): payload_id = {"page": 1, "limit": 10} r = requests.post(url, data=...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2019/9/30 13:58 +Desc: 奇货可查网站目前已经商业化运营, 特提供奇货可查-工具数据接口, 方便您程序化调用 +注:期货价格为收盘价; 现货价格来自网络; 基差=现货价格-期货价格; 基差率=(现货价格-期货价格)/现货价格 * 100 %. +""" from typing import AnyStr @@ -10,6 +15,33 @@ def qhkc_tool_foreign(url: AnyStr = QHKC_TOOL_...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/qhkc_web/qhkc_tool.py
Generate helpful docstrings for debugging
#!/usr/bin/env python # -*- coding:utf-8 -*- import time import pandas as pd import requests import py_mini_racer js_str = """ function mcode(input) { var keyStr = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuv" + "wxyz0123456789+/" + "="; var output = ""; ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2021/9/29 16:19 +Desc: 巨潮资讯-数据中心-专题统计-公司治理-公司诉讼 +http://webapi.cninfo.com.cn/#/thematicStatistics +""" import time @@ -41,6 +46,18 @@ def stock_cg_lawsuit_cninfo( symbol: str = "全部", start_date: str = "20180630", end_date: str ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_cg_lawsuit.py
Include argument descriptions in docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- from functools import partial from urllib import parse import pandas as pd import requests class DataApi: __token = "" __http_url = "https://api.qhkch.com" def __init__(self, token, timeout=10): self.__token = token self.__timeout = timeout ...
--- +++ @@ -1,5 +1,9 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2019/11/10 22:52 +Desc: 数据接口源代码 +""" from functools import partial from urllib import parse @@ -13,10 +17,27 @@ __http_url = "https://api.qhkch.com" def __init__(self, token, timeout=10): + """ + 初始化函数 + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/pro/client.py
Generate docstrings for this script
#!/usr/bin/env python # -*- coding:utf-8 -*- import json import math import pandas as pd import requests from akshare.utils import demjson from tqdm import tqdm def stock_sector_spot(indicator: str = "新浪行业") -> pd.DataFrame: if indicator == "新浪行业": url = "http://vip.stock.finance.sina.com.cn/q/view/new...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/5/9 17:06 +Desc: 新浪行业-板块行情 +http://finance.sina.com.cn/stock/sl/ +""" import json import math @@ -12,6 +17,14 @@ def stock_sector_spot(indicator: str = "新浪行业") -> pd.DataFrame: + """ + 新浪行业-板块行情 + http://finance.sin...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_industry.py
Generate docstrings with examples
# -*- coding:utf-8 -*- # !/usr/bin/env python import math import pandas as pd import requests from akshare.utils.func import fetch_paginated_data def stock_zh_a_st_em() -> pd.DataFrame: url = "https://40.push2.eastmoney.com/api/qt/clist/get" params = { "pn": "1", "pz": "100", "po": ...
--- +++ @@ -1,5 +1,13 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/3/19 15:30 +Desc: 新股和风险警示股 +新浪-行情中心-沪深股市-次新股 +https://vip.stock.finance.sina.com.cn/mkt/#new_stock +东方财富网-行情中心-沪深个股-风险警示板 +https://quote.eastmoney.com/center/gridlist.html#st_board +""" import math @@ -10,6 +18,12 @@ def s...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_zh_a_special.py
Write docstrings for algorithm functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def stock_us_famous_spot_em(symbol: str = "科技类") -> pd.DataFrame: market_map = { "科技类": "0216", "金融类": "0217", "医药食品类": "0218", "媒体类": "0220", "汽车能源类": "0219", "制造零售类": "0221", } ...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/2/24 18:30 +Desc: 东方财富网-行情中心-美股市场-知名美股 +https://quote.eastmoney.com/center/gridlist.html#us_wellknown +""" import pandas as pd import requests def stock_us_famous_spot_em(symbol: str = "科技类") -> pd.DataFrame: + """ + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_us_famous.py
Generate consistent docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import json import pandas as pd import requests def __event_stream(url, params): # 使用 stream=True 参数来启用流式请求 response = requests.get(url, params=params, stream=True) event_data = "" for line in response.iter_lines(): # 过滤掉保持连接的空行 if line: ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/10 18:00 +Desc: 东财财富-日内分时数据 +https://quote.eastmoney.com/f1.html?newcode=0.000001 +""" import json @@ -22,6 +27,14 @@ def stock_intraday_em(symbol: str = "000001") -> pd.DataFrame: + """ + 东方财富-分时数据 + https://quo...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_intraday_em.py
Create documentation strings for testing functions
# -*- coding:utf-8 -*- # !/usr/bin/env python import numpy as np import pandas as pd import requests import py_mini_racer from akshare.datasets import get_ths_js def _get_file_content_ths(file: str = "cninfo.js") -> str: setting_file_path = get_ths_js(file) with open(setting_file_path, encoding="utf-8") as ...
--- +++ @@ -1,5 +1,11 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2024/5/19 18:34 +Desc: 巨潮资讯-行业分类数据 +https://webapi.cninfo.com.cn/#/apiDoc +https://webapi.cninfo.com.cn/api/stock/p_stock2110 +""" import numpy as np import pandas as pd @@ -10,6 +16,13 @@ def _get_file_content_ths(file: str = "...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_industry_cninfo.py
Add docstrings with type hints explained
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import py_mini_racer import requests from akshare.datasets import get_ths_js def _get_file_content_ths(file: str = "cninfo.js") -> str: setting_file_path = get_ths_js(file) with open(setting_file_path, encoding="utf-8") as f: file_data...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/7/24 23:30 +Desc: 巨潮资讯-数据中心-专题统计-公司治理-股权质押 +https://webapi.cninfo.com.cn/#/thematicStatistics +""" import pandas as pd import py_mini_racer @@ -9,6 +14,13 @@ def _get_file_content_ths(file: str = "cninfo.js") -> str: + ""...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_cg_equity_mortgage.py
Add verbose docstrings with examples
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests import py_mini_racer from akshare.datasets import get_ths_js def _get_file_content_ths(file: str = "cninfo.js") -> str: setting_file_path = get_ths_js(file) with open(setting_file_path, encoding="utf-8") as f: file_data...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/6/18 18:30 +Desc: 巨潮资讯-数据中心-行业分析-行业市盈率 +http://webapi.cninfo.com.cn/#/thematicStatistics?name=%E6%8A%95%E8%B5%84%E8%AF%84%E7%BA%A7 +""" import pandas as pd import requests @@ -9,6 +14,13 @@ def _get_file_content_ths(file: st...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_industry_pe_cninfo.py
Generate missing documentation strings
#!/usr/bin/env python # -*- coding:utf-8 -*- import re from functools import lru_cache import pandas as pd import requests from akshare.utils.func import fetch_paginated_data @lru_cache() def __stock_board_industry_name_em() -> pd.DataFrame: url = "https://17.push2.eastmoney.com/api/qt/clist/get" params = ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/10 19:30 +Desc: 东方财富-沪深板块-行业板块 +https://quote.eastmoney.com/center/boardlist.html#industry_board +""" import re from functools import lru_cache @@ -12,6 +17,12 @@ @lru_cache() def __stock_board_industry_name_em() -> pd.Data...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_board_industry_em.py
Write docstrings for utility functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import time from typing import Dict import pandas as pd import requests def stock_js_weibo_nlp_time() -> Dict: url = "https://datacenter-api.jin10.com/weibo/config" payload = {"_": int(time.time() * 1000)} headers = { "authority": "datacenter-api.jin1...
--- +++ @@ -1,5 +1,14 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2022/3/5 17:00 +Desc: 金十数据中心-实时监控-微博舆情报告 +https://datacenter.jin10.com/market +报告内容:时间期限可选择2小时、6小时、12小时、1天、1周、1月。 +该表格展示的是在对应的时间期限内,个股在微博讨论中的人气排行指数。 +红色颜色越深,表明该股票讨论热度越高,其当前的涨幅更大。 +绿色颜色越深,表明该股票讨论的热度越低,其当前的跌幅更大。 +""" import time from t...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_weibo_nlp.py
Add docstrings that explain inputs and outputs
#!/usr/bin/env python # -*- coding:utf-8 -*- import requests import pandas as pd def stock_price_js(symbol: str = "us") -> pd.DataFrame: url = "https://calendar-api.ushknews.com/getWebTargetPriceList" params = { "limit": "20", "category": symbol, } headers = { "accept": "appli...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2022/11/27 13:30 +Desc: 美股目标价 or 港股目标价 +https://www.ushknews.com/report.html +""" import requests import pandas as pd def stock_price_js(symbol: str = "us") -> pd.DataFrame: + """ + 美股目标价 or 港股目标价 + https://www.ushknew...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_us_js.py
Add docstrings to incomplete code
#!/usr/bin/env python # -*- coding:utf-8 -*- import json import re import pandas as pd import py_mini_racer import requests from akshare.stock.cons import ( zh_sina_a_stock_payload, zh_sina_a_stock_url, zh_sina_a_stock_count_url, zh_sina_a_stock_hist_url, hk_js_decode, zh_sina_a_stock_hfq_url...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2026/1/9 22:00 +Desc: 新浪财经-A股-实时行情数据和历史行情数据(包含前复权和后复权因子) +https://finance.sina.com.cn/realstock/company/sh689009/nc.shtml +""" import json import re @@ -23,6 +28,12 @@ def _get_zh_a_page_count() -> int: + """ + 所有股票的总页数 + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_zh_a_sina.py
Add docstrings for utility scripts
#!/usr/bin/env python # -*- coding:utf-8 -*- import json import warnings from functools import lru_cache from io import BytesIO from io import StringIO import pandas as pd import requests from akshare.utils.tqdm import get_tqdm @lru_cache() def stock_info_sz_name_code(symbol: str = "A股列表") -> pd.DataFrame: url ...
--- +++ @@ -1,5 +1,9 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/5/27 15:30 +Desc: 股票基本信息 +""" import json import warnings @@ -14,6 +18,14 @@ @lru_cache() def stock_info_sz_name_code(symbol: str = "A股列表") -> pd.DataFrame: + """ + 深圳证券交易所-股票列表 + https://www.szse.cn/market/product/st...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_info.py
Add docstrings to improve readability
#!/usr/bin/env python # -*- coding:utf-8 -*- import io import pandas as pd import requests from akshare.utils.cons import headers def stock_industry_clf_hist_sw() -> pd.DataFrame: url = "https://www.swsresearch.com/swindex/pdf/SwClass2021/StockClassifyUse_stock.xls" # 此处为 https r = requests.get(url, heade...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/7/22 17:30 +Desc: 申万宏源研究-行业分类 +http://www.swhyresearch.com/institute_sw/allIndex/downloadCenter/industryType +""" import io @@ -10,6 +15,12 @@ def stock_industry_clf_hist_sw() -> pd.DataFrame: + """ + 申万宏源研究-行业分类-全部行业...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_industry_sw.py
Generate NumPy-style docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def stock_bid_ask_em(symbol: str = "000001") -> pd.DataFrame: url = "https://push2.eastmoney.com/api/qt/stock/get" market_code = 1 if symbol.startswith("6") else 0 params = { "fltt": "2", "invt": "2", ...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/2/16 18:30 +Desc: 东方财富-行情报价 +https://quote.eastmoney.com/sz000001.html +""" import pandas as pd import requests def stock_bid_ask_em(symbol: str = "000001") -> pd.DataFrame: + """ + 东方财富-行情报价 + https://quote.eastm...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_ask_bid_em.py
Insert docstrings into my code
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd from akshare.utils.func import fetch_paginated_data def stock_zh_ah_spot_em() -> pd.DataFrame: url = "https://push2.eastmoney.com/api/qt/clist/get" params = { "np": "1", "fltt": "1", "invt": "2", "fs": "b:DLMK01...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/9 23:00 +Desc: 东方财富网-行情中心-沪深港通 +https://quote.eastmoney.com/center/gridlist.html#ah_comparison +""" import pandas as pd @@ -7,6 +12,12 @@ def stock_zh_ah_spot_em() -> pd.DataFrame: + """ + 东方财富网-行情中心-沪深港通-AH股比价-实时行情...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_hsgt_em.py
Add concise docstrings to each method
# -*- coding:utf-8 -*- # !/usr/bin/env python import numpy as np import pandas as pd import py_mini_racer import requests from akshare.datasets import get_ths_js def _get_file_content_cninfo(file: str = "cninfo.js") -> str: setting_file_path = get_ths_js(file) with open(setting_file_path, encoding="utf-8") ...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2024/10/21 22:20 +Desc: 巨潮资讯-股本股东-公司股本变动 +https://webapi.cninfo.com.cn/api/stock/p_stock2215 +""" import numpy as np import pandas as pd @@ -10,6 +15,13 @@ def _get_file_content_cninfo(file: str = "cninfo.js") -> str: + """ +...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_share_changes_cninfo.py
Document this script properly
# !/usr/bin/env python # -*- coding:utf-8 -*- import re from datetime import datetime import pandas as pd import requests def _convert_timestamp(timestamp_ms: int) -> str: timestamp_s = timestamp_ms / 1000 datetime_obj = datetime.fromtimestamp(timestamp_s) return datetime_obj.strftime("%Y-%m-%d %H:%M:%S...
--- +++ @@ -1,5 +1,10 @@ # !/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2026/1/13 15:00 +Desc: 雪球-行情中心-个股 +https://xueqiu.com/S/SH513520 +""" import re from datetime import datetime @@ -9,6 +14,13 @@ def _convert_timestamp(timestamp_ms: int) -> str: + """ + 时间戳转换为字符串时间 + :param timestamp_ms...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_xq.py
Add documentation for all methods
#!/usr/bin/env python # -*- coding:utf-8 -*- import re from functools import lru_cache import pandas as pd import requests from akshare.utils.func import fetch_paginated_data @lru_cache() def __stock_board_concept_name_em() -> pd.DataFrame: url = "https://79.push2.eastmoney.com/api/qt/clist/get" params = {...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/12 17:00 +Desc: 东方财富-沪深板块-概念板块 +https://quote.eastmoney.com/center/boardlist.html#concept_board +""" import re from functools import lru_cache @@ -12,6 +17,12 @@ @lru_cache() def __stock_board_concept_name_em() -> pd.DataFr...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_board_concept_em.py
Add docstrings for better understanding
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def stock_hot_up_em() -> pd.DataFrame: url = "https://emappdata.eastmoney.com/stockrank/getAllHisRcList" payload = { "appId": "appId01", "globalId": "786e4c21-70dc-435a-93bb-38", "marketType": "", ...
--- +++ @@ -1,11 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/6/15 15:15 +Desc: 东方财富个股人气榜 +https://guba.eastmoney.com/rank/ +""" import pandas as pd import requests def stock_hot_up_em() -> pd.DataFrame: + """ + 东方财富-个股人气榜-飙升榜 + https://guba.eastmoney.com/rank/ + :return:...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_hot_up_em.py
Add clean documentation to messy code
#!/usr/bin/env python # -*- coding:utf-8 -*- import json from functools import lru_cache import pandas as pd import requests import py_mini_racer from tqdm import tqdm from akshare.stock.cons import ( js_hash_text, zh_js_decode, us_sina_stock_list_url, us_sina_stock_dict_payload, us_sina_stock_hi...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/1/14 17:00 +Desc: 新浪财经-美股实时行情数据和历史行情数据 +https://finance.sina.com.cn/stock/usstock/sector.shtml +""" import json from functools import lru_cache @@ -20,6 +25,12 @@ @lru_cache() def __get_us_page_count() -> int: + """ + 新...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_us_sina.py
Document this script properly
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.utils.tqdm import get_tqdm def stock_us_pink_spot_em() -> pd.DataFrame: url = "https://23.push2.eastmoney.com/api/qt/clist/get" params = { "np": "1", "fltt": "1", "invt": "1", "fs": ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/6/17 14:00 +Desc: 东方财富网-行情中心-美股市场-粉单市场 +https://quote.eastmoney.com/center/gridlist.html#us_pinksheet +""" import pandas as pd import requests @@ -8,6 +13,12 @@ def stock_us_pink_spot_em() -> pd.DataFrame: + """ + 东方财富...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_us_pink.py
Generate docstrings for script automation
#!/usr/bin/env python # -*- coding:utf-8 -*- import json import pandas as pd import requests from tqdm import tqdm def stock_share_hold_change_sse(symbol: str = "600000") -> pd.DataFrame: url = "https://query.sse.com.cn/commonQuery.do" params = { "isPagination": "true", "pageHelp.pageSize": ...
--- +++ @@ -1,5 +1,15 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/11/8 17:00 +Desc: 董监高及相关人员持股变动 +北京证券交易所-信息披露-监管信息-董监高及相关人员持股变动 +https://www.bse.cn/disclosure/djg_sharehold_change.html +深圳证券交易所-信息披露-监管信息公开-董监高人员股份变动 +https://www.szse.cn/disclosure/supervision/change/index.html +上海证券交易所-披露-监管信息公开-...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_share_hold.py
Improve my code by adding docstrings
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests from tqdm import tqdm def stock_repurchase_em() -> pd.DataFrame: url = "https://datacenter-web.eastmoney.com/api/data/v1/get" params = { "sortColumns": "UPD,DIM_DATE,DIM_SCODE", "sortTypes": "-1,-1,-1", ...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2022/8/29 14:20 +Desc: 东方财富网-数据中心-股票回购-股票回购数据 +https://data.eastmoney.com/gphg/hglist.html +""" import pandas as pd import requests @@ -7,6 +12,12 @@ def stock_repurchase_em() -> pd.DataFrame: + """ + 东方财富网-数据中心-股票回购-股票回购数...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_repurchase_em.py
Create simple docstrings for beginners
#!/usr/bin/env python # -*- coding:utf-8 -*- import warnings from io import BytesIO, StringIO import pandas as pd import requests from bs4 import BeautifulSoup def stock_szse_summary(date: str = "20240830") -> pd.DataFrame: url = "http://www.szse.cn/api/report/ShowReport" params = { "SHOWTYPE": "xls...
--- +++ @@ -1,5 +1,12 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/5/5 00:00 +Desc: 股票数据-总貌-市场总貌 +股票数据-总貌-成交概括 +https://www.szse.cn/market/overview/index.html +https://www.sse.com.cn/market/stockdata/statistic/ +""" import warnings from io import BytesIO, StringIO @@ -10,6 +17,14 @@ def sto...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_summary.py
Document this code for team use
#!/usr/bin/env python # -*- coding:utf-8 -*- from typing import Dict from datetime import datetime from functools import lru_cache from io import StringIO import pandas as pd import requests from bs4 import BeautifulSoup import py_mini_racer from akshare.datasets import get_ths_js from akshare.utils import demjson f...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/27 14:20 +Desc: 同花顺-板块-概念板块 +https://q.10jqka.com.cn/thshy/ +""" from typing import Dict from datetime import datetime @@ -17,6 +22,13 @@ def _get_file_content_ths(file: str = "ths.js") -> str: + """ + 获取 JS 文件的内容 + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock_feature/stock_board_concept_ths.py
Generate missing documentation strings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.stock_feature.stock_a_indicator import get_token_lg, get_cookie_csrf def stock_a_all_pb() -> pd.DataFrame: url = "https://legulegu.com/api/stock-data/market-index-pb" params = { "marketId": "ALL", "...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/4/11 20:40 +Desc: 全部A股-等权重市净率、中位数市净率 +https://www.legulegu.com/stockdata/all-pb +""" import pandas as pd import requests @@ -8,6 +13,12 @@ def stock_a_all_pb() -> pd.DataFrame: + """ + 全部A股-等权重市净率、中位数市净率 + https://l...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock_feature/stock_all_pb.py
Create docstrings for API functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def stock_staq_net_stop() -> pd.DataFrame: url = "https://5.push2.eastmoney.com/api/qt/clist/get" params = { "pn": "1", "pz": "50000", "po": "1", "np": "2", "ut": "bd1d9ddb04089700cf9c27f6...
--- +++ @@ -1,11 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/2/24 18:33 +Desc: 两网及退市 +https://quote.eastmoney.com/center/gridlist.html#staq_net_board +""" import pandas as pd import requests def stock_staq_net_stop() -> pd.DataFrame: + """ + 东方财富网-行情中心-沪深个股-两网及退市 + https://...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_stop.py
Generate documentation strings for clarity
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.utils.tqdm import get_tqdm from akshare.utils.cons import headers def stock_analyst_rank_em(year: str = "2024") -> pd.DataFrame: url = "https://data.eastmoney.com/dataapi/invest/list" params = { "sortColumns...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/8/20 20:00 +Desc: 东方财富网-数据中心-研究报告-东方财富分析师指数 +https://data.eastmoney.com/invest/invest/list.html +""" import pandas as pd import requests @@ -8,6 +13,14 @@ def stock_analyst_rank_em(year: str = "2024") -> pd.DataFrame: + "...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock_feature/stock_analyst_em.py
Add docstrings to make code maintainable
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests def stock_individual_info_em( symbol: str = "603777", timeout: float = None ) -> pd.DataFrame: url = "https://push2.eastmoney.com/api/qt/stock/get" market_code = 1 if symbol.startswith("6") else 0 params = { "fl...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/2/15 22:00 +Desc: 东方财富网-个股-股票信息 +https://quote.eastmoney.com/concept/sh603777.html?from=classic +""" import pandas as pd import requests @@ -8,6 +13,16 @@ def stock_individual_info_em( symbol: str = "603777", timeout: floa...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_info_em.py
Add documentation for all methods
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def stock_hk_security_profile_em(symbol: str = "03900") -> pd.DataFrame: url = "https://datacenter.eastmoney.com/securities/api/data/v1/get" params = { "reportName": "RPT_HKF10_INFO_SECURITYINFO", "columns": "SEC...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/9/11 13:00 +Desc: 东方财富-港股-公司概况 +https://emweb.securities.eastmoney.com/PC_HKF10/pages/home/index.html?code=03900&type=web&color=w#/CompanyProfile +""" import pandas as pd import requests def stock_hk_security_profile_em(sy...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_profile_em.py
Generate descriptive docstrings automatically
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.stock_feature.stock_a_indicator import get_token_lg, get_cookie_csrf def stock_ebs_lg() -> pd.DataFrame: url = "https://legulegu.com/api/stockdata/equity-bond-spread" token = get_token_lg() params = {"token": t...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/19 15:30 +Desc: 乐咕乐股-股债利差 +https://legulegu.com/stockdata/equity-bond-spread +""" import pandas as pd import requests @@ -8,6 +13,12 @@ def stock_ebs_lg() -> pd.DataFrame: + """ + 乐咕乐股-股债利差 + https://legulegu.com/...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock_feature/stock_ebs_lg.py
Write reusable docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import py_mini_racer import requests from akshare.datasets import get_ths_js def _get_file_content_ths(file: str = "cninfo.js") -> str: setting_file_path = get_ths_js(file) with open(setting_file_path, encoding="utf-8") as f: file_data...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/10/14 22:00 +Desc: 巨潮资讯-个股-公司概况 +https://webapi.cninfo.com.cn/#/company +""" import pandas as pd import py_mini_racer @@ -9,6 +14,13 @@ def _get_file_content_ths(file: str = "cninfo.js") -> str: + """ + 获取 JS 文件的内容 + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/stock/stock_profile_cninfo.py