portfolio_toolkit.portfolio.time_series package
Submodules
portfolio_toolkit.portfolio.time_series.plot module
- portfolio_toolkit.portfolio.time_series.plot.plot_evolution(df_portfolio)[fuente]
Generates a chart showing the evolution of the portfolio value over time.
- Parámetros:
df_portfolio (pd.DataFrame) – Structured DataFrame with the portfolio evolution.
- Devuelve:
None
- portfolio_toolkit.portfolio.time_series.plot.plot_evolution_stacked(df_portfolio)[fuente]
Generates a stacked area chart showing the evolution of the portfolio value by ticker.
- Parámetros:
df_portfolio (pd.DataFrame) – Structured DataFrame with the portfolio evolution.
- Devuelve:
None
- portfolio_toolkit.portfolio.time_series.plot.plot_evolution_vs_cost(df_portfolio)[fuente]
Plots the evolution of the portfolio value along with the cost of the shares.
- Parámetros:
df_portfolio (pd.DataFrame) – DataFrame with the portfolio evolution.
- Devuelve:
None
- portfolio_toolkit.portfolio.time_series.plot.plot_evolution_ticker(df_portfolio, ticker)[fuente]
Plots the evolution of the value of a specific ticker in the portfolio, including the accumulated cost.
- Parámetros:
df_portfolio (pd.DataFrame) – Structured DataFrame with the portfolio evolution.
ticker (str) – The asset symbol.
- Devuelve:
None
portfolio_toolkit.portfolio.time_series.plot_evolution module
- portfolio_toolkit.portfolio.time_series.plot_evolution.plot_portfolio_evolution(portfolio: PortfolioTimeSeries) LineChartData [fuente]
Plot open positions in the portfolio
portfolio_toolkit.portfolio.time_series.portfolio_time_series module
- class portfolio_toolkit.portfolio.time_series.portfolio_time_series.PortfolioTimeSeries(name: str, currency: str, assets: List[PortfolioAsset], data_provider: DataProvider, account: Account, start_date: str)[fuente]
Bases:
Portfolio
DataFrame with the following structure:
Columns: - Date (str): Date of the transaction or calculation. - Ticker (str): Asset symbol (including synthetic cash tickers like __EUR). - Quantity (int): Accumulated quantity of shares/units on the date. - Price (float): Share price on the date in original currency (1.0 for cash tickers). - Price_Base (float): Share price converted to portfolio base currency, including fees for purchase transactions. - Value (float): Total value of the shares/units on the date (Quantity * Price). - Value_Base (float): Total value in portfolio base currency (Quantity * Price_Base). - Cost (float): Total accumulated cost of the shares/units on the date in base currency. - Sector (str): Sector to which the asset belongs (Cash for synthetic tickers). - Country (str): Country to which the asset belongs.
Each row represents the state of an asset on a specific date. Cash transactions use synthetic tickers (e.g., __EUR) with constant price of 1.0.
- classmethod from_portfolio(portfolio: Portfolio) PortfolioTimeSeries [fuente]
Alternate constructor that builds PortfolioTimeSeries from a Portfolio.
- plot_evolution() LineChartData [fuente]
- __init__(name: str, currency: str, assets: List[PortfolioAsset], data_provider: DataProvider, account: Account, start_date: str) None
- assets: List[PortfolioAsset]
- data_provider: DataProvider
portfolio_toolkit.portfolio.time_series.print_date_frame module
- portfolio_toolkit.portfolio.time_series.print_date_frame.print_data_frame(portfolio: PortfolioTimeSeries)[fuente]
Prints the portfolio DataFrame in a readable format for debugging purposes.
portfolio_toolkit.portfolio.time_series.utils module
- portfolio_toolkit.portfolio.time_series.utils.get_ticker_holding_intervals(assets, ticker)[fuente]
Returns the date intervals where a specific ticker was held in the portfolio.
- Parámetros:
ticker (str) – The ticker symbol to analyze.
- Devuelve:
- List of tuples with (start_date, end_date) intervals where the ticker was held.
Returns empty list if ticker was never held or is not found.
- Tipo del valor devuelto:
Ejemplo
[(“2025-06-01”, “2025-06-10”), (“2025-06-20”, “2025-07-03”)]
- portfolio_toolkit.portfolio.time_series.utils.create_date_series_from_intervals(intervals)[fuente]
Creates a pandas Series with all dates from multiple intervals.
- Parámetros:
intervals (list) – List of tuples with (start_date, end_date)
- Devuelve:
Series with all dates from the intervals
- Tipo del valor devuelto:
pd.DatetimeIndex
Module contents
- class portfolio_toolkit.portfolio.time_series.PortfolioTimeSeries(name: str, currency: str, assets: List[PortfolioAsset], data_provider: DataProvider, account: Account, start_date: str)[fuente]
Bases:
Portfolio
DataFrame with the following structure:
Columns: - Date (str): Date of the transaction or calculation. - Ticker (str): Asset symbol (including synthetic cash tickers like __EUR). - Quantity (int): Accumulated quantity of shares/units on the date. - Price (float): Share price on the date in original currency (1.0 for cash tickers). - Price_Base (float): Share price converted to portfolio base currency, including fees for purchase transactions. - Value (float): Total value of the shares/units on the date (Quantity * Price). - Value_Base (float): Total value in portfolio base currency (Quantity * Price_Base). - Cost (float): Total accumulated cost of the shares/units on the date in base currency. - Sector (str): Sector to which the asset belongs (Cash for synthetic tickers). - Country (str): Country to which the asset belongs.
Each row represents the state of an asset on a specific date. Cash transactions use synthetic tickers (e.g., __EUR) with constant price of 1.0.
- __init__(name: str, currency: str, assets: List[PortfolioAsset], data_provider: DataProvider, account: Account, start_date: str) None
- classmethod from_portfolio(portfolio: Portfolio) PortfolioTimeSeries [fuente]
Alternate constructor that builds PortfolioTimeSeries from a Portfolio.
- plot_evolution() LineChartData [fuente]
- assets: List[PortfolioAsset]
- data_provider: DataProvider