om-quant-fin 1.1.0
The Outspoken Market is training the next quantitative generation. OM Quant Fin is a modern Python package for quantitative trading analysis. Our mission is to make your quant life easier and more accurate.

# OM Quant Fin

The Outspoken Market is training the next quantitative generation. OM Quant Fin is a modern Python package for quantitative trading analysis. Our mission is to make your quant life easier and more accurate.

## Project Structure

```python
om_quant_fin/               # Root directory of the project
├── om_quant_fin/           # Python package containing the library's code
│   ├── __init__.py         # Marks the directory as a package and can contain package-level code or imports
│   └── om_quant_fin.py     # Contains library's functions
├── setup.py                # Provides package metadata and dependencies for packaging and distribution
├── .gitignore              # Lists files and folders that should not be tracked by Git
└── README.md               # Markdown file with a description of the project, usage instructions, and other information
```

## What's new in version 1.1.0

- OM Quant Fin now introduces the iFat! The iFat is a fantastic indicator for the measurement of the presence of fat tails. The closest to 0, fatter are the tails. Thin tails otherwise.
- You also have a new function that create 27 attributes optimizide for the volatility estimation of any give asset. Apply the model methodology of choice into this attributes, evaluate it with the "regression_metrics" method and forecast the volatility with the "prediction_report" method.

## OM Quant Fin Features

- Download stock data from Yahoo Finance
- Calculates rolling Z-scores
- Calculates the rolling ratio of adjusted close and its mean (RSL indicator)
- Evaluates a model with AUC and Gini for classification models and respective plots
- QCut fit method for the proper binning of unseen data
- Robustness test with bootstrapping
- Calculates the Pain Index which is a measure of portfolio risk that takes into account both the depth and duration of drawdowns
- Calculates the first ACF component for a given time series
- Z-score function only (no rolling)
- Z-score based on the median
- Function to find the next business day given an input date
- Mean Standard Deviation (MAD) Python implementation
- iFat: fat tail index calculation
- Function to create a data frame with 27 attributes for volatility estimation
- Generates a report with main regression metrics: RMSE and MAE
- Generates a report with predicted value and actions to take for a given volatility model

## Installation

Install the library using pip:

```python
pip install om_quant_fin
```

## Some sample usage

```python
import om_quant_fin as mql

#Download stock data:
  data = mql.download_data("AAPL", "2020-01-01", "2022-12-31")

#Calculates rolling Z-score:
  z_score = mql.rolling_z_score(data["Adj Close"], window = 20)

#Calculates rolling ratio:
  ratio = mql.rolling_ratio(data["Adj Close"], window = 20)

#Calculates returns:
  returns = mql.calculate_returns(data["Adj Close"], period = 1)

#Pain index
  window_size = 52 #rolling window for the pain index
  data["Pain_index"] = data["Adj Close"].rolling(window_size).apply(mql.pain_index, raw = True)
  mql.plot_pain_index(ticker1, data.index, data["Adj Close"], data["Pain_index"])

#Bootstrapping
  bs = mql.model_bs(model, x_train, y_train, x_test, y_test, n_iterations = 1000, range_bs = 0.1)
  mql.plot_bs(bs["accuracy_train"])
  mql.plot_bs(bs["accuracy_test"])

#qcut fit and transformer
labels = ["bin1", "bin2", "bin3", "bin4", "bin5", "bin6", "bin7", "bin8", "bin9", "bin10"
          ,"bin11", "bin12", "bin13", "bin14", "bin15", "bin16", "bin17", "bin18", "bin19", "bin20"]
qcut_transformer = mql.QCutTransformer(q = 20, labels = labels)
qcut_transformer.fit(data["column"])
qcut_transformer.transform(data["column"])

#Creates a data frame with 27 attributes for volatility estimation
start_date = = "2015-01-01" 
end_date = "2023-12-31"
data = create_vars("^VIX", start_date, end_date, p = 10):
data.head(5)

#Creates a data frame with 27 attributes for volatility estimation
start_date = = "2015-01-01" 
end_date = "2023-12-31"
data = create_vars("^VIX", start_date, end_date, p = 10):
data.head(5)

#Calculates the iFat
ifat, mstd = ifat(data["Returns"], p = 67)

```

## License

This project is licensed under the MIT License.