get_sector_data().plot(kind='bar',colormap='jet',title='Performance (Long term Annualized)').get_figure().savefig('sector.png',bbox_inches='tight')

e=Email(subject='Morning Update: Sector Performance')
e.add_attachment('sector.png')
e.send()



def get_sp_future():
    return quandl.get("CHRIS/CME_SP1", authtoken=token).resample(rule='d').last().Last.dropna()

sp=get_sp_future()
pct_returns=sp.pct_change()
short_days=1
long_days=60
z=(pd.Series.ewm(pct_returns,short_days).mean()-pd.Series.ewm(pct_returns,long_days).mean())/(pd.Series.ewm(pct_returns,long_days).std())

if z.abs().iloc[-1]>1:
	df=pd.DataFrame()
	df['SP']=sp
	df['Z score']=z
	ax=df['2018':].plot(secondary_y='SP')
	ax.get_figure().savefig('zscore_sp.png')
	e=Email(subject='Morning Update: S&P 500 1sd Move')
	e.add_attachments(['zscore_sp.png'])
	e.send()
else:
	print('No email')


Пример #2
0
}
data_index = pd.DataFrame()
for i in indices.keys():
    file = 'https://wholesale.banking.societegenerale.com/fileadmin/indices_feeds/' + indices[
        i]
    data_index[i] = pd.read_csv(file,
                                sep='\t',
                                index_col=0,
                                parse_dates=[0],
                                usecols=[0, 1]).ix[:, 0]

data_pct = data_index.pct_change()

ax1 = data_pct['2019':].cumsum().ffill().plot(colormap='jet')
ax1.set_xlabel("")
ax1.get_figure().savefig('socgen.png')
plt.show()
plt.gcf().clear()

df = pd.DataFrame()
df['CTA'] = data_index.CTA
df['SP500'] = quandl.get('CHRIS/CME_SP1', authtoken=token).Last
df = df.dropna().pct_change()
ax2 = pd.ewmcorr(df.CTA, df['SP500'], 20)['2019':].plot(
    colormap='jet', title='20 Day Rolling Correlation: CTA index to S&P 500')
ax2.set_xlabel("")
ax2.get_figure().savefig('socgen_corr.png')

e = Email(subject='Morning Update: Soc Gen Indices')
e.add_attachments(['socgen.png', 'socgen_corr.png'])
e.send()