akfamily / akshare Goto Github PK
View Code? Open in Web Editor NEWAKShare is an elegant and simple financial data interface library for Python, built for human beings! 开源财经数据接口库
Home Page: https://akshare.akfamily.xyz/
License: MIT License
AKShare is an elegant and simple financial data interface library for Python, built for human beings! 开源财经数据接口库
Home Page: https://akshare.akfamily.xyz/
License: MIT License
您好,
请问akshare是否有国债历史收益率的数据呢?
手动的话,可以从http://yield.chinabond.com.cn/cbweb-pbc-web/pbc/showHistory?locale=cn_ZH
上下载。但是不知道是否可以通过python程序化抓取。
多谢!
epidemic_baidu_df = ak.epidemic_baidu(indicator="历史")
print(epidemic_baidu_df)
Fetching historic data from epidemic_baidu@akshare...
Traceback (most recent call last):
File "", line 8, in
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/akshare/event/sos.py", line 278, in epidemic_baidu
json_data = json.loads(r.text[r.text.find("V.conf = ") + 9: r.text.find("V.bsData") - 1])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/init.py", line 357, in loads
return _default_decoder.decode(s)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Successfully installed akshare-0.4.1
1.首先非常感谢akshare的开源。非常牛逼强大的一个开源库
2.希望能够有一个接口获取可转债转股价变动记录接口
ak.get_dce_rank_table(date='20180718'),多次调用同一句代码,得到的结果不一致,可能会出现数据缺失,数据可能为14条,可能13、12条
Describe the bug
as title
To Reproduce
Steps to reproduce the behavior:
import akshare as ak
ak.index_stock_cons(index="000001")
---------------------------------------------------------------------------KeyError Traceback (most recent call last)/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3077 try:
-> 3078 return self._engine.get_loc(key)
3079 except KeyError:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: '品种代码'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)<ipython-input-18-c30681f6440d> in <module>
----> 1 ak.index_stock_cons(index="000001")
~/external-libraries/python/akshare/index/index_cons.py in index_stock_cons(index)
97 temp_df = temp_df.append(pd.read_html(r.text, header=1)[3], ignore_index=True)
98 temp_df = temp_df.iloc[:, :3]
---> 99 temp_df["品种代码"] = temp_df["品种代码"].astype(str).str.zfill(6)
100 return temp_df
101
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pandas/core/frame.py in __getitem__(self, key)
2686 return self._getitem_multilevel(key)
2687 else:
-> 2688 return self._getitem_column(key)
2689
2690 def _getitem_column(self, key):
Expected behavior
return a dataframe
中金所得日线数据格式发生更改, futures.get_cffex_daily 在获取数据后的字段对应不上,造成数据错误。
原因是数据的field 与返回的数据row index 强依赖造成的。建议利用返回数据的列名做映射。
TypeError Traceback (most recent call last)
in
1 import akshare as ak
----> 2 currency_hist_df = ak.currency_hist(index_name="usd/jpy", start_date="2005/01/01", end_date="2020/01/17")
3 print(currency_hist_df)
TypeError: currency_hist() got an unexpected keyword argument 'index_name'
I already upgraded akshare. Without index_name the code runs well.
返回值的index 类型不统一,需要优化成datetime
返回值有些是string,有些是float和int,也不完全统一
字段column名称有些错乱
例如今天发现的
df1 = ak.macro_china_market_margin_sz()
df2 = ak.macro_china_market_margin_sh()
我尝试提交一个pull request,但估计是一个批量问题,之前也遇到过一次没有记录。
辛苦了。
K线增加能否增加start_date 参数,用于筛选开始时间
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
Traceback (most recent call last):
File "h:/project/stock/new/test.py", line 9, in
mm = ak.index_investing_global(country="**", index_name="**加权指数", period="每日", start_date="2000-01-01", end_date="2020-06-19")#ak.index_investing_global_country_name_url("日本")#
File "C:\Users\lees\AppData\Roaming\Python\Python37\site-packages\akshare\index\index_investing.py", line 383, in index_investing_global
.astype(float)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py", line 5698, in astype
new_data = self._data.astype(dtype=dtype, copy=copy, errors=errors)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\managers.py", line 582, in astype
return self.apply("astype", dtype=dtype, copy=copy, errors=errors)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\managers.py", line 442, in apply
applied = getattr(b, f)(**kwargs)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\blocks.py", line 625, in astype
values = astype_nansafe(vals1d, dtype, copy=True)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\core\dtypes\cast.py", line 897, in astype_nansafe
return arr.astype(dtype, copy=True)
ValueError: could not convert string to float: '1,975.92'
Describe the bug
Contos 上 import akashare as ak 运行报错
import akshare as ak
File "/usr/local/lib/python3.6/site-packages/akshare/__init__.py", line 1059, in <module>
from akshare.stock_feature.stock_a_pb import stock_a_pb
File "/usr/local/lib/python3.6/site-packages/akshare/stock_feature/stock_a_pb.py", line 317, in <module>
Desktop (please complete the following information):
Parameter description of migration_area_baidu in the document has an error
I found that the parameter indicator of the function migration_area_baidu has an error in the document. The two values of the parameter are the same, both of which are "move_in".
It is recommended to add an interface,Get the time of the Last trading day,When obtaining real-time market data, you can more intuitively understand which day is the data
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
<ipython-input-1-5b43eaffca0e> in <module>
1 import pylab as plt
2 import pandas as pd
----> 3 import akshare as ak
4 import seaborn as sns
~/anaconda3/lib/python3.7/site-packages/akshare/__init__.py in <module>
1222 外盘期货实时行情
1223 """
-> 1224 from akshare.futures.hf_futures_sina import (
1225 futures_hf_spot,
1226 hf_subscribe_exchange_symbol,
~/anaconda3/lib/python3.7/site-packages/akshare/futures/hf_futures_sina.py in <module>
49
50
---> 51 def futures_hf_spot(subscribe_list=hf_subscribe_exchange_symbol()):
52 """
53 订阅数据处理
~/anaconda3/lib/python3.7/site-packages/akshare/futures/hf_futures_sina.py in hf_subscribe_exchange_symbol()
44 res.encoding = "gb2312"
45 data_json = demjson.decode(
---> 46 res.text[res.text.find("var oHF_1 = ") + 12 : res.text.find("var oHF_2 = ") - 2]
47 )
48 return list(data_json.keys())
~/anaconda3/lib/python3.7/site-packages/demjson.py in decode(txt, encoding, **kwargs)
5697 encoding=encoding,
5698 return_errors=(return_errors or write_errors),
-> 5699 return_stats=(return_stats or write_stats) )
5700
5701 if write_errors:
~/anaconda3/lib/python3.7/site-packages/demjson.py in decode(self, txt, encoding, return_errors, return_stats)
4913 errors = [err for err in state.errors if err.severity in ('fatal','error')]
4914 if errors:
-> 4915 raise errors[0]
4916 if return_stats:
4917 return result_type(state.obj, None, state.stats)
JSONDecodeError: ('Unknown identifier', 'ad')
在调用接口get_futures_daily获取上期所日线行情, 其中返回的turnover字段计算有问题,没有乘上相应品种的合约乘数,造成turnover数据不准确
非常感谢你的软件,我最近用了一段时间觉得非常好用
美中不足的是,请问我是否可以像request那样,在调用的时候指定代理IP地址和端口?
因为这样我就不需要单独弄一台机器跑数据了(目前需要单独一个机器,不断的变化自己的IP,但是会影响机器上的其它程序)
期待作者的回复,谢谢
Describe the bug
郑商所可能修改了原有网站,7月24日开始获取成交持仓排名会报错
To Reproduce
import akshare as ak
df = ak.get_czce_rank_table(date='20200224')
print(df)
Expected behavior
没有返回表格
ValueError Traceback (most recent call last)
in
1 import akshare as ak
----> 2 df = ak.get_czce_rank_table(date='20200224')
3 print(df)
~/anaconda3/lib/python3.7/site-packages/akshare/futures/cot.py in get_czce_rank_table(date, vars_list)
358 else:
359 url = cons.CZCE_VOL_RANK_URL_3 % (date.year, date.strftime('%Y%m%d'))
--> 360 data = _czce_df_read(url, skip_rows=0)[0]
361
362 if len(data.columns) < 6:
~/anaconda3/lib/python3.7/site-packages/akshare/futures/cot.py in _czce_df_read(url, skip_rows, encoding, header)
272 data = pd.read_html(r.text, match='.+', flavor=None, header=header, index_col=0, skiprows=skip_rows, attrs=None,
273 parse_dates=False, thousands=', ', encoding="gbk", decimal='.',
--> 274 converters=None, na_values=None, keep_default_na=True)
275 return data
276
~/anaconda3/lib/python3.7/site-packages/pandas/io/html.py in read_html(io, match, flavor, header, index_col, skiprows, attrs, parse_dates, tupleize_cols, thousands, encoding, decimal, converters, na_values, keep_default_na, displayed_only)
1092 io=io,
1093 match=match,
-> 1094 header=header,
1095 index_col=index_col,
1096 skiprows=skiprows,
~/anaconda3/lib/python3.7/site-packages/pandas/io/html.py in _parse(flavor, io, match, attrs, encoding, displayed_only, **kwargs)
914 ret = []
915 for table in tables:
--> 916 try:
917 ret.append(_data_to_frame(data=table, **kwargs))
918 except EmptyDataError: # empty table
~/anaconda3/lib/python3.7/site-packages/pandas/compat/init.py in raise_with_traceback(exc, traceback)
ValueError: No tables found
Desktop (please complete the following information):
现在的新浪分钟数据是没有复权功能的,希望能够增加,谢谢。
According to the documentation, calling history indicator on epidemic_163 should return data grouped by area. But in fact it is not.
Query
import akshare as ak
epidemic_163_df = ak.epidemic_163(indicator="实时")
print(epidemic_163_df)
Expected Result
day time country area dead confirm suspect heal city district
0 1.12 ** 湖北武汉 1 41 0 NaN None None
1 1.13 ** 湖北武汉 1 41 0 NaN None None
2 1.14 ** 湖北武汉 1 41 0 NaN None None
3 1.15 ** 湖北武汉 2 41 0 NaN None None
4 1.16 ** 湖北武汉 2 45 0 NaN None None
.. ... ... ... ... ... ... ... ... ... ...
220 1.26 09:00 ** ** 0 3 0 0.0
221 1.26 09:00 ** ** 0 4 0 0.0
222 1.26 09:00 ** 澳门 0 5 0 0.0
223 1.26 09:00 ** 内蒙古 0 7 0 0.0
224 1.26 09:00 ** 青海 0 4 0 0.0
Actual Result
date confirm suspect dead heal
0 01.21 440 37 9 25
1 01.13 41 0 1 0
2 01.14 41 0 1 0
3 01.15 41 0 2 5
4 01.16 45 0 2 8
.. ... ... ... ... ...
11 01.20 291 54 6 25
12 01.25 1429 1965 42 38
13 01.26 2081 2684 56 49
14 01.27 2858 5794 82 58
15 01.28 4599 6973 106 68
I use akshare with version 0.3.75 .
and I use ak.stock_zh_a_spot() to get all symbols which involve sh603290。But when I use ak.stock_zh_a_daily(symbol='sh603290') I got a exeception. This can be reproduced stably。
All date in fund_em_info data is mismatched.
Code
import akshare as ak
fund_em_info_df = ak.fund_em_info(fund="100032", indicator="单位净值走势")
print(fund_em_info_df)
Output
x | y | equityReturn | unitMoney | |
---|---|---|---|---|
2729 | 2020-03-24 | 0.955 | 2.0299 | |
2730 | 2020-03-25 | 0.947 | -0.8377 | |
2731 | 2020-03-26 | 0.953 | 0.6336 | |
2732 | 2020-03-29 | 0.945 | -0.8395 | |
2733 | 2020-03-30 | 0.943 | -0.2116 | |
2734 | 2020-03-31 | 0.938 | -0.5302 | |
2735 | 2020-04-01 | 0.950 | 1.2793 | |
2736 | 2020-04-02 | 0.945 | -0.5263 |
Question
2020-04-02
should be 2020-04-03
and other dates are all mismatched. 2020-03-29
is Sunday and should not be included in data.
I checked back to 2009-02-01
and this problem has been taken place.
Tried to change timezone to "Asia/Shanghai" and didn't work.
Environment
Python 3.6.9
akshare 0.4.65
File "d:\repo\stock-price-data\akshare\test.py", line 4, in
import akshare as ak
File "C:\ProgramData\Miniconda3\lib\site-packages\akshare_init_.py", line 1009, in
from akshare.futures.futures_foreign import futures_foreign_detail, futures_foreign_hist
File "C:\ProgramData\Miniconda3\lib\site-packages\akshare\futures\futures_foreign.py", line 15, in
from akshare.futures.hf_futures_sina import hf_subscribe_exchange_symbol
File "C:\ProgramData\Miniconda3\lib\site-packages\akshare\futures\hf_futures_sina.py", line 53, in
def futures_hf_spot(subscribe_list=hf_subscribe_exchange_symbol()):
File "C:\ProgramData\Miniconda3\lib\site-packages\akshare\futures\hf_futures_sina.py", line 48, in hf_subscribe_exchange_symbol
res.text[res.text.find("var oHF_1 = ") + 12: res.text.find("var oHF_2 = ") - 2]
File "C:\ProgramData\Miniconda3\lib\site-packages\demjson.py", line 5699, in decode
return_stats=(return_stats or write_stats) )
File "C:\ProgramData\Miniconda3\lib\site-packages\demjson.py", line 4915, in decode
raise errors[0]
demjson.JSONDecodeError: ('Unknown identifier', 'tml')
就这只美股"TEX"有问题,其他股票没发现问题
df = ak.stock_us_daily(‘TEX’)
Traceback (most recent call last):
File "/Users/foo/Workspace/pythonprj/stock/lib/python3.8/site-packages/pandas/core/arrays/datetimes.py", line 1979, in objects_to_datetime64ns
values, tz_parsed = conversion.datetime_to_datetime64(data)
File "pandas/_libs/tslibs/conversion.pyx", line 200, in pandas._libs.tslibs.conversion.datetime_to_datetime64
TypeError: Unrecognized value type: <class 'str'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./src/main.py", line 66, in <module>
main()
File "./src/main.py", line 61, in main
st.update()
File "/Users/foo/Workspace/pythonprj/stock/src/store.py", line 29, in update
self.addStockData(c)
File "/Users/foo/Workspace/pythonprj/stock/src/store.py", line 51, in addStockData
arr = self.getStockData(c)
File "/Users/foo/Workspace/pythonprj/stock/src/store.py", line 38, in getStockData
df = ak.stock_us_daily(c)
File "/Users/foo/Workspace/pythonprj/stock/lib/python3.8/site-packages/akshare/stock/us_stock_sina.py", line 61, in stock_us_daily
data_df.index = pd.to_datetime(data_df["date"])
File "/Users/foo/Workspace/pythonprj/stock/lib/python3.8/site-packages/pandas/util/_decorators.py", line 208, in wrapper
return func(*args, **kwargs)
File "/Users/foo/Workspace/pythonprj/stock/lib/python3.8/site-packages/pandas/core/tools/datetimes.py", line 778, in to_datetime
values = convert_listlike(arg._values, True, format)
File "/Users/foo/Workspace/pythonprj/stock/lib/python3.8/site-packages/pandas/core/tools/datetimes.py", line 456, in _convert_listlike_datetimes
result, tz_parsed = objects_to_datetime64ns(
File "/Users/foo/Workspace/pythonprj/stock/lib/python3.8/site-packages/pandas/core/arrays/datetimes.py", line 1984, in objects_to_datetime64ns
raise e
File "/Users/foo/Workspace/pythonprj/stock/lib/python3.8/site-packages/pandas/core/arrays/datetimes.py", line 1969, in objects_to_datetime64ns
result, tz_parsed = tslib.array_to_datetime(
File "pandas/_libs/tslib.pyx", line 465, in pandas._libs.tslib.array_to_datetime
File "pandas/_libs/tslib.pyx", line 683, in pandas._libs.tslib.array_to_datetime
File "pandas/_libs/tslib.pyx", line 679, in pandas._libs.tslib.array_to_datetime
File "pandas/_libs/tslib.pyx", line 654, in pandas._libs.tslib.array_to_datetime
File "pandas/_libs/tslibs/np_datetime.pyx", line 118, in pandas._libs.tslibs.np_datetime.check_dts_bounds
pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 2703-01-16 00:00:00
================ 2020-06-24
Traceback (most recent call last):
File "h:/project/stock/new/src/data/collect/stock_out_date.py", line 47, in
stock_em_tfp_df = ak.stock_em_tfp(trade_date=day_str)
File "C:\Users\lees\AppData\Roaming\Python\Python37\site-packages\akshare\stock_feature\stock_em_tfp.py", line 38, in stock_em_tfp
temp_df = pd.DataFrame(data_json["data"]).iloc[:, 0].str.split(",", expand=True)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py", line 5270, in getattr
return object.getattribute(self, name)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\core\accessor.py", line 187, in get
accessor_obj = self._accessor(obj)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\core\strings.py", line 2041, in init
self._inferred_dtype = self._validate(data)
File "D:\ProgramData\Anaconda3\lib\site-packages\pandas\core\strings.py", line 2098, in _validate
raise AttributeError("Can only use .str accessor with string values!")
AttributeError: Can only use .str accessor with string values!
获取2020-06-24这天的数据出错
pip install akshare
安装过程中出现问题:cannot import name 'StringIO' from 'pandas.compat'
akshare 中引用的 pandas 版本过低
建议增加股票的财务数据,如PETTM等,想自己计算又发现ak.stock_zh_a_daily返回的是流通股本,不是总股本
epidemic_dxy crashes on indicator="全国" or indicator="浙江省" etc.
Query
epidemic_dxy_df = ak.epidemic_dxy(indicator="全国")
print(epidemic_dxy_df)
Error
Traceback (most recent call last):
File "", line 11, in
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/akshare/event/sos.py", line 75, in epidemic_dxy
data_df.columns = ["地区", "地区简称", "确诊", "疑似", "治愈", "死亡", "备注", "区域"]
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/generic.py", line 5286, in setattr
return object.setattr(self, name, value)
File "pandas/_libs/properties.pyx", line 67, in pandas._libs.properties.AxisProperty.set
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/generic.py", line 661, in _set_axis
self._data.set_axis(axis, labels)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/managers.py", line 177, in set_axis
raise ValueError(
ValueError: Length mismatch: Expected axis has 9 elements, new values have 8 elements
Similarly:
Query
epidemic_dxy_df = ak.epidemic_dxy(indicator="浙江省")
print(epidemic_dxy_df)
Error
Traceback (most recent call last):
File "", line 14, in
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/akshare/event/sos.py", line 75, in epidemic_dxy
data_df.columns = ["地区", "地区简称", "确诊", "疑似", "治愈", "死亡", "备注", "区域"]
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/generic.py", line 5286, in setattr
return object.setattr(self, name, value)
File "pandas/_libs/properties.pyx", line 67, in pandas._libs.properties.AxisProperty.set
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/generic.py", line 661, in _set_axis
self._data.set_axis(axis, labels)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/managers.py", line 177, in set_axis
raise ValueError(
ValueError: Length mismatch: Expected axis has 9 elements, new values have 8 elements
There are some unneccesary duplicate varaible assignment in the official documention. What I have spotted are headers = headers = ...
snipets in some many examples
Simply delete the duplicancy will suffice and make it less confusing for rookies
I have already pull a request for this minor issue
感谢
Parameter end_date in migration_scale_baidu is not work
I try to run the example code in migration_scale_baidu but it returns the data between start_date and Yesterday, not the value of end_date.
Environment: Windows 10, Python 3.7
My code:
import akshare as ak
migration_scale_baidu_df = ak.migration_scale_baidu(
area = "浙江省",
indicator = "move_out",
start_date = "20190112",
end_date = "20200201")
print(migration_scale_baidu_df)
貌似接口对应的新浪地址 http://vip.stock.finance.sina.com.cn/mkt/#hs_s
返回的数据不全,比如最新成立的5G通信、芯片等指数并不包含在内。
我在调用这个接口时,出现了这个错误,这让我不甚其解
fund1 = ak.fund_em_info(fund=’000009‘, indicator="单位净值走势")
I tried to get egg's inventory and spot box, and I get Error.
I guess that the functions get nothing. It would be better to return None under such circumstances.
get_inventory_data(3, 80)
Traceback (most recent call last):
File "C:\Users\2689\AppData\Local\Continuum\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3319, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
jd_invent = ak.get_inventory_data(3, 80, plot=False)
File "C:\Users\2689\AppData\Roaming\Python\Python37\site-packages\akshare\futures\futures_inventory.py", line 72, in get_inventory_data
exchange_name = soup.find_all("select")[0].find_all(attrs={"selected": "selected"})[0].get_text()
IndexError: list index out of range
box_office_spot()
Traceback (most recent call last):
File "C:\Users\2689\AppData\Local\Continuum\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3319, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
ak.box_office_spot()
File "C:\Users\2689\AppData\Roaming\Python\Python37\site-packages\akshare\movie\movie_maoyan.py", line 53, in box_office_spot
map_dict = get_map(text=text)
File "C:\Users\2689\AppData\Roaming\Python\Python37\site-packages\akshare\movie\movie_maoyan.py", line 39, in get_map
map_li = map(lambda x: str(int(x)), _classify.knn_predict(info))
File "C:\Users\2689\AppData\Roaming\Python\Python37\site-packages\akshare\movie\movie_maoyan_knn_font.py", line 43, in knn_predict
np.zeros((df.shape[0], self.len - df.shape[1])),
ValueError: negative dimensions are not allowed
The column name of the output parameter in
https://www.akshare.xyz/zh_CN/latest/data/fund/fund_public.html#id9 is wrong, it should be“ 净值日期 单位净值 累计净值 日增长率 申购状态 赎回状态” ,It should n’t be “净值日期 每万份收益 7日年化收益率 申购状态 赎回状态”.
Hi,
I'm wondering if there is a plan to include more ceicdata.
For example,
https://www.ceicdata.com/zh-hans/china/economic-climate-indicator
Thanks for the great tool.
execjs._exceptions.RuntimeUnavailableError: Could not find an available JavaScript runtime.
Hi,
I noticed there are two functions that can possibly provide real-time data.
I've questions/suggestions regarding both, respectively.
Thanks.
akshare-0.5.3
akshare.futures.requests_fun 的 错误捕捉类型为 TimeoutError,其实并不起作用,应该为requests.exceptions.Timeout , 而且 10秒的Timeout时间会比较少,在爬取DCE交易所经常会读超时(高峰时段,一般会大于10秒后返回,所以会一直读超时),希望可以加长超时时间,或者有其他方案
import akshare as ak
JSONDecodeError Traceback (most recent call last)
in
----> 1 import akshare as ak
~\AppData\Roaming\Python\Python36\site-packages\akshare_init_.py in
1359 外盘期货实时行情
1360 """
-> 1361 from akshare.futures.hf_futures_sina import (
1362 futures_hf_spot,
1363 hf_subscribe_exchange_symbol,
~\AppData\Roaming\Python\Python36\site-packages\akshare\futures\hf_futures_sina.py in
50
51
---> 52 def futures_hf_spot(subscribe_list=hf_subscribe_exchange_symbol()):
53 """
54 订阅数据处理
~\AppData\Roaming\Python\Python36\site-packages\akshare\futures\hf_futures_sina.py in hf_subscribe_exchange_symbol()
45 res.encoding = "gb2312"
46 data_json = demjson.decode(
---> 47 res.text[res.text.find("var oHF_1 = ") + 12: res.text.find("var oHF_2 = ") - 2]
48 )
49 return list(data_json.keys())
~\AppData\Roaming\Python\Python36\site-packages\demjson.py in decode(txt, encoding, **kwargs)
5697 encoding=encoding,
5698 return_errors=(return_errors or write_errors),
-> 5699 return_stats=(return_stats or write_stats) )
5700
5701 if write_errors:
~\AppData\Roaming\Python\Python36\site-packages\demjson.py in decode(self, txt, encoding, return_errors, return_stats)
4913 errors = [err for err in state.errors if err.severity in ('fatal','error')]
4914 if errors:
-> 4915 raise errors[0]
4916 if return_stats:
4917 return result_type(state.obj, None, state.stats)
JSONDecodeError: ('Unknown identifier', 'tml')
python 3.6.2
demjson 2.2.4
akshare 0.4.43
epidemic_history API starts to flip country with country_code:
+-------+------------+---------------------+---------+-----------------------+------+-----------+------+-----------+-----------+-----------+-------+------+
| id | date | timestamp | country | country_code | area | area_code | city | city_code | confirmed | suspected | cured | dead |
+-------+------------+---------------------+---------+-----------------------+------+-----------+------+-----------+-----------+-----------+-------+------+
| 64811 | 2020-05-04 | 2020-05-04 00:00:00 | VE | 委内瑞拉 | None | | None | | 357 | 0 | 148 | 10 |
| 64812 | 2020-05-04 | 2020-05-04 00:00:00 | VG | 英属维尔京群岛 | None | | None | | 6 | 0 | 3 | 1 |
| 64813 | 2020-05-04 | 2020-05-04 00:00:00 | VI | 美属维尔京群岛 | None | | None | | 66 | 0 | 46 | 4 |
| 64814 | 2020-05-04 | 2020-05-04 00:00:00 | VN | 越南 | None | | None | | 271 | 0 | 225 | 0 |
| 64815 | 2020-05-04 | 2020-05-04 00:00:00 | YE | 也门 | None | | None | | 10 | 0 | 1 | 2 |
| 64816 | 2020-05-04 | 2020-05-04 00:00:00 | YT | 马约特 | None | | None | | 650 | 0 | 235 | 6 |
| 64817 | 2020-05-04 | 2020-05-04 00:00:00 | ZA | 南非 | None | | None | | 6783 | 0 | 2549 | 131 |
| 64818 | 2020-05-04 | 2020-05-04 00:00:00 | ZM | 赞比亚 | None | | None | | 124 | 0 | 78 | 3 |
| 64819 | 2020-05-04 | 2020-05-04 00:00:00 | ZW | 津巴布韦 | None | | None | | 34 | 0 | 5 | 4 |
| 64820 | 2020-05-04 | 2020-05-04 00:00:00 | None | 纳米比亚 | None | | None | | 16 | 0 | 8 | 0 |
+-------+------------+---------------------+---------+-----------------------+------+-----------+------+-----------+-----------+-----------+-------+------+
Most of the data of classified funds have "accumulated net value". In the “ fund_em_graded_fund_info” interface, I think there should also be this part of data.
我爬取生意社的时候被墙了,请问怎么把高匿代理结合到Ak包中,有没有示例?
The following regions are not working:
areas.pop('香港', None)
areas.pop('**', None)
areas.pop('澳门', None)
areas.pop('西藏', None)
areas.pop('待明确地区', None)
To reproduce, try:
epidemic_dxy_df = ak.epidemic_dxy(indicator="西藏自治区")
Error:
Traceback (most recent call last):
File "", line 14, in
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/akshare/event/sos.py", line 110, in epidemic_dxy
sub_area.columns = ["区域", "确诊人数", "疑似人数", "治愈人数", "死亡人数", "区域ID"]
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/generic.py", line 5286, in setattr
return object.setattr(self, name, value)
File "pandas/_libs/properties.pyx", line 67, in pandas._libs.properties.AxisProperty.set
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/generic.py", line 661, in _set_axis
self._data.set_axis(axis, labels)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/managers.py", line 177, in set_axis
raise ValueError(
ValueError: Length mismatch: Expected axis has 0 elements, new values have 6 elements
pip3 show akshare
Name: akshare
Version: 0.3.70
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.