mplfinance default values rise error in plot function
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 38/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- data-visualization
Línea de trabajo
Empieza en plotting.py, en los validadores de configuración de addplot y alines citados en el informe, y sigue cómo se pasan esas opciones a mpf.plot(). Reproduce la llamada con ambas opciones vacías y compárala con un gráfico de velas normal. Se considera terminado cuando una configuración vacía de addplot y alines se acepta sin errores de los validadores y el gráfico sigue renderizándose.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hi!
First of all, thank you for such useful library for plotting candles!
I'm trying to process a scenario, when addplot and alines is empty (at the present moment buys and sells lists have only one point in format ['date','price'], but it doesn't matter for question). So my function, that builds a graph is:
def mplfplotcoin(df,title,
buys=[],
sells=[],
rsi=False):
adp = []
# adding trades
if buys:
buysdf = pd.DataFrame([buys],columns=['Date', 'OpenPrice']) # when buys list consists of one point
buysdf = df.merge(buysdf,on='Date',how='left')['OpenPrice'] # left join
addbuys = mpf.make_addplot(buysdf,scatter=True,markersize=300,marker=6,color='forestgreen',alpha=0.75) # buy markers
adp.append(addbuys)
if sells:
sellsdf = pd.DataFrame([sells], columns=['Date', 'ClosePrice']) # when sells list consists of one point
sellsdf = df.merge(sellsdf,on='Date',how='left')['ClosePrice'] # left join
addsells = mpf.make_addplot(sellsdf,scatter=True,markersize=300,marker=7,color='firebrick',alpha=0.75) # sell markers
adp.append(addsells)
# adding line between trades https://github.com/matplotlib/mplfinance/blob/master/examples/using_lines.ipynb
if len(buys) == len(sells) and buys: # I know it's awful))) I'll change it later
tradeline = dict(alines=[tuple(buys),tuple(sells)],colors='lightslategray',linestyle='--',linewidths=2,alpha=0.5)
else: tradeline = None
# adding rsi
if rsi:
addrsi = mpf.make_addplot((df['rsi']),panel=1,type='line',color='orange',width=1,ylabel='rsi',ylim=(-5,105))
adp.append(addrsi)
# checking adp list
if not adp: adp = None
# drawing
mpf.plot(df,
type='candle',
style='tradingview',
volume=True,
show_nontrading=True,
addplot=adp,
alines=tradeline,
figscale=1.3,
title=title,
ylabel='USDT')
so, lines else: tradeline = None and if not adp: adp = None are like this, because I found it in your library file plottin.py:
#211 line:
'addplot' : { 'Default' : None,
'Description' : 'addplot object or sequence of addplot objects (from `mpf.make_addplot()`)',
'Validator' : lambda value: isinstance(value,dict) or (isinstance(value,list) and all([isinstance(d,dict) for d in value])) },
# 267 line:
'alines' : { 'Default' : None,
'Description' : 'Draw one or more ARBITRARY LINES anywhere on the plot, by'+
' specifying a sequence of two or more date/price pairs, or by'+
' specifying a sequence of sequences of two or more date/price pairs.'+
' May also be a dict with key `alines` (as date/price pairs described above),'+
' plus one or more of the following keys:'+
' `colors`, `linestyle`, `linewidths`, `alpha`.',
however I get errors for mpf.plot(..., addplot=adp, alines=tradeline, ...):
TypeError: kwarg "addplot" validator returned False for value: "None"
'Validator' : lambda value: isinstance(value,dict) or (isinstance(value,list) and all([isinstance(d,dict) for d in value])) },
and the same for alines parameter:
TypeError: kwarg "alines" validator returned False for value: "None"
'Validator' : lambda value: _alines_validator(value) },
If I go to plotting.py, I can't understand why error is rised, because there is only one if about addplot is None:
# 739 line
addplot = config['addplot']
if addplot is not None and ptype not in VALID_PMOVE_TYPES:
...
# and then 816 line is new condition:
# fill_between is NOT supported for external_axes_mode
# (caller can easily call ax.fill_between() themselves).
if config['fill_between'] is not None and not external_axes_mode:
...
Ok, I tried to define ptype in my code:
# checking adp list
if not adp: adp = [mpf.make_addplot(None,type='line')]
But again error:
raise TypeError('Wrong type for data, in make_addplot()')
TypeError: Wrong type for data, in make_addplot()
Please, help me to understand how to draw plot if addplot and alines (and other kwards) are empty?
- Lenguaje dominante
- Python
- Estrellas
- 4.4k
- Forks
- 678
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de matplotlib/mplfinance
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
matplotlib/mplfinance#672 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
matplotlib/mplfinance#700 ·
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
matplotlib/mplfinance#695 ·
-
question
Dificultad 3/5 1-2 días Aptitud para principiantes 25/100
matplotlib/mplfinance#691 · 1 comentario ·
-
question
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
matplotlib/mplfinance#690 · 5 comentarios ·
Todos los issues de matplotlib/mplfinance
Issues similares
-
[Bug] reef-hermes tells me to resume with hermes --resume, which does not work from my shell Abiertoarea: harness bug status: needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Human-Agent-Society/reef#625 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
learningequality/kolibri#15351 · 2 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Name consistency Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
eellak/triplestore#65 · 1 comentario ·