Skip to main content

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 description

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

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:

pip install om_quant_fin

Some sample usage

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

om_quant_fin-1.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

om_quant_fin-1.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file om_quant_fin-1.1.0.tar.gz.

File metadata

  • Download URL: om_quant_fin-1.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for om_quant_fin-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b99df46a1087d265e350c4f367301905d20f84757dad6d99000441b0b15833da
MD5 788d531c9fb0d180278171af85399233
BLAKE2b-256 9ed2f9d9303f5b5dcea0be49a83713564fb7b5666039998a06dc5ef0f4ff8ed7

See more details on using hashes here.

File details

Details for the file om_quant_fin-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: om_quant_fin-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for om_quant_fin-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0fd765cd9da204ffd627fba988ab32fae25812bb9517c7f707115ada947d1b32
MD5 70c04f83ba4db96a1d0a055fdc0bc0bf
BLAKE2b-256 bb8d522113c20bf689abf26911675a9db3bd19f15fd0eeac6be47609c54dc72d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page