instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Write docstrings including parameters and return values
#!/usr/bin/env python # -*- coding:utf-8 -*- import time import pandas as pd import requests from tqdm import tqdm # 金十数据中心-经济指标-欧元区-国民经济运行状况 # 金十数据中心-经济指标-欧元区-国民经济运行状况-经济状况 # 金十数据中心-经济指标-欧元区-国民经济运行状况-经济状况-欧元区季度GDP年率报告 def macro_euro_gdp_yoy() -> pd.DataFrame: ec = 84 url = "https://datacenter-api.jin10.com...
--- +++ @@ -1,5 +1,15 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/4/3 17:08 +Desc: 金十数据中心-经济指标-欧元区 +金十数据中心-经济指标-欧元区-国民经济运行状况-经济状况 +金十数据中心-经济指标-欧元区-国民经济运行状况-物价水平 +金十数据中心-经济指标-欧元区-国民经济运行状况-劳动力市场 +金十数据中心-经济指标-欧元区-贸易状况 +金十数据中心-经济指标-欧元区-产业指标 +金十数据中心-经济指标-欧元区-领先指标 +""" import time @@ -12,6 +22,12 @...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/economic/macro_euro.py
Create docstrings for all classes and functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import json import math import ssl import time import pandas as pd import requests from requests.adapters import HTTPAdapter from urllib3.poolmanager import PoolManager from akshare.economic.cons import ( JS_CHINA_ENERGY_DAILY_URL, ) from akshare.utils...
--- +++ @@ -1,5 +1,9 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/11/12 15:20 +Desc: 宏观数据-中国 +""" import datetime import json @@ -38,6 +42,12 @@ def __macro_china_base_func(symbol: str, params: dict) -> pd.DataFrame: + """ + 金十数据中心-经济指标-美国-基础函数 + https://datacenter.jin10.com/econom...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/economic/macro_china.py
Generate docstrings for exported functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import functools import pandas as pd import requests from akshare.utils.tqdm import get_tqdm from akshare.bond.bond_china import bond_china_close_return_map @functools.lru_cache() def bond_info_cm_query(symbol: str = "评级等级") -> pd.DataFrame: bond_china_close_return_m...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/5/10 14:00 +Desc: 中国外汇交易中心暨全国银行间同业拆借中心 +https://www.chinamoney.com.cn/chinese/scsjzqxx/ +""" import functools @@ -11,6 +16,14 @@ @functools.lru_cache() def bond_info_cm_query(symbol: str = "评级等级") -> pd.DataFrame: + """ +...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/bond/bond_info_cm.py
Document all public functions with docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import warnings import pandas as pd import requests def fund_etf_scale_szse() -> pd.DataFrame: url = "https://fund.szse.cn/api/report/ShowReport" params = { "SHOWTYPE": "xlsx", "CATALOGID": "1000_lf", "TABKEY": "tab1", "random": "0...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2026/1/20 15:00 +Desc: 深圳证券交易所-ETF基金份额数据 +https://fund.szse.cn/marketdata/fundslist/index.html +""" import warnings @@ -8,6 +13,12 @@ def fund_etf_scale_szse() -> pd.DataFrame: + """ + 深圳证券交易所-基金产品-基金列表-ETF基金份额 + https:...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_etf_szse.py
Add docstrings to make code maintainable
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO import pandas as pd import requests from akshare.bond.bond_china_money import bond_china_close_return_map from akshare.utils.cons import headers def bond_spot_quote() -> pd.DataFrame: bond_china_close_return_map() url = "https://www.china...
--- +++ @@ -1,5 +1,12 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/10/1 17:00 +Desc: 中国外汇交易中心暨全国银行间同业拆借中心 +中国外汇交易中心暨全国银行间同业拆借中心-市场数据-债券市场行情-现券市场做市报价 +中国外汇交易中心暨全国银行间同业拆借中心-市场数据-债券市场行情-现券市场成交行情 +https://www.chinamoney.com.cn/chinese/mkdatabond/ +""" from io import StringIO @@ -11,6 +18,12 @@ ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/bond/bond_china.py
Add docstrings that explain purpose and usage
# -*- coding:utf-8 -*- # !/usr/bin/env python import re from datetime import datetime from io import StringIO import pandas as pd import requests from bs4 import BeautifulSoup def currency_boc_safe() -> pd.DataFrame: url = "https://www.safe.gov.cn/safe/2020/1218/17833.html" r = requests.get(url) r.encod...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2024/4/29 17:00 +Desc: 人民币汇率中间价 +https://www.safe.gov.cn/safe/rmbhlzjj/index.html +""" import re from datetime import datetime @@ -11,6 +16,12 @@ def currency_boc_safe() -> pd.DataFrame: + """ + 人民币汇率中间价 + https://www.s...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/currency/currency_safe.py
Write docstrings for data processing functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import time import pandas as pd import requests def __get_interest_rate_data(attr_id: str, name: str = "利率") -> pd.DataFrame: t = time.time() headers = { "Accept": "*/*", "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8", "User-...
--- +++ @@ -1,5 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/11/5 17:11 +Desc: 金十数据中心-经济指标-央行利率-主要央行利率 +https://datacenter.jin10.com/economic +输出数据格式为 float64 +美联储利率决议报告 +欧洲央行决议报告 +新西兰联储决议报告 +中国央行决议报告 +瑞士央行决议报告 +英国央行决议报告 +澳洲联储决议报告 +日本央行决议报告 +俄罗斯央行决议报告 +印度央行决议报告 +巴西央行决议报告 +""" import dateti...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/economic/macro_bank.py
Add docstrings that explain purpose and usage
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.utils.tqdm import get_tqdm headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/123.0.0.0 Safari/537.36", "Content-Type": "application/json", } ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/4/29 16:00 +Desc: 中国证券投资基金业协会-信息公示数据 +中国证券投资基金业协会-新版: https://gs.amac.org.cn +""" import pandas as pd import requests @@ -14,6 +19,10 @@ def _get_pages(url: str = "", payload: str = "") -> pd.DataFrame: + """ + 中国证券投资基...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_amac.py
Can you add docstrings to this Python file?
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests def bond_zh_cov_info_ths() -> pd.DataFrame: url = "https://data.10jqka.com.cn/ipo/kzz/" headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/89.0....
--- +++ @@ -1,11 +1,22 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2024/8/14 11:30 +Desc: 同花顺-数据中心-可转债 +https://data.10jqka.com.cn/ipo/bond/ +""" import pandas as pd import requests def bond_zh_cov_info_ths() -> pd.DataFrame: + """ + 同花顺-数据中心-可转债 + https://data.10jqka.com.cn/ipo/bond...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/bond/bond_cb_ths.py
Create documentation strings for testing functions
#!/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 from tqdm import tqdm @lru_cache() def _fortune_rank_year_url_map() -> dict: url = "https://www.fortunechina.com/fortune500/index.htm" r = re...
--- +++ @@ -1,5 +1,12 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/8/4 17:22 +Desc: 历年世界 500 强榜单数据 +https://www.fortunechina.com/fortune500/index.htm +特殊情况说明: +2010年由于网页端没有公布公司所属的国家, 故 2010 年数据没有国家这列 +""" from functools import lru_cache from io import StringIO @@ -12,6 +19,12 @@ @lru_cache() ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fortune/fortune_500.py
Create docstrings for all classes and functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import json import math import time from io import StringIO import pandas as pd import py_mini_racer import requests from akshare.utils import demjson from akshare.utils.cons import headers from akshare.utils.tqdm import get_tqdm def fund_purchase_em() -> pd.DataFrame: ...
--- +++ @@ -1,5 +1,19 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2026/1/20 17:00 +Desc: 东方财富网站-天天基金网-基金数据-开放式基金净值 +https://fund.eastmoney.com/manager/default.html#dt14;mcreturnjson;ftall;pn20;pi1;scabbname;stasc +1.基金经理基本数据, 建议包含:基金经理代码,基金经理姓名,从业起始日期,现任基金公司,管理资产总规模,上述数据可在"基金经理列表: +https://fund.eastmon...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_em.py
Write proper docstrings for these functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import json import pandas as pd import requests from akshare.event.cons import province_dict, city_dict def migration_area_baidu( area: str = "重庆市", indicator: str = "move_in", date: str = "20230922" ) -> pd.DataFrame: city_dict.update(province_dict) inner_d...
--- +++ @@ -1,5 +1,9 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/5/12 22:30 +Desc: 百度地图慧眼-百度迁徙数据 +""" import json @@ -12,6 +16,22 @@ def migration_area_baidu( area: str = "重庆市", indicator: str = "move_in", date: str = "20230922" ) -> pd.DataFrame: + """ + 百度地图慧眼-百度迁徙-XXX迁入地详情 + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/event/migration.py
Document all endpoints with docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests # 新屋开工 def macro_canada_new_house_rate() -> pd.DataFrame: url = "https://datacenter-web.eastmoney.com/api/data/v1/get" params = { "reportName": "RPT_ECONOMICVALUE_CA", "columns": "ALL", "filter": '(INDICA...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2022/11/27 20:30 +Desc: 东方财富-经济数据-加拿大 +https://data.eastmoney.com/cjsj/foreign_5_0.html +""" import pandas as pd import requests @@ -7,6 +12,12 @@ # 新屋开工 def macro_canada_new_house_rate() -> pd.DataFrame: + """ + 东方财富-经济数据-加...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/economic/macro_canada.py
Add well-formatted docstrings
#!/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 from tqdm import tqdm @lru_cache() def _currency_boc_sina_map( start_date: str = "20210614", end_date: str = "20230810" ) -> dict: url = "htt...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/12/8 17:20 +Desc: 新浪财经-中行人民币牌价历史数据查询 +https://biz.finance.sina.com.cn/forex/forex.php?startdate=2012-01-01&enddate=2021-06-14&money_code=EUR&type=0 +""" from functools import lru_cache from io import StringIO @@ -14,6 +19,16 @@ ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/currency/currency_china_bank_sina.py
Write docstrings for utility functions
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests from akshare.utils.tqdm import get_tqdm def fund_fh_em( year: str = "2025", typ: str = "", rank: str = "BZDM", sort: str = "asc", page: int = -1, ) -> pd.DataFrame: def get_df_from_response(response): ...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2026/2/22 13:00 +Desc: 天天基金网-基金数据-分红送配 +https://fund.eastmoney.com/data/fundfenhong.html +""" import pandas as pd import requests @@ -14,6 +19,26 @@ sort: str = "asc", page: int = -1, ) -> pd.DataFrame: + """ + 天天基金网...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_fhsp_em.py
Create docstrings for reusable components
#!/usr/bin/env python # -*- coding:utf-8 -*- from functools import lru_cache import pandas as pd import requests from akshare.utils.func import fetch_paginated_data @lru_cache() def _fund_lof_code_id_map_em() -> dict: url = "https://2.push2.eastmoney.com/api/qt/clist/get" params = { "pn": "1", ...
--- +++ @@ -1,5 +1,11 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/11 17:00 +Desc: 东方财富-LOF 行情 +https://quote.eastmoney.com/center/gridlist.html#fund_lof +https://quote.eastmoney.com/sz166009.html +""" from functools import lru_cache @@ -11,6 +17,12 @@ @lru_cache() def _fund_lof_code_id_m...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_lof_em.py
Create Google-style docstrings for my code
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO import pandas as pd import requests from bs4 import BeautifulSoup from tqdm import tqdm from akshare.utils import demjson from akshare.utils.cons import headers def energy_carbon_domestic(symbol: str = "湖北") -> pd.DataFrame: url = "http://k.t...
--- +++ @@ -1,5 +1,23 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/6/25 15:00 +Desc: 碳排放交易 +北京市碳排放权电子交易平台-北京市碳排放权公开交易行情 +https://www.bjets.com.cn/article/jyxx/ + +深圳碳排放交易所-国内碳情 +http://www.cerx.cn/dailynewsCN/index.htm + +深圳碳排放交易所-国际碳情 +http://www.cerx.cn/dailynewsOuter/index.htm + +湖北碳排放权交易中心-现货交易...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/energy/energy_carbon.py
Write proper docstrings for these functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def bond_sh_buy_back_em() -> pd.DataFrame: url = "https://push2.eastmoney.com/api/qt/clist/get" params = { "np": "1", "fltt": "1", "invt": "2", "fs": "m:1+b:MK0356", "fields": "f12,f13,f1...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/4/5 17:30 +Desc: 东方财富网-行情中心-债券市场-质押式回购 +https://quote.eastmoney.com/center/gridlist.html#bond_sz_buyback +""" import pandas as pd @@ -7,6 +12,12 @@ def bond_sh_buy_back_em() -> pd.DataFrame: + """ + 东方财富网-行情中心-债券市场-上证...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/bond/bond_buy_back_em.py
Create docstrings for reusable components
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from bs4 import BeautifulSoup def forbes_rank(symbol: str = "2021福布斯中国创投人100") -> pd.DataFrame: url = "https://www.forbeschina.com/lists" r = requests.get(url, verify=False) soup = BeautifulSoup(r.text, "lxml") need_list...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2022/1/26 15:10 +Desc: 福布斯中国-榜单 +https://www.forbeschina.com/lists +""" import pandas as pd import requests @@ -7,6 +12,15 @@ def forbes_rank(symbol: str = "2021福布斯中国创投人100") -> pd.DataFrame: + """ + 福布斯中国-榜单 + https://w...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fortune/fortune_forbes_500.py
Add docstrings to meet PEP guidelines
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def crypto_bitcoin_cme(date: str = "20230830") -> pd.DataFrame: url = "https://datacenter-api.jin10.com/reports/list" params = { "category": "cme", "date": "-".join([date[:4], date[4:6], date[6:]]), "attr...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/9/5 15:41 +Desc: 芝加哥商业交易所-比特币成交量报告 +https://datacenter.jin10.com/reportType/dc_cme_btc_report +""" import pandas as pd import requests def crypto_bitcoin_cme(date: str = "20230830") -> pd.DataFrame: + """ + 芝加哥商业交易所-...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/crypto/crypto_bitcoin_cme.py
Replace inline comments with docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import py_mini_racer import requests from akshare.stock.cons import hk_js_decode from akshare.utils import demjson def fund_etf_category_sina(symbol: str = "LOF基金") -> pd.DataFrame: fund_map = { "封闭式基金": "close_fund", "ETF基金": "etf...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/11/10 15:30 +Desc: 新浪财经-基金行情 +https://vip.stock.finance.sina.com.cn/fund_center/index.html#jjhqetf +""" import pandas as pd import py_mini_racer @@ -10,6 +15,14 @@ def fund_etf_category_sina(symbol: str = "LOF基金") -> pd.Data...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_etf_sina.py
Generate NumPy-style docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def bond_debt_nafmii(page: str = "1") -> pd.DataFrame: url = "http://zhuce.nafmii.org.cn/fans/publicQuery/releFileProjDataGrid" payload = { "regFileName": "", "itemType": "", "startTime": "", "end...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/3/16 9:00 +Desc:中国银行间市场交易商协会(https://www.nafmii.org.cn/) +孔雀开屏(http://zhuce.nafmii.org.cn/fans/publicQuery/manager)的债券基本信息数据 +""" import pandas as pd import requests def bond_debt_nafmii(page: str = "1") -> pd.DataFrame: +...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/bond/bond_nafmii.py
Add inline docstrings for readability
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.utils import demjson def fund_new_found_em() -> pd.DataFrame: url = "https://fund.eastmoney.com/data/FundNewIssue.aspx" params = { "t": "xcln", "sort": "jzrgq,desc", "y": "", "page":...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/11/7 18:30 +Desc: 基金数据-新发基金-新成立基金 +https://fund.eastmoney.com/data/xinfound.html +""" import pandas as pd import requests @@ -8,6 +13,12 @@ def fund_new_found_em() -> pd.DataFrame: + """ + 基金数据-新发基金-新成立基金 + https://...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_init_em.py
Add docstrings that explain purpose and usage
#!/usr/bin/env python # -*- coding:utf-8 -*- import re from io import StringIO import pandas as pd import requests from bs4 import BeautifulSoup def fund_fee_em(symbol: str = "015641", indicator: str = "认购费率") -> pd.DataFrame: url = f"https://fundf10.eastmoney.com/jjfl_{symbol}.html" r = requests.get(url) ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/12/22 17:00 +Desc: 天天基金-基金档案 +https://fundf10.eastmoney.com/jjfl_015641.html +""" import re from io import StringIO @@ -10,6 +15,16 @@ def fund_fee_em(symbol: str = "015641", indicator: str = "认购费率") -> pd.DataFrame: + ""...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_fee_em.py
Add docstrings for production code
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import re import pandas as pd import requests import py_mini_racer from akshare.bond.cons import ( zh_sina_bond_hs_count_url, zh_sina_bond_hs_payload, zh_sina_bond_hs_url, zh_sina_bond_hs_hist_url, ) from akshare.stock.cons import hk_js_dec...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/6/18 18:30 +Desc: 新浪财经-债券-沪深债券-实时行情数据和历史行情数据 +https://vip.stock.finance.sina.com.cn/mkt/#hs_z +""" import datetime import re @@ -20,6 +25,12 @@ def get_zh_bond_hs_page_count() -> int: + """ + 行情中心首页-债券-沪深债券的总页数 + ht...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/bond/bond_zh_sina.py
Document all public functions with docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def crypto_bitcoin_hold_report(): url = "https://datacenter-api.jin10.com/bitcoin_treasuries/list" headers = { "X-App-Id": "lnFP5lxse24wPgtY", "X-Version": "1.0.0", } r = requests.get(url, headers=headers...
--- +++ @@ -1,11 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/8/31 23:00 +Desc: 金十数据-比特币持仓报告 +https://datacenter.jin10.com/dc_report?name=bitcoint +""" import pandas as pd import requests def crypto_bitcoin_hold_report(): + """ + 金十数据-比特币持仓报告 + https://datacenter.jin10.com/d...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/crypto/crypto_hold.py
Add docstrings explaining edge cases
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO import pandas as pd import requests import time from akshare.utils import demjson def bond_cb_index_jsl() -> pd.DataFrame: url = "https://www.jisilu.cn/webapi/cb/index_history/" r = requests.get(url) data_dict = demjson.decode(r.text)[...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/5/16 19:00 +Desc: 债券-集思录-可转债 +集思录:https://www.jisilu.cn/data/cbnew/#cb +""" from io import StringIO import pandas as pd @@ -10,6 +15,12 @@ def bond_cb_index_jsl() -> pd.DataFrame: + """ + 首页-可转债-集思录可转债等权指数 + https:/...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/bond/bond_convert.py
Add concise docstrings to each method
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def macro_japan_core(symbol: str = "EMG00341602") -> pd.DataFrame: url = "https://datacenter-web.eastmoney.com/api/data/v1/get" params = { "reportName": "RPT_ECONOMICVALUE_JPAN", "columns": "ALL", "filter...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/4/3 16:00 +Desc: 东方财富-经济数据-日本 +https://data.eastmoney.com/cjsj/foreign_3_0.html +""" import pandas as pd import requests def macro_japan_core(symbol: str = "EMG00341602") -> pd.DataFrame: + """ + 东方财富-数据中心-经济数据一览-宏观经...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/economic/macro_japan.py
Document my Python code with docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from bs4 import BeautifulSoup def index_bloomberg_billionaires_hist(year: str = "2021") -> pd.DataFrame: url = f"https://stats.areppim.com/listes/list_billionairesx{year[-2:]}xwor.htm" r = requests.get(url) soup = BeautifulS...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2022/4/10 18:24 +Desc: 彭博亿万富豪指数 +https://www.bloomberg.com/billionaires/ +""" import pandas as pd import requests @@ -7,6 +12,14 @@ def index_bloomberg_billionaires_hist(year: str = "2021") -> pd.DataFrame: + """ + Bloomber...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fortune/fortune_bloomberg.py
Generate docstrings for script automation
#!/usr/bin/env python # -*- coding:utf-8 -*- from functools import lru_cache import pandas as pd import requests from akshare.utils.func import fetch_paginated_data @lru_cache() def _fund_etf_code_id_map_em() -> dict: url = "https://88.push2.eastmoney.com/api/qt/clist/get" params = { "pn": "1", ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/2/15 22:00 +Desc: 东方财富-ETF行情 +https://quote.eastmoney.com/sh513500.html +""" from functools import lru_cache @@ -11,6 +16,12 @@ @lru_cache() def _fund_etf_code_id_map_em() -> dict: + """ + 东方财富-ETF代码和市场标识映射 + https:...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_etf_em.py
Document all endpoints with docstrings
class AkshareException(Exception): def __init__(self, message): self.message = message super().__init__(self.message) class APIError(AkshareException): def __init__(self, message, status_code=None): self.status_code = status_code super().__init__(f"API Error: {message} (Sta...
--- +++ @@ -1,6 +1,10 @@+""" +AKShare 异常处理模块 +""" class AkshareException(Exception): + """Base exception for akshare library""" def __init__(self, message): self.message = message @@ -8,6 +12,7 @@ class APIError(AkshareException): + """Raised when API request fails""" def __init__(...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/exceptions.py
Add docstrings that explain inputs and outputs
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.utils import demjson from akshare.utils.tqdm import get_tqdm def fund_manager_em() -> pd.DataFrame: big_df = pd.DataFrame() url = "https://fund.eastmoney.com/Data/FundDataPortfolio_Interface.aspx" params = { ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/9/14 18:00 +Desc: 基金经理大全 +https://fund.eastmoney.com/manager/default.html +""" import pandas as pd import requests @@ -9,6 +14,12 @@ def fund_manager_em() -> pd.DataFrame: + """ + 天天基金网-基金数据-基金经理大全 + https://fund.ea...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_manager.py
Help me add docstrings to my project
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO import pandas as pd import requests from akshare.article.cons import ff_home_url def article_ff_crr() -> pd.DataFrame: res = requests.get(ff_home_url) # first table list_index = ( pd.read_html(StringIO(res.text), header=0, ind...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/1/20 22:30 +Desc: FF-data-library +https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html +""" from io import StringIO @@ -10,6 +15,12 @@ def article_ff_crr() -> pd.DataFrame: + """ + FF多因子模型 + h...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/article/ff_factor.py
Can you add docstrings to this Python file?
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import time import pandas as pd import requests from tqdm import tqdm def macro_cons_gold() -> pd.DataFrame: t = time.time() headers = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/4/3 16:08 +Desc: 金十数据-数据中心-主要机构-宏观经济 +https://datacenter.jin10.com/ +""" import datetime import time @@ -10,6 +15,12 @@ def macro_cons_gold() -> pd.DataFrame: + """ + 全球最大黄金 ETF—SPDR Gold Trust 持仓报告, 数据区间从 20041118-至今 ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/economic/macro_constitute.py
Generate missing documentation strings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.futures.cons import futures_inventory_em_symbol_dict def futures_inventory_em(symbol: str = "a") -> pd.DataFrame: url = "https://datacenter-web.eastmoney.com/api/data/v1/get" params = { "reportName": "RPT_FU...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/5 17:30 +Desc: 东方财富网-数据中心-期货库存数据 +https://data.eastmoney.com/ifdata/kcsj.html +""" import pandas as pd import requests @@ -7,6 +12,14 @@ def futures_inventory_em(symbol: str = "a") -> pd.DataFrame: + """ + 东方财富网-数据中心...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_inventory_em.py
Provide clean and structured docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from bs4 import BeautifulSoup def fund_rating_all() -> pd.DataFrame: url = "https://fund.eastmoney.com/data/fundrating.html" r = requests.get(url) soup = BeautifulSoup(r.text, features="lxml") data_text = soup.find(name=...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/12/12 16:30 +Desc: 基金评级 +https://fund.eastmoney.com/data/fundrating.html +""" import pandas as pd import requests @@ -7,6 +12,12 @@ def fund_rating_all() -> pd.DataFrame: + """ + 天天基金网-基金评级-基金评级总汇 + https://fund.eas...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_rating.py
Add return value explanations in docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import re import warnings import math import pandas as pd from akshare.futures import cons from akshare.futures.futures_daily_bar import get_futures_daily from akshare.futures.symbol_var import symbol_market, symbol_varieties calendar = cons.get_calendar(...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/7/16 17:40 +Desc: 中国期货各合约展期收益率 +日线数据从 daily_bar 函数获取, 需要在收盘后运行 +""" import datetime import re @@ -16,6 +21,16 @@ def get_roll_yield(date=None, var="BB", symbol1=None, symbol2=None, df=None): + """ + 指定交易日指定品种(主力和次主力)或任...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_roll_yield.py
Write docstrings including parameters and return values
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO import pandas as pd import requests def futures_rule(date: str = "20231205") -> pd.DataFrame: import urllib3 urllib3.disable_warnings() url = " https://www.gtjaqh.com/pc/calendar" params = {"date": f"{date}"} r = requests.get(...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/31 18:00 +Desc: 国泰君安期货-交易日历数据表 +https://www.gtjaqh.com/pc/calendar.html +""" from io import StringIO @@ -8,6 +13,14 @@ def futures_rule(date: str = "20231205") -> pd.DataFrame: + """ + 国泰君安期货-交易日历数据表 + https://ww...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_rule.py
Write beginner-friendly docstrings
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests from akshare.utils import demjson def fund_scale_open_sina(symbol: str = "股票型基金") -> pd.DataFrame: fund_map = { "股票型基金": "2", "混合型基金": "1", "债券型基金": "3", "货币型基金": "5", "QDII基金": "6", } ...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2024/9/1 16:20 +Desc: 新浪财经-基金规模 +https://vip.stock.finance.sina.com.cn/fund_center/index.html#jjgmall +""" import pandas as pd import requests @@ -8,6 +13,14 @@ def fund_scale_open_sina(symbol: str = "股票型基金") -> pd.DataFrame: + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_scale_sina.py
Add verbose docstrings with examples
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests from akshare.utils import demjson def fund_scale_change_em() -> pd.DataFrame: url = "https://fund.eastmoney.com/data/FundDataPortfolio_Interface.aspx" params = { "dt": "9", "pi": "1", "pn": "50", ...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2023/10/27 20:30 +Desc: 天天基金网-基金数据-规模份额 +https://fund.eastmoney.com/data/cyrjglist.html +""" import pandas as pd import requests @@ -8,6 +13,12 @@ def fund_scale_change_em() -> pd.DataFrame: + """ + 天天基金网-基金数据-规模份额-规模变动 + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_scale_em.py
Add docstrings that explain purpose and usage
# -*- 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_cninfo(file: str = "cninfo.js") -> str: setting_file_path = get_ths_js(file) with open(setting_file_path, encoding="utf-8") as f: file_...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +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_cninfo(file: str = "cninfo.js") -> str: + """...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_report_cninfo.py
Include argument descriptions in docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def fund_individual_basic_info_xq( symbol: str = "000001", timeout: float = None ) -> pd.DataFrame: url = f"https://danjuanfunds.com/djapi/fund/{symbol}" headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/10/27 22:30 +Desc: 雪球基金-基金详情 +https://danjuanfunds.com/funding/003545 +""" import pandas as pd import requests @@ -8,6 +13,16 @@ def fund_individual_basic_info_xq( symbol: str = "000001", timeout: float = None ) -> pd.Data...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_xq.py
Generate consistent documentation across files
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.utils.cons import headers def futures_rule_em() -> pd.DataFrame: url = "https://eastmoneyfutures.com/api/ComManage/GetPZJYInfo" r = requests.get(url, headers=headers) data_json = r.json() temp_df = pd.DataFr...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/1/17 19:30 +Desc: 东方财富网-期货行情-品种及交易规则 +https://portal.eastmoneyfutures.com/pages/service/jyts.html#jyrl +""" import pandas as pd import requests @@ -7,6 +12,12 @@ def futures_rule_em() -> pd.DataFrame: + """ + 东方财富网-期货行...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_rule_em.py
Add detailed documentation for each class
#!/usr/bin/env python # -*- coding:utf-8 -*- from datetime import datetime, date import pandas as pd import requests from akshare.utils import demjson def __one_year_ago(date_str: str) -> date: # 将字符串格式的日期转换为date对象 given_date = date(int(date_str[0:4]), int(date_str[4:6]), int(date_str[6:8])) try: ...
--- +++ @@ -1,5 +1,12 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/7/24 13:00 +Desc: 东方财富网-数据中心-开放基金排行 +https://fund.eastmoney.com/data/fundranking.html +名词解释 +https://help.1234567.com.cn/list_236.html +""" from datetime import datetime, date @@ -24,6 +31,14 @@ def fund_open_fund_rank_em(s...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fund/fund_rank_em.py
Document this script properly
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO import pandas as pd import requests from akshare.futures.cons import ( zh_subscribe_exchange_symbol_url, zh_match_main_contract_url, zh_match_main_contract_payload, ) from akshare.utils import demjson def zh_subscribe_exchange_symbol(...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/3/1 23:00 +Desc: 新浪财经-期货的主力合约数据 +https://finance.sina.com.cn/futuremarket/index.shtml +""" from io import StringIO @@ -15,6 +20,14 @@ def zh_subscribe_exchange_symbol(symbol: str = "dce") -> pd.DataFrame: + """ + 订阅指定...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures_derivative/futures_index_sina.py
Generate documentation strings for clarity
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO, BytesIO import pandas as pd import requests def futures_to_spot_shfe(date: str = "202312") -> pd.DataFrame: url = f"https://tsite.shfe.com.cn/data/instrument/ExchangeDelivery{date}.dat" headers = { "User-Agent": "Mozilla/5.0 (Wind...
--- +++ @@ -1,5 +1,9 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/1/22 20:30 +Desc: 期货-期转现-交割 +""" from io import StringIO, BytesIO @@ -8,6 +12,16 @@ def futures_to_spot_shfe(date: str = "202312") -> pd.DataFrame: + """ + 上海期货交易所-期转现 + https://tsite.shfe.com.cn/statements/dataview...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_to_spot.py
Add docstrings for internal functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import zipfile from io import BytesIO import pandas as pd import requests def index_all_cni() -> pd.DataFrame: url = "https://www.cnindex.com.cn/index/indexList" params = { "channelCode": "-1", "rows": "2000", "pageNum": "1", } r =...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2026/1/12 15:00 +Desc: 国证指数 +https://www.cnindex.com.cn/index.html +""" import zipfile from io import BytesIO @@ -9,6 +14,12 @@ def index_all_cni() -> pd.DataFrame: + """ + 国证指数-最近交易日的所有指数 + https://www.cnindex.com.cn/zh...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_cni.py
Add docstrings for internal functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import json import os import pickle import re futures_inventory_em_symbol_dict = { "a": "A", # 豆一 "ag": "AG", # 沪银 "al": "AL", # 沪铝 "ao": "AO", # 氧化铝 "AP": "AP", # 苹果 "au": "AU", # 沪金 "b": "B", # 豆二 "bb": None, # 胶合板...
--- +++ @@ -1,5 +1,9 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/7/21 15:00 +Desc: 期货配置文件 +""" import datetime import json @@ -516,6 +520,11 @@ def convert_date(date): + """ + transform a date string to datetime.date object + :param date, string, e.g. 2016-01-01, 20160101 or 2016/...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/cons.py
Add docstrings for production code
#!/usr/bin/env python # -*- coding:utf-8 -*- import time import pandas as pd import requests from akshare.fx.cons import ( SHORT_HEADERS, FX_SPOT_URL, FX_SWAP_URL, FX_PAIR_URL, ) def fx_spot_quote() -> pd.DataFrame: payload = {"t": str(int(round(time.time() * 1000)))} res = requests.post(FX...
--- +++ @@ -1,5 +1,12 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2022/6/28 14:57 +Desc: 中国外汇交易中心暨全国银行间同业拆借中心-市场数据-市场行情-外汇市场行情 +人民币外汇即期报价: fx_spot_quote +人民币外汇远掉报价: fx_swap_quote +外币对即期报价: fx_pair_quote +""" import time @@ -15,6 +22,12 @@ def fx_spot_quote() -> pd.DataFrame: + """ + 中国外汇...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fx/fx_quote.py
Document classes and their methods
#!/usr/bin/env python # -*- coding:utf-8 -*- import xml.etree.ElementTree as ET import pandas as pd import requests def futures_contract_info_czce(date: str = "20240228") -> pd.DataFrame: headers = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9," "image/webp,image/apng,*/*;q=...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/4/11 16:30 +Desc: 郑州商品交易所-交易数据-参考数据 +http://www.czce.com.cn/cn/jysj/cksj/H770322index_1.htm +""" import xml.etree.ElementTree as ET @@ -8,6 +13,14 @@ def futures_contract_info_czce(date: str = "20240228") -> pd.DataFrame: +...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures_derivative/futures_contract_info_czce.py
Write documentation strings for class attributes
#!/usr/bin/env python # -*- coding:utf-8 -*- import math from typing import Optional import pandas as pd import requests from akshare.utils.tqdm import get_tqdm def __futures_global_hist_market_code(symbol: str = "HG00Y") -> Optional[int]: # 提取品种代码(去掉年份和月份部分) base_symbol = "" i = 0 while i < len(sy...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/9 22:00 +Desc: 东方财富网-行情中心-期货市场-国际期货 +https://quote.eastmoney.com/center/gridlist.html#futures_global +""" import math from typing import Optional @@ -11,6 +16,14 @@ def __futures_global_hist_market_code(symbol: str = "HG00...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_hf_em.py
Include argument descriptions in docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import xml.etree.ElementTree as ET import pandas as pd import requests def futures_contract_info_cffex(date: str = "20240228") -> pd.DataFrame: headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/2/28 17:00 +Desc: 中国金融期货交易所-数据-交易参数 +http://www.cffex.com.cn/jycs/ +""" import xml.etree.ElementTree as ET @@ -8,6 +13,14 @@ def futures_contract_info_cffex(date: str = "20240228") -> pd.DataFrame: + """ + 中国金融期货交易所-数...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures_derivative/futures_contract_info_cffex.py
Add documentation for all methods
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.utils.tqdm import get_tqdm def futures_comex_inventory(symbol: str = "黄金") -> pd.DataFrame: symbol_map = { "黄金": "EMI00069026", "白银": "EMI00069027", } url = "https://datacenter-web.eastmoney.com...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/11/15 18:00 +Desc: 东方财富网-数据中心-期货期权-COMEX库存数据 +https://data.eastmoney.com/pmetal/comex/by.html +""" import pandas as pd import requests @@ -8,6 +13,14 @@ def futures_comex_inventory(symbol: str = "黄金") -> pd.DataFrame: + "...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_comex_em.py
Add docstrings to improve readability
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO import pandas as pd import requests from bs4 import BeautifulSoup def _futures_comm_qihuo_process(df: pd.DataFrame, name: str = None) -> pd.DataFrame: import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/4/11 17:00 +Desc: 九期网-期货手续费 +https://www.9qihuo.com/qihuoshouxufei +""" from io import StringIO @@ -9,6 +14,16 @@ def _futures_comm_qihuo_process(df: pd.DataFrame, name: str = None) -> pd.DataFrame: + """ + 期货手续费数据细节处...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_comm_qihuo.py
Add docstrings following best practices
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import re import warnings from io import BytesIO from typing import List import pandas as pd import requests from akshare.futures import cons from akshare.futures.requests_fun import requests_link, pandas_read_html_link from akshare.futures.symbol_var impo...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/7/21 15:00 +Desc: 每日注册仓单数据 +大连商品交易所, 上海期货交易所, 郑州商品交易所, 广州期货交易所 +""" import datetime import re @@ -30,6 +35,16 @@ def get_dce_receipt(date: str = None, vars_list: List = cons.contract_symbols): + """ + 大连商品交易所-注册仓单数据 + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/receipt.py
Document classes and their methods
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def futures_contract_info_dce() -> pd.DataFrame: url = "http://www.dce.com.cn/dcereport/publicweb/tradepara/contractInfo" payload = { "lang": "zh", "tradeType": "1", "varietyId": "all", } r = requ...
--- +++ @@ -1,11 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/8/18 11:00 +Desc: 大连商品交易所-业务/服务-业务参数-交易参数-合约信息查询 +http://www.dce.com.cn/dalianshangpin/ywfw/ywcs/jycs/hyxxcx/index.html +""" import pandas as pd import requests def futures_contract_info_dce() -> pd.DataFrame: + """ + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures_derivative/futures_contract_info_dce.py
Add docstrings for internal functions
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests def futures_news_shmet(symbol: str = "全部") -> pd.DataFrame: url = "https://www.shmet.com/api/rest/news/queryNewsflashList" if symbol == "全部": payload = {"currentPage": 1, "pageSize": 100} else: symbol_map = ...
--- +++ @@ -1,11 +1,24 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2024/12/26 18:00 +Desc: 上海金属网-快讯 +https://www.shmet.com/newsFlash/newsFlash.html?searchKeyword= +""" import pandas as pd import requests def futures_news_shmet(symbol: str = "全部") -> pd.DataFrame: + """ + 上海金属网-快讯 + h...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_news_shmet.py
Generate helpful docstrings for debugging
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import re import time import warnings from typing import List import pandas as pd from akshare.futures import cons from akshare.futures.requests_fun import pandas_read_html_link from akshare.futures.symbol_var import chinese_to_english calendar = cons.get...
--- +++ @@ -1,5 +1,17 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/12/12 17:00 +Desc: 生意社网站采集大宗商品现货价格及相应基差数据, 数据时间段从 20110104-至今 +备注:现期差 = 现货价格 - 期货价格(这里的期货价格为结算价) +黄金为 元/克, 白银为 元/千克, 玻璃现货为 元/平方米, 鸡蛋现货为 元/公斤, 鸡蛋期货为 元/500千克, 其余为 元/吨. +焦炭现货规格是: 一级冶金焦; 焦炭期货规格: 介于一级和二级之间, 焦炭现期差仅供参考. +铁矿石现货价格是: 湿吨, 铁矿石期...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_basis.py
Add docstrings with type hints explained
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO import pandas as pd import requests from bs4 import BeautifulSoup def __get_sys_spot_futures_dict() -> dict: url = "https://www.100ppi.com/sf/792.html" res = requests.get(url) soup = BeautifulSoup(res.text, features="lxml") temp_it...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/4/5 20:20 +Desc: 生意社-商品与期货-现期图 +https://www.100ppi.com/sf/792.html +""" from io import StringIO @@ -9,6 +14,12 @@ def __get_sys_spot_futures_dict() -> dict: + """ + 生意社-商品与期货-现期图: 品种和网址字典 + https://www.100ppi.com/s...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures_derivative/futures_spot_sys.py
Add docstrings to improve readability
# -*- coding:utf-8 -*- # !/usr/bin/env python import json import pandas as pd import requests def futures_index_ccidx(symbol: str = "中证商品期货指数") -> pd.DataFrame: futures_index_map = { "中证商品期货指数": "100001.CCI", "中证商品期货价格指数": "000001.CCI", } url = "http://www.ccidx.com/CCI-ZZZS/index/getDat...
--- +++ @@ -1,5 +1,10 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/10/29 15:00 +Desc: 中证商品指数 +http://www.ccidx.com/ +""" import json @@ -8,6 +13,14 @@ def futures_index_ccidx(symbol: str = "中证商品期货指数") -> pd.DataFrame: + """ + 中证商品指数-商品指数-日频率 + http://www.ccidx.com/index.html + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_index_ccidx.py
Add docstrings to my Python code
#!/usr/bin/env python # -*- coding:utf-8 -*- import ssl import pandas as pd import requests from requests.adapters import HTTPAdapter class LegacySSLAdapter(HTTPAdapter): def init_poolmanager(self, *args, **kwargs): context = ssl.create_default_context() # 允许不安全的 legacy renegotiation con...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/9/9 14:57 +Desc: 中国外汇交易中心暨全国银行间同业拆借中心-基准-外汇市场-外汇掉期曲线-外汇掉漆 C-Swap 定盘曲线 +https://www.chinamoney.org.cn/chinese/bkcurvfsw +""" import ssl @@ -18,6 +23,12 @@ def fx_c_swap_cm(): + """ + 中国外汇交易中心暨全国银行间同业拆借中心-基准-外汇市场-外汇掉期曲线...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fx/fx_c_swap_cm.py
Create documentation strings for testing functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import re from io import BytesIO, StringIO import pandas as pd import requests def futures_warehouse_receipt_czce(date: str = "20251103") -> dict: import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) if int(date) > 20251101: ...
--- +++ @@ -1,5 +1,17 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/7/1 16:30 +Desc: 期货-仓单日报 +上海期货交易所-仓单日报 +https://tsite.shfe.com.cn/statements/dataview.html?paramid=dailystock +郑州商品交易所-交易数据-仓单日报 +http://www.czce.com.cn/cn/jysj/cdrb/H770310index_1.htm +大连商品交易所-行情数据-统计数据-日统计-仓单日报 +http://www.dce.com...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_warehouse_receipt.py
Write clean docstrings for readability
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd from curl_cffi import requests def fx_quote_baidu(symbol: str = "人民币") -> pd.DataFrame: symbol_map = { "人民币": "rmb", "美元": "dollar", } num = 0 out_df = pd.DataFrame() while True: try: url = "https...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2026/1/9 22:12 +Desc: 百度股市通-外汇-行情榜单 +https://gushitong.baidu.com/top/foreign-common-%E5%B8%B8%E7%94%A8 +""" import pandas as pd from curl_cffi import requests def fx_quote_baidu(symbol: str = "人民币") -> pd.DataFrame: + """ + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fx/fx_quote_baidu.py
Write docstrings for this repository
#!/usr/bin/env python # -*- coding:utf-8 -*- from datetime import datetime from io import StringIO import pandas as pd import requests from akshare.futures.futures_hq_sina import ( futures_foreign_commodity_subscribe_exchange_symbol, ) def futures_foreign_hist(symbol: str = "ZSD") -> pd.DataFrame: today = ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/5 18:00 +Desc: 外盘期货-历史行情数据-日频率 +https://finance.sina.com.cn/money/future/hf.html +""" from datetime import datetime from io import StringIO @@ -13,6 +18,14 @@ def futures_foreign_hist(symbol: str = "ZSD") -> pd.DataFrame: ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_foreign.py
Write reusable docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def futures_contract_info_ine(date: str = "20241129") -> pd.DataFrame: url = f"https://www.ine.cn/data/busiparamdata/future/ContractBaseInfo{date}.dat" params = {"rnd": "0.8312696798757147"} headers = { "User-Agent":...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/11/30 19:00 +Desc: 上海国际能源交易中心-业务指南-交易参数汇总(期货) +https://www.ine.cn/bourseService/summary/?name=currinstrumentprop +""" import pandas as pd import requests def futures_contract_info_ine(date: str = "20241129") -> pd.DataFram...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures_derivative/futures_contract_info_ine.py
Add docstrings for production code
#!/usr/bin/env python # -*- coding:utf-8 -*- import math from io import BytesIO, StringIO import pandas as pd import requests from bs4 import BeautifulSoup from akshare.utils import demjson def index_stock_cons_sina(symbol: str = "000300") -> pd.DataFrame: if symbol == "000300": symbol = "hs300" ...
--- +++ @@ -1,5 +1,11 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/6/17 14:00 +Desc: 股票指数成份股数据, 新浪有两个接口, 这里使用老接口: +新接口:https://vip.stock.finance.sina.com.cn/mkt/#zhishu_000001 +老接口:https://vip.stock.finance.sina.com.cn/corp/view/vII_NewestComponent.php?page=1&indexid=399639 +""" import math fro...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_cons.py
Write docstrings describing functionality
#!/usr/bin/env python # -*- coding:utf-8 -*- import time from typing import Union, List import pandas as pd import requests from bs4 import BeautifulSoup from akshare.utils import demjson def _get_real_name_list() -> list: url = "https://finance.sina.com.cn/money/future/hf.html" r = requests.get(url) r...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/5 18:00 +Desc: 新浪财经-外盘期货 +https://finance.sina.com.cn/money/future/hf.html +""" import time from typing import Union, List @@ -12,6 +17,12 @@ def _get_real_name_list() -> list: + """ + 新浪-外盘期货所有品种的中文名称 + https://f...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_hq_sina.py
Help me comply with documentation standards
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd def hf_sp_500(year: str = "2017") -> pd.DataFrame: url = f"https://github.com/FutureSharks/financial-data/raw/master/pyfinancialdata/data/stocks/histdata/SPXUSD/DAT_ASCII_SPXUSD_M1_{year}.csv" temp_df = pd.read_table(url, header=None, sep=";") ...
--- +++ @@ -1,10 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2020/4/21 15:34 +Desc: 高频数据-标普 500 指数 +https://github.com/FutureSharks/financial-data +long history data for S&P 500 index daily +http://www.econ.yale.edu/~shiller/data.htm +""" import pandas as pd def hf_sp_500(year: str = "201...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/hf/hf_sp500.py
Add docstrings to existing functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def futures_hog_core(symbol: str = "外三元") -> pd.DataFrame: if symbol == "外三元": url = "https://xt.yangzhu.vip/data/getzhujiahitsdata" params = {"ptype": "1", "areano": "-1", "datetype": "0"} r = requests.post(...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/3/18 14:00 +Desc: 玄田数据 +https://zhujia.zhuwang.com.cn +""" import pandas as pd import requests def futures_hog_core(symbol: str = "外三元") -> pd.DataFrame: + """ + 玄田数据-核心数据 + https://zhujia.zhuwang.com.cn + :par...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures_derivative/futures_hog.py
Write docstrings including parameters and return values
#!/usr/bin/env python # -*- coding:utf-8 -*- import zipfile from io import BytesIO from io import StringIO import pandas as pd import requests def __fetch_ftse_index_futu(date: str = "20231108") -> int: url = "https://push2his.eastmoney.com/api/qt/stock/kline/get" params = { "secid": "100.STI", ...
--- +++ @@ -1,5 +1,11 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/1/18 16:25 +Desc: 新加坡交易所-衍生品-历史数据-历史结算价格 +https://www.sgx.com/zh-hans/research-education/derivatives +https://links.sgx.com/1.0.0/derivatives-daily/5888/FUTURE.zip +""" import zipfile from io import BytesIO @@ -10,6 +16,14 @@ ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_settlement_price_sgx.py
Expand my code with proper documentation strings
#!/usr/bin/env python # -*- coding:utf-8 -*- import json import pandas as pd import requests def futures_comm_js(date: str = "20260213") -> pd.DataFrame: headers = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/107.0.0.0 S...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2026/2/22 15:45 +Desc: 金十数据-期货手续费 +https://www.jin10.com/ +""" import json import pandas as pd @@ -7,6 +12,14 @@ def futures_comm_js(date: str = "20260213") -> pd.DataFrame: + """ + 金十财经-期货手续费 + https://www.jin10.com/ + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_comm_js.py
Can you add docstrings to this Python file?
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def futures_contract_info_gfex() -> pd.DataFrame: url = "http://www.gfex.com.cn/u/interfacesWebTtQueryContractInfo/loadList" params = { "variety": "", "trade_type": "0", } headers = { "User-Agent"...
--- +++ @@ -1,11 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/2/28 16:00 +Desc: 广州期货交易所-业务/服务-合约信息 +http://www.gfex.com.cn/gfex/hyxx/ywcs.shtml +""" import pandas as pd import requests def futures_contract_info_gfex() -> pd.DataFrame: + """ + 广州期货交易所-业务/服务-合约信息 + http://www....
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures_derivative/futures_contract_info_gfex.py
Generate docstrings with examples
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def futures_stock_shfe_js(date: str = "20240419") -> pd.DataFrame: headers = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/107.0.0.0 Safari/537.36", ...
--- +++ @@ -1,11 +1,25 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/4/24 18:10 +Desc: 上海期货交易所指定交割仓库库存周报 +https://datacenter.jin10.com/reportType/dc_shfe_weekly_stock +https://tsite.shfe.com.cn/statements/dataview.html?paramid=kx +""" import pandas as pd import requests def futures_stock_sh...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_stock_js.py
Write docstrings for data processing functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import json from datetime import datetime from functools import lru_cache import pandas as pd import requests from bs4 import BeautifulSoup @lru_cache(maxsize=32) def __get_99_symbol_map() -> pd.DataFrame: import warnings warnings.filterwarnings("ignore") url...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/11/25 18:00 +Desc: 99 期货网-大宗商品库存数据 +https://www.99qh.com/ +""" import json from datetime import datetime @@ -12,6 +17,12 @@ @lru_cache(maxsize=32) def __get_99_symbol_map() -> pd.DataFrame: + """ + 99 期货网-品种代码对照表 + h...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_inventory_99.py
Document this script properly
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import json import re import time import warnings import zipfile from io import BytesIO from io import StringIO import pandas as pd import requests from bs4 import BeautifulSoup from akshare.futures import cons from akshare.futures.requests_fun import requ...
--- +++ @@ -1,5 +1,18 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/7/21 15:00 +Desc: 期货-中国-交易所-会员持仓数据接口 +大连商品交易所、上海期货交易所、郑州商品交易所、中国金融期货交易所、广州期货交易所 +采集前 20 会员持仓数据; +建议下午 16:30 以后采集当天数据, 避免交易所数据更新不稳定; +郑州商品交易所格式分为三类 +大连商品交易所有具体合约的持仓排名, 通过 futures_dce_position_rank 获取 +20171228 +http://www.czce.com.cn...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/cot.py
Generate docstrings for script automation
#!/usr/bin/env python # -*- coding:utf-8 -*- import re from akshare.futures import cons def symbol_varieties(contract_code: str): symbol_detail = "".join(re.findall(r"\D", contract_code)).upper().strip() if symbol_detail == "PTA": symbol_detail = "TA" return symbol_detail def symbol_market(sym...
--- +++ @@ -1,5 +1,9 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/7/21 15:00 +Desc: 期货品种映射表 +""" import re @@ -7,6 +11,11 @@ def symbol_varieties(contract_code: str): + """ + 查找到具体合约代码, 返回大写字母的品种名称 + :param contract_code: ru1801 + :return: RU + """ symbol_detail = "".jo...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/symbol_var.py
Add inline docstrings for readability
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO import pandas as pd import requests def futures_hold_pos_sina( symbol: str = "成交量", contract: str = "OI2501", date: str = "20240223" ) -> pd.DataFrame: date = "-".join([date[:4], date[4:6], date[6:]]) url = "https://vip.stock.finance.s...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/5 18:00 +Desc: 新浪财经-期货-成交持仓 +https://vip.stock.finance.sina.com.cn/q/view/vFutures_Positions_cjcc.php +""" from io import StringIO @@ -10,6 +15,18 @@ def futures_hold_pos_sina( symbol: str = "成交量", contract: str = "OI250...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures_derivative/futures_cot_sina.py
Write docstrings for algorithm functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def index_price_cflp(symbol: str = "周指数") -> pd.DataFrame: symbol_map = { "周指数": "2", "月指数": "3", "季度指数": "4", "年度指数": "5", } url = "http://index.0256.cn/expcenter_trend.action" params = {...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2021/12/27 15:47 +Desc: 中国公路物流运价、运量指数 +http://index.0256.cn/expx.htm +""" import pandas as pd import requests def index_price_cflp(symbol: str = "周指数") -> pd.DataFrame: + """ + 中国公路物流运价指数 + http://index.0256.cn/expx.ht...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_cflp.py
Document all endpoints with docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- from io import StringIO import pandas as pd import requests from bs4 import BeautifulSoup def futures_contract_detail(symbol: str = "AP2101") -> pd.DataFrame: url = f"https://finance.sina.com.cn/futures/quotes/{symbol}.shtml" r = requests.get(url) r.encoding ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/10/30 17:00 +Desc: 查询期货合约当前时刻的详情 +https://finance.sina.com.cn/futures/quotes/V2101.shtml +""" from io import StringIO @@ -9,6 +14,14 @@ def futures_contract_detail(symbol: str = "AP2101") -> pd.DataFrame: + """ + 查询期货...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_contract_detail.py
Write docstrings for this repository
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from bs4 import BeautifulSoup from akshare.utils.tqdm import get_tqdm def currency_pair_map(symbol: str = "美元") -> pd.DataFrame: region_code = [] region_name = [] headers = { "Accept": "application/json, text/javascr...
--- +++ @@ -1,5 +1,11 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/6/26 15:33 +Desc: 英为财情-外汇-货币对历史数据 +https://cn.investing.com/currencies/ +https://cn.investing.com/currencies/eur-usd-historical-data +""" import pandas as pd import requests @@ -8,6 +14,14 @@ def currency_pair_map(symbol: st...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/fx/currency_investing.py
Create documentation strings for testing functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import time from io import StringIO from typing import Dict import pandas as pd import requests def requests_link( url: str, encoding: str = "utf-8", method: str = "get", data: Dict = None, headers: Dict = None, ): i = 0 while True: tr...
--- +++ @@ -1,5 +1,9 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/9/15 19:00 +Desc: 请求网站内容的函数: 在链接失败后可重复 20 次 +""" import time from io import StringIO @@ -16,6 +20,15 @@ data: Dict = None, headers: Dict = None, ): + """ + 利用 requests 请求网站, 爬取网站内容, 如网站链接失败, 可重复爬取 20 次 + :param...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/requests_fun.py
Add docstrings to clarify complex logic
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import json import re import zipfile from io import BytesIO, StringIO import numpy as np import pandas as pd import requests from akshare.futures import cons from akshare.futures.requests_fun import requests_link calendar = cons.get_calendar() def _futu...
--- +++ @@ -1,5 +1,9 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/11/30 18:00 +Desc: 期货日线行情 +""" import datetime import json @@ -20,6 +24,16 @@ def _futures_daily_czce( date: str = "20100824", dataset: str = "datahistory2010" ) -> pd.DataFrame: + """ + 郑州商品交易所-交易数据-历史行情下载 + http:...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_daily_bar.py
Can you add docstrings to this Python file?
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.utils import demjson def futures_spot_stock(symbol: str = "能源") -> pd.DataFrame: map_dict = { "能源": 0, "化工": 1, "塑料": 2, "纺织": 3, "有色": 4, "钢铁": 5, "建材": 6, ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/3/21 12:00 +Desc: 东方财富网-数据中心-现货与股票 +https://data.eastmoney.com/ifdata/xhgp.html +""" import pandas as pd import requests @@ -8,6 +13,14 @@ def futures_spot_stock(symbol: str = "能源") -> pd.DataFrame: + """ + 东方财富网-数据中心-...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_spot_stock_em.py
Generate docstrings with parameter types
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def futures_contract_info_shfe(date: str = "20240513") -> pd.DataFrame: url = ( f"https://www.shfe.com.cn/data/busiparamdata/future/ContractBaseInfo{date}.dat" ) headers = { "User-Agent": "Mozilla/5.0 (Window...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/5/13 17:45 +Desc: 上海期货交易所-交易所服务-业务数据-交易参数汇总查询 +https://tsite.shfe.com.cn/bourseService/businessdata/summaryinquiry/ +""" import pandas as pd import requests def futures_contract_info_shfe(date: str = "20240513") -> pd.Data...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures_derivative/futures_contract_info_shfe.py
Create docstrings for all classes and functions
#!/usr/bin/env python # -*- coding:utf-8 -*- import json import time from functools import lru_cache import pandas as pd import requests import py_mini_racer from akshare.futures.cons import ( zh_subscribe_exchange_symbol_url, zh_match_main_contract_url, zh_match_main_contract_payload, ) from akshare.fut...
--- +++ @@ -1,5 +1,11 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/3/20 16:00 +Desc: 新浪财经-国内期货-实时数据获取 +https://vip.stock.finance.sina.com.cn/quotes_service/view/qihuohangqing.html#titlePos_3 +P.S. 注意采集速度, 容易封禁 IP, 如果不能访问请稍后再试 +""" import json import time @@ -20,6 +26,12 @@ @lru_cache() def f...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_zh_sina.py
Auto-generate documentation strings for this file
#!/usr/bin/env python # -*- coding:utf-8 -*- from datetime import datetime from io import StringIO import pandas as pd import requests from bs4 import BeautifulSoup def futures_fees_info() -> pd.DataFrame: url = "http://openctp.cn/fees.html" r = requests.get(url) r.encoding = "utf-8" soup = Beautifu...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/7/6 18:00 +Desc: openctp 期货交易费用参照表 +http://openctp.cn/fees.html +""" from datetime import datetime from io import StringIO @@ -10,6 +15,12 @@ def futures_fees_info() -> pd.DataFrame: + """ + openctp 期货交易费用参照表 + http...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_comm_ctp.py
Document all endpoints with docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import pandas as pd import requests from io import StringIO from akshare.futures import cons from akshare.utils.cons import headers gfex_headers = { "Accept": "application/json, text/javascript, */*; q=0.01", "Accept-Language": "zh-CN,zh;q=0.9,en;...
--- +++ @@ -1,5 +1,16 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2026/2/20 10:00 +Desc: 期货结算信息 +期货交易所结算参数数据 +- 中金所: 结算参数(保证金、手续费等) - 已实现 +- 郑商所: 结算参数 - 已实现 +- 上期所: 结算参数 - 已实现 +- 广期所: 结算参数 - 已实现 +- 上能中心: 结算参数 - 已实现 +- 大商所: 待解决(网站反爬虫保护,所有接口返回412错误) +""" import datetime @@ -46,6 +57,13 @@ def _n...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_settle.py
Add concise docstrings to each method
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.index.cons import index_global_em_symbol_map def index_global_spot_em() -> pd.DataFrame: url = "https://push2.eastmoney.com/api/qt/clist/get" params = { "np": "2", "fltt": "1", "invt": "2", ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/7 17:00 +Desc: 东方财富网-行情中心-全球指数 +https://quote.eastmoney.com/center/gridlist.html#global_qtzs +""" import pandas as pd import requests @@ -8,6 +13,12 @@ def index_global_spot_em() -> pd.DataFrame: + """ + 东方财富网-行情中心-全...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_global_em.py
Add documentation for all methods
#!/usr/bin/env python # -*- coding:utf-8 -*- import warnings from io import BytesIO import pandas as pd import requests def index_csindex_all() -> pd.DataFrame: warnings.filterwarnings( "ignore", category=UserWarning, message="Workbook contains no default style" ) url = "https://www.csindex.com....
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/8/4 14:00 +Desc: 中证指数网站-指数列表 +网站:https://www.csindex.com.cn/#/indices/family/list?index_series=1 +""" import warnings from io import BytesIO @@ -9,6 +14,13 @@ def index_csindex_all() -> pd.DataFrame: + """ + 中证指数网站-指数列...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_csindex.py
Document this script properly
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def index_eri(symbol: str = "月度") -> pd.DataFrame: symbol_map = { "月度": "MONTH", "季度": "QUARTER", } url = "https://zs.zjpwq.net/pwq-index-webapi/indexData" params = { "cycle": symbol_map[symbol], ...
--- +++ @@ -1,11 +1,24 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2023/6/19 18:16 +Desc: 浙江省排污权交易指数 +https://zs.zjpwq.net/ +""" import pandas as pd import requests def index_eri(symbol: str = "月度") -> pd.DataFrame: + """ + 浙江省排污权交易指数 + https://zs.zjpwq.net + :param symbol: choice ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_eri.py
Add docstrings to improve code quality
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests def index_news_sentiment_scope() -> pd.DataFrame: url = "https://www.chinascope.com/inews/senti/index" params = {"period": "YEAR"} r = requests.get(url=url, params=params) data_json = r.json() temp_df = pd.DataFrame(...
--- +++ @@ -1,11 +1,22 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/4/17 19:00 +Desc: 数库-A股新闻情绪指数 +https://www.chinascope.com/reasearch.html +""" import pandas as pd import requests def index_news_sentiment_scope() -> pd.DataFrame: + """ + 数库-A股新闻情绪指数 + https://www.chinascope.com/...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_zh_a_scope.py
Create simple docstrings for beginners
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd import requests def index_pmi_com_cx() -> pd.DataFrame: url = "https://yun.ccxe.com.cn/api/index/pro/cxIndexTrendInfo" params = {"type": "com"} r = requests.get(url, params=params) data_json = r.json() temp_df = pd.DataFrame(data_j...
--- +++ @@ -1,11 +1,22 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/8/7 18:30 +Desc: 财新数据-指数报告-数字经济指数 +https://yun.ccxe.com.cn/indices/dei +""" import pandas as pd import requests def index_pmi_com_cx() -> pd.DataFrame: + """ + 财新数据-指数报告-财新中国 PMI-综合 PMI + https://yun.ccxe.com.cn/...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_cx.py
Add docstrings including usage examples
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from akshare.utils.tqdm import get_tqdm def rate_interbank( market: str = "上海银行同业拆借市场", symbol: str = "Shibor人民币", indicator: str = "隔夜", ): market_map = { "上海银行同业拆借市场": "001", "中国银行同业拆借市场": "002", ...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/5/11 22:00 +Desc: 东方财富网-经济数据-银行间拆借利率 +https://data.eastmoney.com/shibor/shibor.aspx +""" import pandas as pd import requests @@ -11,6 +16,18 @@ symbol: str = "Shibor人民币", indicator: str = "隔夜", ): + """ + 东方财富-拆借...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/interest_rate/interbank_rate_em.py
Turn comments into proper docstrings
#!/usr/bin/env python # -*- coding:utf-8 -*- from functools import lru_cache import pandas as pd import requests from akshare.utils.func import fetch_paginated_data @lru_cache() def index_code_id_map_em() -> dict: url = "https://80.push2.eastmoney.com/api/qt/clist/get" params = { "pn": "1", ...
--- +++ @@ -1,5 +1,9 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/11 17:00 +Desc: 东方财富网-指数行情数据 +""" from functools import lru_cache @@ -11,6 +15,12 @@ @lru_cache() def index_code_id_map_em() -> dict: + """ + 东方财富-股票和市场代码 + https://quote.eastmoney.com/center/gridlist.html#hs_a_boa...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_zh_em.py
Create docstrings for each class method
#!/usr/bin/env python # -*- coding:utf-8 -*- import pandas as pd import requests from bs4 import BeautifulSoup from akshare.utils import demjson def drewry_wci_index(symbol: str = "composite") -> pd.DataFrame: symbol_map = { "composite": 0, "shanghai-rotterdam": 1, "rotterdam-shanghai": ...
--- +++ @@ -1,5 +1,11 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/9/26 18:00 +Desc: Drewry 集装箱指数 +https://www.drewry.co.uk/supply-chain-advisors/supply-chain-expertise/world-container-index-assessed-by-drewry +https://infogram.com/world-container-index-1h17493095xl4zj +""" import pandas as pd ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_drewry.py
Write docstrings describing functionality
#!/usr/bin/env python # -*- coding:utf-8 -*- import re from functools import lru_cache from typing import Tuple, Dict import pandas as pd import requests def __futures_hist_separate_char_and_numbers_em(symbol: str = "焦煤2506") -> tuple: char = re.findall(pattern="[\u4e00-\u9fa5a-zA-Z]+", string=symbol) numbe...
--- +++ @@ -1,5 +1,10 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2024/2/20 17:00 +Desc: 东方财富网-期货行情 +https://qhweb.eastmoney.com/quote +""" import re from functools import lru_cache @@ -10,6 +15,14 @@ def __futures_hist_separate_char_and_numbers_em(symbol: str = "焦煤2506") -> tuple: + """ + ...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/futures/futures_hist_em.py
Write Python docstrings for this snippet
# -*- coding:utf-8 -*- # !/usr/bin/env python import pandas as pd from functools import lru_cache @lru_cache def __get_optbbs_daily() -> pd.DataFrame: url = "http://1.optbbs.com/d/csv/d/k.csv" temp_df = pd.read_csv(url, encoding="gbk") return temp_df def index_option_50etf_qvix() -> pd.DataFrame: t...
--- +++ @@ -1,5 +1,12 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2023/10/19 16:00 +Desc: 50 ETF 期权波动率指数 QVIX +300 ETF 期权波动率指数 QVIX +http://1.optbbs.com/s/vix.shtml?50ETF +http://1.optbbs.com/s/vix.shtml?300ETF +""" import pandas as pd from functools import lru_cache @@ -7,12 +14,24 @@ @lru_cach...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_option_qvix.py
Add concise docstrings to each method
# -*- coding:utf-8 -*- # !/usr/bin/env python from io import BytesIO import pandas as pd import requests def option_current_day_szse() -> pd.DataFrame: import warnings warnings.filterwarnings( action="ignore", message="Workbook contains no default style" ) url = "https://www.sse.org.cn/api/...
--- +++ @@ -1,5 +1,9 @@ # -*- coding:utf-8 -*- # !/usr/bin/env python +""" +Date: 2025/9/13 16:00 +Desc: 深圳证券交易所-期权子网-行情数据-当日合约 +""" from io import BytesIO @@ -8,6 +12,12 @@ def option_current_day_szse() -> pd.DataFrame: + """ + 深圳证券交易所-期权子网-行情数据-当日合约 + https://www.sse.org.cn/option/quotation/contrac...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/option_current_szse.py
Add docstrings to improve code quality
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import json import os import re # 中国金融期货交易所 CFFEX_OPTION_URL_300 = "http://www.cffex.com.cn/quote_IO.txt" # 深圳证券交易所 SZ_OPTION_URL_300 = "http://www.szse.cn/api/report/ShowReport?SHOWTYPE=xlsx&CATALOGID=ysplbrb&TABKEY=tab1&random=0.10432465776720479" # 上...
--- +++ @@ -1,5 +1,9 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2019/9/30 13:58 +Desc: 期权配置文件 +""" import datetime import json @@ -59,6 +63,11 @@ def convert_date(date): + """ + transform a date string to datetime.date object + :param date, string, e.g. 2016-01-01, 20160101 or 2016/01...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/option/cons.py
Expand my code with proper documentation strings
#!/usr/bin/env python # -*- coding:utf-8 -*- import datetime import re import pandas as pd import py_mini_racer import requests from akshare.index.cons import ( zh_sina_index_stock_payload, zh_sina_index_stock_url, zh_sina_index_stock_count_url, zh_sina_index_stock_hist_url, ) from akshare.stock.cons...
--- +++ @@ -1,5 +1,11 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +""" +Date: 2025/3/10 18:30 +Desc: 股票指数数据-新浪-东财-腾讯 +所有指数-实时行情数据和历史行情数据 +https://finance.sina.com.cn/realstock/company/sz399552/nc.shtml +""" import datetime import re @@ -21,6 +27,13 @@ def _replace_comma(x): + """ + 去除单元格中的 "," + :...
https://raw.githubusercontent.com/akfamily/akshare/HEAD/akshare/index/index_stock_zh.py