1 Star 0 Fork 16

龙在江湖/traderStock-gui

forked from macroan/traderStock-gui 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
kline1.pyx 2.28 KB
一键复制 编辑 原始数据 按行查看 历史
macroan 提交于 2017-11-10 12:18 . no commit message
#coding=utf-8
import public
import talib
import pandas as pd
class Kline:
__instance = None
def __init__(self):
pass
@classmethod
def getInstance(cls):
if(cls.__instance == None):
cls.__instance = Kline()
return cls.__instance
def shape(func_name, df):
df = df[['date', 'open', 'high', 'low', 'close', 'code']]
df = df.sort_values('date', ascending=True)
open_p = df['open'].values
high_p = df['high'].values
low_p = df['low'].values
close_p = df['close'].values
if func_name == 'CDL2CROWS':
ret = talib.CDL2CROWS(open_p, high_p, low_p, close_p)
df['CDL2CROWS'] = pd.Series(ret)
df = df.sort_values('date', ascending=False)
return df
def CDL2CROWS(df):
meettotalCount, meettotal = public.init_succ_var()
df = shape(CDL2CROWS.func_name, df)
dflen = df.shape[0]
for i in xrange(dflen):
if int(df.iloc[i]['CDL2CROWS']) == -100:
meettotalCount = public.compute_succ_zf(df, i, meettotalCount, meettotal)
df.to_csv(df.iloc[0]['code']+'.csv', encoding='gbk')
return meettotalCount, meettotal
#(df.iloc[i]['high']-df.iloc[i]['open'])/(df.iloc[i]['open']-df.iloc[i]['close']) > 3.0) and \
def ZADF(df):
meettotalCount, meettotal = public.init_succ_var()
dflen = df.shape[0]
for i in xrange(dflen):
if i == 0:
continue
if i+2<dflen \
and df.iloc[i]['MA_60'] > df.iloc[i+1]['MA_60'] and df.iloc[i+1]['MA_60'] > df.iloc[i+2]['MA_60'] \
and df.iloc[i]['close'] > df.iloc[i]['MA_60']:
if (df.iloc[i]['close'] < df.iloc[i]['open']*0.95 or (df.iloc[0]['close']==df.iloc[0]['open'] and df.iloc[0]['change']<-0.098)) \
and df.iloc[i-1]['change'] > 0.095:
meettotalCount = public.compute_succ_zf(df, i-1, meettotalCount, meettotal)
return meettotalCount, meettotal
#============================选股==============================
def ZADF_XG(df, code):
retcode = 0
dflen = df.shape[0]
if 2<dflen \
and df.iloc[0]['MA_60'] > df.iloc[1]['MA_60'] and df.iloc[1]['MA_60'] > df.iloc[2]['MA_60'] \
and df.iloc[0]['close'] > df.iloc[0]['MA_60']:
if (df.iloc[0]['close'] < df.iloc[0]['open']*0.95) or (df.iloc[0]['close'] == df.iloc[0]['open'] and df.iloc[0]['change']<-0.098):
#or ((df.iloc[0]['high']-df.iloc[0]['open'])/(df.iloc[0]['open']-df.iloc[0]['close']) > 2.0):
retcode = code
return retcode
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/yizhengsh/traderStock-gui.git
git@gitee.com:yizhengsh/traderStock-gui.git
yizhengsh
traderStock-gui
traderStock-gui
master

搜索帮助