plt.axvline(k - 0.5, alpha=0.6) plt.title('Northbound Cash Flow TOP' + str(k) + ' ' + date, size=title_size) plt.text((k - 4) / 2, text_loc, 'Top Inflow', size=title_size, alpha=2, bbox=dict(facecolor='g', edgecolor='blue', alpha=0.35)) plt.text((k - 4) / 2 + k, text_loc, 'Top Outflow', size=title_size, alpha=2, bbox=dict(facecolor='g', edgecolor='blue', alpha=0.35)) ax.set_xticklabels(northbound_rank.index, rotation=90, fontsize=txt_size, color='red') plt.savefig(sub_file_path + '\\%s' % 'Northbound CF TOP') today = datetime.today().date().strftime('%Y-%m-%d') attachment_list = [ sub_file_path + '\\Northbound CF TOP.png', sub_file_path + '\\北向净流出T20.png', sub_file_path + '\\北向净流入TOP20.png' ] send_email('%s:北向资金流入流出TOP个股' % today, '流入流出TOP个股', images=attachment_list, receivers=NORTH_GROUP)
fig = plt.figure(figsize=(20, 10)) ax = plt.subplot(211) hk_to_all.sum(axis=1).plot(kind='bar', legend=False, ax=ax) ax2 = ax.twinx() ax2.set_ylim(ax.get_ylim()) plt.grid(False) ax.set_title(f'Northbound Cash Flow, {hk_to_all.index[-1]:%Y-%m-%d}') ax3 = plt.subplot(212) hk_to_all.plot(kind='bar', stacked=True, legend=True, ax=ax3, sharex=True) ax4 = ax3.twinx() ax4.set_ylim(ax3.get_ylim()) plt.grid(False) ax3.set_title(f'SH vs. SZ') plt.savefig(sub_file_path + '\\%s.png' % f'SHvsSZ') today = datetime.today().date().strftime('%Y-%m-%d') attachment_list = [ sub_file_path + '\\NorthboundCashFlow1-10_%s.png' % date_end, sub_file_path + '\\NorthboundCashFlow11-20_%s.png' % date_end, sub_file_path + '\\SHNorthboundCashFlow1-10_%s.png' % date_end, sub_file_path + '\\SHNorthboundCashFlow11-20_%s.png' % date_end, sub_file_path + '\\SZNorthboundCashFlow1-10_%s.png' % date_end, sub_file_path + '\\SZNorthboundCashFlow11-20_%s.png' % date_end, sub_file_path + '\\SHvsSZ.png' ] send_email('%s:机构北向资金流动对比(按市场)' % today, '机构北向资金流动对比(按市场)', images=attachment_list, receivers=NORTH_GROUP)
plt.title('Southbound Cash Flow TOP' + str(k) + ' ' + date, size=title_size) plt.text((k - 4) / 2, text_loc, 'Top ' + str(k) + ' Inflow: ' + str(southbound_rank['CF'][:k].sum().round(2)) + '亿元\n\n' + 'Total Inflow: ' + str(southbound_cf.query('CF>0')['CF'].sum().round(2)) + '亿元', size=txt_size + 5, alpha=2, bbox=dict(facecolor='g', edgecolor='blue', alpha=0.35)) plt.text((k - 4) / 2 + k, text_loc, 'Top ' + str(k) + ' Outflow: ' + str(southbound_rank['CF'][-k:].sum().round(2)) + '亿元\n\n' + 'Total Outflow: ' + str(southbound_cf.query('CF<0')['CF'].sum().round(2)) + '亿元', size=txt_size + 5, alpha=2, bbox=dict(facecolor='g', edgecolor='blue', alpha=0.35)) plt.savefig(sub_file_path + '\\南向资金净流入净流出个股_%s' % date_end.strftime('%Y-%m-%d')) today = datetime.today().date().strftime('%Y-%m-%d') attachment_list = [sub_file_path + '\\南向资金净流入净流出个股_%s.png' % date_end] send_email('%s:南向资金净流入净流出个股' % today, '南向资金净流入净流出个股', images=attachment_list, receivers=NORTH_GROUP)
plt.axvline(9.5, alpha=0.6) plt.axvline(10.5, alpha=0.6) plt.axvline(16.5, alpha=0.6) plt.axvline(20.5, alpha=0.6) plt.axvline(23.5, alpha=0.6) plt.axvline(28.5, alpha=0.6) plt.text(1, text_loc, "周期\n" + str(cash_flow_ind.at['周期', 'cash_flow'].round(2)), size=txt_size, alpha=2, bbox=dict(facecolor='g', edgecolor='blue', alpha=0.35)) plt.text(6.5, text_loc, "制造\n" + str(cash_flow_ind.at['制造', 'cash_flow'].round(2)), size=txt_size, alpha=2, bbox=dict(facecolor='g', edgecolor='blue', alpha=0.35)) plt.text(9.6, text_loc, "医药\n" + str(cash_flow_ind.at['医药', 'cash_flow'].round(2)), size=txt_size, alpha=2, bbox=dict(facecolor='g', edgecolor='blue', alpha=0.35)) plt.text(13, text_loc, "消费\n" + str(cash_flow_ind.at['消费', 'cash_flow'].round(2)), size=txt_size, alpha=2, bbox=dict(facecolor='g', edgecolor='blue', alpha=0.35)) plt.text(18, text_loc, "科技\n" + str(cash_flow_ind.at['科技', 'cash_flow'].round(2)), size=txt_size, alpha=2, bbox=dict(facecolor='g', edgecolor='blue', alpha=0.35)) plt.text(21, text_loc, "金融\n" + str(cash_flow_ind.at['金融', 'cash_flow'].round(2)), size=txt_size, alpha=2, bbox=dict(facecolor='g', edgecolor='blue', alpha=0.35)) plt.text(25, text_loc, "基地\n" + str(cash_flow_ind.at['基地', 'cash_flow'].round(2)), size=txt_size, alpha=2, bbox=dict(facecolor='g', edgecolor='blue', alpha=0.35)) plt.text(29, text_loc, "综合\n" + str(cash_flow_ind.at['综合', 'cash_flow'].round(2)), size=txt_size, alpha=2, bbox=dict(facecolor='g', edgecolor='blue', alpha=0.35)) plt.savefig(sub_file_path+'\\%s' % "中信一级行业涨跌幅与北向资金净流入对比") today=datetime.today().date().strftime('%Y-%m-%d') attachment_list=[sub_file_path+"\\中信一级行业涨跌幅与北向资金净流入对比.png"] send_email('%s:中信一级行业分类北向资金数据' % today,'中信一级行业分类北向资金数据', images=attachment_list, receivers=NORTH_GROUP)
attachment_list8 = [] for file1, file2, file3, file4 in zip(attachment_list3, attachment_list4, attachment_list5, attachment_list6): attachment_list7.extend([file1, file2]) attachment_list8.extend([file3, file4]) attachment_list1 = [x + '.png' for x in attachment_list1] attachment_list2 = [x + '.png' for x in attachment_list2] attachment_list3 = [x + '.png' for x in attachment_list3] attachment_list4 = [x + '.png' for x in attachment_list4] attachment_list7 = [x + '.png' for x in attachment_list7] attachment_list8 = [x + '.png' for x in attachment_list8] send_email('%s:北向资金净流入TOP3机构资金去向(个股)' % today, '北向资金净流入TOP机构资金去向(个股)', images=attachment_list7, receivers=NORTH_GROUP) send_email('%s:北向资金净流出TOP3机构资金去向(个股)' % today, '北向资金净流出TOP机构资金去向(个股)', images=attachment_list8, receivers=NORTH_GROUP) send_email('%s:北向资金净流入TOP3机构资金去向(行业)' % today, '北向资金净流入TOP机构资金去向(行业)', images=attachment_list1, receivers=NORTH_GROUP) send_email('%s:北向资金净流出TOP3机构资金去向(行业)' % today, '北向资金净流出TOP机构资金去向(行业)', images=attachment_list2,
stacked=True, legend=False, ax=ax, sharex=True, width=0.3) plt.legend(loc='lower right', fontsize=14) ax2 = ax.twinx() summary.iloc[:, -1].plot(kind='bar', legend=False, ax=ax2, edgecolor='r', linewidth=3, facecolor='none') ylim = (b_limit, t_limit) ax.set_ylim(ylim) ax2.set_ylim(ylim) ax2.axis(False) ax2.grid(False) plt.gcf().autofmt_xdate() plt.title(act_top.index[j] + ' ' + act_top.iloc[j, 2] + ' (' + '%.2f%%' % act_top.iloc[j, -1].round(2) + ')', size=25) fig.suptitle(date + ' 活跃个股TOP10(按市场)', fontsize=50) plt.savefig(sub_file_path + '\\%s' % '活跃个股TOP10(按市场)') today = datetime.today().date().strftime('%Y-%m-%d') attachment_list = sub_file_path + '\\活跃个股TOP10(按市场).png' send_email('%s:北向资金成交活跃个股TOP10' % today, '成交活跃个股TOP10', images=attachment_list, receivers=NORTH_GROUP)