portfolio_toolkit.utils package
Subpackages
- portfolio_toolkit.utils.period package
- Submodules
- portfolio_toolkit.utils.period.get_current_month module
- portfolio_toolkit.utils.period.get_current_period module
- portfolio_toolkit.utils.period.get_current_quarter module
- portfolio_toolkit.utils.period.get_current_week module
- portfolio_toolkit.utils.period.get_current_year module
- portfolio_toolkit.utils.period.get_last_months module
- portfolio_toolkit.utils.period.get_last_periods module
- portfolio_toolkit.utils.period.get_last_quarters module
- portfolio_toolkit.utils.period.get_last_weeks module
- portfolio_toolkit.utils.period.get_last_years module
- portfolio_toolkit.utils.period.period module
- Module contents
Submodules
portfolio_toolkit.utils.correlation module
- portfolio_toolkit.utils.correlation.calculate_correlation(returns1, returns2)[fuente]
Calculates the correlation between two return series.
- Parámetros:
returns1 (pd.Series) – The first return series.
returns2 (pd.Series) – The second return series.
- Devuelve:
The correlation between the two return series.
- Tipo del valor devuelto:
portfolio_toolkit.utils.log_returns module
Module contents
- portfolio_toolkit.utils.get_last_periods(n=4, period_type='weeks', include_current=False) List[Period] [fuente]
Returns the last n periods as Period objects.
- Parámetros:
- Devuelve:
List of Period objects representing each period
- Tipo del valor devuelto:
List[Period]
Ejemplo
# Get last 3 completed weeks get_last_periods(3, “weeks”, include_current=False)
# Get last 2 weeks + current week get_last_periods(2, “weeks”, include_current=True)
- portfolio_toolkit.utils.get_current_period(period_type: str) Period [fuente]
Returns the current period as a Period object based on the specified type.
- Parámetros:
period_type (str) – Type of period (“year”, “quarter”, “month”, “week”)
- Devuelve:
Period object representing the current period
- Tipo del valor devuelto:
- Muestra:
ValueError – If period_type is not supported
Ejemplo
current_week = get_current_period(“week”) current_quarter = get_current_period(“quarter”) current_year = get_current_period(“year”)
- class portfolio_toolkit.utils.Period(label: str, start_date: date, end_date: date)[fuente]
Bases:
object
Represents a time period with a label and start/end dates.
- start_date
Start date of the period
- Type:
date
- end_date
End date of the period
- Type:
date
Ejemplo
quarter = Period(«Q3 2025», date(2025, 7, 1), date(2025, 9, 30)) month = Period(«July 2025», date(2025, 7, 1), date(2025, 7, 31))