Code Monkey home page Code Monkey logo

Comments (16)

pipivv avatar pipivv commented on September 23, 2024 1

第一步成功运行,但是运行第二步时候(python task/zh_get_daily.py)又出现了新的错误

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

from market-breadth.

pipivv avatar pipivv commented on September 23, 2024 1

第一步成功运行,但是运行第二步时候(python task/zh_get_daily.py)又出现了新的错误
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

遇到同样问题,macOS

Processing 第 1 批 【0~40/2342】...
[*********************100%***********************]  40 of 40 completed
Traceback (most recent call last):
  File "task/us_get_daily.py", line 65, in <module>
    df = analysis.stock_analysis(df, 20, 60, 120)
  File "task/../tools/util/analysis.py", line 148, in stock_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 "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 7552, in apply
    return op.get_result()
  File "/usr/local/lib/python3.7/site-packages/pandas/core/apply.py", line 178, in get_result
    return self.apply_raw()
  File "/usr/local/lib/python3.7/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 "/usr/local/lib/python3.7/site-packages/numpy/lib/shape_base.py", line 379, in apply_along_axis
    res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
  File "/usr/local/lib/python3.7/site-packages/pandas/core/apply.py", line 228, in wrapper
    result = func(*args, **kwargs)
  File "task/../tools/util/analysis.py", line 90, in <lambda>
    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

我把analysis.py里面的raw=true改成false可以运行了,不过有些数据(如pe)获取不到,都是返回null。

from market-breadth.

hk-Lei avatar hk-Lei commented on September 23, 2024 1

我重新修改了下 tools 的引入方式,你们看一下正常了没

from market-breadth.

kentio avatar kentio commented on September 23, 2024

可以告知一下启动执行的命令吗?
从rep代码结构来看应该是执行python task/zh_get_info.py

from market-breadth.

pipivv avatar pipivv commented on September 23, 2024

对,就是执行上面命令后出错

from market-breadth.

kentio avatar kentio commented on September 23, 2024

我尝试了一下,不过我遇到了其他的问题,环境太耦合了,不太规范,我放弃了,建议参照代码思路即可

from market-breadth.

moonmonk14134 avatar moonmonk14134 commented on September 23, 2024

there is a missing "init.py" file in tools (package) directory. it is a multi-level package, every level must have a "init.py" file.
To fix the above error, create an empty "init.py" in tools directory.
In tools directory>>>.
$> ls
"init.py" pycache/ mydb/ util/

from market-breadth.

hk-Lei avatar hk-Lei commented on September 23, 2024

我加上了 tools/init.py

from market-breadth.

pipivv avatar pipivv commented on September 23, 2024

已经加了init.py。结果还是一样ModuleNotFoundError: No module named 'tools.mydb'。
不知道是不是mysql版本问题,现在用的是8.0

from market-breadth.

hk-Lei avatar hk-Lei commented on September 23, 2024

我理解和 mysql 版本没关系的,Windows 的话 用 python .\task\zh_get_daily.py

from market-breadth.

MARGI3 avatar MARGI3 commented on September 23, 2024

第一步成功运行,但是运行第二步时候(python task/zh_get_daily.py)又出现了新的错误

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

遇到同样问题,macOS

Processing 第 1 批 【0~40/2342】...
[*********************100%***********************]  40 of 40 completed
Traceback (most recent call last):
  File "task/us_get_daily.py", line 65, in <module>
    df = analysis.stock_analysis(df, 20, 60, 120)
  File "task/../tools/util/analysis.py", line 148, in stock_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 "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 7552, in apply
    return op.get_result()
  File "/usr/local/lib/python3.7/site-packages/pandas/core/apply.py", line 178, in get_result
    return self.apply_raw()
  File "/usr/local/lib/python3.7/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 "/usr/local/lib/python3.7/site-packages/numpy/lib/shape_base.py", line 379, in apply_along_axis
    res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
  File "/usr/local/lib/python3.7/site-packages/pandas/core/apply.py", line 228, in wrapper
    result = func(*args, **kwargs)
  File "task/../tools/util/analysis.py", line 90, in <lambda>
    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

from market-breadth.

moonmonk14134 avatar moonmonk14134 commented on September 23, 2024

Same here now.

  1. python task/us_get_info.py works.
  2. python task/us_get_daily.py >> error >
    TRUNCATE TABLE us_stocks_d;
    =========================================
    Processing 第 1 批 【0~40/2342】...
    [100%**] 40 of 40 completed
    Traceback (most recent call last):
    File "task/us_get_daily.py", line 65, in
    df = analysis.stock_analysis(df, 20, 60, 120)
    File "/Users/jchang/gh/python/leilone/market-breadth-main/tools/util/analysis.py", line 148, in stock_analysis
    data = stock_gap_and_over(data)
    File "/Users/jchang/gh/python/leilone/market-breadth-main/tools/util/analysis.py", line 91, in stock_gap_and_over
    axis=1, raw=True)
    File "/Users/jchang/gh/python/leilone/lib/python3.7/site-packages/pandas/core/frame.py", line 7548, in apply
    return op.get_result()
    File "/Users/jchang/gh/python/leilone/lib/python3.7/site-packages/pandas/core/apply.py", line 178, in get_result
    return self.apply_raw()
    File "/Users/jchang/gh/python/leilone/lib/python3.7/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 "/Users/jchang/gh/python/leilone/lib/python3.7/site-packages/numpy/lib/shape_base.py", line 379, in apply_along_axis
    res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
    File "/Users/jchang/gh/python/leilone/lib/python3.7/site-packages/pandas/core/apply.py", line 228, in wrapper
    result = func(*args, **kwargs)
    File "/Users/jchang/gh/python/leilone/market-breadth-main/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
    =================================================
    Are some values not "integers" causing this IndexError ?

from market-breadth.

MARGI3 avatar MARGI3 commented on September 23, 2024

第一步成功运行,但是运行第二步时候(python task/zh_get_daily.py)又出现了新的错误
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

遇到同样问题,macOS

Processing 第 1 批 【0~40/2342】...
[*********************100%***********************]  40 of 40 completed
Traceback (most recent call last):
  File "task/us_get_daily.py", line 65, in <module>
    df = analysis.stock_analysis(df, 20, 60, 120)
  File "task/../tools/util/analysis.py", line 148, in stock_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 "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 7552, in apply
    return op.get_result()
  File "/usr/local/lib/python3.7/site-packages/pandas/core/apply.py", line 178, in get_result
    return self.apply_raw()
  File "/usr/local/lib/python3.7/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 "/usr/local/lib/python3.7/site-packages/numpy/lib/shape_base.py", line 379, in apply_along_axis
    res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
  File "/usr/local/lib/python3.7/site-packages/pandas/core/apply.py", line 228, in wrapper
    result = func(*args, **kwargs)
  File "task/../tools/util/analysis.py", line 90, in <lambda>
    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

我把analysis.py里面的raw=true改成false可以运行了,不过有些数据(如pe)获取不到,都是返回null。

刚试了一下, 脚本跑成功了。 但是最后分析出来的图表有点看不懂,感觉数据不对

最后的 TOTAL 的值 不应该是 前面所有 Industry value 相加的结果吗? 为啥感觉对不上

更正 TOTAL = average of (industry value1 + industry value2 + .......)

from market-breadth.

moonmonk14134 avatar moonmonk14134 commented on September 23, 2024

@hk-Lei
Request.txt :你跑的MySQL 是版本8 如果是3.X至3.7 。tabbles'的collate 設定值要改為utf8mb4_general_ci.
imgkit: 不只install imgkit, 是不是也要 install wkhtmltoimage on OS from https://wkhtmltopdf.org

ThX

from market-breadth.

moonmonk14134 avatar moonmonk14134 commented on September 23, 2024

@hk-Lei

  1. downloaded new updates and run
    $> python task/us_get_daily.py
    Processing 第 61 批 【2400~2440/2404】...
    [100%**] 4 of 4 completed
    Download Data use 0:09:21.198070

很好

mysql> SELECT * FROM us_stocks_sector_d ORDER BY date desc ;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 2330
Current database: lei

+------------+------+------+------+------+------+------+------+------+------+------+------+-------+
| date | MAT | COM | CNS | CND | ENE | FIN | HLT | IND | REI | TEC | UTL | TOTAL |
+------------+------+------+------+------+------+------+------+------+------+------+------+-------+
| 2020-11-11 | 89 | 80 | 77 | 75 | 96 | 95 | 84 | 88 | 81 | 82 | 89 | 85 |
| 2020-11-10 | 93 | 76 | 61 | 67 | 96 | 88 | 75 | 88 | 77 | 69 | 93 | 80 |
| 2020-11-09 | 89 | 72 | 42 | 62 | 96 | 88 | 81 | 81 | 65 | 85 | 89 | 77 |

TOTAL: 不對
CNS:77 但是 https://slack-files.com/TKX46TJ4X-F01EJQSD3EE-770862c623 是 75.

from market-breadth.

moonmonk14134 avatar moonmonk14134 commented on September 23, 2024

I got the image below on my Mac OS Cataline 10.15.7 after running python task/us_get_daily.py.
CNS issue is a minor issue. But TOTAL has to be fixed in the script.

python --version
Python 3.7.3
mysql> select @@Version
-> ;
+------------+
| @@Version |
+------------+
| 5.7.32-log |
+------------+

Market-Breadth-US

from market-breadth.

Related Issues (17)

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.