From 4d21882220fa7589afe65e3bd89363c623ffc365 Mon Sep 17 00:00:00 2001 From: mdnahas Date: Sat, 29 Jul 2017 19:54:48 -0500 Subject: [PATCH] Small fix and updated documentation from running on OSX (#1) * Made code run on Unix systems. Removed Windows-specific directory slash. * Updated README.md for my experience installing on OSX * Added file describing my install experience on OSX --- README.md | 6 ++++-- data_read.py | 8 +++---- install_log__OSX__2017_Jun_20.txt | 35 +++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) mode change 100644 => 100755 data_read.py create mode 100644 install_log__OSX__2017_Jun_20.txt diff --git a/README.md b/README.md index 373f280..edd1144 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ All the yield curve data files (i.e A_Country_All_Data_Bloomberg.xlsm) for the r For initial reproduction of results, sample data files (i.e A_Country_All_Data_Bloomberg.xls) for the respective countries have been provided till November 2015. Instructions for generating the results -1. Generation of Yield curve data: data_read.py script generates the spliced yield curve dataset (Govt. data spliced with the OIS data after a specific date) for a respective country (Line 61 in the code) in monthly, weekly and daily csv formats. -2. Generation of Shadow rate and other results: AAA_RUN_KANSM2_Est_LB.py script generates the results in a csv format as in the “Comparison of international monetary policy measures” for a respective country (Line 27) in the desired frequency (Line 28). +0. Install pip (E.g., on Unix run "sudo easy_install pip") +1. Install libraries. (E.g. run "pip install openpyxl") +2. Run "python data\_read.py" This generates yield curve data. The script generates the spliced yield curve dataset (Govt. data spliced with the OIS data after a specific date) for a respective country (Line 61 in the code) in monthly, weekly and daily csv formats. +3. Run "python AAA\_RUN\_KANSM2\_Est\_LB.py" This generates the shadow rate and other results. The script generates the results in a csv format as in the “Comparison of international monetary policy measures” for a respective country (Line 27) in the desired frequency (Line 28). Please Note: Currently the code uses given parameters (FinalNaturalParameters_Country.dat) but you have the option (Line 23) of estimating it from the whole dataset, although the code running time becomes slower and needs to be optimized further. diff --git a/data_read.py b/data_read.py old mode 100644 new mode 100755 index d713499..4112f0d --- a/data_read.py +++ b/data_read.py @@ -60,8 +60,8 @@ def filter_data(a,index,dim): Country='UK'# US, EA, JP, UK. CurveType='OIS' -PathName=os.getcwd()+'\\' -ExcelName=PathName+'A_'+Country+'_All_Data_Bloomberg.xlsx' +PathName=os.getcwd() +ExcelName=os.path.join(PathName, 'A_'+Country+'_All_Data_Bloomberg.xlsx') if CurveType is 'OIS': ExcelSheetName='D. Live OIS data' if CurveType is 'Govt': @@ -140,7 +140,7 @@ def filter_data(a,index,dim): #GOVT if Country is 'EA': - wbG=openpyxl.load_workbook(PathName+'A_GE_All_Data_Bloomberg.xlsx') + wbG=openpyxl.load_workbook(os.path.join(PathName, 'A_GE_All_Data_Bloomberg.xlsx')) sheet=wbG.get_sheet_by_name('D. Live Govt data') datenumG = [[] for i in range(len(datelist))] values_dataG=[[] for i in range(len(datelist))] @@ -182,7 +182,7 @@ def filter_data(a,index,dim): post_euro_ge_index=filter_data(common_datenumG,index_to_del,1) post_euro_ge_vlues=filter_data(values_dataG,index_to_del,len(values_dataG)) - wbF=openpyxl.load_workbook(PathName+'A_FR_All_Data_Bloomberg.xlsx') + wbF=openpyxl.load_workbook(os.path.join(PathName, 'A_FR_All_Data_Bloomberg.xlsx')) sheet=wbG.get_sheet_by_name('D. Live Govt data') datenumF = [[] for i in range(len(datelist))] values_dataF=[[] for i in range(len(datelist))] diff --git a/install_log__OSX__2017_Jun_20.txt b/install_log__OSX__2017_Jun_20.txt new file mode 100644 index 0000000..1eb1a52 --- /dev/null +++ b/install_log__OSX__2017_Jun_20.txt @@ -0,0 +1,35 @@ +# This is the log of the commands run by Michael Nahas +# when I installed on 2017 Jun 19. +# on OSX 10.10.5 Yosemite + +# May need pip. Installed in /usr/local/bin/pip +# sudo easy_install pip + +# Tried to run this. It hit an exception, so I skipped it. +#pip install --upgrade pip + +# needed library +# I added --user flag when I had permissions error. +pip install openpyxl + +# Had to remove Windows-specific directory slash \\ so that it worked on Unix. +python data_read.py + +# That command created these files: +# UK_Daily.csv +# UK_Monthly. csv +# UK_Weekly.csv + +python ./AAA_RUN_KANSM2_Est_LB.py + +# That command opened a number of graphs +# It created files: +# EMS_Monthly.jpg +# ETZ_Monthly.jpg +# SSR_Monthly.jpg +# UK_GSW_Govt_rL_Est_30.000000_KANSM2_Monthly_IEKF_E-5.000000_Final_2017_06_19_15_59_39_final.csv +# plot.pdf + +# Seemed to only run the UK data, not all countries. +# +# Unfortunately, ran out of time to play with the code right now. Leaving this here.