Python 金叉判定
来源:互联网 发布:电气设计软件下载 编辑:程序博客网 时间:2024/04/28 02:49
def jincha(context, bar_dict, his):
#站上5日线
def zs5(context, bar_dict, his):
ma_n = pd.rolling_mean(his, 5)
temp = his - ma_n
#temp_s包含了前一天站上五日线得股票代码
temp_s = list(temp[temp>0].iloc[-1,:].dropna().index)
return temp_s
#站上10日线
def zs10(context, bar_dict, his):
ma_n = pd.rolling_mean(his, 10)
temp = his - ma_n
temp_s = list(temp[temp>0].iloc[-1,:].dropna().index)
return temp_s
#金叉突破
def jc(context, bar_dict, his):
mas = pd.rolling_mean(his,5)
mal = pd.rolling_mean(his, 10)
temp = mas - mal
#temp_jc昨天大于0股票代码
#temp_r前天大于0股票代码
temp_jc = list(temp[temp>0].iloc[-1,:].dropna().index)
temp_r = list(temp[temp>0].iloc[-2,:].dropna().index)
temp = []
for stock in temp_jc:
if stock not in temp_r:
temp.append(stock)
return temp
#求三种条件下的股票代码交集
con1 = zs5(context, bar_dict, his)
con2 = zs10(context, bar_dict, his)
con3 = jc(context, bar_dict, his)
tar_list=[con1,con2,con3]
tarstock = tar_list[0]
for i in tar_list:
tarstock = list(set(tarstock).intersection(set(i)))
return tarstock
#站上5日线
def zs5(context, bar_dict, his):
ma_n = pd.rolling_mean(his, 5)
temp = his - ma_n
#temp_s包含了前一天站上五日线得股票代码
temp_s = list(temp[temp>0].iloc[-1,:].dropna().index)
return temp_s
#站上10日线
def zs10(context, bar_dict, his):
ma_n = pd.rolling_mean(his, 10)
temp = his - ma_n
temp_s = list(temp[temp>0].iloc[-1,:].dropna().index)
return temp_s
#金叉突破
def jc(context, bar_dict, his):
mas = pd.rolling_mean(his,5)
mal = pd.rolling_mean(his, 10)
temp = mas - mal
#temp_jc昨天大于0股票代码
#temp_r前天大于0股票代码
temp_jc = list(temp[temp>0].iloc[-1,:].dropna().index)
temp_r = list(temp[temp>0].iloc[-2,:].dropna().index)
temp = []
for stock in temp_jc:
if stock not in temp_r:
temp.append(stock)
return temp
#求三种条件下的股票代码交集
con1 = zs5(context, bar_dict, his)
con2 = zs10(context, bar_dict, his)
con3 = jc(context, bar_dict, his)
tar_list=[con1,con2,con3]
tarstock = tar_list[0]
for i in tar_list:
tarstock = list(set(tarstock).intersection(set(i)))
return tarstock
1 0
- Python 金叉判定
- python null 判定
- python 判定 NaN
- python 字典元素判定方法
- python 判定变量是函数
- Python联系题2--对称数判定
- python之 数据类型判定与类型转换
- 10 行代码判定色*情*图片——Python
- Python脚本示例[命令行参数,函数,判定,退出等]
- nyoj68 三点顺序 利用叉积判定
- 判定覆盖
- 素数判定
- 浏览器判定
- 判定字符串
- 素数判定
- 素数判定
- 素数判定
- 素数判定
- Demo02逻辑运算符__短路运算
- [Qingdao Regional]最好的周末
- android-控制屏幕常亮不锁屏
- android进阶------高性能编程---理解中
- COM 编程
- Python 金叉判定
- 安卓中五种数据存储方式
- tensorflow0.10.0升级到tensorflow.011.0
- Effective C++ 学习笔记(九)
- 测试
- c语言基本数据类型及表达式
- oracle存储过程实战练习
- linux命令行下使用github
- CodeForces 107C