# Bankruptcy Plots

**Module:** `sovai.plots.bankruptcy.bankruptcy_plots`

## Functions

### `plot_ticker_probabilities()`

```python
def plot_ticker_probabilities(
    df,
    tickers,
    probability_column = 'probability',
    moving_average = None,
    same_plot = True,
    lookback_period = None,
    dark_mode = False,
)
```

Plots a specified probability column and optionally its moving average over time for specified tickers on the same or separate plots using Plotly Express. Allows for an optional lookback period selection and dark mode.

**Parameters**

| Parameter            | Type | Description                                                              |
| -------------------- | ---- | ------------------------------------------------------------------------ |
| `df`                 | —    | Pandas DataFrame containing the data with MultiIndex (ticker, date).     |
| `tickers`            | —    | List of tickers to plot.                                                 |
| `probability_column` | —    | The probability column to plot, defaults to 'probability'.               |
| `moving_average`     | —    | The window size for the moving average, None for no moving average.      |
| `same_plot`          | —    | Boolean to indicate if all tickers should be plotted on the same plot.   |
| `lookback_period`    | —    | Number of days in the past to include in the plot, None for all history. |
| `dark_mode`          | —    | Boolean to enable dark mode for the plot.                                |

***

### `plot_pca_clusters()`

```python
def plot_pca_clusters(df, target = 'target', max_lag = 12, max_date = None)
```

Plot a scatter plot of PCA clusters using Plotly with a lag slider to adjust the date.

**Parameters**

| Parameter  | Type | Description                                             |
| ---------- | ---- | ------------------------------------------------------- |
| `df`       | —    | DataFrame containing PCA components and target.         |
| `target`   | —    | Name of the target column that indicates health status. |
| `max_lag`  | —    | The maximum number of months to lag.                    |
| `max_date` | —    | The maximum date available in the dataset.              |

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sov.ai/api-reference/plots-1/bankruptcy-plots.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
