Example #1
0
def kdj_select():
    ResultSymbols = list()
    ResultDf = pd.DataFrame()
    iNum = 0
    for iSymbol in da.symbol_list():
        print(iSymbol[:-4], ':', iNum)
        iNum += 1
        df = da.data_read(iSymbol)
        startDate = '20180501'
        df1 = df[df['trade_date'] > startDate]
        df2 = df1[df1['kdX'] == 1]  #满足金叉的数据
        df2_success = df2[(df2['ROC+1'] > 0) | (df2['ROC+2'] > 0) |
                          (df2['ROC+3'] > 0)]  #把预测出金叉中后三天内上涨的画出来
        if len(df2) != 0:
            success_rate = len(df2_success) / len(df2)
        else:
            continue
        if success_rate > 0.6:
            ResultSymbols.append(iSymbol)
            if df.iloc[-1, :]['kdX'] == 1:
                ResultDf = ResultDf.append(df.iloc[-1, :])
                print(iSymbol, ':',
                      '--------------------OK----------------------')

    #ResultDf.to_pickle('result_data/Select_macd.pkl')
    return ResultDf
Example #2
0
da.data_cal_index()
# 数据获取及分析,分析今日出现MACD金叉,金叉Pre的股票
import pandas as pd
import symbol_select as ss
select_Df_macd = ss.macd_select()
#select_Df_kdj=ss.kdj_select()

# 绘图
import kplot as kp
import dataAnalysis as da
import matplotlib.pyplot as plt

#ResultDf=pd.read_pickle('result_data/Select_macd.pkl')
#select_Df2=select_Df[select_Df['kdX']==1]#
select_Df = select_Df_macd
if len(select_Df) != 0:
    Symbollist = select_Df.loc[:, 'ts_code']
else:
    Symbollist = []
Symbollist.to_pickle('Symbollist.pkl')

for iSymbol in Symbollist:
    df = da.data_read(iSymbol)
    startDate = '20180501'
    df1 = df[df['trade_date'] > startDate]
    #fig=kp.kplot(df1,'MACD')#绘图
    #fig=kp.kplot(df1,'KDJ')#绘图

    fig = kp.kplot(df1, 'MACD_KDJ')
    fig.savefig('MACD_%s.jpg' % df1['ts_code'][0], dpi=600)
Example #3
0
        ax2.grid(True)
        plt.setp(ax2.get_xticklabels(), visible=True)
    elif index == 'vol':
        fig = plt.figure(figsize=[12, 8])
        ax1 = plt.axes([0.1, 0.3, 0.8, 0.6])
        ax_kline(ax1, df)
        ax2 = plt.axes([0.1, 0.1, 0.8, 0.2], sharex=ax1)
        ax2.bar(df['iNum'], df['vol'], color='b')
        ax2.plot(df['iNum'], df[['mavol5']])
        ax2.plot(df['iNum'], df[['mavol10']])
        # make these tick labels invisible
        ax2.set_ylabel('vol')
        ax2.grid(True)
        plt.setp(ax2.get_xticklabels(), visible=True)
    elif index == 'incomeSum':
        fig = plt.figure(figsize=[12, 8])
        ax1 = plt.axes([0.1, 0.3, 0.8, 0.6])
        ax_kline(ax1, df)
        ax2 = plt.axes([0.1, 0.1, 0.8, 0.2], sharex=ax1)
        ax2.plot(df['iNum'], df[['incomeSum']])
        # make these tick labels invisible
        ax2.set_ylabel('incomeSum')
        ax2.grid(True)
        plt.setp(ax2.get_xticklabels(), visible=True)
    return fig


if __name__ == '__main__':
    df = da.data_read('600000')  #读取某个文件数据
    kplot(df, 'MACD')
Example #4
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Apr  5 17:04:26 2019

@author: mac
"""
# 把所有数据获取一遍,并更新数据信息,每天运行一次即可
import dataAnalysis as da
import pandas as pd
df = da.data_read('000002.SZ')

# 绘图
import kplot as kp
import dataAnalysis as da
import matplotlib.pyplot as plt

startDate = '20181201'
df1 = df[df['trade_date'] > startDate]

df1['mavol5'] = df1['vol'].rolling(5).mean()
df1['mavol10'] = df1['vol'].rolling(10).mean()
df1.to_csv('a1.csv')
fig = kp.kplot(df1, 'vol')