Example #1
0
    def get_asset_values(self, case='MEAN'):

        if case=='WORST':

            units = utils.subdf(self.df,
                          input_key='max_units',
                          output_key='min_units',
                          to_numeric=True)

            prices = utils.subdf(self.df,
                           input_key='max_price',
                           output_key='min_price',
                           to_numeric=True)

        elif case=='BEST':

            units = utils.subdf(self.df,
                          input_key='min_units',
                          output_key='max_units',
                          to_numeric=True)

            prices = utils.subdf(self.df,
                           input_key='min_price',
                           output_key='max_price',
                           to_numeric=True)

        else: # ('MEAN')

            units = ( utils.subdf(self.df,
                          input_key='min_units',
                          output_key='min_units',
                          to_numeric=True) +
                      utils.subdf(self.df,
                          input_key='max_units',
                          output_key='max_units',
                          to_numeric=True) ) / 2.
			# Add known means, if 'f_units' is a number:
            known_units_means = utils.subdf(self.df, input_key='f_units',
							  output_key='f_units',to_numeric=True)
            # add dataframe with 'f_units', and fillna(.0)
            units = utils.replace_known_numeric_values(units, known_units_means)

            prices = ( utils.subdf(self.df,
                           input_key='min_price',
                           output_key='min_price',
                           to_numeric=True) +
                       utils.subdf(self.df,
                           input_key='max_price',
                           output_key='max_price',
                           to_numeric=True) ) / 2.
			# Add known means, if 'f_price' is a number:
            known_price_means = utils.subdf(self.df, input_key='f_price',
							  output_key='f_price',to_numeric=True)
            # add dataframe with 'f_units', and fillna(.0)
            prices = utils.replace_known_numeric_values(prices, known_price_means)

        return units * prices * self.get_price_unit_values()
Example #2
0
    def get_price_unit_values(self, default=pandas.np.nan):

        price_units = utils.subdf(self.df, 'price_unit', 'price_unit')    

        price_unit_values = price_units.applymap(
            lambda x: self.rates[x].values[0] if x in self.rates.columns
            else pandas.np.nan).apply(pandas.to_numeric,
                                      errors='coerce')

        return price_unit_values.fillna(default)