wkingnet / stock-analysis

使用python进行股票分析和选股
Apache License 2.0
233 stars 98 forks source link

这个脚本太好了 #11

Open yylaji2 opened 4 months ago

yylaji2 commented 4 months ago

通达信缺陷太多,感谢wkingnet,请教一个问题,这个可以扩展为小时或者半小时线吗?

wkingnet commented 4 months ago

通达信缺陷太多,感谢wkingnet,请教一个问题,这个可以扩展为小时或者半小时线吗?

理论可以,我没有实现。

通达信就两种线的数据。 日线:基于日线生成周线、季线、年线等。 1分钟线:基于1分钟线生成5、30、60分钟线等。

所以你需要获取1分钟线,自己算其他分钟线。

首先你要下载通达信1分钟线数据,然后怎么解析通达信数据,我代码里有,你可以研究组合一下。

yylaji2 commented 3 months ago

谢谢,奇怪,这几天发现了报错: data['if_trade'].fillna(value=False, inplace=True) # if_trade列,无效的值填充为False d:\happywork\python\stock-analysis-master\func.py:549: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. data.fillna(method='ffill', inplace=True) # 向下填充无效值 d:\happywork\python\stock-analysis-master\func.py:601: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. data = data.fillna(method='ffill') # 向下填充无效值 d:\happywork\python\stock-analysis-master\func.py:602: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. data = data.fillna(method='bfill') # 向上填充无效值 为了弥补开始几行的空值 d:\happywork\python\stock-analysis-master\func.py:548: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method. The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.

data['if_trade'].fillna(value=False, inplace=True) # if_trade列,无效的值填充为False d:\happywork\python\stock-analysis-master\func.py:549: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. data.fillna(method='ffill', inplace=True) # 向下填充无效值 d:\happywork\python\stock-analysis-master\func.py:601: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. data = data.fillna(method='ffill') # 向下填充无效值 d:\happywork\python\stock-analysis-master\func.py:602: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. data = data.fillna(method='bfill') # 向上填充无效值 为了弥补开始几行的空值 d:\happywork\python\stock-analysis-master\func.py:548: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method. The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object. 就是在读取日线,复权时候一堆提醒代码。

notanymore commented 2 weeks ago

谢谢,奇怪,这几天发现了报错: data['if_trade'].fillna(value=False, inplace=True) # if_trade列,无效的值填充为False d:\happywork\python\stock-analysis-master\func.py:549: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. data.fillna(method='ffill', inplace=True) # 向下填充无效值 d:\happywork\python\stock-analysis-master\func.py:601: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. data = data.fillna(method='ffill') # 向下填充无效值 d:\happywork\python\stock-analysis-master\func.py:602: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. data = data.fillna(method='bfill') # 向上填充无效值 为了弥补开始几行的空值 d:\happywork\python\stock-analysis-master\func.py:548: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method. The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.

data['if_trade'].fillna(value=False, inplace=True) # if_trade列,无效的值填充为False d:\happywork\python\stock-analysis-master\func.py:549: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. data.fillna(method='ffill', inplace=True) # 向下填充无效值 d:\happywork\python\stock-analysis-master\func.py:601: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. data = data.fillna(method='ffill') # 向下填充无效值 d:\happywork\python\stock-analysis-master\func.py:602: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. data = data.fillna(method='bfill') # 向上填充无效值 为了弥补开始几行的空值 d:\happywork\python\stock-analysis-master\func.py:548: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method. The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object. 就是在读取日线,复权时候一堆提醒代码。

在func.py文件中找到有以上warning提示的行(549、601、602行),进行以下修改: 把 data.fillna(method='ffill', inplace=True) 改为 data.ffill(inplace=True) 把 data.fillna(method='bfill', inplace=True) 改为 data.bfill(inplace=True)

wkingnet commented 2 weeks ago

感谢提醒,是pandas版本升级改动函数了。