pricedb/mappers.py
def map_entity(self, entity: dal.Price) -> PriceModel:
        """ Map the price entity """
        if not entity:
            return None

        result = PriceModel()
        result.currency = entity.currency

        # date/time
        dt_string = entity.date
        format_string = "%Y-%m-%d"
        if entity.time:
            dt_string += f"T{entity.time}"
            format_string += "T%H:%M:%S"
        price_datetime = datetime.strptime(dt_string, format_string)
        result.datum = Datum()
        result.datum.from_datetime(price_datetime)
        assert isinstance(result.datum, Datum)

        #result.namespace = entity.namespace
        #result.symbol = entity.symbol
        result.symbol = SecuritySymbol(entity.namespace, entity.symbol)

        # Value
        value = Decimal(entity.value) / Decimal(entity.denom)
        result.value = Decimal(value)

        return result
def map_entity(self, entity: dal.Price) -> PriceModel:
        """ Map the price entity """
        if not entity:
            return None

        result = PriceModel()
        result.currency = entity.currency

        # date/time
        dt_string = entity.date
        format_string = "%Y-%m-%d"
        if entity.time:
            dt_string += f"T{entity.time}"
            format_string += "T%H:%M:%S"
        price_datetime = datetime.strptime(dt_string, format_string)
        result.datum = Datum()
        result.datum.from_datetime(price_datetime)
        assert isinstance(result.datum, Datum)

        #result.namespace = entity.namespace
        #result.symbol = entity.symbol
        result.symbol = SecuritySymbol(entity.namespace, entity.symbol)

        # Value
        value = Decimal(entity.value) / Decimal(entity.denom)
        result.value = Decimal(value)

        return result
def map_entity ( self , entity : dal . Price ) -> PriceModel : if not entity : return None result = PriceModel ( ) result . currency = entity . currency # date/time dt_string = entity . date format_string = "%Y-%m-%d" if entity . time : dt_string += f"T{entity.time}" format_string += "T%H:%M:%S" price_datetime = datetime . strptime ( dt_string , format_string ) result . datum = Datum ( ) result . datum . from_datetime ( price_datetime ) assert isinstance ( result . datum , Datum ) #result.namespace = entity.namespace #result.symbol = entity.symbol result . symbol = SecuritySymbol ( entity . namespace , entity . symbol ) # Value value = Decimal ( entity . value ) / Decimal ( entity . denom ) result . value = Decimal ( value ) return result
Map the price entity
Map the price entity