akshare 1.12.99__py3-none-any.whl → 1.15.72__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of akshare might be problematic. Click here for more details.
- akshare/__init__.py +441 -138
- akshare/air/air_hebei.py +79 -53
- akshare/air/air_zhenqi.py +29 -43
- akshare/air/sunrise_tad.py +32 -17
- akshare/bank/bank_cbirc_2020.py +12 -9
- akshare/bond/bond_cb_ths.py +17 -9
- akshare/bond/bond_china.py +38 -39
- akshare/bond/bond_china_money.py +75 -48
- akshare/bond/bond_info_cm.py +28 -8
- akshare/bond/bond_issue_cninfo.py +73 -30
- akshare/bond/bond_zh_cov.py +1 -1
- akshare/bond/bond_zh_sina.py +57 -51
- akshare/cal/__init__.py +0 -0
- akshare/cal/rv.py +170 -0
- akshare/cost/cost_living.py +7 -5
- akshare/currency/currency_safe.py +7 -6
- akshare/data/cninfo.js +15 -0
- akshare/datasets.py +10 -21
- akshare/economic/macro_bank.py +95 -653
- akshare/economic/macro_china.py +772 -1024
- akshare/economic/macro_china_hk.py +65 -243
- akshare/economic/macro_china_nbs.py +24 -7
- akshare/economic/macro_constitute.py +17 -12
- akshare/economic/macro_euro.py +13 -6
- akshare/economic/macro_finance_ths.py +133 -0
- akshare/economic/macro_info_ws.py +100 -0
- akshare/economic/macro_japan.py +5 -4
- akshare/economic/macro_other.py +12 -9
- akshare/economic/macro_usa.py +376 -1940
- akshare/economic/marco_cnbs.py +11 -6
- akshare/energy/energy_carbon.py +94 -125
- akshare/event/migration.py +3 -2
- akshare/exceptions.py +43 -0
- akshare/file_fold/calendar.json +245 -2
- akshare/fortune/fortune_500.py +15 -48
- akshare/fund/fund_amac.py +157 -75
- akshare/fund/fund_em.py +191 -184
- akshare/fund/fund_etf_em.py +16 -15
- akshare/fund/fund_etf_sina.py +71 -23
- akshare/fund/fund_etf_ths.py +93 -0
- akshare/fund/fund_fee_em.py +98 -0
- akshare/fund/fund_portfolio_em.py +60 -50
- akshare/fund/fund_rank_em.py +91 -82
- akshare/fund/fund_report_cninfo.py +63 -48
- akshare/fund/fund_scale_sina.py +20 -10
- akshare/fund/fund_xq.py +139 -109
- akshare/futures/cons.py +8 -31
- akshare/futures/cot.py +185 -137
- akshare/futures/futures_basis.py +97 -32
- akshare/futures/futures_comm_ctp.py +37 -0
- akshare/futures/futures_comm_qihuo.py +74 -45
- akshare/futures/futures_daily_bar.py +121 -184
- akshare/futures/futures_hf_em.py +66 -61
- akshare/futures/futures_hq_sina.py +79 -61
- akshare/futures/futures_index_ccidx.py +6 -3
- akshare/futures/futures_inventory_99.py +61 -272
- akshare/futures/futures_news_shmet.py +4 -2
- akshare/futures/futures_roll_yield.py +12 -25
- akshare/futures/futures_spot_stock_em.py +19 -13
- akshare/futures/futures_stock_js.py +14 -12
- akshare/futures/futures_to_spot.py +38 -33
- akshare/futures/futures_warehouse_receipt.py +75 -71
- akshare/futures/futures_zh_sina.py +5 -5
- akshare/futures/symbol_var.py +18 -13
- akshare/futures_derivative/futures_contract_info_czce.py +60 -52
- akshare/futures_derivative/futures_contract_info_ine.py +43 -34
- akshare/futures_derivative/futures_contract_info_shfe.py +46 -35
- akshare/futures_derivative/futures_cot_sina.py +26 -19
- akshare/futures_derivative/futures_spot_sys.py +21 -8
- akshare/fx/currency_investing.py +19 -285
- akshare/index/index_cflp.py +29 -26
- akshare/index/index_cni.py +86 -88
- akshare/index/index_cons.py +26 -10
- akshare/index/index_cx.py +248 -47
- akshare/index/index_drewry.py +17 -16
- akshare/index/index_option_qvix.py +329 -0
- akshare/index/index_research_fund_sw.py +134 -0
- akshare/index/{index_sw_research.py → index_research_sw.py} +122 -58
- akshare/index/index_spot.py +9 -5
- akshare/index/index_stock_hk.py +35 -16
- akshare/index/index_stock_us_sina.py +1 -1
- akshare/index/index_stock_zh.py +180 -89
- akshare/index/index_stock_zh_csindex.py +15 -369
- akshare/index/index_sw.py +62 -34
- akshare/index/index_yw.py +46 -23
- akshare/index/index_zh_a_scope.py +48 -0
- akshare/index/index_zh_em.py +6 -4
- akshare/interest_rate/interbank_rate_em.py +14 -9
- akshare/movie/artist_yien.py +32 -5
- akshare/movie/movie_yien.py +92 -18
- akshare/movie/video_yien.py +28 -5
- akshare/news/news_baidu.py +78 -44
- akshare/news/news_cctv.py +38 -38
- akshare/news/news_stock.py +6 -3
- akshare/nlp/nlp_interface.py +7 -8
- akshare/option/cons.py +11 -11
- akshare/option/option_comm_qihuo.py +86 -0
- akshare/option/option_commodity.py +178 -51
- akshare/option/option_daily_stats_sse_szse.py +146 -0
- akshare/option/option_em.py +147 -138
- akshare/option/option_finance_sina.py +160 -137
- akshare/option/option_lhb_em.py +62 -56
- akshare/option/option_risk_indicator_sse.py +17 -14
- akshare/other/other_car_cpca.py +934 -0
- akshare/other/{other_car.py → other_car_gasgoo.py} +15 -54
- akshare/qdii/__init__.py +0 -0
- akshare/qdii/qdii_jsl.py +233 -0
- akshare/request.py +117 -0
- akshare/spot/spot_hog_soozhu.py +232 -0
- akshare/spot/spot_price_qh.py +121 -0
- akshare/spot/spot_sge.py +63 -10
- akshare/stock/stock_allotment_cninfo.py +10 -9
- akshare/stock/stock_board_concept_em.py +23 -14
- akshare/stock/stock_board_industry_em.py +40 -34
- akshare/stock/stock_cg_equity_mortgage.py +15 -11
- akshare/stock/stock_cg_guarantee.py +41 -51
- akshare/stock/stock_cg_lawsuit.py +36 -35
- akshare/stock/stock_dividend_cninfo.py +12 -6
- akshare/stock/stock_dzjy_em.py +347 -260
- akshare/stock/stock_fund_em.py +332 -84
- akshare/stock/stock_hk_famous.py +108 -0
- akshare/stock/stock_hk_sina.py +8 -7
- akshare/stock/stock_hold_control_cninfo.py +100 -15
- akshare/stock/stock_hold_control_em.py +4 -3
- akshare/stock/stock_hold_num_cninfo.py +18 -12
- akshare/stock/stock_hot_rank_em.py +2 -1
- akshare/stock/stock_hot_search_baidu.py +5 -2
- akshare/stock/stock_industry_cninfo.py +24 -18
- akshare/stock/stock_industry_pe_cninfo.py +45 -31
- akshare/stock/stock_industry_sw.py +9 -10
- akshare/stock/stock_info.py +25 -15
- akshare/stock/stock_info_em.py +5 -2
- akshare/stock/stock_intraday_em.py +5 -2
- akshare/stock/stock_intraday_sina.py +22 -18
- akshare/stock/stock_ipo_summary_cninfo.py +25 -10
- akshare/stock/stock_new_cninfo.py +32 -19
- akshare/stock/stock_news_cx.py +39 -0
- akshare/stock/stock_profile_cninfo.py +9 -8
- akshare/stock/stock_rank_forecast.py +8 -6
- akshare/stock/stock_share_changes_cninfo.py +18 -14
- akshare/stock/stock_share_hold.py +24 -19
- akshare/stock/stock_summary.py +54 -26
- akshare/stock/stock_us_famous.py +15 -6
- akshare/stock/stock_us_pink.py +7 -5
- akshare/stock/stock_us_sina.py +15 -12
- akshare/stock/stock_xq.py +38 -12
- akshare/stock/stock_zh_a_sina.py +53 -78
- akshare/stock/stock_zh_b_sina.py +32 -55
- akshare/stock/stock_zh_kcb_report.py +11 -9
- akshare/stock/stock_zh_kcb_sina.py +67 -64
- akshare/stock_feature/stock_a_below_net_asset_statistics.py +5 -2
- akshare/stock_feature/stock_a_high_low.py +5 -2
- akshare/stock_feature/stock_a_indicator.py +12 -9
- akshare/stock_feature/stock_a_pe_and_pb.py +27 -6
- akshare/stock_feature/stock_account_em.py +58 -40
- akshare/stock_feature/stock_analyst_em.py +36 -27
- akshare/stock_feature/stock_board_industry_ths.py +136 -400
- akshare/stock_feature/stock_comment_em.py +118 -85
- akshare/stock_feature/stock_concept_futu.py +183 -0
- akshare/stock_feature/stock_cyq_em.py +58 -54
- akshare/stock_feature/stock_disclosure_cninfo.py +147 -102
- akshare/stock_feature/stock_esg_sina.py +216 -11
- akshare/stock_feature/stock_fhps_em.py +60 -25
- akshare/stock_feature/stock_fhps_ths.py +25 -6
- akshare/stock_feature/stock_fund_flow.py +38 -25
- akshare/stock_feature/stock_gdfx_em.py +180 -95
- akshare/stock_feature/stock_gdhs.py +73 -49
- akshare/stock_feature/stock_gpzy_em.py +78 -46
- akshare/stock_feature/stock_hist_em.py +55 -23
- akshare/stock_feature/stock_hk_valuation_baidu.py +20 -8
- akshare/stock_feature/stock_hsgt_em.py +184 -452
- akshare/stock_feature/stock_info.py +52 -29
- akshare/stock_feature/stock_inner_trade_xq.py +39 -31
- akshare/stock_feature/stock_irm_cninfo.py +32 -9
- akshare/stock_feature/stock_jgdy_em.py +41 -38
- akshare/stock_feature/stock_lh_yybpm.py +36 -37
- akshare/stock_feature/stock_lhb_em.py +135 -71
- akshare/stock_feature/stock_lhb_sina.py +93 -46
- akshare/stock_feature/stock_margin_em.py +102 -0
- akshare/stock_feature/{stock_sse_margin.py → stock_margin_sse.py} +21 -15
- akshare/stock_feature/{stock_szse_margin.py → stock_margin_szse.py} +23 -19
- akshare/stock_feature/stock_market_legu.py +13 -8
- akshare/stock_feature/stock_pankou_em.py +72 -34
- akshare/stock_feature/stock_report_em.py +244 -54
- akshare/stock_feature/stock_research_report_em.py +48 -19
- akshare/stock_feature/stock_sns_sseinfo.py +15 -12
- akshare/stock_feature/stock_sy_em.py +86 -33
- akshare/stock_feature/stock_technology_ths.py +152 -120
- akshare/stock_feature/stock_tfp_em.py +35 -13
- akshare/stock_feature/stock_three_report_em.py +119 -77
- akshare/stock_feature/stock_ttm_lyr.py +4 -7
- akshare/stock_feature/stock_value_em.py +83 -0
- akshare/stock_feature/stock_wencai.py +21 -9
- akshare/stock_feature/stock_yjyg_em.py +63 -28
- akshare/stock_feature/stock_zf_pg.py +61 -38
- akshare/stock_feature/stock_zh_valuation_baidu.py +3 -2
- akshare/stock_feature/stock_ztb_em.py +62 -40
- akshare/stock_fundamental/stock_finance.py +150 -58
- akshare/stock_fundamental/stock_finance_ths.py +116 -31
- akshare/stock_fundamental/stock_mda_ym.py +5 -3
- akshare/stock_fundamental/stock_notice.py +29 -15
- akshare/stock_fundamental/stock_profit_forecast_em.py +31 -13
- akshare/stock_fundamental/stock_profit_forecast_ths.py +19 -10
- akshare/stock_fundamental/stock_register_em.py +448 -0
- akshare/stock_fundamental/stock_restricted_em.py +79 -32
- akshare/stock_fundamental/stock_zygc.py +10 -8
- akshare/stock_fundamental/stock_zyjs_ths.py +5 -3
- akshare/tool/trade_date_hist.py +4 -3
- akshare/utils/cons.py +10 -0
- akshare/utils/context.py +43 -0
- akshare/utils/demjson.py +2 -2
- akshare/utils/func.py +26 -0
- akshare/utils/tqdm.py +13 -3
- {akshare-1.12.99.dist-info → akshare-1.15.72.dist-info}/METADATA +52 -69
- akshare-1.15.72.dist-info/RECORD +385 -0
- {akshare-1.12.99.dist-info → akshare-1.15.72.dist-info}/WHEEL +1 -1
- tests/test_func.py +3 -5
- akshare/bond/bond_futures.py +0 -50
- akshare/bond/bond_investing.py +0 -139
- akshare/crypto/crypto_hist_investing.py +0 -249
- akshare/fortune/fortune_it_juzi.py +0 -123
- akshare/futures/futures_international.py +0 -170
- akshare/futures/futures_news_baidu.py +0 -54
- akshare/futures/inventory_data.py +0 -100
- akshare/futures_derivative/futures_index_price_nh.py +0 -61
- akshare/futures_derivative/futures_index_return_nh.py +0 -47
- akshare/futures_derivative/futures_index_volatility_nh.py +0 -51
- akshare/futures_derivative/futures_other_index_nh.py +0 -145
- akshare/index/index_fear_greed_funddb.py +0 -71
- akshare/index/index_investing.py +0 -232
- akshare/sport/sport_olympic_winter.py +0 -39
- akshare/stock_feature/stock_board_concept_ths.py +0 -422
- akshare/stock_fundamental/stock_register.py +0 -292
- akshare-1.12.99.dist-info/RECORD +0 -374
- {akshare-1.12.99.dist-info → akshare-1.15.72.dist-info}/LICENSE +0 -0
- {akshare-1.12.99.dist-info → akshare-1.15.72.dist-info}/top_level.txt +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# -*- coding:utf-8 -*-
|
|
2
2
|
# !/usr/bin/env python
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/9/3 16:30
|
|
5
5
|
Desc: 主营构成
|
|
6
6
|
https://emweb.securities.eastmoney.com/PC_HSF10/BusinessAnalysis/Index?type=web&code=SH688041#
|
|
7
|
-
|
|
7
|
+
https://f10.emoney.cn/f10/zbyz/1000001
|
|
8
8
|
"""
|
|
9
|
+
|
|
9
10
|
from io import StringIO
|
|
10
11
|
|
|
11
12
|
import pandas as pd
|
|
@@ -16,7 +17,7 @@ from bs4 import BeautifulSoup
|
|
|
16
17
|
def stock_zygc_ym(symbol: str = "000001") -> pd.DataFrame:
|
|
17
18
|
"""
|
|
18
19
|
益盟-F10-主营构成
|
|
19
|
-
|
|
20
|
+
https://f10.emoney.cn/f10/zbyz/1000001
|
|
20
21
|
:param symbol: 股票代码
|
|
21
22
|
:type symbol: str
|
|
22
23
|
:return: 主营构成
|
|
@@ -24,12 +25,11 @@ def stock_zygc_ym(symbol: str = "000001") -> pd.DataFrame:
|
|
|
24
25
|
"""
|
|
25
26
|
url = f"http://f10.emoney.cn/f10/zygc/{symbol}"
|
|
26
27
|
r = requests.get(url)
|
|
27
|
-
soup = BeautifulSoup(r.text, "lxml")
|
|
28
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
28
29
|
year_list = [
|
|
29
30
|
item.text.strip()
|
|
30
31
|
for item in soup.find(attrs={"class": "swlab_t"}).find_all("li")
|
|
31
32
|
]
|
|
32
|
-
|
|
33
33
|
big_df = pd.DataFrame()
|
|
34
34
|
for i, item in enumerate(year_list, 2):
|
|
35
35
|
temp_df = pd.read_html(StringIO(r.text), header=0)[i]
|
|
@@ -113,8 +113,10 @@ def stock_zygc_em(symbol: str = "SH688041") -> pd.DataFrame:
|
|
|
113
113
|
"毛利率",
|
|
114
114
|
]
|
|
115
115
|
]
|
|
116
|
-
temp_df["报告日期"] = pd.to_datetime(temp_df["报告日期"]).dt.date
|
|
117
|
-
temp_df["分类类型"] = temp_df["分类类型"].map(
|
|
116
|
+
temp_df["报告日期"] = pd.to_datetime(temp_df["报告日期"], errors="coerce").dt.date
|
|
117
|
+
temp_df["分类类型"] = temp_df["分类类型"].map(
|
|
118
|
+
{"2": "按产品分类", "3": "按地区分类"}
|
|
119
|
+
)
|
|
118
120
|
temp_df["主营收入"] = pd.to_numeric(temp_df["主营收入"], errors="coerce")
|
|
119
121
|
temp_df["收入比例"] = pd.to_numeric(temp_df["收入比例"], errors="coerce")
|
|
120
122
|
temp_df["主营成本"] = pd.to_numeric(temp_df["主营成本"], errors="coerce")
|
|
@@ -126,7 +128,7 @@ def stock_zygc_em(symbol: str = "SH688041") -> pd.DataFrame:
|
|
|
126
128
|
|
|
127
129
|
|
|
128
130
|
if __name__ == "__main__":
|
|
129
|
-
stock_zygc_ym_df = stock_zygc_ym(symbol="
|
|
131
|
+
stock_zygc_ym_df = stock_zygc_ym(symbol="000338")
|
|
130
132
|
print(stock_zygc_ym_df)
|
|
131
133
|
|
|
132
134
|
stock_zygc_em_df = stock_zygc_em(symbol="SH688041")
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# -*- coding:utf-8 -*-
|
|
2
2
|
# !/usr/bin/env python
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/3/29 10:30
|
|
5
5
|
Desc: 同花顺-主营介绍
|
|
6
6
|
https://basic.10jqka.com.cn/new/000066/operate.html
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import pandas as pd
|
|
9
10
|
import requests
|
|
10
11
|
from bs4 import BeautifulSoup
|
|
@@ -19,9 +20,10 @@ def stock_zyjs_ths(symbol: str = "000066") -> pd.DataFrame:
|
|
|
19
20
|
:return: 主营介绍
|
|
20
21
|
:rtype: pandas.DataFrame
|
|
21
22
|
"""
|
|
22
|
-
url = f"
|
|
23
|
+
url = f"https://basic.10jqka.com.cn/new/{symbol}/operate.html"
|
|
23
24
|
headers = {
|
|
24
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
25
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
26
|
+
"Chrome/109.0.0.0 Safari/537.36"
|
|
25
27
|
}
|
|
26
28
|
r = requests.get(url, headers=headers)
|
|
27
29
|
r.encoding = "gb2312"
|
akshare/tool/trade_date_hist.py
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/3/25 16:30
|
|
5
5
|
Desc: 新浪财经-交易日历
|
|
6
6
|
https://finance.sina.com.cn/realstock/company/klc_td_sh.txt
|
|
7
7
|
此处可以用来更新 calendar.json 文件,注意末尾没有 "," 号
|
|
8
8
|
"""
|
|
9
|
+
|
|
9
10
|
import datetime
|
|
10
11
|
|
|
11
12
|
import pandas as pd
|
|
12
13
|
import requests
|
|
13
|
-
|
|
14
|
+
import py_mini_racer
|
|
14
15
|
|
|
15
16
|
from akshare.stock.cons import hk_js_decode
|
|
16
17
|
|
|
@@ -32,7 +33,7 @@ def tool_trade_date_hist_sina() -> pd.DataFrame:
|
|
|
32
33
|
temp_df["trade_date"] = pd.to_datetime(temp_df["trade_date"]).dt.date
|
|
33
34
|
temp_list = temp_df["trade_date"].to_list()
|
|
34
35
|
# 该日期是交易日,但是在新浪返回的交易日历缺失该日期,这里补充上
|
|
35
|
-
temp_list.append(datetime.date(1992, 5, 4))
|
|
36
|
+
temp_list.append(datetime.date(year=1992, month=5, day=4))
|
|
36
37
|
temp_list.sort()
|
|
37
38
|
temp_df = pd.DataFrame(temp_list, columns=["trade_date"])
|
|
38
39
|
return temp_df
|
akshare/utils/cons.py
ADDED
akshare/utils/context.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
class AkshareConfig:
|
|
2
|
+
_instance = None
|
|
3
|
+
|
|
4
|
+
def __new__(cls):
|
|
5
|
+
if cls._instance is None:
|
|
6
|
+
cls._instance = super().__new__(cls)
|
|
7
|
+
cls._instance.proxies = None
|
|
8
|
+
return cls._instance
|
|
9
|
+
|
|
10
|
+
@classmethod
|
|
11
|
+
def set_proxies(cls, proxies):
|
|
12
|
+
cls().proxies = proxies
|
|
13
|
+
|
|
14
|
+
@classmethod
|
|
15
|
+
def get_proxies(cls):
|
|
16
|
+
return cls().proxies
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
config = AkshareConfig()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# 导出 set_proxies 函数
|
|
23
|
+
def set_proxies(proxies):
|
|
24
|
+
config.set_proxies(proxies)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def get_proxies():
|
|
28
|
+
return config.get_proxies()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ProxyContext:
|
|
32
|
+
def __init__(self, proxies):
|
|
33
|
+
self.proxies = proxies
|
|
34
|
+
self.old_proxies = None
|
|
35
|
+
|
|
36
|
+
def __enter__(self):
|
|
37
|
+
self.old_proxies = config.get_proxies()
|
|
38
|
+
config.set_proxies(self.proxies)
|
|
39
|
+
return self
|
|
40
|
+
|
|
41
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
42
|
+
config.set_proxies(self.old_proxies)
|
|
43
|
+
return False # 不处理异常
|
akshare/utils/demjson.py
CHANGED
|
@@ -117,7 +117,7 @@ def determine_float_limits(number_type=float):
|
|
|
117
117
|
else:
|
|
118
118
|
numeric_exceptions = (ValueError,)
|
|
119
119
|
|
|
120
|
-
if decimal and number_type
|
|
120
|
+
if decimal and number_type is decimal.Decimal:
|
|
121
121
|
number_type = decimal.DefaultContext
|
|
122
122
|
|
|
123
123
|
if decimal and isinstance(number_type, decimal.Context):
|
|
@@ -125,7 +125,7 @@ def determine_float_limits(number_type=float):
|
|
|
125
125
|
create_num = number_type.create_decimal
|
|
126
126
|
decimal_ctx = decimal.localcontext(number_type)
|
|
127
127
|
is_zero_or_subnormal = lambda n: n.is_zero() or n.is_subnormal()
|
|
128
|
-
elif number_type
|
|
128
|
+
elif number_type is float:
|
|
129
129
|
create_num = number_type
|
|
130
130
|
decimal_ctx = _dummy_context_manager
|
|
131
131
|
is_zero_or_subnormal = lambda n: n == 0
|
akshare/utils/func.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# !/usr/bin/env python
|
|
2
|
+
"""
|
|
3
|
+
Date: 2024/4/7 15:30
|
|
4
|
+
Desc: 通用帮助函数
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import List
|
|
8
|
+
|
|
9
|
+
import pandas as pd
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def set_df_columns(df: pd.DataFrame, cols: List[str]) -> pd.DataFrame:
|
|
13
|
+
"""
|
|
14
|
+
设置 pandas.DataFrame 为空的情况
|
|
15
|
+
:param df: 需要设置命名的数据框
|
|
16
|
+
:type df: pandas.DataFrame
|
|
17
|
+
:param cols: 字段的列表
|
|
18
|
+
:type cols: list
|
|
19
|
+
:return: 重新设置后的数据
|
|
20
|
+
:rtype: pandas.DataFrame
|
|
21
|
+
"""
|
|
22
|
+
if df.shape == (0, 0):
|
|
23
|
+
return pd.DataFrame(data=[], columns=cols)
|
|
24
|
+
else:
|
|
25
|
+
df.columns = cols
|
|
26
|
+
return df
|
akshare/utils/tqdm.py
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
def get_tqdm():
|
|
1
|
+
def get_tqdm(enable: bool = True):
|
|
2
2
|
"""
|
|
3
3
|
返回适用于当前环境的 tqdm 对象。
|
|
4
|
+
|
|
5
|
+
Args:
|
|
6
|
+
enable (bool): 是否启用进度条。默认为 True。
|
|
7
|
+
|
|
8
|
+
Returns:
|
|
9
|
+
tqdm 对象。
|
|
4
10
|
"""
|
|
11
|
+
if not enable:
|
|
12
|
+
# 如果进度条被禁用,返回一个不显示进度条的 tqdm 对象
|
|
13
|
+
return lambda iterable, *args, **kwargs: iterable
|
|
14
|
+
|
|
5
15
|
try:
|
|
6
|
-
# 尝试检查是否在
|
|
16
|
+
# 尝试检查是否在 jupyter notebook 环境中,有利于退出进度条
|
|
7
17
|
# noinspection PyUnresolvedReferences
|
|
8
18
|
shell = get_ipython().__class__.__name__
|
|
9
|
-
if shell ==
|
|
19
|
+
if shell == "ZMQInteractiveShell":
|
|
10
20
|
from tqdm.notebook import tqdm
|
|
11
21
|
else:
|
|
12
22
|
from tqdm import tqdm
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: akshare
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.15.72
|
|
4
4
|
Summary: AKShare is an elegant and simple financial data interface library for Python, built for human beings!
|
|
5
5
|
Home-page: https://github.com/akfamily/akshare
|
|
6
6
|
Author: AKFamily
|
|
@@ -12,39 +12,56 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
16
|
Classifier: License :: OSI Approved :: MIT License
|
|
16
17
|
Classifier: Operating System :: OS Independent
|
|
17
18
|
Requires-Python: >=3.8
|
|
18
19
|
Description-Content-Type: text/markdown
|
|
19
20
|
License-File: LICENSE
|
|
20
|
-
Requires-Dist: beautifulsoup4
|
|
21
|
-
Requires-Dist: lxml
|
|
22
|
-
Requires-Dist: pandas
|
|
23
|
-
Requires-Dist: requests
|
|
24
|
-
Requires-Dist:
|
|
25
|
-
Requires-Dist:
|
|
26
|
-
Requires-Dist:
|
|
27
|
-
Requires-Dist:
|
|
28
|
-
Requires-Dist:
|
|
29
|
-
Requires-Dist:
|
|
30
|
-
Requires-Dist:
|
|
31
|
-
Requires-Dist:
|
|
32
|
-
Requires-Dist:
|
|
33
|
-
Requires-Dist: py-mini-racer
|
|
34
|
-
Requires-Dist: akracer
|
|
35
|
-
Requires-Dist: pyarrow >=15.0.0
|
|
21
|
+
Requires-Dist: beautifulsoup4>=4.9.1
|
|
22
|
+
Requires-Dist: lxml>=4.2.1
|
|
23
|
+
Requires-Dist: pandas>=0.25
|
|
24
|
+
Requires-Dist: requests>=2.22.0
|
|
25
|
+
Requires-Dist: html5lib>=1.0.1
|
|
26
|
+
Requires-Dist: xlrd>=1.2.0
|
|
27
|
+
Requires-Dist: urllib3>=1.25.8
|
|
28
|
+
Requires-Dist: tqdm>=4.43.0
|
|
29
|
+
Requires-Dist: openpyxl>=3.0.3
|
|
30
|
+
Requires-Dist: jsonpath>=0.82
|
|
31
|
+
Requires-Dist: tabulate>=0.8.6
|
|
32
|
+
Requires-Dist: decorator>=4.4.2
|
|
33
|
+
Requires-Dist: mini-racer>=0.12.4; platform_system != "Linux"
|
|
34
|
+
Requires-Dist: py-mini-racer>=0.6.0; platform_system == "Linux"
|
|
35
|
+
Requires-Dist: akracer[py-mini-racer]>=0.0.13; platform_system == "Linux"
|
|
36
36
|
Provides-Extra: full
|
|
37
|
-
Requires-Dist: akqmt
|
|
37
|
+
Requires-Dist: akqmt; extra == "full"
|
|
38
38
|
Provides-Extra: qmt
|
|
39
|
-
Requires-Dist: akqmt
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
Requires-Dist: akqmt; extra == "qmt"
|
|
40
|
+
Dynamic: author
|
|
41
|
+
Dynamic: author-email
|
|
42
|
+
Dynamic: classifier
|
|
43
|
+
Dynamic: description
|
|
44
|
+
Dynamic: description-content-type
|
|
45
|
+
Dynamic: home-page
|
|
46
|
+
Dynamic: keywords
|
|
47
|
+
Dynamic: license
|
|
48
|
+
Dynamic: provides-extra
|
|
49
|
+
Dynamic: requires-dist
|
|
50
|
+
Dynamic: requires-python
|
|
51
|
+
Dynamic: summary
|
|
52
|
+
|
|
53
|
+
**欢迎加入专注于财经数据和量化投资的知识社区,请点击[了解更多](https://akshare.akfamily.xyz/learn.html)**
|
|
54
|
+
|
|
55
|
+
**量化投研视频课程:《PyBroker-入门及实战》已经上架!《PyBroker-进阶及实战》正在更新!**
|
|
56
|
+
|
|
57
|
+
**更多视频教程已经发布:《AKShare-初阶-使用教学》、《AKShare-初阶-实战应用》、《AKShare-源码解析》、《开源项目巡礼》**,
|
|
58
|
+
详情请关注【数据科学实战】公众号,查看更多课程信息!
|
|
44
59
|
|
|
45
60
|
**AKQuant 量化教程请访问:[利用 PyBroker 进行量化投资](https://akquant.akfamily.xyz/)**
|
|
46
61
|
|
|
47
|
-
**本次发布 [AKTools](https://github.com/akfamily/aktools) 作为 AKShare 的 HTTP API
|
|
62
|
+
**本次发布 [AKTools](https://github.com/akfamily/aktools) 作为 AKShare 的 HTTP API 版本,
|
|
63
|
+
突破 Python 语言的限制,欢迎各位小伙伴试用并提出更好的意见或建议!
|
|
64
|
+
点击 [AKTools](https://github.com/akfamily/aktools) 查看使用指南。另外提供 [awesome-data](https://github.com/akfamily/awesome-data) 方便各位小伙伴查询各种数据源。**
|
|
48
65
|
|
|
49
66
|

|
|
50
67
|
|
|
@@ -63,14 +80,13 @@ Requires-Dist: akqmt ; extra == 'qmt'
|
|
|
63
80
|
|
|
64
81
|
## Overview
|
|
65
82
|
|
|
66
|
-
[AKShare](https://github.com/akfamily/akshare) requires Python(64 bit) 3.8 or
|
|
83
|
+
[AKShare](https://github.com/akfamily/akshare) requires Python(64 bit) 3.8 or higher and
|
|
84
|
+
aims to simplify the process of fetching financial data.
|
|
67
85
|
|
|
68
86
|
**Write less, get more!**
|
|
69
87
|
|
|
70
88
|
- Documentation: [中文文档](https://akshare.akfamily.xyz/)
|
|
71
89
|
|
|
72
|
-

|
|
73
|
-
|
|
74
90
|
## Installation
|
|
75
91
|
|
|
76
92
|
### General
|
|
@@ -87,7 +103,8 @@ pip install akshare -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host=mir
|
|
|
87
103
|
|
|
88
104
|
### PR
|
|
89
105
|
|
|
90
|
-
Please check out [
|
|
106
|
+
Please check out [Documentation](https://akshare.akfamily.xyz/contributing.html) if you
|
|
107
|
+
want to contribute to AKShare
|
|
91
108
|
|
|
92
109
|
### Docker
|
|
93
110
|
|
|
@@ -151,11 +168,9 @@ import akshare as ak
|
|
|
151
168
|
import mplfinance as mpf # Please install mplfinance as follows: pip install mplfinance
|
|
152
169
|
|
|
153
170
|
stock_us_daily_df = ak.stock_us_daily(symbol="AAPL", adjust="qfq")
|
|
154
|
-
stock_us_daily_df = stock_us_daily_df[
|
|
155
|
-
stock_us_daily_df.columns = ["Open", "High", "Low", "Close", "Volume"]
|
|
156
|
-
stock_us_daily_df.index.name = "Date"
|
|
171
|
+
stock_us_daily_df = stock_us_daily_df.set_index(["date"])
|
|
157
172
|
stock_us_daily_df = stock_us_daily_df["2020-04-01": "2020-04-29"]
|
|
158
|
-
mpf.plot(stock_us_daily_df, type=
|
|
173
|
+
mpf.plot(stock_us_daily_df, type="candle", mav=(3, 6, 9), volume=True, show_nontrading=False)
|
|
159
174
|
```
|
|
160
175
|
|
|
161
176
|
Output:
|
|
@@ -164,7 +179,8 @@ Output:
|
|
|
164
179
|
|
|
165
180
|
## Communication
|
|
166
181
|
|
|
167
|
-
|
|
182
|
+
Welcome to join the **数据科学实战** knowledge planet to learn more about quantitative investment,
|
|
183
|
+
please visit [数据科学实战](https://akshare.akfamily.xyz/learn.html) for more information:
|
|
168
184
|
|
|
169
185
|
<div>
|
|
170
186
|
<img alt="data science" src="https://jfds-1252952517.cos.ap-chengdu.myqcloud.com/akshare/readme/qrcode/data_scientist.png">
|
|
@@ -176,9 +192,6 @@ Pay attention to **数据科学实战** WeChat Official Accounts to get the [AKS
|
|
|
176
192
|
<img alt="ds" src="https://github.com/akfamily/akshare/blob/main/assets/images/ds.png">
|
|
177
193
|
</div>
|
|
178
194
|
|
|
179
|
-
Application to add **AKShare-VIP QQ group** and talk about [AKShare](https://github.com/akfamily/akshare) issues, please contact **AKShare-小助手 QQ**: 1254836886
|
|
180
|
-

|
|
181
|
-
|
|
182
195
|
## Features
|
|
183
196
|
|
|
184
197
|
- **Easy of use**: Just one line code to fetch the data;
|
|
@@ -256,14 +269,10 @@ Special thanks [TuShare](https://github.com/waditu/tushare) for the opportunity
|
|
|
256
269
|
|
|
257
270
|
Thanks for the data provided by [生意社网站](http://www.100ppi.com/);
|
|
258
271
|
|
|
259
|
-
Thanks for the data provided by [奇货可查网站](https://qhkch.com/);
|
|
260
|
-
|
|
261
272
|
Thanks for the data provided by [中国银行间市场交易商协会网站](http://www.nafmii.org.cn/);
|
|
262
273
|
|
|
263
274
|
Thanks for the data provided by [99期货网站](http://www.99qh.com/);
|
|
264
275
|
|
|
265
|
-
Thanks for the data provided by [英为财情网站](https://cn.investing.com/);
|
|
266
|
-
|
|
267
276
|
Thanks for the data provided by [中国外汇交易中心暨全国银行间同业拆借中心网站](http://www.chinamoney.com.cn/chinese/);
|
|
268
277
|
|
|
269
278
|
Thanks for the data provided by [金十数据网站](https://www.jin10.com/);
|
|
@@ -272,8 +281,6 @@ Thanks for the data provided by [和讯财经网站](http://www.hexun.com/);
|
|
|
272
281
|
|
|
273
282
|
Thanks for the data provided by [新浪财经网站](https://finance.sina.com.cn/);
|
|
274
283
|
|
|
275
|
-
Thanks for the data provided by [Oxford-Man Institute 网站](https://realized.oxford-man.ox.ac.uk/);
|
|
276
|
-
|
|
277
284
|
Thanks for the data provided by [DACHENG-XIU 网站](https://dachxiu.chicagobooth.edu/);
|
|
278
285
|
|
|
279
286
|
Thanks for the data provided by [上海证券交易所网站](http://www.sse.com.cn/assortment/options/price/);
|
|
@@ -300,12 +307,6 @@ Thanks for the data provided by [南华期货网站](http://www.nanhua.net/nhzc/
|
|
|
300
307
|
|
|
301
308
|
Thanks for the data provided by [Economic Policy Uncertainty 网站](http://www.nanhua.net/nhzc/varietytrend.html);
|
|
302
309
|
|
|
303
|
-
Thanks for the data provided by [微博指数网站](https://data.weibo.com/index/newindex);
|
|
304
|
-
|
|
305
|
-
Thanks for the data provided by [百度指数网站](http://index.baidu.com/v2/main/index.html);
|
|
306
|
-
|
|
307
|
-
Thanks for the data provided by [谷歌指数网站](https://trends.google.com/trends/?geo=US);
|
|
308
|
-
|
|
309
310
|
Thanks for the data provided by [申万指数网站](http://www.swsindex.com/idx0120.aspx?columnid=8832);
|
|
310
311
|
|
|
311
312
|
Thanks for the data provided by [真气网网站](https://www.zq12369.com/);
|
|
@@ -320,30 +321,12 @@ Thanks for the data provided by [北京市碳排放权电子交易平台网站](
|
|
|
320
321
|
|
|
321
322
|
Thanks for the data provided by [国家金融与发展实验室网站](http://www.nifd.cn/);
|
|
322
323
|
|
|
323
|
-
Thanks for the data provided by [IT桔子网站](https://www.itjuzi.com);
|
|
324
|
-
|
|
325
324
|
Thanks for the data provided by [东方财富网站](http://data.eastmoney.com/jgdy/);
|
|
326
325
|
|
|
327
326
|
Thanks for the data provided by [义乌小商品指数网站](http://www.ywindex.com/Home/Product/index/);
|
|
328
327
|
|
|
329
|
-
Thanks for the data provided by [中国国家发展和改革委员会网站](http://jgjc.ndrc.gov.cn/dmzs.aspx?clmId=741);
|
|
330
|
-
|
|
331
|
-
Thanks for the data provided by [163网站](https://news.163.com/special/epidemic/);
|
|
332
|
-
|
|
333
|
-
Thanks for the data provided by [丁香园网站](http://3g.dxy.cn/newh5/view/pneumonia?scene=2&clicktime=1579615030&enterid=1579615030&from=groupmessage&isappinstalled=0);
|
|
334
|
-
|
|
335
|
-
Thanks for the data provided by [百度新型肺炎网站](https://voice.baidu.com/act/newpneumonia/newpneumonia/?from=osari_pc_1);
|
|
336
|
-
|
|
337
328
|
Thanks for the data provided by [百度迁徙网站](https://qianxi.baidu.com/?from=shoubai#city=0);
|
|
338
329
|
|
|
339
|
-
Thanks for the data provided by [新型肺炎-相同行程查询工具网站](https://rl.inews.qq.com/h5/trip?from=newsapp&ADTAG=tgi.wx.share.message);
|
|
340
|
-
|
|
341
|
-
Thanks for the data provided by [新型肺炎-小区查询网站](https://ncov.html5.qq.com/community?channelid=1&from=singlemessage&isappinstalled=0);
|
|
342
|
-
|
|
343
|
-
Thanks for the data provided by [商业特许经营信息管理网站](http://txjy.syggs.mofcom.gov.cn/);
|
|
344
|
-
|
|
345
|
-
Thanks for the data provided by [慈善中国网站](http://cishan.chinanpo.gov.cn/platform/login.html);
|
|
346
|
-
|
|
347
330
|
Thanks for the data provided by [思知网站](https://www.ownthink.com/);
|
|
348
331
|
|
|
349
332
|
Thanks for the data provided by [Currencyscoop 网站](https://currencyscoop.com/);
|
|
@@ -354,6 +337,6 @@ Thanks for the tutorials provided by [微信公众号: Python大咖谈](https://
|
|
|
354
337
|
|
|
355
338
|
## Backer and Sponsor
|
|
356
339
|
|
|
357
|
-
<a href="https://www.jetbrains.com/?from=
|
|
358
|
-
<img
|
|
340
|
+
<a href="https://www.jetbrains.com/?from=albertandking/akshare" target="_blank">
|
|
341
|
+
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.png" alt="JetBrains logo.">
|
|
359
342
|
</a>
|