How to use the technical.exchange.TICKER_INTERVAL_MINUTES.keys function in technical

To help you get started, we’ve selected a few technical examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github freqtrade / technical / technical / util.py View on Github external
def compute_interval(dataframe: DataFrame, exchange_interval=False):
    """
        calculates the interval of the given dataframe for us
    :param dataframe:
    :param exchange_interval: should we convert the result to an exchange interval or just a number
    :return:
    """
    res_interval = int((dataframe['date'] - dataframe['date'].shift()).min().total_seconds() // 60)

    if exchange_interval:
        # convert to our allowed ticker values
        from technical.exchange import TICKER_INTERVAL_MINUTES
        converted = list(TICKER_INTERVAL_MINUTES.keys())[
            list(TICKER_INTERVAL_MINUTES.values()).index(exchange_interval)]
        if len(converted) > 0:
            return converted
        else:
            raise Exception(
                f"sorry, your interval of {res_interval} is not "
                f"supported in {TICKER_INTERVAL_MINUTES}")

    return res_interval