<a id="datasets"></a>

<a id="id1"></a>

# Datasets

`skfolio` comes with three native datasets available via:

> * [`load_sp500_dataset`](https://skfolio.org/generated/skfolio.datasets.load_sp500_dataset.html.md#skfolio.datasets.load_sp500_dataset)
> * [`load_sp500_index`](https://skfolio.org/generated/skfolio.datasets.load_sp500_index.html.md#skfolio.datasets.load_sp500_index)
> * [`load_factors_dataset`](https://skfolio.org/generated/skfolio.datasets.load_factors_dataset.html.md#skfolio.datasets.load_factors_dataset)

Larger datasets are downloaded from the GitHub repo and cached locally to a data
directory. They are available via:

> * [`load_ftse100_dataset`](https://skfolio.org/generated/skfolio.datasets.load_ftse100_dataset.html.md#skfolio.datasets.load_ftse100_dataset)
> * [`load_nasdaq_dataset`](https://skfolio.org/generated/skfolio.datasets.load_nasdaq_dataset.html.md#skfolio.datasets.load_nasdaq_dataset)
> * [`load_sp500_implied_vol_dataset`](https://skfolio.org/generated/skfolio.datasets.load_sp500_implied_vol_dataset.html.md#skfolio.datasets.load_sp500_implied_vol_dataset)

By default the data directory is set to a folder named “skfolio_data” in the user home
folder. Alternatively, it can be set by the `SKFOLIO_DATA` environment variable.
If the folder does not already exist, it is automatically created.

For characteristics-based factor models, [`make_synthetic_characteristics`](https://skfolio.org/generated/skfolio.datasets.make_synthetic_characteristics.html.md#skfolio.datasets.make_synthetic_characteristics)
generates a synthetic [`AssetPanel`](https://skfolio.org/generated/skfolio.containers.AssetPanel.html.md#skfolio.containers.AssetPanel) with the market and
fundamental fields used by the default descriptors and
[`CharacteristicsFactorModel`](https://skfolio.org/generated/skfolio.prior.CharacteristicsFactorModel.html.md#skfolio.prior.CharacteristicsFactorModel). Use it for examples, tests, and
local prototyping when you do not have a point-in-time fundamentals feed.

#### CAUTION
This dataset is provided solely for testing and example purposes. It is a stale
dataset and does not reflect current or accurate market prices. It is not
intended for investment, trading, or commercial use and should not be relied
upon as authoritative market data.

**Example:**

Loading the S&P 500 dataset, which contains daily adjusted closing prices for 20
selected constituents of the S&P 500 Index, covering the period from 1990-01-02 to
2022-12-28:

```python
from skfolio.datasets import load_sp500_dataset

prices = load_sp500_dataset()
print(prices.head())
```

Generating a synthetic characteristics panel:

```python
from skfolio.datasets import make_synthetic_characteristics

panel = make_synthetic_characteristics(n_assets=200, n_observations=1000)
print(panel.n_assets, panel.n_observations)
```
