mplfinance default values rise error in plot function
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- data-visualization
Hướng nghiên cứu
Bắt đầu trong plotting.py tại các trình xác thực cấu hình addplot và alines được nêu trong báo cáo, sau đó theo dõi cách các tùy chọn đó được truyền vào mpf.plot(). Tái hiện lời gọi với cả hai tùy chọn đều trống và so sánh với một biểu đồ nến thông thường. Được xem là hoàn tất khi cấu hình addplot và alines trống được chấp nhận mà không có lỗi từ trình xác thực và biểu đồ vẫn được render.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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?
- Ngôn ngữ chính
- Python
- Star
- 4.4k
- Fork
- 678
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của matplotlib/mplfinance
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
matplotlib/mplfinance#672 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
matplotlib/mplfinance#700 ·
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
matplotlib/mplfinance#695 ·
-
question
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
matplotlib/mplfinance#691 · 1 bình luận ·
-
question
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
matplotlib/mplfinance#690 · 5 bình luận ·
Tất cả issue của matplotlib/mplfinance
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stephrobert/dsoxlab#238 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
sublimehq/package_control#1780 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
nwg-piotr/nwg-displays#145 ·