Package: om-quant-fin
OM Quant FinThe 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 Structureom_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 informationWhat's new in version 1.1.0OM 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 FeaturesDownload stock data from Yahoo FinanceCalculates rolling Z-scoresCalculates the rolling ratio of adjusted close and its mean (RSL indicator)Evaluates a model with AUC and Gini for classification models and respective plotsQCut fit method for the proper binning of unseen dataRobustness test with bootstrappingCalculates the Pain Index which is a measure of portfolio risk that takes into account both the depth and duration of drawdownsCalculates the first ACF component for a given time seriesZ-score function only (no rolling)Z-score based on the medianFunction to find the next business day given an input dateMean Standard Deviation (MAD) Python implementationiFat: fat tail index calculationFunction to create a data frame with 27 attributes for volatility estimationGenerates a report with main regression metrics: RMSE and MAEGenerates a report with predicted value and actions to take for a given volatility modelInstallationInstall the library using pip:pipinstallom_quant_finSome sample usageimportom_quant_finasmql#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 indexwindow_size=52#rolling window for the pain indexdata["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"])#Bootstrappingbs=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 transformerlabels=["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 estimationstart_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 estimationstart_date=="2015-01-01"end_date="2023-12-31"data=create_vars("^VIX",start_date,end_date,p=10):data.head(5)#Calculates the iFatifat,mstd=ifat(data["Returns"],p=67)LicenseThis project is licensed under the MIT License.