vistock.plotly package

Submodules

vistock.plotly.bull_draw module

Visualize a BullRun and Drawdown for a stock.

vistock.plotly.bull_draw.plot(symbol='TSLA', period='1y', interval='1d', ma_nitems=(5, 10, 20, 50, 150), vma_nitems=50, market_color_style=MarketColorStyle.AUTO, template='plotly', 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)

  • 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.

  • market_color_style (MarketColorStyle, optional) – Color style for market data visualization. Default is MarketColorStyle.AUTO.

  • template (str, optional:) –

    The Plotly template to use for styling the chart. Defaults to ‘plotly’. Available templates include:

    • ’plotly’: Default Plotly template with interactive plots.

    • ’plotly_white’: Light theme with a white background.

    • ’plotly_dark’: Dark theme for the chart background.

    • ’ggplot2’: Style similar to ggplot2 from R.

    • ’seaborn’: Style similar to Seaborn in Python.

    • ’simple_white’: Minimal white style with no gridlines.

    • ’presentation’: Designed for presentations with a clean look.

    • ’xgridoff’: Plot with x-axis gridlines turned off.

    • ’ygridoff’: Plot with y-axis gridlines turned off.

    For more details on templates, refer to Plotly’s official documentation.

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

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

vistock.plotly.fig_utils module

Common utility for Plotly figures.

vistock.plotly.fig_utils.add_crosshair_cursor(fig)[source]

Add crosshair cursor to a given figure.

Parameters:

fig (plotly.graph_objects.Figure) – the figure

vistock.plotly.fig_utils.add_hovermode_menu(fig, x=0, y=1.05)[source]

Add a dropdown menu for selecting a hover mode.

Parameters:
  • fig (plotly.graph_objects.Figure) – the figure.

  • x (int) – the x position of the menu

  • y (int) – the y position of the menu

vistock.plotly.fig_utils.get_candlestick_colors(market_color_style=MarketColorStyle.WESTERN)[source]
vistock.plotly.fig_utils.get_volume_colors(market_color_style=MarketColorStyle.WESTERN)[source]
vistock.plotly.fig_utils.hide_nontrading_periods(fig, df, interval)[source]

Hide non-tranding time-periods.

This function can hide certain time-periods to avoid the gaps at non-trading time-periods.

Parameters:
  • fig (plotly.graph_objects.figure) – the figure

  • df (pandas.DataFrame) – the stock table

  • interval (str) –

    the interval of an OHLC item. Valid values are 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo. 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)

vistock.plotly.financials module

This module provides a function to plot financial data for a given stock symbol using Plotly. The data includes Basic EPS, Operating Revenue, Trailing EPS, and Forward EPS (if available), plotted on two subplots with customizable styles via the template parameter.

The plot function generates:

  1. Quarterly financial data.

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

The plot is saved as an HTML file in the specified out_dir, with support for interactive exploration.

vistock.plotly.financials.plot(symbol, template='plotly', out_dir='out')[source]

Plots the financial data of a stock symbol using Plotly.

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 two subplots, one for each frequency. The primary y-axis displays Basic EPS, and the secondary y-axis displays Operating Revenue. The chart’s layout is customizable through the template parameter.

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

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

  • template (str, optional:) –

    The Plotly template to use for styling the chart. Defaults to ‘plotly’. Available templates include:

    • ’plotly’: Default Plotly template with interactive plots.

    • ’plotly_white’: Light theme with a white background.

    • ’plotly_dark’: Dark theme for the chart background.

    • ’ggplot2’: Style similar to ggplot2 from R.

    • ’seaborn’: Style similar to Seaborn in Python.

    • ’simple_white’: Minimal white style with no gridlines.

    • ’presentation’: Designed for presentations with a clean look.

    • ’xgridoff’: Plot with x-axis gridlines turned off.

    • ’ygridoff’: Plot with y-axis gridlines turned off.

    For more details on templates, refer to Plotly’s official documentation.

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

vistock.plotly.ibd_rs module

ibd_rs.py - Provides IBD-compatible stock charts.

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.plotly import ibd_rs
ibd_rs.plot('TSLA', period='1y', interval='1d')
vistock.plotly.ibd_rs.plot(symbol, period='2y', interval='1d', ticker_ref=None, rs_window='12mo', market_color_style=MarketColorStyle.AUTO, template='plotly', 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.

Creates an interactive Plotly figure showing:
  • Candlestick chart of the stock with moving averages.

  • Relative Strength (RS) indicator in a separate subplot.

  • Volume and volume moving average in another subplot.

The figure is saved as an HTML file in the specified output directory.

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

  • period (str) –

    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) – 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.

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

  • market_color_style (MarketColorStyle, optional) – Color style for market data visualization. Default is MarketColorStyle.AUTO.

  • template (str, optional:) –

    The Plotly template to use for styling the chart. Defaults to ‘plotly’. Available templates include:

    • ’plotly’: Default Plotly template with interactive plots.

    • ’plotly_white’: Light theme with a white background.

    • ’plotly_dark’: Dark theme for the chart background.

    • ’ggplot2’: Style similar to ggplot2 from R.

    • ’seaborn’: Style similar to Seaborn in Python.

    • ’simple_white’: Minimal white style with no gridlines.

    • ’presentation’: Designed for presentations with a clean look.

    • ’xgridoff’: Plot with x-axis gridlines turned off.

    • ’ygridoff’: Plot with y-axis gridlines turned off.

    For more details on templates, refer to Plotly’s official documentation.

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

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

Raises:

ValueError – If an unsupported interval is provided.

vistock.plotly.ibd_rs_cmp module

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

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 Plotly. It fetches historical stock data from Yahoo Finance, calculates RS values, and generates an interactive Plotly chart. The resulting chart can be saved as an HTML 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.plotly.ibd_rs_cmp.plot(symbols, period='2y', interval='1d', ticker_ref=None, rs_window='12mo', template='plotly', colorway=['rgb(141,211,199)', 'rgb(255,255,179)', 'rgb(190,186,218)', 'rgb(251,128,114)', 'rgb(128,177,211)', 'rgb(253,180,98)', 'rgb(179,222,105)', 'rgb(252,205,229)', 'rgb(217,217,217)', 'rgb(188,128,189)', 'rgb(204,235,197)', 'rgb(255,237,111)'], hides_nontrading=True, out_dir='out')[source]

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

This function generates an interactive Plotly chart that compares the RS values 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 HTML 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 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.

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

  • template (str, optional:) –

    The Plotly template to use for styling the chart. Defaults to ‘plotly’. Available templates include:

    • ’plotly’: Default Plotly template with interactive plots.

    • ’plotly_white’: Light theme with a white background.

    • ’plotly_dark’: Dark theme for the chart background.

    • ’ggplot2’: Style similar to ggplot2 from R.

    • ’seaborn’: Style similar to Seaborn in Python.

    • ’simple_white’: Minimal white style with no gridlines.

    • ’presentation’: Designed for presentations with a clean look.

    • ’xgridoff’: Plot with x-axis gridlines turned off.

    • ’ygridoff’: Plot with y-axis gridlines turned off.

    For more details on templates, refer to Plotly’s official documentation.

  • colorway (list or None) –

    Sets the default trace colors for the plot. If None, Plotly’s default color sequence will be used. You can pass a list of custom colors or choose from Plotly’s predefined color sequences.

    By default, this is set to px.colors.qualitative.Set3, which consists of 24 vibrant colors.

    Useful predefined color sequences include:

    • px.colors.qualitative.Light24 (24 colors, vibrant and varied)

    • px.colors.qualitative.Dark24 (24 colors, darker tones)

    • px.colors.qualitative.Pastel (26 colors, soft pastel tones)

    • px.colors.qualitative.Bold (26 colors, bold and distinct)

    • px.colors.qualitative.Alphabet (26 colors, one for each letter)

    • px.colors.qualitative.Set3 (12 colors, good for categorical data)

    • px.colors.qualitative.G10 (10 colors, general use)

    • px.colors.qualitative.T10 (10 colors, clear and bright)

    • px.colors.qualitative.Plotly (10 colors, default Plotly colors)

  • hides_nontrading (bool, optional) – Whether to hide non-trading periods on the plot. Defaults to True.

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

Returns:

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

Return type:

None

Example

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

vistock.plotly.mansfield module

Mansfield Stock Charts

This module provides functionality for generating and plotting Mansfield Stock Charts and Mansfield Relative Strength (RSM) charts based on the methods outlined in Stan Weinstein’s book “Secrets for Profiting in Bull and Bear Markets.” It includes two main classes for creating visualizations:

  1. StockChart:
    • Generates a Mansfield Stock Chart for a given stock symbol compared to a reference index.

    • Allows customization of chart elements such as moving averages, chart templates, and hiding non-trading periods.

  2. RelativeStrengthLines:
    • Plots the Mansfield Relative Strength (RSM) of multiple stocks compared to a reference index.

    • Allows comparison of multiple stocks’ RS values against a reference index with customization options for the time period, data interval, and moving average type.

Usage:

To generate a Mansfield Stock Chart:
>>> StockChart.plot('TSLA', interval='1wk')
To generate a Relative Strength Lines chart for multiple stocks:
>>> RelativeStrengthLines.plot(['NVDA', 'MSFT', 'META'], interval='1wk')

See Also:

class vistock.plotly.mansfield.RelativeStrengthLines[source]

Bases: object

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

This class generates an interactive Plotly chart that compares the Relative Strength (RS) of multiple stocks against a reference index (e.g., S&P 500 or Taiwan Weighted Index). It provides a visualization of how each stock’s RS changes over time relative to the reference index, with options to customize the time period, data interval, and moving average type.

static plot(symbols, period='2y', interval='1d', ticker_ref=None, ma='SMA', template='plotly_dark', colorway=['rgb(141,211,199)', 'rgb(255,255,179)', 'rgb(190,186,218)', 'rgb(251,128,114)', 'rgb(128,177,211)', 'rgb(253,180,98)', 'rgb(179,222,105)', 'rgb(252,205,229)', 'rgb(217,217,217)', 'rgb(188,128,189)', 'rgb(204,235,197)', 'rgb(255,237,111)'], hides_nontrading=True, out_dir='out')[source]

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

This function generates an interactive Plotly chart that compares the RS values 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 HTML 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 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’.

  • template (str, optional:) –

    The Plotly template to use for styling the chart. Defaults to ‘plotly_dark’.

    Available templates include:

    • ’plotly’: Default Plotly template with interactive plots.

    • ’plotly_white’: Light theme with a white background.

    • ’plotly_dark’: Dark theme for the chart background.

    • ’ggplot2’: Style similar to ggplot2 from R.

    • ’seaborn’: Style similar to Seaborn in Python.

    • ’simple_white’: Minimal white style with no gridlines.

    • ’presentation’: Designed for presentations with a clean look.

    • ’xgridoff’: Plot with x-axis gridlines turned off.

    • ’ygridoff’: Plot with y-axis gridlines turned off.

    For more details on templates, refer to Plotly’s official documentation.

  • colorway (list or None) –

    Sets the default trace colors for the plot. If None, Plotly’s default color sequence will be used. You can pass a list of custom colors or choose from Plotly’s predefined color sequences.

    By default, this is set to px.colors.qualitative.Set3, which consists of 24 vibrant colors.

    Useful predefined color sequences include:

    • px.colors.qualitative.Light24 (24 colors, vibrant and varied)

    • px.colors.qualitative.Dark24 (24 colors, darker tones)

    • px.colors.qualitative.Pastel (26 colors, soft pastel tones)

    • px.colors.qualitative.Bold (26 colors, bold and distinct)

    • px.colors.qualitative.Alphabet (26 colors, one for each letter)

    • px.colors.qualitative.Set3 (12 colors, good for categorical data)

    • px.colors.qualitative.G10 (10 colors, general use)

    • px.colors.qualitative.T10 (10 colors, clear and bright)

    • px.colors.qualitative.Plotly (10 colors, default Plotly colors)

  • hides_nontrading (bool, optional) – Whether to hide non-trading periods on the plot. Defaults to True.

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

Returns:

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

Return type:

None

Example

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

Bases: object

A class for generating and plotting Mansfield Stock Charts based on Stan Weinstein’s methods outlined in the book “Secrets for Profiting in Bull and Bear Markets.”

static plot(symbol, period='2y', interval='1wk', ticker_ref=None, ma='SMA', market_color_style=MarketColorStyle.AUTO, template='plotly', 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.

  • period (str, optional) –

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

    • y – years

    • ytd – year to date

    • max – all data

  • interval (str, optional) –

    the interval of an OHLC item. Valid values are 1d, 1wk, 1mo, 3mo. Default is ‘1wk’.

    • d – days

    • wk – weeks

    • mo – months

  • 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’.

  • market_color_style (MarketColorStyle, optional) – Color style for market data visualization. Default is MarketColorStyle.AUTO.

  • template (str, optional:) –

    The Plotly template to use for styling the chart. Defaults to ‘plotly’. Available templates include:

    • ’plotly’: Default Plotly template with interactive plots.

    • ’plotly_white’: Light theme with a white background.

    • ’plotly_dark’: Dark theme for the chart background.

    • ’ggplot2’: Style similar to ggplot2 from R.

    • ’seaborn’: Style similar to Seaborn in Python.

    • ’simple_white’: Minimal white style with no gridlines.

    • ’presentation’: Designed for presentations with a clean look.

    • ’xgridoff’: Plot with x-axis gridlines turned off.

    • ’ygridoff’: Plot with y-axis gridlines turned off.

    For more details on templates, refer to Plotly’s official documentation.

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

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

Raises:

ValueError – If an unsupported interval is provided.

vistock.plotly.prf2s module

Visualize a profile chart (eigher Volume Profile or Turnover Profile) with 2-section layout for a given stock.

class vistock.plotly.prf2s.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, hbar_align_on_right=True, market_color_style=MarketColorStyle.AUTO, template='plotly', hides_nontrading=True, out_dir='out')[source]

Plot a price-by-volume, PBV (also called volume profile) figure for a given stock. This figure shows the volume distribution across price levels for a stock.

Here the PBV is overlaied with the price subplot. This figure consists of two subplots: a price subplot and a volume subplot. The former includes candlestick, moving average lines, while the latter includes trading volume bar chart and 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)

  • 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.

  • hbar_align_on_right (bool) – decide if the price-by-volume bars align on right. True to set the starting position of the horizontal bars to the right; False the left.

  • market_color_style (MarketColorStyle, optional) – Color style for market data visualization. Default is MarketColorStyle.AUTO.

  • template (str, optional:) –

    The Plotly template to use for styling the chart. Defaults to ‘plotly’. Available templates include:

    • ’plotly’: Default Plotly template with interactive plots.

    • ’plotly_white’: Light theme with a white background.

    • ’plotly_dark’: Dark theme for the chart background.

    • ’ggplot2’: Style similar to ggplot2 from R.

    • ’seaborn’: Style similar to Seaborn in Python.

    • ’simple_white’: Minimal white style with no gridlines.

    • ’presentation’: Designed for presentations with a clean look.

    • ’xgridoff’: Plot with x-axis gridlines turned off.

    • ’ygridoff’: Plot with y-axis gridlines turned off.

    For more details on templates, refer to Plotly’s official documentation.

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

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

class vistock.plotly.prf2s.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, hbar_align_on_right=True, market_color_style=MarketColorStyle.AUTO, template='plotly', hides_nontrading=True, out_dir='out')[source]

Plot a price-by-volume, PBV (also called volume profile) figure for a given stock. This figure shows the volume distribution across price levels for a stock.

Here the PBV is overlaied with the price subplot. This figure consists of two subplots: a price subplot and a volume subplot. The former includes candlestick, moving average lines, while the latter includes trading volume bar chart and 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)

  • 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.

  • hbar_align_on_right (bool) – decide if the price-by-volume bars align on right. True to set the starting position of the horizontal bars to the right; False the left.

  • market_color_style (MarketColorStyle, optional) – Color style for market data visualization. Default is MarketColorStyle.AUTO.

  • template (str, optional:) –

    The Plotly template to use for styling the chart. Defaults to ‘plotly’. Available templates include:

    • ’plotly’: Default Plotly template with interactive plots.

    • ’plotly_white’: Light theme with a white background.

    • ’plotly_dark’: Dark theme for the chart background.

    • ’ggplot2’: Style similar to ggplot2 from R.

    • ’seaborn’: Style similar to Seaborn in Python.

    • ’simple_white’: Minimal white style with no gridlines.

    • ’presentation’: Designed for presentations with a clean look.

    • ’xgridoff’: Plot with x-axis gridlines turned off.

    • ’ygridoff’: Plot with y-axis gridlines turned off.

    For more details on templates, refer to Plotly’s official documentation.

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

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

vistock.plotly.prf4s module

Visualize a profile chart (eigher Volume Profile or Turnover Profile) with 4-section layout for a given stock.

class vistock.plotly.prf4s.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, market_color_style=MarketColorStyle.AUTO, template='plotly', hides_nontrading=True, out_dir='out')[source]

Plot a price-by-volume, PBV (also called volume profile) figure for a given stock. This figure shows the volume distribution across price levels for a stock.

Here the PBV is overlaied with the price subplot. This figure consists of two subplots: a price subplot and a volume subplot. The former includes candlestick, moving average lines, while the latter includes trading volume bar chart and 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)

  • 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.

  • market_color_style (MarketColorStyle, optional) – Color style for market data visualization. Default is MarketColorStyle.AUTO.

  • template (str, optional:) –

    The Plotly template to use for styling the chart. Defaults to ‘plotly’. Available templates include:

    • ’plotly’: Default Plotly template with interactive plots.

    • ’plotly_white’: Light theme with a white background.

    • ’plotly_dark’: Dark theme for the chart background.

    • ’ggplot2’: Style similar to ggplot2 from R.

    • ’seaborn’: Style similar to Seaborn in Python.

    • ’simple_white’: Minimal white style with no gridlines.

    • ’presentation’: Designed for presentations with a clean look.

    • ’xgridoff’: Plot with x-axis gridlines turned off.

    • ’ygridoff’: Plot with y-axis gridlines turned off.

    For more details on templates, refer to Plotly’s official documentation.

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

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

class vistock.plotly.prf4s.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, market_color_style=MarketColorStyle.AUTO, template='plotly', hides_nontrading=True, out_dir='out')[source]

Plot a price-by-volume, PBV (also called volume profile) figure for a given stock. This figure shows the volume distribution across price levels for a stock.

Here the PBV is overlaied with the price subplot. This figure consists of two subplots: a price subplot and a volume subplot. The former includes candlestick, moving average lines, while the latter includes trading volume bar chart and 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)

  • 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.

  • market_color_style (MarketColorStyle, optional) – Color style for market data visualization. Default is MarketColorStyle.AUTO.

  • template (str, optional:) –

    The Plotly template to use for styling the chart. Defaults to ‘plotly’. Available templates include:

    • ’plotly’: Default Plotly template with interactive plots.

    • ’plotly_white’: Light theme with a white background.

    • ’plotly_dark’: Dark theme for the chart background.

    • ’ggplot2’: Style similar to ggplot2 from R.

    • ’seaborn’: Style similar to Seaborn in Python.

    • ’simple_white’: Minimal white style with no gridlines.

    • ’presentation’: Designed for presentations with a clean look.

    • ’xgridoff’: Plot with x-axis gridlines turned off.

    • ’ygridoff’: Plot with y-axis gridlines turned off.

    For more details on templates, refer to Plotly’s official documentation.

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

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

vistock.plotly.pv1s module

Show a price-and-volume overlaid stock chart.

  • Data from yfinance

  • Plot with Plotly (for candlestick, MA, volume, volume MA)

vistock.plotly.pv1s.plot(symbol='TSLA', period='1y', interval='1d', ma_nitems=(5, 10, 20, 50, 150), vma_nitems=50, market_color_style=MarketColorStyle.AUTO, template='plotly', hides_nontrading=True, out_dir='out')[source]

Plot a stock figure overlaying charts in a single subplot.

These charts include candlesticks, price moving-average lines, 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)

  • 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.

  • market_color_style (MarketColorStyle, optional) – Color style for market data visualization. Default is MarketColorStyle.AUTO.

  • template (str, optional:) –

    The Plotly template to use for styling the chart. Defaults to ‘plotly’. Available templates include:

    • ’plotly’: Default Plotly template with interactive plots.

    • ’plotly_white’: Light theme with a white background.

    • ’plotly_dark’: Dark theme for the chart background.

    • ’ggplot2’: Style similar to ggplot2 from R.

    • ’seaborn’: Style similar to Seaborn in Python.

    • ’simple_white’: Minimal white style with no gridlines.

    • ’presentation’: Designed for presentations with a clean look.

    • ’xgridoff’: Plot with x-axis gridlines turned off.

    • ’ygridoff’: Plot with y-axis gridlines turned off.

    For more details on templates, refer to Plotly’s official documentation.

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

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

vistock.plotly.pv2s module

Show a price-and-volume separated stock chart.

  • Data from yfinance

  • Plot with Plotly (for candlestick, MA, volume, volume MA)

vistock.plotly.pv2s.plot(symbol='TSLA', period='1y', interval='1d', ma_nitems=(5, 10, 20, 50, 150), vma_nitems=50, market_color_style=MarketColorStyle.AUTO, template='plotly', 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 candlesticks, moving average lines, 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)

  • 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.

  • market_color_style (MarketColorStyle, optional) – Color style for market data visualization. Default is MarketColorStyle.AUTO.

  • template (str, optional:) –

    The Plotly template to use for styling the chart. Defaults to ‘plotly’. Available templates include:

    • ’plotly’: Default Plotly template with interactive plots.

    • ’plotly_white’: Light theme with a white background.

    • ’plotly_dark’: Dark theme for the chart background.

    • ’ggplot2’: Style similar to ggplot2 from R.

    • ’seaborn’: Style similar to Seaborn in Python.

    • ’simple_white’: Minimal white style with no gridlines.

    • ’presentation’: Designed for presentations with a clean look.

    • ’xgridoff’: Plot with x-axis gridlines turned off.

    • ’ygridoff’: Plot with y-axis gridlines turned off.

    For more details on templates, refer to Plotly’s official documentation.

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

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

Module contents

Initialize vistock.plotly package.