Esempio n. 1
0
def plot_candidate(s, lines):
    fig = plt.figure(figsize=(12, 9))
    gs = gridspec.GridSpec(2, 1, height_ratios=[4, 1])
    _ax1 = plt.subplot(gs[0])
    gs.update(left=0.05, right=0.48, hspace=0.0)
    ax1 = plt.subplot(gs[1])
    _gdfquotes = DataAPI.MktEqudAdjGet(ticker=s,
                                       endDate=now,
                                       field=[
                                           u'secShortName', 'tradeDate',
                                           'openPrice', 'highestPrice',
                                           'lowestPrice', 'closePrice',
                                           'turnoverVol'
                                       ],
                                       isOpen=1)
    _beginindex = max(len(_gdfquotes) - 60, 0)
    print _gdfquotes[u'secShortName'].iloc[-1], v[0]
    _ax1.set_title(u'%s' % (k[:6]), fontproperties=font, fontsize='16')
    fig.sca(_ax1)
    xg.plot_dragonpoint(_ax1, _gdfquotes, _beginindex, lines, 60)
    #成交量
    fig.sca(ax1)
    xg.plot_volume_overlay(ax1, _gdfquotes, _beginindex)
    ax1.yaxis.set_visible(False)
    plt.show()
Esempio n. 2
0
def plot_security_his(data, security_name):
    security = data[data['ticker'] == security_name]
    #reset figure for plot
    fig = plt.figure(figsize=(12, 9))
    gs = gridspec.GridSpec(2, 2, height_ratios=[4, 1], width_ratios=[3, 1])
    gs.update(hspace=0.0)
    ax0 = plt.subplot(gs[0, 0])
    ax2 = plt.subplot(gs[1, 0])
    ax1 = plt.subplot(gs[:, 1])
    plt.sca(ax0)
    plt.cla()
    #plot title
    ax0.set_title(
        u'%s%s 回报%f' %
        (security_name, security['name'].iloc[0], security['amount'].sum()),
        fontproperties=font,
        fontsize='16')
    #plot candlestick graph
    _dfquotes = mktgethis(security_name,
                          someday(str(security['tradeDate'].iloc[0]), -365),
                          someday(str(security['tradeDate'].iloc[-1]), 3), [
                              u'tradeDate', u'openPrice', u'highestPrice',
                              u'lowestPrice', u'closePrice', u'turnoverVol'
                          ])
    beginx = 0
    _period = [(x.replace('-', '')) for x in _dfquotes['tradeDate']]
    beginx = _period.index(str(security['tradeDate'].iloc[0]))
    beginx = max(beginx - 20, 0)
    xg.plot_security_k(ax0, _dfquotes, beginx)
    plotbsp(_period[beginx:], security)
    plt.grid()
    #成交量
    fig.sca(ax2)
    xg.plot_volume_overlay(ax2, _dfquotes, beginx)
    ax2.yaxis.set_visible(False)
    plt.grid()
    plottranlog(ax1, security)
    plt.tight_layout()  #to avoid the axis label is cut
    plt.show()
    plt.savefig('%s_his.svg' % (security_name))
    pass
Esempio n. 3
0
cols = []
for i in range(0, len(df)):
    cols.append('%s封板开板%i次%s封死' % (firstzt[i], kbnumber[i], lastzt[i]))

df[u'涨跌停时间'] = cols
del df['highestPrice']
del df['secID']
dfsort = df.sort_values([u'涨跌停次数', u'涨跌停时间'], ascending=[False, True])
dfsort.to_excel('dailyreview.xlsx')

#plot da pang K线图
fig = plt.figure(figsize=(12, 9))
fig.set_size_inches(24, 18)
gs = gridspec.GridSpec(2, 1, height_ratios=[4, 1])
_ax1 = plt.subplot(gs[0])
gs.update(left=0.05, right=0.48, hspace=0.0)
ax1 = plt.subplot(gs[1])
_his.columns = [
    u'secShortName', 'tradeDate', 'openPrice', 'highestPrice', 'lowestPrice',
    'closePrice', 'turnoverVol'
]
_beginindex = max(len(_his) - 120, 0)
#_ax1.set_title('%s'%(_his['secShortName'].iloc[-1]),fontproperties=font,fontsize='16')
fig.sca(_ax1)
xg.plot_security_k(_ax1, _his, _beginindex, 60)
#成交量
fig.sca(ax1)
xg.plot_volume_overlay(ax1, _his, _beginindex)
ax1.yaxis.set_visible(False)
plt.show()