Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/mplfinance/_styledata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from mplfinance._styledata import binance
from mplfinance._styledata import kenan
from mplfinance._styledata import ibd
from mplfinance._styledata import binancedark
from mplfinance._styledata import tradingview

_style_names = [n for n in dir() if not n.startswith('_')]

Expand Down
27 changes: 27 additions & 0 deletions src/mplfinance/_styledata/binancedark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
style = dict(style_name = 'binancedark',
base_mpl_style= 'dark_background',
marketcolors = {'candle' : {'up': '#3dc985', 'down': '#ef4f60'},
'edge' : {'up': '#3dc985', 'down': '#ef4f60'},
'wick' : {'up': '#3dc985', 'down': '#ef4f60'},
'ohlc' : {'up': 'green', 'down': 'red'},
'volume' : {'up': '#247252', 'down': '#82333f'},
'vcedge' : {'up': '#247252', 'down': '#82333f'},
'vcdopcod' : False,
'alpha' : 1.0,
},
mavcolors = ['#ffc201','#ff10ff','#cd0468','#1f77b4',
'#ff7f0e','#2ca02c','#40e0d0'],
y_on_right = True,
gridcolor = None,
gridstyle = '--',
facecolor = None,
rc = [ ('axes.grid','True'),
('axes.grid.axis' , 'y'),
('axes.edgecolor' , '#474d56' ),
('axes.titlecolor','red'),
('figure.titlesize', 'x-large' ),
('figure.titleweight','semibold'),
('figure.facecolor', '#0a0a0a' ),
],
base_mpf_style= 'binancedark'
)
27 changes: 27 additions & 0 deletions src/mplfinance/_styledata/tradingview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
style = dict(style_name = 'tradingview',
base_mpl_style= 'fast',
marketcolors = {'candle' : {'up': '#26a69a', 'down': '#ef5350'},
'edge' : {'up': '#26a69a', 'down': '#ef5350'},
'wick' : {'up': '#26a69a', 'down': '#ef5350'},
'ohlc' : {'up': '#26a69a', 'down': '#ef5350'},
'volume' : {'up': '#26a69a', 'down': '#ef5350'},
'vcedge' : {'up': 'white' , 'down': 'white' },
'vcdopcod' : False,
'alpha' : 1.0,
'volume_alpha': 0.65,
},
scale_width_adjustment = { 'volume': 0.8 },
mavcolors = ['#2962ff','#2962ff',],
y_on_right = True,
gridcolor = None,
gridstyle = '--',
facecolor = None,
rc = [ ('axes.grid','True'),
('axes.edgecolor' , 'grey' ),
('axes.titlecolor','red'),
('figure.titlesize', 'x-large' ),
('figure.titleweight','semibold'),
('figure.facecolor', 'white' ),
],
base_mpf_style = 'tradingview'
)
2 changes: 1 addition & 1 deletion src/mplfinance/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version_info = (0, 12, 9, 'beta', 8)
version_info = (0, 12, 9, 'beta', 9)

_specifier_ = {'alpha': 'a','beta': 'b','candidate': 'rc','final': ''}

Expand Down
36 changes: 21 additions & 15 deletions src/mplfinance/_widths.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,21 @@ def _valid_update_width_kwargs():

return vkwargs

def _scale_width_config(scale,width_config):
if scale['volume'] is not None:
width_config['volume_width'] *= scale['volume']
if scale['ohlc'] is not None:
width_config['ohlc_ticksize'] *= scale['ohlc']
if scale['candle'] is not None:
width_config['candle_width'] *= scale['candle']
if scale['lines'] is not None:
width_config['line_width'] *= scale['lines']
if scale['volume_linewidth'] is not None:
width_config['volume_linewidth'] *= scale['volume_linewidth']
if scale['ohlc_linewidth'] is not None:
width_config['ohlc_linewidth' ] *= scale['ohlc_linewidth']
if scale['candle_linewidth'] is not None:
width_config['candle_linewidth'] *= scale['candle_linewidth']

def _determine_width_config( xdates, config ):
'''
Expand Down Expand Up @@ -138,23 +153,14 @@ def _determine_width_config( xdates, config ):
width_config['candle_linewidth'] = _dfinterpolate(_widths,datalen,'clw')
width_config['line_width' ] = _dfinterpolate(_widths,datalen,'lw')

if config['scale_width_adjustment'] is not None:
if 'scale_width_adjustment' in config['style']:
scale = _process_kwargs(config['style']['scale_width_adjustment'],_valid_scale_width_kwargs())
_scale_width_config(scale,width_config)

if config['scale_width_adjustment'] is not None:
scale = _process_kwargs(config['scale_width_adjustment'],_valid_scale_width_kwargs())
if scale['volume'] is not None:
width_config['volume_width'] *= scale['volume']
if scale['ohlc'] is not None:
width_config['ohlc_ticksize'] *= scale['ohlc']
if scale['candle'] is not None:
width_config['candle_width'] *= scale['candle']
if scale['lines'] is not None:
width_config['line_width'] *= scale['lines']
if scale['volume_linewidth'] is not None:
width_config['volume_linewidth'] *= scale['volume_linewidth']
if scale['ohlc_linewidth'] is not None:
width_config['ohlc_linewidth' ] *= scale['ohlc_linewidth']
if scale['candle_linewidth'] is not None:
width_config['candle_linewidth'] *= scale['candle_linewidth']
_scale_width_config(scale,width_config)


if config['update_width_config'] is not None:

Expand Down
14 changes: 13 additions & 1 deletion src/mplfinance/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ def plot( data, **kwargs ):
panels.at[config['main_panel'],'used2nd'] = True
else:
volumeAxes = panels.at[config['volume_panel'],'axes'][0]
if config['style']['base_mpf_style'] == 'tradingview':
volumeAxes.grid(False)
else:
pass
else:
volumeAxes = None

Expand Down Expand Up @@ -840,6 +844,11 @@ def plot( data, **kwargs ):

axA1.set_ylabel(config['ylabel'])

if config['title']:
script_title = config['title']
else:
script_title = None

if config['volume']:
if external_axes_mode:
volumeAxes.tick_params(axis='x',rotation=xrotation)
Expand Down Expand Up @@ -910,7 +919,10 @@ def plot( data, **kwargs ):
title_kwargs.update(title_dict) # allows override default values set by mplfinance above
else:
title = config['title'] # config['title'] is a string
fig.suptitle(title,**title_kwargs)
if config['style']['base_mpf_style'] == 'tradingview':
axA1.legend(['Price'],title=script_title, title_fontsize='large',loc='upper left',frameon=False)
else:
fig.suptitle(title,**title_kwargs)


if config['axtitle'] is not None:
Expand Down