vistock.mpl package

Submodules

vistock.mpl.bull_draw module

Visualize a BullRun and Drawdown for a stock.

vistock.mpl.bull_draw.plot(symbol='TSLA', period='1y', interval='1d', legend_loc='best', market_color_style=MarketColorStyle.AUTO, style='yahoo', hides_nontrading=True, out_dir='out')[source]

Plot a stock figure that consists of two subplots: a price subplot and a volume subplot.

The price subplot includes price lines, bull-run bar cahrt, and drawdown bar chart, while the volume subplot includes a volume histogram and a volume moving average line.

Parameters:
  • symbol (str) – the stock symbol.

  • period (str, optional) –

    the period data to download. Valid values are 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max. Default is ‘1y’

    • d – days

    • mo – monthes

    • y – years

    • ytd – year to date

    • max – all data

  • interval (str, optional) –

    the interval of an OHLC item. Valid values are 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo. Default is ‘1d’

    • m – minutes

    • h – hours

    • wk – weeks

    • mo – monthes

    Intraday data cannot extend last 60 days:

    • 1m - max 7 days within last 30 days

    • up to 90m - max 60 days

    • 60m, 1h - max 730 days (yes 1h is technically < 90m but this what Yahoo does)

  • legend_loc (str, optional) –

    the location of the legend (default is ‘best’). Valid locations are

    • ’best’

    • ’upper right’

    • ’upper left’

    • ’lower left’

    • ’lower right’

    • ’right’

    • ’center left’

    • ’center right’

    • ’lower center’

    • ’upper center’

    • ’center’

  • market_color_style (MarketColorStyle, optional) – The market color style to use. Default is MarketColorStyle.AUTO.

  • style (str, optional) –

    The chart style to use. Common styles include:

    • ’yahoo’: Yahoo Finance style

    • ’charles’: Charles style

    • ’tradingview’: TradingView style

    • ’binance’: Binance style

    • ’binancedark’: Binance dark mode style

    • ’mike’: Mike style (dark mode)

    • ’nightclouds’: Dark mode with sleek appearance

    • ’checkers’: Checkered style

    • ’ibd’: Investor’s Business Daily style

    • ’sas’: SAS style

    • ’starsandstripes’: Stars and Stripes style

    • ’kenan’: Kenan style

    • ’blueskies’: Blue Skies style

    • ’brasil’: Brasil style

    Default is ‘yahoo’.

  • hides_nontrading (bool, optional) – Whether to hide non-trading periods. Default is True.

  • out_dir (str, optional) – the output directory for saving figure.

vistock.mpl.financials module

This module provides a function to plot financial data for a given stock symbol using mplfinance. The data includes Basic EPS, Operating Revenue, Trailing EPS, and Forward EPS (if available). The function allows customization of chart styles via the style parameter and supports saving the plots as PNG files.

The plot function generates two subplots:

  1. Quarterly financial data.

  2. Annual financial data, with markers for Trailing EPS and Forward EPS.

The plot is saved in the specified out_dir as a PNG file.

See Also:

vistock.mpl.financials.plot(symbol, style='yahoo', out_dir='out')[source]

Plots the financial data of a stock symbol using mplfinance.

The function fetches Basic EPS, Operating Revenue, Trailing EPS, and Forward EPS for the given stock symbol from Yahoo Finance, with data divided into quarterly and annual segments. The data is plotted using mplfinance with different chart styles as specified by the style parameter. Dummy OHLC data is generated for plotting purposes, with Basic EPS and Operating Revenue plotted on separate y-axes.

The function also saves the plot as a PNG file in the specified out_dir after generating the chart using mplfinance.

Parameters:
  • symbol (str) – The stock symbol to analyze.

  • style (str, optional) –

    The chart style to use. Common styles include:

    • ’yahoo’: Yahoo Finance style

    • ’charles’: Charles style

    • ’tradingview’: TradingView style

    • ’binance’: Binance style

    • ’binancedark’: Binance dark mode style

    • ’mike’: Mike style (dark mode)

    • ’nightclouds’: Dark mode with sleek appearance

    • ’checkers’: Checkered style

    • ’ibd’: Investor’s Business Daily style

    • ’sas’: SAS style

    • ’starsandstripes’: Stars and Stripes style

    • ’kenan’: Kenan style

    • ’blueskies’: Blue Skies style

    • ’brasil’: Brasil style

    Default is ‘yahoo’.

  • out_dir (str, optional) – Directory to save the output HTML file. Default is ‘out’.

vistock.mpl.ibd_rs module

ibd_rs.py - IBD Relative Strength Analysis and Plotting Module

This module provides functionality for analyzing and plotting stock data with a focus on Investor’s Business Daily (IBD) Relative Strength metrics. It includes capabilities for generating candlestick charts with moving averages, volume analysis, and relative strength comparisons.

The main function ‘plot’ allows users to visualize stock performance over various time periods and intervals, with customizable reference indexes and styling options.

Usage:

from vistock.mpl import ibd_rs
ibd_rs.plot('TSLA', period='1y', interval='1d')
vistock.mpl.ibd_rs.plot(symbol, period='2y', interval='1d', ticker_ref=None, rs_window='12mo', legend_loc='best', market_color_style=MarketColorStyle.AUTO, style='yahoo', hides_nontrading=True, out_dir='out')[source]

Generate and display a stock analysis plot with candlestick charts, moving averages, volume analysis, and Relative Strength (RS) metrics.

Parameters:
  • symbol (str) – The stock symbol to analyze.

  • period (str, optional) –

    The period of historical data to fetch. Valid values are ‘6mo’, ‘1y’, ‘2y’, ‘5y’, ‘10y’, ‘ytd’, ‘max’. Default is ‘2y’.

    • mo – monthes

    • y – years

    • ytd – year to date

    • max – all data

  • interval (str, optional) – The interval for data points. Valid values are ‘1d’ for daily or ‘1wk’ for weekly. Default is ‘1d’.

  • ticker_ref (str, optional) – The ticker symbol of the reference index. If None, defaults to S&P 500 (‘^GSPC’) or Taiwan Weighted Index (‘^TWII’) if the first stock is a Taiwan stock.

  • rs_window (str, optional) – Specify the time window (‘3mo’ or ‘12mo’) for Relative Strength calculation. Default to ‘12mo’.

  • legend_loc (str, optional) –

    the location of the legend (default is ‘best’). Valid locations are

    • ’best’

    • ’upper right’

    • ’upper left’

    • ’lower left’

    • ’lower right’

    • ’right’

    • ’center left’

    • ’center right’

    • ’lower center’

    • ’upper center’

    • ’center’

  • market_color_style (MarketColorStyle, optional) – The market color style to use. Default is MarketColorStyle.AUTO.

  • style (str, optional) –

    The chart style to use. Common styles include:

    • ’yahoo’: Yahoo Finance style

    • ’charles’: Charles style

    • ’tradingview’: TradingView style

    • ’binance’: Binance style

    • ’binancedark’: Binance dark mode style

    • ’mike’: Mike style (dark mode)

    • ’nightclouds’: Dark mode with sleek appearance

    • ’checkers’: Checkered style

    • ’ibd’: Investor’s Business Daily style

    • ’sas’: SAS style

    • ’starsandstripes’: Stars and Stripes style

    • ’kenan’: Kenan style

    • ’blueskies’: Blue Skies style

    • ’brasil’: Brasil style

    Default is ‘yahoo’.

  • hides_nontrading (bool, optional) – Whether to hide non-trading periods. Default is True.

  • out_dir (str, optional) – the output directory for saving figure.

Raises:

ValueError – If an unsupported interval is provided.

vistock.mpl.ibd_rs_cmp module

ibd_rs_cmp - A module for plotting IBD Relative Strength (RS) comparisons of multiple stocks using mplfinance.

This module provides functionality to plot the Relative Strength (RS) of multiple stocks compared to a reference index (e.g., S&P 500 or Taiwan Weighted Index) using mplfinance. It fetches historical stock data from Yahoo Finance, calculates RS values, and generates a multi-panel chart. The resulting chart is saved as an image file.

Functions: - plot: Generates a Relative Strength comparison plot for multiple stocks.

Usage: To use this module, call the plot function with a list of stock symbols and desired parameters.

vistock.mpl.ibd_rs_cmp.plot(symbols, period='2y', interval='1d', ticker_ref=None, rs_window='12mo', legend_loc='best', style='checkers', color_cycle=((0.6509803921568628, 0.807843137254902, 0.8901960784313725), (0.12156862745098039, 0.47058823529411764, 0.7058823529411765), (0.6980392156862745, 0.8745098039215686, 0.5411764705882353), (0.2, 0.6274509803921569, 0.17254901960784313), (0.984313725490196, 0.6039215686274509, 0.6), (0.8901960784313725, 0.10196078431372549, 0.10980392156862745), (0.9921568627450981, 0.7490196078431373, 0.43529411764705883), (1.0, 0.4980392156862745, 0.0), (0.792156862745098, 0.6980392156862745, 0.8392156862745098), (0.41568627450980394, 0.23921568627450981, 0.6039215686274509), (1.0, 1.0, 0.6), (0.6941176470588235, 0.34901960784313724, 0.1568627450980392)), out_dir='out')[source]

Plot the Relative Strength (RS) of multiple stocks compared to a reference index using mplfinance.

This function generates a multi-panel chart that compares the RS values i of the specified stocks against a reference index (e.g., S&P 500 or Taiwan Weighted Index). The chart includes RS lines for each stock, and can be customized based on the selected period and interval. The resulting plot is saved as an image file in the specified output directory.

Parameters:
  • symbols (list of str) – List of stock symbols to compare. Can include both US and Taiwan stocks.

  • period (str, optional) –

    The period of historical data to fetch. Valid values are ‘6mo’, ‘1y’, ‘2y’, ‘5y’, ‘10y’, ‘ytd’, ‘max’. Default is ‘2y’.

    • mo – monthes

    • y – years

    • ytd – year to date

    • max – all data

  • interval (str, optional) – The interval for data points. Valid values are ‘1d’ for daily or ‘1wk’ for weekly. Default is ‘1d’.

  • ticker_ref (str, optional) – The ticker symbol of the reference index. If None, defaults to S&P 500 (‘^GSPC’) or Taiwan Weighted Index (‘^TWII’) if the first stock is a Taiwan stock.

  • rs_window (str, optional) – Specify the time window (‘3mo’ or ‘12mo’) for Relative Strength calculation. Default to ‘12mo’.

  • legend_loc (str, optional) –

    the location of the legend (default is ‘best’). Valid locations are

    • ’best’

    • ’upper right’

    • ’upper left’

    • ’lower left’

    • ’lower right’

    • ’right’

    • ’center left’

    • ’center right’

    • ’lower center’

    • ’upper center’

    • ’center’

  • style (str, optional) –

    The chart style to use. Common styles include:

    • ’yahoo’: Yahoo Finance style

    • ’charles’: Charles style

    • ’tradingview’: TradingView style

    • ’binance’: Binance style

    • ’binancedark’: Binance dark mode style

    • ’mike’: Mike style (dark mode)

    • ’nightclouds’: Dark mode with sleek appearance

    • ’checkers’: Checkered style

    • ’ibd’: Investor’s Business Daily style

    • ’sas’: SAS style

    • ’starsandstripes’: Stars and Stripes style

    • ’kenan’: Kenan style

    • ’blueskies’: Blue Skies style

    • ’brasil’: Brasil style

    Default is ‘checkers’.

  • color_cycle (list or None) –

    Specifies a list of colors to be used for cycling through plot lines. If None, the default matplotlib color cycle will be used. You can pass a list of colors to override the default color cycle. Each plot line will use the next color in the sequence.

    Default color sequence:

    • plt.cm.Paired.colors (20 colors, cooler and more muted)

    Other useful predefined color cycles:

    • plt.cm.tab20.colors (20 colors, brighter)

    • plt.cm.tab20b.colors (20 colors, darker)

    • plt.cm.Paired.colors (12 colors, alternating between deep and pastel colors; useful for categorical data)

    • plt.cm.Set3.colors (12 colors, pastel-like; good for categorical data)

    • plt.cm.Set1.colors (9 colors, bold and highly distinct; ideal for categorical data)

  • out_dir (str, optional) – Directory to save the image file. Defaults to ‘out’.

Returns:

The function generates a plot and saves it as an image file.

Return type:

None

Example

>>> symbols = ['NVDA', 'MSFT', 'META', 'AAPL', 'TSM']
>>> plot(symbols)

vistock.mpl.mansfield module

Mansfield Stock Charts

This module provides tools for generating and plotting Mansfield Stock Charts based on Stan Weinstein’s methods, as described in the book “Secrets for Profiting in Bull and Bear Markets.” It includes functionalities for calculating and plotting Mansfield Relative Strength (RSM) using mplfinance for visualization.

Classes:

  • StockChart: A class for generating and plotting Mansfield Stock Charts for individual stocks.

  • RelativeStrengthLines: A class for plotting Mansfield Relative Strength (RSM) lines of multiple stocks compared to a reference index.

Usage:

To generate a Mansfield Stock Chart for a single stock:
>>> StockChart.plot('TSLA', interval='1wk')
To compare the Mansfield Relative Strength of multiple stocks:
>>> symbols = ['NVDA', 'MSFT', 'META', 'AAPL', 'TSM']
>>> RelativeStrengthLines.plot(symbols, interval='1d')

See Also:

class vistock.mpl.mansfield.RelativeStrengthLines[source]

Bases: object

A class for plotting Mansfield Relative Strength (RSM) lines of multiple stocks.

This class allows for the comparison of the relative strength of multiple stocks against a reference index over a specified period. It supports various intervals and moving average calculations (SMA and EMA) for the relative strength computation.

static plot(symbols, period='2y', interval='1d', ticker_ref=None, ma='SMA', legend_loc='upper left', style='charles', color_cycle=((0.6509803921568628, 0.807843137254902, 0.8901960784313725), (0.12156862745098039, 0.47058823529411764, 0.7058823529411765), (0.6980392156862745, 0.8745098039215686, 0.5411764705882353), (0.2, 0.6274509803921569, 0.17254901960784313), (0.984313725490196, 0.6039215686274509, 0.6), (0.8901960784313725, 0.10196078431372549, 0.10980392156862745), (0.9921568627450981, 0.7490196078431373, 0.43529411764705883), (1.0, 0.4980392156862745, 0.0), (0.792156862745098, 0.6980392156862745, 0.8392156862745098), (0.41568627450980394, 0.23921568627450981, 0.6039215686274509), (1.0, 1.0, 0.6), (0.6941176470588235, 0.34901960784313724, 0.1568627450980392)), out_dir='out')[source]

Plot the Mansfield Relative Strength (RSM) of multiple stocks compared to a reference index.

Parameters:
  • symbols (list of str) – List of stock symbols to compare. Can include both US and Taiwan stocks.

  • period (str, optional) –

    the period data to download. . Defaults to ‘2y’. Valid values are 6mo, 1y, 2y, 5y, 10y, ytd, max.

    • mo – monthes

    • y – years

    • ytd – year to date

    • max – all data

  • interval (str, optional) – The interval for data points (‘1d’ for daily, ‘1wk’ for weekly; default is ‘1d’).

  • ticker_ref (str, optional) – The ticker symbol of the reference index. If None, defaults to S&P 500 (‘^GSPC’) or Taiwan Weighted Index (‘^TWII’) if the first stock is a Taiwan stock.

  • ma (str, optional) – Moving average type (‘SMA’, ‘EMA’). Default to ‘SMA’.

  • legend_loc (str, optional) –

    the location of the legend (default is ‘upper left’). Valid locations are

    • ’best’

    • ’upper right’

    • ’upper left’

    • ’lower left’

    • ’lower right’

    • ’right’

    • ’center left’

    • ’center right’

    • ’lower center’

    • ’upper center’

    • ’center’

  • style (str, optional) –

    The chart style to use. Common styles include:

    • ’yahoo’: Yahoo Finance style

    • ’charles’: Charles style

    • ’tradingview’: TradingView style

    • ’binance’: Binance style

    • ’binancedark’: Binance dark mode style

    • ’mike’: Mike style (dark mode)

    • ’nightclouds’: Dark mode with sleek appearance

    • ’checkers’: Checkered style

    • ’ibd’: Investor’s Business Daily style

    • ’sas’: SAS style

    • ’starsandstripes’: Stars and Stripes style

    • ’kenan’: Kenan style

    • ’blueskies’: Blue Skies style

    • ’brasil’: Brasil style

    Default is ‘charles’.

  • color_cycle (list or None) –

    Specifies a list of colors to be used for cycling through plot lines. If None, the default matplotlib color cycle will be used. You can pass a list of colors to override the default color cycle. Each plot line will use the next color in the sequence.

    Default color sequence:

    • plt.cm.Paired.colors (20 colors, cooler and more muted)

    Other useful predefined color cycles:

    • plt.cm.tab20.colors (20 colors, brighter)

    • plt.cm.tab20b.colors (20 colors, darker)

    • plt.cm.Paired.colors (12 colors, alternating between deep and pastel colors; useful for categorical data)

    • plt.cm.Set3.colors (12 colors, pastel-like; good for categorical data)

    • plt.cm.Set1.colors (9 colors, bold and highly distinct; ideal for categorical data)

  • out_dir (str, optional) – Directory to save the image file. Defaults to ‘out’.

Returns:

The function generates a plot and saves it as an image file.

Return type:

None

Example

>>> symbols = ['NVDA', 'MSFT', 'META', 'AAPL', 'TSM']
>>> plot(symbols)
class vistock.mpl.mansfield.StockChart[source]

Bases: object

A class for generating and plotting Mansfield Stock Charts.

Mansfield Stock Charts are a method for visualizing stock trends and relative strength compared to a reference index, as popularized by Stan Weinstein. This class provides methods to fetch stock data, compute relative strength, and plot the resulting charts using mplfinance.

static plot(symbol, period='2y', interval='1d', ticker_ref=None, ma='SMA', legend_loc='upper left', market_color_style=MarketColorStyle.AUTO, style='yahoo', hides_nontrading=True, out_dir='out')[source]

Plot a Mansfield Stock Chart for a given stock symbol and time period.

Parameters:
  • symbol (str) – The stock symbol to analyze.

  • period (str, optional) –

    The period of historical data to fetch. Valid values are ‘6mo’, ‘1y’, ‘2y’, ‘5y’, ‘10y’, ‘ytd’, ‘max’. Default is ‘2y’.

    • mo – monthes

    • y – years

    • ytd – year to date

    • max – all data

  • interval (str, optional) – The interval for data points. Valid values are ‘1d’ for daily or ‘1wk’ for weekly. Default is ‘1d’.

  • ticker_ref (str, optional) – The ticker symbol of the reference index. If None, defaults to S&P 500 (‘^GSPC’) or Taiwan Weighted Index (‘^TWII’) if the first stock is a Taiwan stock.

  • ma (str, optional) – Moving average type (‘SMA’, ‘EMA’). Default to ‘SMA’.

  • legend_loc (str, optional) –

    the location of the legend (default is ‘upper left’). Valid locations are

    • ’best’

    • ’upper right’

    • ’upper left’

    • ’lower left’

    • ’lower right’

    • ’right’

    • ’center left’

    • ’center right’

    • ’lower center’

    • ’upper center’

    • ’center’

  • market_color_style (MarketColorStyle, optional) – The market color style to use. Default is MarketColorStyle.AUTO.

  • style (str, optional) –

    The chart style to use. Common styles include:

    • ’yahoo’: Yahoo Finance style

    • ’charles’: Charles style

    • ’tradingview’: TradingView style

    • ’binance’: Binance style

    • ’binancedark’: Binance dark mode style

    • ’mike’: Mike style (dark mode)

    • ’nightclouds’: Dark mode with sleek appearance

    • ’checkers’: Checkered style

    • ’ibd’: Investor’s Business Daily style

    • ’sas’: SAS style

    • ’starsandstripes’: Stars and Stripes style

    • ’kenan’: Kenan style

    • ’blueskies’: Blue Skies style

    • ’brasil’: Brasil style

    Default is ‘yahoo’.

  • hides_nontrading (bool, optional) – Whether to hide non-trading periods. Default is True.

  • out_dir (str, optional) – the output directory for saving figure.

Raises:

ValueError – If an unsupported interval is provided.

vistock.mpl.mpf_utils module

Utility for mplfinance.

vistock.mpl.mpf_utils.decide_mpf_style(base_mpf_style='yahoo', market_color_style=MarketColorStyle.WESTERN)[source]

Determine the mplfinance style based on the base style and market color style.

Parameters:
  • base_mpf_style (str) – The base mplfinance style to use. Default is ‘yahoo’.

  • market_color_style (MarketColorStyle) – The market color style to use. Default is MarketColorStyle.WESTERN.

Returns:

The mplfinance style dictionary with the appropriate market colors.

Return type:

dict

vistock.mpl.mpf_utils.use_mac_chinese_font()[source]

vistock.mpl.profile module

Visualize a Volume Profile (or Turnover Profile) for a stock.

class vistock.mpl.profile.Turnover[source]

Bases: object

Turnover Profile

Here “turnover” means “trading value” (= price * volume)

static plot(symbol='TSLA', period='1y', interval='1d', ma_nitems=(5, 10, 20, 50, 150), vma_nitems=50, total_bins=42, legend_loc='best', market_color_style=MarketColorStyle.AUTO, style='binancedark', hides_nontrading=True, out_dir='out')[source]

Plot a turnover profile figure for a given stock.

Here the provile is overlaid with the price subplot. This figure consists of two subplots: a price subplot and a volume subplot. The former includes price candlesticks, price moving average lines, while the latter includes a trading volume histogram and a volume moving average line.

Parameters:
  • symbol (str) – the stock symbol.

  • period (str, optional) –

    the period data to download (default is ‘1y’). Valid values are 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max.

    • d – days

    • mo – monthes

    • y – years

    • ytd – year to date

    • max – all data

  • interval (str, optional) –

    the interval of an OHLC item (default is ‘1d’). Valid values are 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo.

    • m – minutes

    • h – hours

    • wk – weeks

    • mo – monthes

    Intraday data cannot extend last 60 days:

    • 1m - max 7 days within last 30 days

    • up to 90m - max 60 days

    • 60m, 1h - max 730 days (yes 1h is technically < 90m but this what Yahoo does)

  • ma_nitems (sequence of int) – a sequence to list the number of data items to calclate moving averges.

  • vma_nitems (int) – the number of data items to calculate the volume moving average.

  • total_bins (int) – the number of bins to calculate comulative volume for bins.

  • legend_loc (str, optional) –

    the location of the legend (default is ‘best’). Valid locations are

    • ’best’

    • ’upper right’

    • ’upper left’

    • ’lower left’

    • ’lower right’

    • ’right’

    • ’center left’

    • ’center right’

    • ’lower center’

    • ’upper center’

    • ’center’

  • market_color_style (MarketColorStyle, optional) – The market color style to use. Default is MarketColorStyle.AUTO.

  • style (str, optional) –

    The chart style to use. Common styles include:

    • ’yahoo’: Yahoo Finance style

    • ’charles’: Charles style

    • ’tradingview’: TradingView style

    • ’binance’: Binance style

    • ’binancedark’: Binance dark mode style

    • ’mike’: Mike style (dark mode)

    • ’nightclouds’: Dark mode with sleek appearance

    • ’checkers’: Checkered style

    • ’ibd’: Investor’s Business Daily style

    • ’sas’: SAS style

    • ’starsandstripes’: Stars and Stripes style

    • ’kenan’: Kenan style

    • ’blueskies’: Blue Skies style

    • ’brasil’: Brasil style

    Default is ‘yahoo’.

  • hides_nontrading (bool, optional) – Whether to hide non-trading periods. Default is True.

  • out_dir (str, optional) – the output directory for saving figure.

class vistock.mpl.profile.Volume[source]

Bases: object

Volume Profile, i.e., PBV (Price-by-Volume) or Volume-by-Price

static plot(symbol='TSLA', period='1y', interval='1d', ma_nitems=(5, 10, 20, 50, 150), vma_nitems=50, total_bins=42, legend_loc='best', market_color_style=MarketColorStyle.AUTO, style='binancedark', hides_nontrading=True, out_dir='out')[source]

Plot a price-by-volume, PBV (also called volume profile) figure for a given stock.

Here the PBV is overlaid with the price subplot. This figure consists of two subplots: a price subplot and a volume subplot. The former includes price candlesticks, price moving average lines, while the latter includes a trading volume histogram and a volume moving average line.

Parameters:
  • symbol (str) – the stock symbol.

  • period (str, optional) –

    the period data to download (default is ‘1y’). Valid values are 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max.

    • d – days

    • mo – monthes

    • y – years

    • ytd – year to date

    • max – all data

  • interval (str, optional) –

    the interval of an OHLC item (default is ‘1d’). Valid values are 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo.

    • m – minutes

    • h – hours

    • wk – weeks

    • mo – monthes

    Intraday data cannot extend last 60 days:

    • 1m - max 7 days within last 30 days

    • up to 90m - max 60 days

    • 60m, 1h - max 730 days (yes 1h is technically < 90m but this what Yahoo does)

  • ma_nitems (sequence of int) – a sequence to list the number of data items to calclate moving averges.

  • vma_nitems (int) – the number of data items to calculate the volume moving average.

  • total_bins (int) – the number of bins to calculate comulative volume for bins.

  • legend_loc (str, optional) –

    the location of the legend (default is ‘best’). Valid locations are

    • ’best’

    • ’upper right’

    • ’upper left’

    • ’lower left’

    • ’lower right’

    • ’right’

    • ’center left’

    • ’center right’

    • ’lower center’

    • ’upper center’

    • ’center’

  • market_color_style (MarketColorStyle, optional) – The market color style to use. Default is MarketColorStyle.AUTO.

  • style (str, optional) –

    The chart style to use. Common styles include:

    • ’yahoo’: Yahoo Finance style

    • ’charles’: Charles style

    • ’tradingview’: TradingView style

    • ’binance’: Binance style

    • ’binancedark’: Binance dark mode style

    • ’mike’: Mike style (dark mode)

    • ’nightclouds’: Dark mode with sleek appearance

    • ’checkers’: Checkered style

    • ’ibd’: Investor’s Business Daily style

    • ’sas’: SAS style

    • ’starsandstripes’: Stars and Stripes style

    • ’kenan’: Kenan style

    • ’blueskies’: Blue Skies style

    • ’brasil’: Brasil style

    Default is ‘yahoo’.

  • hides_nontrading (bool, optional) – Whether to hide non-trading periods. Default is True.

  • out_dir (str, optional) – the output directory for saving figure.

vistock.mpl.rsi module

Plot a 3-split (price, volume, RSI) stock chart.

  • Data from yfinance

  • Plot with mplfinance

  • RSI from TA-Lib

vistock.mpl.rsi.plot(symbol='TSLA', period='1y', interval='1d', ma_nitems=(5, 10, 20, 50, 150), vma_nitems=50, legend_loc='best', market_color_style=MarketColorStyle.AUTO, style='yahoo', hides_nontrading=True, out_dir='out')[source]

Plot a stock figure that consists 3 suplots: a price subplot, a volume subplot, and a RSI subplot.

The price subplot shows price candlesticks, and price moving-average lines. The volume subplot shows a volume bar chart and a volume moving average line. The RSI subplot shows only the RSI curve.

Parameters:
  • symbol (str) – the stock symbol.

  • period (str, optional) –

    the period data to download. Valid values are 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max. Default is ‘1y’

    • d – days

    • mo – monthes

    • y – years

    • ytd – year to date

    • max – all data

  • interval (str, optional) –

    the interval of an OHLC item. Valid values are 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo. Default is ‘1d’

    • m – minutes

    • h – hours

    • wk – weeks

    • mo – monthes

    Intraday data cannot extend last 60 days:

    • 1m - max 7 days within last 30 days

    • up to 90m - max 60 days

    • 60m, 1h - max 730 days (yes 1h is technically < 90m but this what Yahoo does)

  • ma_nitems (sequence of int, optional) – a sequence to list the number of data items to calclate moving averges.

  • vma_nitems (int, optional) – the number of data items to calculate the volume moving average.

  • legend_loc (str, optional) –

    the location of the legend. Default is ‘best’. Valid locations are

    • ’best’

    • ’upper right’

    • ’upper left’

    • ’lower left’

    • ’lower right’

    • ’right’

    • ’center left’

    • ’center right’

    • ’lower center’

    • ’upper center’

    • ’center’

  • market_color_style (MarketColorStyle, optional) – The market color style to use. Default is MarketColorStyle.AUTO.

  • style (str, optional) –

    The chart style to use. Common styles include:

    • ’yahoo’: Yahoo Finance style

    • ’charles’: Charles style

    • ’tradingview’: TradingView style

    • ’binance’: Binance style

    • ’binancedark’: Binance dark mode style

    • ’mike’: Mike style (dark mode)

    • ’nightclouds’: Dark mode with sleek appearance

    • ’checkers’: Checkered style

    • ’ibd’: Investor’s Business Daily style

    • ’sas’: SAS style

    • ’starsandstripes’: Stars and Stripes style

    • ’kenan’: Kenan style

    • ’blueskies’: Blue Skies style

    • ’brasil’: Brasil style

    Default is ‘yahoo’.

  • hides_nontrading (bool, optional) – Whether to hide non-trading periods. Default is True.

  • out_dir (str) – the output directory for saving figure.

Module contents

Initialize vistock.mpl package.