matplotlib / matplotlib/mplfinance

TypeError: object of type 'int' has no len() - renko with return_calculated_values and mav

Aperta
#394 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug
Lingua principale
Python
Stelle
4.4k
Fork
678
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hello,

Firstly i'd like to say this is an excellent library, very very good indeed, and I really appreciate the work done here.

I am using the return_calculated_values feature so I can test (and hopefully add to the plot) my own studies that are based on the renko data.

I am using python 3.7 on Google Colab, the following code works perfectly, and retvals is populated:

retvals = {}
mpf.plot(df, type='renko', return_calculated_values=retvals,
         title=f'ADAUSDT / Renko Chart (1m base)',
         renko_params=dict(brick_size='atr', atr_length=10),
         style='yahoo', figratio=(35,12),figscale=1.8
)

However, adding mav=10 or mav=(10) generates an error:

retvals = {}
mpf.plot(df, type='renko', return_calculated_values=retvals, mav=(10),
         title=f'ADAUSDT / Renko Chart (1m base)',
         renko_params=dict(brick_size='atr', atr_length=10),
         style='yahoo', figratio=(35,12),figscale=1.8
)

TypeError                                 Traceback (most recent call last)
<ipython-input-72-29c81de85c1f> in <module>()
      5          title=f'ADAUSDT / Renko Chart (1m base)',
      6          renko_params=dict(brick_size='atr', atr_length=10),
----> 7          style='yahoo', figratio=(35,12),figscale=1.8
      8 )

/usr/local/lib/python3.7/dist-packages/mplfinance/plotting.py in plot(data, **kwargs)
    483         if config['mav'] is not None:
    484             mav = config['mav']
--> 485             if len(mav) != len(mavprices):
    486                 warnings.warn('len(mav)='+str(len(mav))+' BUT len(mavprices)='+str(len(mavprices)))
    487             else:

TypeError: object of type 'int' has no len()

Dependencies:

mplfinance in /usr/local/lib/python3.7/dist-packages (0.12.7a17)
pandas in /usr/local/lib/python3.7/dist-packages (from mplfinance) (1.1.5)
matplotlib in /usr/local/lib/python3.7/dist-packages (from mplfinance) (3.2.2)
numpy>=1.15.4 in /usr/local/lib/python3.7/dist-packages (from pandas->mplfinance) (1.19.5)
pytz>=2017.2 in /usr/local/lib/python3.7/dist-packages (from pandas->mplfinance) (2018.9)
python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas->mplfinance) (2.8.1)
pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mplfinance) (2.4.7)
kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mplfinance) (1.3.1)
cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mplfinance) (0.10.0)
six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.7.3->pandas->mplfinance) (1.15.0)

Thanks

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo la chiamata al grafico Renko con return_calculated_values e mav=10, quindi esamina plotting.py intorno alla riga 485, dove mav viene passato a len(). Confronta i casi scalare e tupla e verifica che il comportamento corretto gestisca ancora la configurazione Renko segnalata senza sollevare TypeError.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
matplotlib, python
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.