portfolio_toolkit.plot package

Submodules

portfolio_toolkit.plot.bar_chart_data module

class portfolio_toolkit.plot.bar_chart_data.BarChartData(title: str, grid: bool = True, figsize: tuple = (10, 6), labels: ~typing.List[str] = <factory>, values: ~typing.List[float] = <factory>, xlabel: str = 'Categories', ylabel: str = 'Values', colors: ~typing.List[str] | None = None, horizontal: bool = False)[source]

Bases: PlotBase

Data structure for bar charts

labels: List[str]
values: List[float]
xlabel: str = 'Categories'
ylabel: str = 'Values'
colors: List[str] | None = None
horizontal: bool = False
get_plot_type() str[source]

Return the type of plot

validate() bool[source]

Validate that data is consistent

__init__(title: str, grid: bool = True, figsize: tuple = (10, 6), labels: ~typing.List[str] = <factory>, values: ~typing.List[float] = <factory>, xlabel: str = 'Categories', ylabel: str = 'Values', colors: ~typing.List[str] | None = None, horizontal: bool = False) None

portfolio_toolkit.plot.engine module

class portfolio_toolkit.plot.engine.PlotEngine[source]

Bases: object

Universal plotting engine that can handle different plot types

static plot(data: PlotBase, save_path: str | None = None, show: bool = True) None[source]

Plot data based on its type

Parameters:
  • data – Plot data structure inheriting from PlotBase

  • save_path – Optional path to save the plot

  • show – Whether to display the plot

portfolio_toolkit.plot.line_chart_data module

class portfolio_toolkit.plot.line_chart_data.LineChartData(title: str, grid: bool = True, figsize: tuple = (10, 6), x_data: ~typing.List[~typing.Any] = <factory>, y_data: ~typing.List[~typing.List[float]] = <factory>, labels: ~typing.List[str] = <factory>, xlabel: str = 'X Axis', ylabel: str = 'Y Axis', colors: ~typing.List[str] | None = None, linestyles: ~typing.List[str] | None = None, markers: ~typing.List[str] | None = None)[source]

Bases: PlotBase

Data structure for line charts

x_data: List[Any]
y_data: List[List[float]]
labels: List[str]
xlabel: str = 'X Axis'
ylabel: str = 'Y Axis'
colors: List[str] | None = None
linestyles: List[str] | None = None
markers: List[str] | None = None
get_plot_type() str[source]

Return the type of plot

validate() bool[source]

Validate that data is consistent

__init__(title: str, grid: bool = True, figsize: tuple = (10, 6), x_data: ~typing.List[~typing.Any] = <factory>, y_data: ~typing.List[~typing.List[float]] = <factory>, labels: ~typing.List[str] = <factory>, xlabel: str = 'X Axis', ylabel: str = 'Y Axis', colors: ~typing.List[str] | None = None, linestyles: ~typing.List[str] | None = None, markers: ~typing.List[str] | None = None) None

portfolio_toolkit.plot.pie_chart_data module

class portfolio_toolkit.plot.pie_chart_data.PieChartData(title: str, grid: bool = True, figsize: tuple = (10, 6), labels: ~typing.List[str] = <factory>, values: ~typing.List[float] = <factory>, colors: ~typing.List[str] | None = None, autopct: str = '%1.1f%%', startangle: float = 90, explode: ~typing.List[float] | None = None)[source]

Bases: PlotBase

Data structure for pie charts

labels: List[str]
values: List[float]
colors: List[str] | None = None
autopct: str = '%1.1f%%'
startangle: float = 90
explode: List[float] | None = None
get_plot_type() str[source]

Return the type of plot

validate() bool[source]

Validate that data is consistent

__init__(title: str, grid: bool = True, figsize: tuple = (10, 6), labels: ~typing.List[str] = <factory>, values: ~typing.List[float] = <factory>, colors: ~typing.List[str] | None = None, autopct: str = '%1.1f%%', startangle: float = 90, explode: ~typing.List[float] | None = None) None

portfolio_toolkit.plot.plot_assets module

portfolio_toolkit.plot.plot_assets.plot_assets(price_series_list, asset_names)[source]

Plots the closing prices for multiple assets.

Parameters:
  • price_series_list (list of pd.Series) – List of closing price series.

  • asset_names (list of str) – List of asset names.

Returns:

None

portfolio_toolkit.plot.plot_base module

class portfolio_toolkit.plot.plot_base.PlotBase(title: str, grid: bool = True, figsize: tuple = (10, 6))[source]

Bases: ABC

Base class for all plot data structures

title: str
grid: bool = True
figsize: tuple = (10, 6)
abstractmethod get_plot_type() str[source]

Return the type of plot

__init__(title: str, grid: bool = True, figsize: tuple = (10, 6)) None

portfolio_toolkit.plot.scatter_plot_data module

class portfolio_toolkit.plot.scatter_plot_data.ScatterPlotData(title: str, grid: bool = True, figsize: tuple = (10, 6), x_data: ~typing.List[float] = <factory>, y_data: ~typing.List[float] = <factory>, labels: ~typing.List[str] | None = None, xlabel: str = 'X Axis', ylabel: str = 'Y Axis', colors: ~typing.List[str] | None = None, sizes: ~typing.List[float] | None = None, alpha: float = 0.7)[source]

Bases: PlotBase

Data structure for scatter plots

x_data: List[float]
y_data: List[float]
labels: List[str] | None = None
xlabel: str = 'X Axis'
ylabel: str = 'Y Axis'
colors: List[str] | None = None
sizes: List[float] | None = None
alpha: float = 0.7
get_plot_type() str[source]

Return the type of plot

validate() bool[source]

Validate that data is consistent

__init__(title: str, grid: bool = True, figsize: tuple = (10, 6), x_data: ~typing.List[float] = <factory>, y_data: ~typing.List[float] = <factory>, labels: ~typing.List[str] | None = None, xlabel: str = 'X Axis', ylabel: str = 'Y Axis', colors: ~typing.List[str] | None = None, sizes: ~typing.List[float] | None = None, alpha: float = 0.7) None

Module contents

class portfolio_toolkit.plot.PlotBase(title: str, grid: bool = True, figsize: tuple = (10, 6))[source]

Bases: ABC

Base class for all plot data structures

__init__(title: str, grid: bool = True, figsize: tuple = (10, 6)) None
figsize: tuple = (10, 6)
abstractmethod get_plot_type() str[source]

Return the type of plot

grid: bool = True
title: str
class portfolio_toolkit.plot.PieChartData(title: str, grid: bool = True, figsize: tuple = (10, 6), labels: ~typing.List[str] = <factory>, values: ~typing.List[float] = <factory>, colors: ~typing.List[str] | None = None, autopct: str = '%1.1f%%', startangle: float = 90, explode: ~typing.List[float] | None = None)[source]

Bases: PlotBase

Data structure for pie charts

__init__(title: str, grid: bool = True, figsize: tuple = (10, 6), labels: ~typing.List[str] = <factory>, values: ~typing.List[float] = <factory>, colors: ~typing.List[str] | None = None, autopct: str = '%1.1f%%', startangle: float = 90, explode: ~typing.List[float] | None = None) None
autopct: str = '%1.1f%%'
colors: List[str] | None = None
explode: List[float] | None = None
get_plot_type() str[source]

Return the type of plot

startangle: float = 90
validate() bool[source]

Validate that data is consistent

labels: List[str]
values: List[float]
title: str
class portfolio_toolkit.plot.LineChartData(title: str, grid: bool = True, figsize: tuple = (10, 6), x_data: ~typing.List[~typing.Any] = <factory>, y_data: ~typing.List[~typing.List[float]] = <factory>, labels: ~typing.List[str] = <factory>, xlabel: str = 'X Axis', ylabel: str = 'Y Axis', colors: ~typing.List[str] | None = None, linestyles: ~typing.List[str] | None = None, markers: ~typing.List[str] | None = None)[source]

Bases: PlotBase

Data structure for line charts

__init__(title: str, grid: bool = True, figsize: tuple = (10, 6), x_data: ~typing.List[~typing.Any] = <factory>, y_data: ~typing.List[~typing.List[float]] = <factory>, labels: ~typing.List[str] = <factory>, xlabel: str = 'X Axis', ylabel: str = 'Y Axis', colors: ~typing.List[str] | None = None, linestyles: ~typing.List[str] | None = None, markers: ~typing.List[str] | None = None) None
colors: List[str] | None = None
get_plot_type() str[source]

Return the type of plot

linestyles: List[str] | None = None
markers: List[str] | None = None
validate() bool[source]

Validate that data is consistent

xlabel: str = 'X Axis'
ylabel: str = 'Y Axis'
x_data: List[Any]
y_data: List[List[float]]
labels: List[str]
title: str
class portfolio_toolkit.plot.BarChartData(title: str, grid: bool = True, figsize: tuple = (10, 6), labels: ~typing.List[str] = <factory>, values: ~typing.List[float] = <factory>, xlabel: str = 'Categories', ylabel: str = 'Values', colors: ~typing.List[str] | None = None, horizontal: bool = False)[source]

Bases: PlotBase

Data structure for bar charts

__init__(title: str, grid: bool = True, figsize: tuple = (10, 6), labels: ~typing.List[str] = <factory>, values: ~typing.List[float] = <factory>, xlabel: str = 'Categories', ylabel: str = 'Values', colors: ~typing.List[str] | None = None, horizontal: bool = False) None
colors: List[str] | None = None
get_plot_type() str[source]

Return the type of plot

horizontal: bool = False
validate() bool[source]

Validate that data is consistent

xlabel: str = 'Categories'
ylabel: str = 'Values'
labels: List[str]
values: List[float]
title: str
class portfolio_toolkit.plot.ScatterPlotData(title: str, grid: bool = True, figsize: tuple = (10, 6), x_data: ~typing.List[float] = <factory>, y_data: ~typing.List[float] = <factory>, labels: ~typing.List[str] | None = None, xlabel: str = 'X Axis', ylabel: str = 'Y Axis', colors: ~typing.List[str] | None = None, sizes: ~typing.List[float] | None = None, alpha: float = 0.7)[source]

Bases: PlotBase

Data structure for scatter plots

__init__(title: str, grid: bool = True, figsize: tuple = (10, 6), x_data: ~typing.List[float] = <factory>, y_data: ~typing.List[float] = <factory>, labels: ~typing.List[str] | None = None, xlabel: str = 'X Axis', ylabel: str = 'Y Axis', colors: ~typing.List[str] | None = None, sizes: ~typing.List[float] | None = None, alpha: float = 0.7) None
alpha: float = 0.7
colors: List[str] | None = None
get_plot_type() str[source]

Return the type of plot

labels: List[str] | None = None
sizes: List[float] | None = None
validate() bool[source]

Validate that data is consistent

xlabel: str = 'X Axis'
ylabel: str = 'Y Axis'
x_data: List[float]
y_data: List[float]
title: str
class portfolio_toolkit.plot.PlotEngine[source]

Bases: object

Universal plotting engine that can handle different plot types

static plot(data: PlotBase, save_path: str | None = None, show: bool = True) None[source]

Plot data based on its type

Parameters:
  • data – Plot data structure inheriting from PlotBase

  • save_path – Optional path to save the plot

  • show – Whether to display the plot