[Python] Iterate a function over a list of dataframes

Discussão em 'Python' iniciado por Stack, Setembro 26, 2024.

  1. Stack

    Stack Membro Participativo

    I have 2 timeframes, for example 15 minutes and 4 hours, and want to calculate volume ma on them. I wrote a function for it, now I want to use a for loop for this purpose. But I have faced some errors.

    The function:

    def volume_ma(timeframe=M15, length=20):
    timeframe['volume_ma'] = ta.sma(timeframe['tick_volume'], length=length)

    volume_ma()


    Loop:

    dataframes = {'M1': M1, 'H4': H4}

    for name, sublist in dataframes.items():
    volume_ma(name)

    Continue reading...

Compartilhe esta Página