> ## Documentation Index
> Fetch the complete documentation index at: https://alphacastio.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Portfolio Statistics and Tear Sheets

> Design and test portfolio and trading strategies — tear sheets from daily returns, plus dynamic rolling stats.

Alphacast pipelines can be used to design and test portfolio and trading strategies. The **Portfolio Analysis** step produces tear sheets from daily returns, and dynamic rolling statistics across timeframes.

<Frame>
  <img src="https://mintcdn.com/alphacastio/ttF_U-V9HDrmrPbo/images/steps/portfolio-analysis-1.png?fit=max&auto=format&n=ttF_U-V9HDrmrPbo&q=85&s=8f994fe5a34a46aee39108197d0b6235" alt="Portfolio Analysis step in the pipeline editor" width="291" height="73" data-path="images/steps/portfolio-analysis-1.png" />
</Frame>

## 1. Load data and calculate daily returns

Any dataset works. As an example, load Yahoo Finance data and compute daily returns for three assets:

<Steps>
  <Step title="Open the pipeline editor">
    **Create new → Pipeline**.
  </Step>

  <Step title="Add Yahoo Finance as the source">
    Add the tickers you want to analyze — `MSFT`, `AAPL`, `GOOG` — and select the period.
  </Step>

  <Step title="Calculate the daily return">
    Add a [Calculate Variable](/steps/calculate-variable) step with the formula:

    ```
    pct_change(@Close, 1, @Ticker)
    ```

    <Frame>
      <img src="https://mintcdn.com/alphacastio/ttF_U-V9HDrmrPbo/images/steps/portfolio-analysis-2.png?fit=max&auto=format&n=ttF_U-V9HDrmrPbo&q=85&s=54460c2896c13f13500adb91ee8c9727" alt="Yahoo Finance source configuration" width="1060" height="431" data-path="images/steps/portfolio-analysis-2.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/alphacastio/ttF_U-V9HDrmrPbo/images/steps/portfolio-analysis-3.png?fit=max&auto=format&n=ttF_U-V9HDrmrPbo&q=85&s=a3f5ef9f3494d4d5fe6c7c1db4434548" alt="Calculating daily returns" width="278" height="70" data-path="images/steps/portfolio-analysis-3.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/alphacastio/ttF_U-V9HDrmrPbo/images/steps/portfolio-analysis-4.png?fit=max&auto=format&n=ttF_U-V9HDrmrPbo&q=85&s=97ad8ba46fdb5fd8d39e7543ec026bbe" alt="Daily returns in the pipeline output" width="1048" height="313" data-path="images/steps/portfolio-analysis-4.png" />
    </Frame>
  </Step>
</Steps>

## 2. Calculate the tear sheet

Add a **Portfolio Analysis** step, choose the metrics to compute, and select the column holding the daily returns — `pct_change` in this example.

Available statistics: annual return, cumulative returns, annual volatility, Sharpe ratio, Calmar ratio, stability, max drawdown, Omega ratio, Sortino ratio, skew, kurtosis, tail ratio, daily value at risk, and total return.

<Frame>
  <img src="https://mintcdn.com/alphacastio/ttF_U-V9HDrmrPbo/images/steps/portfolio-analysis-5.png?fit=max&auto=format&n=ttF_U-V9HDrmrPbo&q=85&s=7af21a4fe90502af2bea9a41d20f04f4" alt="Selecting portfolio statistics" width="1388" height="620" data-path="images/steps/portfolio-analysis-5.png" />
</Frame>

### Tear sheet on

A single tear sheet is calculated for the whole sample period.

<Frame>
  <img src="https://mintcdn.com/alphacastio/ttF_U-V9HDrmrPbo/images/steps/portfolio-analysis-6.png?fit=max&auto=format&n=ttF_U-V9HDrmrPbo&q=85&s=933cfe0d122018f45e52daefa0442e28" alt="A portfolio tear sheet" width="760" height="99" data-path="images/steps/portfolio-analysis-6.png" />
</Frame>

### Tear sheet off

Statistics are estimated recursively for each day of the sample, each one computed from that day up to the most recent one. Two extra parameters apply:

| Parameter   | Meaning                                                                                                            |
| ----------- | ------------------------------------------------------------------------------------------------------------------ |
| `dropLastN` | Statistics are not calculated for timeframes beginning in the last N days. Defaults to excluding 252 trading days. |
| `Skip days` | Start days are sampled every N days rather than daily. Matters for performance. Defaults to 10 days.               |

The result looks like [this dataset](https://www.alphacast.io/datasets/23156).

## Optional: add technical indicators

The [Technical Analysis](/steps/talib) step estimates 132 metrics on the same price data — cycle, momentum, volatility and volume indicators, overlap studies, pattern recognition and statistics functions.

## Next steps

<CardGroup cols={2}>
  <Card title="Technical analysis" icon="chart-line" href="/steps/talib">
    132 technical indicators for the same assets.
  </Card>

  <Card title="Publish dataset" icon="upload" href="/steps/publish">
    Save the tear sheet as an auto-updating dataset.
  </Card>
</CardGroup>
