Example #1
0
    def __init__(self, fileName):
        self.CashFlowDB = Query.Query()
        self.fileName = fileName
        #self.filePath = '~/Box Sync/Shared/Lock-up Fund Client Holdings & Performance Tracker/Cash Flow Model/{}.xlsx'.format(fileName)
        self.validationDf = pd.read_excel(ospath(self.fileName), sheet_name='Validation', header=1)

        self.sponsorDataTableDf = pd.read_excel(ospath(self.fileName), sheet_name='Sponsor Data Table', header=1)[["ID Code",
            "Client", "Sponsor", "Fund Family", "Designation", "Fund Style", "Vintage Year", "Close Date",
            "Invest Start Date", "Fund Size ($M)", "Commitment ($M)","Contribution (% of Rem. Commit)", "Unnamed: 14",
            "Unnamed: 15", "Unnamed: 16", "Unnamed: 17", "Model Metrics", "Unnamed: 19", "Unnamed: 20", "Model Years to",
            "Unnamed: 22", "Projected Metrics", "Unnamed: 29", "Unnamed: 30", "Projected Years to", "Unnamed: 32", "Currency",
            "Projected Contribution (% of Rem. Commit)", "Unnamed: 24", "Unnamed: 25", "Unnamed: 26","Unnamed: 27"]]
        print pd.read_excel(ospath(fileName), sheet_name='Sponsor Data Table', header=1).columns

        # Renamming the columns to be readable
        self.sponsorDataTableDf.columns = ["ID Code", "Client", "Sponsor", "Fund Family", "Designation", "Fund Style", "Vintage Year",
            "Close Date", "Invest Start Date", "Fund Size", "Commitment", "Contribution 1", "Contribution 2", "Contribution 3",
            "Contribution 4", "Contribution 5", "Bow", "Growth Rate", "Yield", "Invest Years", "Life", "Projected Bow",
            "Projected Growth", "Projected Yield", "Projected Invest Years", "Projected Life", "Currency", "Projected Contribution 1",
            "Projected Contribution 2", "Projected Contribution 3", "Projected Contribution 4", "Projected Contribution 5"]

        self.sponsorDataTableDf = self.sponsorDataTableDf[self.sponsorDataTableDf["ID Code"].notna()]
        self.sponsorDataTableDf["Fund Family"] = self.sponsorDataTableDf["Fund Family"].str.strip()
        self.sponsorDataTableDf["Fund Size"] = self.sponsorDataTableDf["Fund Size"].fillna(value='null')
        print self.sponsorDataTableDf.head(3)

        # Should probably be abstracted given more time
        self.initializeClientDf()
        self.initializeFundStyleDf()
        self.initializeSponsorDf()
        self.initializeMergedDf()
def importarArchivo():
    tiempo_inicial = time()
    archivo = pd.read_excel(
        ospath('~/PycharmProjects/Elecciones2019/resources/actas.xlsx'))
    tiempo_final = time()
    print("tiempo de importación: ", tiempo_final - tiempo_inicial)
    return archivo
Example #3
0
    def my_figure(self, thiscountry):
        country = thiscountry

        df = pd.read_excel(ospath('C:/Users/taged/PycharmProjects/CovidTracker/CovidApp/total_cases.xlsx'),
                           'total_cases')
        x = df['date']
        y = df[country].divide(1000000)
        labels = []
        for i in range(1, len(df['date'])):
            if df['date'][i].month not in labels:
                labels.append(df['date'][i].month)

        fig = Figure()
        canvas = FigureCanvas(fig)
        ax = fig.add_subplot(111)

        ax.plot(x, y, color='r')
        ax.set_title('Covid 19 Cases in ' + country)
        ax.set_xlabel('Month (mm)')
        ax.set_ylabel('Number of cases (x1e6)')
        ax.spines['top'].set_visible(False)
        ax.spines['right'].set_visible(False)
        ax.grid(color='gray', linestyle='-', linewidth=0.25, alpha=0.5)
        ax.set_xticklabels(labels)
        return canvas
Example #4
0
class SelectCountry(models.Model):
    df = pd.read_excel(ospath('C:/Users/taged/PycharmProjects/CovidTracker/CovidApp/total_cases.xlsx'), 'total_cases')
    country_names = {}
    for entry in df[0:1]:
        country_names[entry] = entry
    country_list = [(k, v) for k, v in country_names.items()]
    COUNTRY_CHOICES = tuple(country_list[1:])

    country_model = models.CharField(max_length=50, choices=COUNTRY_CHOICES)
Example #5
0
    def _read(self):
        #todo
        # Reads the Raw_Data sheet, deletes rows where fund is na, and iterates over the rows
        raw_data = pd.read_excel(ospath(self.getFileName()),
                                 sheet_name="Raw_Data",
                                 header=1)

        raw_data = self._cleanData(raw_data)

        for row in raw_data.iterrows():
            self._processRow(row[1])
Example #6
0
def MSV_plot(series, fitted_model, label):
    fig, axes = plt.subplots(3, figsize=(10,7))
    
    ax=axes[0]
    ax.plot(series)
    ax.set_ylabel('Retorno')
    ax.set_title(series.name + ' retornos')
    
    ax = axes[1]
    ax.plot(fitted_model.smoothed_marginal_probabilities[0])
    ax.set(title='Probabilidade de um regime de baixa variância para retornos futuros')
    ax.set_ylabel('Probabilidade')

    ax = axes[2]
    ax.plot(fitted_model.smoothed_marginal_probabilities[1])
    ax.set(title='Probabilidade de um regime de alta variância para retornos futuros')
    ax.set_ylabel('Probabilidade')
    fig.tight_layout()

    fig.savefig(ospath(os.getcwd() + '/figs/'+ label +'MSV.png'))

def log_fun(x):
    return numpy.log(x)


# data_frame

num_fe = 4

### Reading the data extracted after implementing IHME_data_creation.R

from os.path import expanduser as ospath

#---Change the path where the extracted data set is located---#
df7_Italy = pd.read_excel(ospath('data/df7_Italy_v1.xlsx'))
df14_Italy = pd.read_excel(ospath('data/df14_Italy_v1.xlsx'))
df0_Italy = pd.read_excel(ospath('data/df0_Italy_v1.xlsx'))

#### model run for 7 days before peak ------ Italy
# We create social distance covariate as below:
# social distance covariate is equivalent to count of days (starting from 0 and increasing with an increment of one) when training data starts to the day before the first intervention. For days with first intervention active, we take the social distance covarite as 0.67 and for days when two interventions are active, the social distance covariate is measured as 0.33. When three or four inrterventions are active, the social distance covariate is taken as 0. For more details, see the data creation file.
model = curvefit.core.model.CurveModel(
    df=df7_Italy,
    col_t='time',
    col_obs='smooth',
    col_group='group',
    col_covs=[['intercept'], ['intercept', 'social_distance'], ['intercept']],
    param_names=['alpha', 'beta', 'p'],
    link_fun=[exp_fun, identity_fun, exp_fun],
    var_link_fun=num_fe * [identity_fun],
Example #8
0
def readData(file):
    df = pd.read_excel(ospath(os.getcwd() + '/data/' + file), index_col=0, skiprows=[0,1,2], header = None)
    df.columns = ['date', 'price']
    df["date"] = pd.to_datetime(df["date"])
    df['logReturn'] = logReturn(df.price)
    return df
Example #9
0
import pandas as pd
from os.path import expanduser as ospath

pd.set_option('display.expand_frame_repr', False)

fileVersion = "2.14"
filePath = '~/Box Sync/Shared/Lock-up Fund Client Holdings & Performance Tracker/Cash Flow Model/CBA Cash Flow Model - v{} - Far Hills.xlsx'.format(
    fileVersion)
df = pd.read_excel(ospath(filePath), sheet_name='Raw_Data', header=1)

df = df.drop(df.columns[14:-1], axis=1)

####

validationDf = pd.read_excel(ospath(filePath),
                             sheet_name='Validation',
                             header=1)

sponsorDf = validationDf[['Sponsor_List', 'Sponsor_Code']]
sponsorDf = sponsorDf.dropna()
sponsorDf['Sponsor_List'] = sponsorDf['Sponsor_List'].str.strip()

fundStyleDf = validationDf[['Fund_Style', 'Fund_Code']]
fundStyleDf = fundStyleDf.dropna()
fundStyleDf['Fund_Style'] = fundStyleDf['Fund_Style'].str.strip()

clientDf = validationDf[["Client_List", "Client_Code"]]
clientDf = clientDf.dropna()
clientDf['Client_List'] = clientDf['Client_List'].str.strip()

###
Example #10
0
 def restore(self, name='model.h5', path='./'):
     self.autoencoder.load_weights(ospath(path,name))
Example #11
0
 def save(self, name='model.h5', path='./'):
     self.autoencoder.save_weights(ospath(path,name))