Returns a Price data structure from either a float or a Price
340410
def get_price_as_price(reward):
        
        if isinstance(reward, Price):
            final_price = reward
        else:
            final_price = Price(reward)
        return final_price
1069706
def __get_float(section, name):
    """"""
    try:
        return float(section[name])
    except (ValueError, TypeError, KeyError):
        return float(0)
279474
def getBasePrice(self,**kwargs):
        '''
        
        '''
        if not self.pricingTier:
            return None
        return self.pricingTier.getBasePrice(**kwargs) * max(self.numSlots,1)
840337
def try_float(s, default=None, minimum=None):
    
    if not s:
        return default
    try:
        val = float(s)
    except (TypeError, ValueError):
        raise InvalidNumber(s, label='Invalid float value')
    if (minimum is not None) and (val < minimum):
        val = minimum
    return val
541799
def convert_float(value, parameter):
    '''
    
    '''
    value = _check_default(value, parameter, ( '', '-', None ))
    if value is None or isinstance(value, float):
        return value
    try:
        return float(value)
    except Exception as e:
        raise ValueError(str(e))
988890
def get_price(self, **kwargs):
        
        def fmt_p(out):
            return pd.DataFrame(out, index=self.symbols)

        return self._get_endpoint("price", fmt_p=fmt_p, params=kwargs)
1335433
def items_with_price(raw_df):
    
    df = (
        raw_df
        [['PRONAC', 'idPlanilhaAprovacao', 'Item',
            'idPlanilhaItens', 'VlUnitarioAprovado',
            'idSegmento', 'DataProjeto', 'idPronac',
            'UfItem', 'idProduto', 'cdCidade', 'cdEtapa']]
    ).copy()

    df['VlUnitarioAprovado'] = df['VlUnitarioAprovado'].apply(pd.to_numeric)
    return df
147039
def _enforceDataType(self, data):
        
        value = float(data)
        if math.isnan(value):
            raise ValueError("FloatCti can't store NaNs")

        if math.isinf(value):
            if value > 0:
                logger.warn("Replacing inf by the largest representable float")
                value = sys.float_info.max
            else:
                logger.warn("Replacing -inf by the smallest representable float")
                value = -sys.float_info.max

        return value
1177939
def to_price_index(returns, start=100):
    
    return (returns.replace(to_replace=np.nan, value=0) + 1).cumprod() * start
1049790
def parse_float(float_str):
    """"""
    factor = __get_factor(float_str)
    if factor != 1:
        float_str = float_str[:-1]

    try:
        return float(float_str.replace(',', '')) * factor
    except ValueError:
        return None
1082645
def _ConvertFloat(value):
  """"""
  if value == 'nan':
    raise ParseError('Couldn\'t parse float "nan", use "NaN" instead.')
  try:
    # Assume Python compatible syntax.
    return float(value)
  except ValueError:
    # Check alternative spellings.
    if value == _NEG_INFINITY:
      return float('-inf')
    elif value == _INFINITY:
      return float('inf')
    elif value == _NAN:
      return float('nan')
    else:
      raise ParseError('Couldn\'t parse float: {0}.'.format(value))
21653
def get_as_float(self, key):
        
        value = self.get(key)
        return FloatConverter.to_float(value)
844715
def price(self, minimum: float = 10.00,
              maximum: float = 1000.00) -> str:
        
        price = self.random.uniform(minimum, maximum, precision=2)
        return '{0} {1}'.format(price, self.currency_symbol())
1231278
def getFloat(t):
    
    d = c_double()
    if PL_get_float(t, byref(d)):
        return d.value
    else:
        raise InvalidTypeError("float")
502027
def get_value(self) -> Decimal:
        
        quantity = self.get_quantity()
        price = self.get_last_available_price()
        if not price:
            # raise ValueError("no price found for", self.full_symbol)
            return Decimal(0)

        value = quantity * price.value
        return value
407313
def from_dict(data, ctx):
        

        data = data.copy()

        if data.get('units') is not None:
            data['units'] = ctx.convert_decimal_number(
                data.get('units')
            )

        if data.get('averagePrice') is not None:
            data['averagePrice'] = ctx.convert_decimal_number(
                data.get('averagePrice')
            )


        if data.get('pl') is not None:
            data['pl'] = ctx.convert_decimal_number(
                data.get('pl')
            )

        if data.get('unrealizedPL') is not None:
            data['unrealizedPL'] = ctx.convert_decimal_number(
                data.get('unrealizedPL')
            )

        if data.get('resettablePL') is not None:
            data['resettablePL'] = ctx.convert_decimal_number(
                data.get('resettablePL')
            )

        if data.get('financing') is not None:
            data['financing'] = ctx.convert_decimal_number(
                data.get('financing')
            )

        if data.get('guaranteedExecutionFees') is not None:
            data['guaranteedExecutionFees'] = ctx.convert_decimal_number(
                data.get('guaranteedExecutionFees')
            )

        return PositionSide(**data)
991232
def from_dict(data, ctx):
        

        data = data.copy()

        if data.get('price') is not None:
            data['price'] = ctx.convert_decimal_number(
                data.get('price')
            )

        if data.get('bucketWidth') is not None:
            data['bucketWidth'] = ctx.convert_decimal_number(
                data.get('bucketWidth')
            )

        if data.get('buckets') is not None:
            data['buckets'] = [
                ctx.instrument.OrderBookBucket.from_dict(d, ctx)
                for d in data.get('buckets')
            ]

        return OrderBook(**data)