代码拉取完成,页面将自动刷新
同步操作将从 macroan/traderStock-gui 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#coding=utf-8
import pandas as pd
import time,datetime
import macd
import kdj
import rsi
import stock
class MacdKdjRsi:
__instance = None
@classmethod
def getInstance(cls):
if(cls.__instance == None):
cls.__instance = MacdKdjRsi()
return cls.__instance
def __init__(self):
self.Macd = macd.Macd.getInstance()
self.Kdj = kdj.Kdj.getInstance()
self.Rsi = rsi.Rsi.getInstance()
#修改了的函数,按照多个指标进行分析
#按照MACD,KDJ等进行分析
def get_TA_All(self):
operate_array1=[]
operate_array2=[]
operate_array3=[]
operate1 = 0
operate2 = 0
operate3 = 0
count = 0
#获取股票列表
#code,代码 name,名称 industry,所属行业 area,地区 pe,
#市盈率 outstanding,流通股本 totals,总股本(万) totalAssets,总资产(万)liquidAssets,流动资产
# fixedAssets,固定资产 reserved,公积金 reservedPerShare,
#每股公积金 eps,每股收益 bvps,每股净资 pb,市净率 timeToMarket,上市日期
s = stock.Stock.getInstance()
df_Code = s.get_Stock_List()
delIndex = []
for code in df_Code.index:
count = count + 1
if df_Code.loc[code]['name'][:2].lower() == "st" or df_Code.loc[code]['name'][1:3].lower() == "st":
delIndex.append(code)
continue
#过滤大盘股
if df_Code.loc[code]['outstanding']*10000 > 100000000:
delIndex.append(code)
continue
#市盈率为负数或过大
#if df_Code.loc[code]['pe'] < 0 or df_Code.loc[code]['pe'] > 500:
#delIndex.append(code)
#continue
#每股收益
#if df_Code.loc[code]['bvps'] <= 0:
#delIndex.append(code)
#continue
# index,0 - 6 date:日期 open:开盘价 high:最高价 close:收盘价
#low:最低价 volume:成交量 price_change:价格变动 p_change:涨跌幅
# 7-12 ma5:5日均价 ma10:10日均价 ma20:20日均价 v_ma5:5日均量v_ma10:10日均量 v_ma20:20日均量
operate1, operate2, operate3 = self.get_TA_One(code, start='2014-12-20')
if operate1 <=0 or operate2 <=0 or operate3 <=0:
delIndex.append(code)
continue
operate_array1.append(operate1)
operate_array2.append(operate2)
operate_array3.append(operate3)
if count == 0:
write_Blog(str(count))
time.sleep(0.1)
for code in delIndex:
df_Code = df_Code.drop(code)
df_Code['macd_score']=pd.Series(operate_array1,index=df_Code.index)
df_Code['kdj_score']=pd.Series(operate_array2,index=df_Code.index)
df_Code['rsi_score']=pd.Series(operate_array3,index=df_Code.index)
return df_Code
def get_TA_One(self, code, start):
s = stock.Stock.getInstance()
df = s.get_Hist_Data(code, start)
if df is None:
return (0, 0, 0)
#停牌的股
date = time.strftime('%Y-%m-%d',time.localtime(time.time()))
if df.iloc[0]['date'] != date and df.iloc[0]['date'] != date:
return (0, 0, 0)
dflen = df.shape[0]
operate1 = 0
operate2 = 0
operate3 = 0
print(df)
if dflen > 35:
try:
operate1, df = self.Macd.get_MACD(df)
operate2, df = self.Kdj.get_KDJ(df)
operate3, df = self.Rsi.get_RSI(df)
except Exception, e:
write_Blog(e)
return operate1, operate2, operate3
#日志记录
def write_Blog(strinput):
TODAY = datetime.date.today()
CURRENTDAY=TODAY.strftime('%Y-%m-%d')
TIME = time.strftime("%H:%M:%S")
#写入本地文件
fp = open('./output/'+'blog.txt','a')
fp.write('------------------------------\n'+CURRENTDAY +" "+TIME+" "+ str(strinput)+' \n')
fp.close()
time.sleep(1)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。