Historical Data
Collect and adjust historical price data for the portfolio’s tickers.
The following columns are included:
- Open: the opening price of each asset over time.
- High: the highest price of each asset over time.
- Low: the lowest price of each asset over time.
- Close: the closing price of each asset over time.
- Adj Close: the adjusted closing price of each asset over time.
- Volume: the volume of each asset over time.
- Dividends: the dividends of each asset over time. -
Returns: the returns of each asset over time.
- Cumulative Return: the cumulative return of each asset over time.
Volatility, Excess Return and Excess Volatility are not included here. These are available via the Risk module (e.g. toolkit.risk.get_volatility) and the Performance module (e.g. toolkit.performance.get_excess_return) instead.
This method retrieves historical price data (daily and weekly) for the portfolio’s tickers and adjusts for any currency mismatches if necessary. It fetches data from a specified data source, applies currency conversion where applicable, and stores the adjusted data in separate DataFrames for the daily and weekly periods.
The method uses the Toolkit class to fetch historical price data and the Currency Toolkit to handle currency conversions if the portfolio’s transaction currency does not match the historical data’s currency.
Historical Data in Python
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call collect_historical_data as shown below.
from financetoolkit import Portfolio
portfolio = Portfolio(example=True, api_key="FINANCIAL_MODELING_PREP_KEY")
portfolio.collect_historical_data()
Which returns:
| (‘Open’, ‘ASML’) | (‘Open’, ‘SKY’) | (‘Open’, ‘AMZN’) | (‘Open’, ‘FIX’) | (‘Open’, ‘MSFT’) | (‘Open’, ‘AMD’) | (‘Open’, ‘AAPL’) | |
|---|---|---|---|---|---|---|---|
| 2026-09-24 | 1708.85 | 85.38 | 246.02 | 1584 | 495.07 | 600.27 | 336.72 |
| 2026-09-25 | 1741.25 | 85.91 | 248.56 | 1656.27 | 499.04 | 634.54 | 336.04 |
| 2026-09-28 | 1748.82 | 86.83 | 246.63 | 1655.82 | 505.47 | 624.9 | 340.37 |
| 2026-09-29 | 1811.51 | 87.41 | 246.71 | 1681.64 | 508.31 | 616.74 | 336.97 |
| 2026-09-30 | 1828.6 | 85.85 | 246.79 | 1677.78 | 511.61 | 609.89 | 330.8 |
| 2026-10-01 | 1799.1 | 84.62 | 251.61 | 1658 | 519.88 | 612.7 | 330 |
| 2026-10-02 | 1849.74 | 89.57 | 251.51 | 1714.05 | 519.39 | 635.95 | 333.26 |
| 2026-10-05 | 1852.53 | 87.53 | 250.19 | 1723.93 | 521.62 | 630.61 | 332.82 |
| 2026-10-06 | 1870 | 85.9 | 253.4 | 1725 | 531.68 | 648.04 | 332.28 |
| 2026-10-07 | 1788.92 | 84.2 | 254.23 | 1770.01 | 530.73 | 634.77 | 336.96 |
Parameters
collect_historical_data accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
rounding | int | None | An optional integer specifying the number of decimal places to round the historical price data. If None, the default rounding value is used. | 2 |