quantlib.plot package

Submodules

quantlib.plot.bar module

class quantlib.plot.bar.BarPlot(history: BarHistory, plot_index: bool, start_idx: int = None, end_idx: int = None)

Bases: object

A Plot utility for plotting bars and lines on a candlestick chart Method chaining pattern is used to allow chaining of plot methods

>>> plot = BarPlot(history, plot_index,self.start_plot_idx, self.end_plot_idx)
>>> plot.plot_bars().plot_line(
>>>     line=resistance, name="Resistance"
>>> ).plot_line(
>>>     line=support, name="Support"
>>> ).plot_vertical(
>>>     history.bars[first_considered_bar_idx], line_color='lime'
>>> ).plot_vertical(
>>>     history.bars[current_bar_idx], line_color='red'
>>> )
plot_bars() BarPlot

Generate a candlestick plot of the bars in the history

Returns:

self

Return type:

BarPlot

plot_line(line: Line | None, name: str | None = None) BarPlot

Plot a single extended line on the current plot

Parameters:
  • line (Line | None) – line to plot

  • name (str | None, optional) – line label, defaults to None

Returns:

self

Return type:

BarPlot

plot_lines(lines: list[Line]) BarPlot
plot_residual_x(intersection_x: float, intersection_y: float) BarPlot
plot_scatter(xs: Iterable[float | datetime], ys: ndarray | Iterable[float], name: str | None = None) BarPlot

Used to plot lines on the candlestick chart

Parameters:
  • xs (Iterable[float | datetime]) – x coordinates of the points

  • ys (np.ndarray | Iterable[float]) – y coordinates of the points (price)

  • name (str | None, optional) – line label, defaults to None

Returns:

self

Return type:

BarPlot

plot_vertical(bar: Bar, line_color: str = 'black', line_style: str = 'solid') BarPlot

Plot vertical line on the current plot, we use these vertical lines to mark range of bars considered

Parameters:
  • bar (Bar) – represent position to plot the vertical line

  • line_color (str, optional) – line color, defaults to ‘black’

  • line_style (str, optional) – line style, defaults to ‘solid’

Returns:

self

Return type:

BarPlot

show()
title(title: str) BarPlot

Module contents