Пример #1
0
 def get_wma(self,
             data: list,
             prices: int,
             parameter: str,
             round_value: bool = True) -> float:
     data = data[len(data) - prices:]
     wma = get_wma(data, prices, parameter, desc=False)
     return round(wma, self.precision) if round_value else wma
Пример #2
0
    def get_wma(self,
                data: list,
                prices: int,
                parameter: str,
                round_value=True) -> float:
        data = data[0:prices]
        wma = get_wma(data, prices, parameter)

        return round(wma, self.precision) if round_value else wma
Пример #3
0
    def get_wma(self, prices: int, parameter: str, shift: int = 0, round_value: bool = True,
                update: bool = True) -> float:
        """
        Returns the weighted moving average with run-time data and prices provided.
        :param update: Boolean for whether function should call API and get latest data or not.
        :param shift: Prices shifted from current period.
        :param boolean round_value: Boolean that specifies whether return value should be rounded
        :param int prices: Number of prices to loop over for average
        :param parameter: Parameter to get the average of (e.g. open, close, high or low values)
        :return: WMA
        """
        if not self.is_valid_average_input(shift, prices):
            raise ValueError('Invalid average input specified.')

        data = [self.get_current_data()] + self.data if update else self.get_total_non_updated_data()
        data = data[shift: prices + shift]
        wma = get_wma(data, prices, parameter)

        if round_value:
            return round(wma, self.precision)
        return wma