Code Monkey home page Code Monkey logo

market-breadth's Issues

pandas版本0.25.3 numpy版本1.20.0,执行us_get_info.py报错:<attribute 'dtype' of 'numpy.generic' objects>

开发者您好:
pandas版本0.25.3 numpy版本1.20.0,执行us_get_info.py报错:<attribute 'dtype' of 'numpy.generic' objects>
尝试了一些旧版本numpy,1.18.1还有1.16.5会报错:numpy.ndarray size changed, may indicate binary incompatibility,尝试改变pandas的版本,比如最新的,又会报错:pandas.errors.ParserError: Error tokenizing data...

请教您的环境是哪个版本的numpy?

Traceback (most recent call last):
File "D:/Depix-main/newmarket-breadth-main/task/us_get_info.py", line 28, in
mydb.upsert_table(info_table, spx_columns, us.get_spx())
File "D:/Depix-main/newmarket-breadth-main/task..\tools\util\us.py", line 41, in get_spx
return pd.DataFrame({'code': symbol_list, 'name': name_list, 'is_spx': 'Y', 'sp_sector': sector_list})
File "D:\Depix-main\venv\lib\site-packages\pandas\core\frame.py", line 411, in init
mgr = init_dict(data, index, columns, dtype=dtype)
File "D:\Depix-main\venv\lib\site-packages\pandas\core\internals\construction.py", line 257, in init_dict
return arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype)
File "D:\Depix-main\venv\lib\site-packages\pandas\core\internals\construction.py", line 82, in arrays_to_mgr
arrays = _homogenize(arrays, index, dtype)
File "D:\Depix-main\venv\lib\site-packages\pandas\core\internals\construction.py", line 322, in _homogenize
val = sanitize_array(
File "D:\Depix-main\venv\lib\site-packages\pandas\core\internals\construction.py", line 712, in sanitize_array
subarr = construct_1d_arraylike_from_scalar(value, len(index), dtype)
File "D:\Depix-main\venv\lib\site-packages\pandas\core\dtypes\cast.py", line 1233, in construct_1d_arraylike_from_scalar
subarr = np.empty(length, dtype=dtype)
TypeError: Cannot interpret '<attribute 'dtype' of 'numpy.generic' objects>' as a data type

进程已结束,退出代码1

usstock.get_symbols() return error, please check the traceback log

python task/us_get_info.py
Traceback (most recent call last):
File "C:\Python-workspace\marketbreath\market-breadth\task\us_get_info.py", line 37, in
symbols, msg = usstock.get_symbols()
File "C:\Users\joann\AppData\Local\Programs\Python\Python39\lib\site-packages\opendatatools\usstock\usstock_interface.py", line 11, in get_symbols
return usstock_agent.get_symbols()
File "C:\Users\joann\AppData\Local\Programs\Python\Python39\lib\site-packages\opendatatools\usstock\usstock_agent.py", line 37, in get_symbols
df_nasdaq = self._get_symbols('nasdaq')
File "C:\Users\joann\AppData\Local\Programs\Python\Python39\lib\site-packages\opendatatools\usstock\usstock_agent.py", line 32, in _get_symbols
df = pd.read_csv(io.BytesIO(response))
File "C:\Users\joann\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\parsers.py", line 686, in read_csv
return _read(filepath_or_buffer, kwds)
File "C:\Users\joann\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\parsers.py", line 458, in _read
data = parser.read(nrows)
File "C:\Users\joann\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\parsers.py", line 1196, in read
ret = self._engine.read(nrows)
File "C:\Users\joann\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\parsers.py", line 2155, in read
data = self._reader.read(nrows)
File "pandas_libs\parsers.pyx", line 847, in pandas._libs.parsers.TextReader.read
File "pandas_libs\parsers.pyx", line 862, in pandas._libs.parsers.TextReader._read_low_memory
File "pandas_libs\parsers.pyx", line 918, in pandas._libs.parsers.TextReader._read_rows
File "pandas_libs\parsers.pyx", line 905, in pandas._libs.parsers.TextReader._tokenize_rows
File "pandas_libs\parsers.pyx", line 2042, in pandas._libs.parsers.raise_parser_error
pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 23, saw 45

无法运行only integers, slices (`:`), ellipsis (`...`)

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices
在analysis.py文件中,提示一个函数库使用错误:

data['is_gap'] = data.apply( lambda row: is_gap(row['high'], row['low'], row['close'], row['pre_high'], row['pre_low'], row['pre_close']), axis=1, raw=True) data['is_esm_over'] = data.apply( lambda row: is_over(row['esm'], row['pesm']), axis=1, raw=True) data['is_eml_over'] = data.apply( lambda row: is_over(row['eml'], row['peml']), axis=1, raw=True)

最终分析结果 图标中的 TOTAL 数值问题

最终分析的图表中的 TOTAL column 的数值,按照理解应该是 所有 industry 的value 相加的结果。

TOTAL = (MAT + COM + CNS + CND + NEN + .......) ?

但是发现 数值对不上,是我的理解有问题吗?谢谢!

zh_get_daily.py 报错

$ python3.6 task/zh_get_daily.py
清空表数据:
TRUNCATE TABLE zh_stocks_d;

processing [1/4056] : 000001.SZ
Traceback (most recent call last):
File "task/zh_get_daily.py", line 59, in
df = analysis.stock_zh_analysis(df, 20, 60, 120)
File "task/../tools/util/analysis.py", line 164, in stock_zh_analysis
data = stock_gap_and_over(data)
File "task/../tools/util/analysis.py", line 91, in stock_gap_and_over
axis=1, raw=True)
File "/home/wawa/.local/lib/python3.6/site-packages/pandas/core/frame.py", line 7552, in apply
return op.get_result()
File "/home/wawa/.local/lib/python3.6/site-packages/pandas/core/apply.py", line 178, in get_result
return self.apply_raw()
File "/home/wawa/.local/lib/python3.6/site-packages/pandas/core/apply.py", line 235, in apply_raw
result = np.apply_along_axis(wrap_function(self.f), self.axis, self.values)
File "<array_function internals>", line 6, in apply_along_axis
File "/home/wawa/.local/lib/python3.6/site-packages/numpy/lib/shape_base.py", line 379, in apply_along_axis
res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
File "/home/wawa/.local/lib/python3.6/site-packages/pandas/core/apply.py", line 228, in wrapper
result = func(*args, **kwargs)
File "task/../tools/util/analysis.py", line 90, in
lambda row: is_gap(row['high'], row['low'], row['close'], row['pre_high'], row['pre_low'], row['pre_close']),
IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

us_get_daily: Max retries exceeded

执行us_get_daily时会抛出异常:
requests.exceptions.ProxyError: HTTPSConnectionPool(host='query1.finance.yahoo.com', port=443): Max retries exceeded with url: /v8/finance/chart/NFJ?period1=1607529600&period2=1607616000&interval=1d&includePrePost=False&events=div%2Csplits (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None)))

尝试科学上网并更换IP依然无果,请问如何处理?

国内用户访问不到维基百科有没有代理的方法

raise MaxRetryError(_pool, url, error or ResponseError(cause))

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='en.wikipedia.org', port=80): Max retries exceeded with url: /wiki/List_of_S%26P_500_companies (Caused by Ne
wConnectionError('<urllib3.connection.HTTPConnection object at 0x000002301F16D1C8>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有
正确答复或连接的主机没有反应,连接尝试失败。'))

美股市场宽度生成不了。

df = mydb.read_from_sql('SELECT * FROM us_stocks_sector_d ORDER BY date desc;')
mb_name = path + './data/Market-Breadth-US.jpg'
analysis.market_breadth(df, mb_name)

us_stocks_sector_d是不是应该是us_stocks_d

请问怎样获取历史数据?

我搭好了环境,然后运行'python task/zh_get_info.py' 命令行报错,df1 = df.loc[df['section_name'] == "一级行业"] 在zh_get_info.py的126行这里报错。
我检查了数据库,里面只有我建的表,但没有数据,感觉是缺少数据导致分析出错的。

请问怎么下载到历史数据写到表里?谢谢

opendatatools这个包已经失效,如何修复?

(base) PS C:\WINDOWS\system32> pip install opendatatools
Collecting opendatatools
Using cached OpenDataTools-1.0.0-py3-none-any.whl.metadata (1.1 kB)
Requirement already satisfied: requests in d:\programdata\anaconda3\lib\site-packages (from opendatatools) (2.31.0)
Requirement already satisfied: bs4 in d:\programdata\anaconda3\lib\site-packages (from opendatatools) (0.0.1)
Requirement already satisfied: pandas in d:\programdata\anaconda3\lib\site-packages (from opendatatools) (2.0.3)
Collecting demjson (from opendatatools)
Using cached demjson-2.2.4.tar.gz (131 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
error in demjson setup command: use_2to3 is invalid.
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
(base) PS C:\WINDOWS\system32>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.