clear all close all clc set(0,'DefaultTextFontSize',12); set(0,'DefaultAxesFontSize',12); set(0,'DefaultLineLineWidth',2); set(0,'DefaultLineMarkerSize',12); block=urlread('https://fred.stlouisfed.org/data/M2SL.txt'); readData=textscan(block, '%s %s'); X01=readData{1,1}; Y0=readData{1,2}; X=datenum(X01(end-12*15:end)); Y=str2double(Y0(end-12*15:end)); figure(length(findobj('type','figure'))+1) plot(X(2:end),100*(Y(2:end)./Y(1:end-1)-1),'b',X(2:end), movmean(100*(Y(2:end)./Y(1:end-1)-1),[11 0]),'m') ylabel('M2 Monthly Variation [%]') datetick('x',10) grid on %% block=urlread('https://fred.stlouisfed.org/data/DGS10.txt'); readData=textscan(block, '%s %s'); X0=readData{1,1}; Y0=readData{1,2}; X=datenum(X0(end-15*260:end)); Y=str2double(Y0(end-15*260:end)); figure(length(findobj('type','figure'))+1) plot(X,Y,'b') hold on datetick('x',10) X_10Y=X; Y_10Y=Y; clear X0 Y0 X Y grid on ylabel('10 Year T-Bond Yield') %% block=urlread('https://fred.stlouisfed.org/data/CPIAUCSL.txt'); readData=textscan(block, '%s %s'); X0=readData{1,1}; Y0=readData{1,2}; X=datenum(X0(end-15*12:end)); Y=str2double(Y0(end-15*12:end)); Y_CPI_YoY=100*((Y(1+12:end)./Y(1:end-12))-1); %% figure(length(findobj('type','figure'))+1) hold on plot(X(2:end),100*((Y(2:end)./Y(1:end-1)).^12-1),'m') datetick('x',10) X_CPIm=X; Y_CPIm=100*((Y(2:end)./Y(1:end-1)).^12-1); mean(Y_CPIm) clear X0 Y0 X Y grid on Y_10Ym=interp1(X_10Y,Y_10Y,X_CPIm,'v5cubic'); Yieal_10Y_real=-Y_CPIm+Y_10Ym(2:end); hold on plot(X_CPIm(2:end),Yieal_10Y_real,'k') %legend('CPI [%]','PPI [%]','Real 10Y Yield [%]') legend('Annualized Monthly Inflation [%]','Real 10Y Yield [%]') datetick('x',10) clear X0 Y0 X Y grid on median_cpi=median(Y_CPIm) median_real_yield=median(Yieal_10Y_real,'omitnan') yield_10Y_avg_trgt=median_cpi+median_real_yield %% block=urlread('https://fred.stlouisfed.org/data/INDPRO.txt'); readData=textscan(block, '%s %s'); X0=readData{1,1}; Y0=readData{1,2}; X=datenum(X0(end-15*12:end)); Y=str2double(Y0(end-15*12:end)); figure(length(findobj('type','figure'))+1) hold on plot(X,Y,'b') X_prod=X; Y_prod=Y; ylabel('Industrial Production [-]') datetick('x',10) clear X0 Y0 X Y grid on %% block=urlread('https://fred.stlouisfed.org/data/PCE.txt'); readData=textscan(block, '%s %s'); X0=readData{1,1}; Y0=readData{1,2}; X=datenum(X0(end-12*50:end)); Y=str2double(Y0(end-12*50:end)); Y_PCE=Y; X_PCE=X; Ydd=0; for i0=2:length(Y) Ydd=[Ydd; Y(i0)/max(Y(1:i0))-1]; end figure(length(findobj('type','figure'))+1) hold on plot(X,Ydd,'g') ylabel('Personal Consumption Drawdown') datetick('x',10) clear X0 Y0 X Y grid on %% block=urlread('https://fred.stlouisfed.org/data/AMTUNO.txt'); readData=textscan(block, '%s %s'); X0=readData{1,1}; Y0=readData{1,2}; X=datenum(X0(end-12*30:end)); Y=str2double(Y0(end-12*30:end)); figure(length(findobj('type','figure'))+1) hold on plot(X,Y,'b') ylabel('Manufacturing Unfilled New Orders') datetick('x',10) clear X0 Y0 X Y grid on %% block=urlread('https://fred.stlouisfed.org/data/RETAILIRSA.txt'); readData=textscan(block, '%s %s'); X0=readData{1,1}; Y0=readData{1,2}; X=datenum(X0(end-12*20:end)); Y=str2double(Y0(end-12*20:end)); figure(length(findobj('type','figure'))+1) hold on plot(X,Y,'b') ylabel('Inventories to Sale Ratio') datetick('x',10) clear X0 Y0 X Y grid on %% block=urlread('https://fred.stlouisfed.org/data/DSPI.txt'); readData=textscan(block, '%s %s'); X0=readData{1,1}; Y0=readData{1,2}; X=datenum(X0(end-15*12:end)); Y=str2double(Y0(end-15*12:end)); %% X_DSPI=X; Y_DSPI=100*((Y(1+12:end)./Y(1:end-12))-1); %Y_DSPI=100*((Y(2:end)./Y(1:end-1)).^12-1); figure(length(findobj('type','figure'))+1) hold on plot(X(1+12:end),Y_DSPI,'m',X(1+12:end),Y_CPI_YoY,'k') datetick('x',10) %ylabel('Annualized Disposable Income Variation [%]') legend('Disposable Income YoY [%]','CPI YoY [%]') grid on ylim([-25 25]) AVG_Annualized_Disposable_Income=median(100*((Y(2:end)./Y(1:end-1)).^12-1)) clear X0 Y0 X Y %% webpage=urlread('https://www.multpl.com/s-p-500-pe-ratio'); str_current_val='S&P 500 PE Ratio:'; k_current_val = strfind(webpage,str_current_val); PE_Current=str2num(webpage(k_current_val+length(str_current_val)+1:... k_current_val+length(str_current_val)+1+4)); PE_mean=17.48; PE_std=10.53; Relative_SP500_Valuation=PE_Current/PE_mean; figure(length(findobj('type','figure'))+1) bar(Relative_SP500_Valuation) set(gca,'XTick',[]) ylabel('PE SP500 Valuation [-]') grid on title(['Overvaluation: ' num2str((Relative_SP500_Valuation-1)*100,4) ' [%]']) %% block=urlread('https://fred.stlouisfed.org/data/PSAVERT.txt'); readData=textscan(block, '%s %s'); X0=readData{1,1}; Y0=readData{1,2}; X=datenum(X0(end-12*20:end)); Y=str2double(Y0(end-12*20:end)); figure(length(findobj('type','figure'))+1) hold on plot(X,Y,'b') ylabel('Personal Saving Rate') datetick('x',10) %clear X0 Y0 X Y grid on %% block=urlread('https://fred.stlouisfed.org/data/CCLACBW027SBOG.txt'); readData=textscan(block, '%s %s'); X0=readData{1,1}; Y0=readData{1,2}; X1=datenum(X0(end-52*10:end)); Y1=str2double(Y0(end-52*10:end)); Y=100*(Y1(2:end)./Y1(1:end-1)-1); X=X1(2:end); CreditCardSpendingVariation_YoY=100*((mean(Y/100)+1)^52-1) figure(length(findobj('type','figure'))+1) hold on plot(X,Y,'b',X,movmean(Y,[51 0]),'m') ylabel('Credit Cards and Other Revolving Plans WoW [%]') datetick('x',10) %clear X0 Y0 X Y grid on