# Dataism Lab for Quantatative Finance (DLQF) Python Library
## Summary - The goal of this library provide a collection of methods that can be implemented by clients to test for linearity and non-linearity on univariate and multivariate data sets.
# 0. Abstract
In quantitative finance, accurately modeling the dynamics of asset prices is critical for risk management, portfolio optimization, and the development of trading strategies. Many financial time series exhibit complex, potentially nonlinear behavior that cannot be adequately captured by traditional linear models. Detecting nonlinearity in time series can signal the need for more advanced modeling techniques such as regime-switching models, nonlinear autoregressive models, or machine learning methods. This document proposes the development of an expanded Python library for nonlinearity testing by integrating and extending the functionality of an existing package called nln-test.py. The new library is designed to support both univariate and multivariate nonlinearity tests with specific focus on financial time series (e.g., equities, indices, and market volumes). In addition to implementing conventional tests such as those proposed by Ramsey, Keenan, Tsay, and Terasvirta, the package will incorporate an artificial neural network (ANN) approach to further enhance testing power. Ultimately, the library aims to aid quantitative finance practitioners and researchers in determining the appropriateness of linear versus nonlinear modeling in financial applications.
# 1. Introduction
Many financial time series exhibit nonlinear dynamics that standard linear models do not capture. For quantitative finance practitioners, nonlinearity tests are crucial to decide if more advanced models such as nonlinear autoregressive models, regime-switching models, or machine learning techniques are necessary. The expanded library, hereafter referred to as fin_nln, is designed to build on the existing nln-test.py package by incorporating modules for both univariate and multivariate nonlinearity tests, as well as tests based on artificial neural networks (ANNs). Additionally, the library will include integrated support for financial data acquisition and preprocessing.
# 2. Surface-Level
1. **fin_nln.univariate**:
+ This module builds on the existing nlntstuniv functionality.
+ It implements tests such as Ramsey’s RESET, Keenan’s test, Tsay’s test, and Terasvirta’s test for univariate time series.
+ Enhancements will be provided to support financial time series, including flexibility in selecting lag structures.
2. **fin_nln.multivariate**:
+ This module extends the functionality of the nlntstmultv module for multivariate nonlinearity testing.
+ It is designed to accept and analyze multiple related financial time series.
+ Applications include testing for nonlinear interactions among equity returns or asset classes.
3. **fin_nln.ann**:
+ This module enhances the annnlntst module, implementing and optimizing ANN based tests.
+ Modifications may include additional neural network architectures or hyperparameter tuning to improve test power, particularly for financial data.
4. **fin_nln.data**:
+ A new module to handle data acquisition and preprocessing.
+ Functions to download financial data from sources such as Yahoo Finance or FRED using packages like pandas-datareader or yfinance.
+ Includes typical preprocessing steps such as computing log returns, detrending, and scaling.
5. **fin_nln.visualize**:
+ An optional module for creating diagnostic plots and visualizations.
+ Will include autocorrelation plots, evolution of test statistics, and plots illustrating nonlinear dynamics.
# 3. Deeper Breakdown
### Univariate Linearity Tests
- **Ljung-Box Test** *from univariate.linearity.ljung_box_test import ljung_box_test*
- Tests for autocorrelation in residuals (linear dependence).
- **Augmented Dickey-Fuller (ADF)** *from univariate.linearity.adf_test import adf_test*
- Stationarity check — helps determine linear time series behavior.
- **AR Model Fit & Residual Analysis** *from univariate.linearity.fit_ar_resid import fit_ar_resid*
- Fit AR(p) and inspect residuals for linear structure.
### Univariate **Non**-Linearity Tests
- **Hurst Exponent (R/S Analysis)** *from univariate.non-linearity.hurst_exponent import hurst_exponent*
- Measures long memory (persistence or anti-persistence).
- **BDS Test** *from univariate.non-linearity.bds_test import bds_test*
- Detects general nonlinearity in residuals of a time series.
- **Largest Lyapunov Exponent** *from univariate.non-linearity.lyapunov_exponent import lyapunov_exponent*
- Detects chaotic behavior via sensitivity to initial conditions.
- **Tsay Test** *from univariate.non-linearity.tsay_test import tsay_test*
- A test for threshold nonlinearity in autoregressive processes.
### Multivariate Linearity Tests
- **VAR Model Fit** *from multivariate.linearity.var_model_fit*
- Tests for linear interdependencies among variables.
- **Granger Causality Test** *from multivariate.linearity.granger_test import granger_test*
- Determines if one time series linearly predicts another.
- **Cointegration Tests (Johansen)** *from multivariate.linearity.johansen_cointegration import johansen_cointegration*
- Tests for linear long-run equilibrium relationships.
### Multivariate **Non**-Linearity Tests
- **Multivariate BDS Test (mBDS)** *from multivariate.non-linearity.mBDS_test import mBDS_test*
- Extension of BDS to multivariate context.
- **Mutual Information** *from multivariate.non-linearity.mutual_info import mutual_info*
- Measures nonlinear dependence among variables.
- **Nonlinear PCA / Kernel PCA** *from multivariate.non-linearity.nonlinear_pca.py import nonlinear_pca / from multivariate.non-linearity.kernel_pca import kernel_pca*
- Uncovers nonlinear structures in multivariate data.
- **Cross-Lyapunov Exponents** *from multivariate.non-linearity.lyapunov_exponent import lyapunov_exponent*
- Tests chaotic synchronization across variables.
Raw data
{
"_id": null,
"home_page": "https://github.com/Ross-Ede/fin_nln",
"name": "fin-nln",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "finance, time-series, nonlinearity, econometrics, statistics",
"author": "Ross Ede",
"author_email": "Ross Ede <your.email@example.com>",
"download_url": "https://files.pythonhosted.org/packages/cc/20/b1e9b50083ceb1756ce505f3a49446926944c2e928c2e2f9b6b7b9c5a5fd/fin_nln-0.1.0.tar.gz",
"platform": null,
"description": "# Dataism Lab for Quantatative Finance (DLQF) Python Library\n\n## Summary - The goal of this library provide a collection of methods that can be implemented by clients to test for linearity and non-linearity on univariate and multivariate data sets.\n\n# 0. Abstract\n\nIn quantitative finance, accurately modeling the dynamics of asset prices is critical for risk management, portfolio optimization, and the development of trading strategies. Many financial time series exhibit complex, potentially nonlinear behavior that cannot be adequately captured by traditional linear models. Detecting nonlinearity in time series can signal the need for more advanced modeling techniques such as regime-switching models, nonlinear autoregressive models, or machine learning methods. This document proposes the development of an expanded Python library for nonlinearity testing by integrating and extending the functionality of an existing package called nln-test.py. The new library is designed to support both univariate and multivariate nonlinearity tests with specific focus on financial time series (e.g., equities, indices, and market volumes). In addition to implementing conventional tests such as those proposed by Ramsey, Keenan, Tsay, and Terasvirta, the package will incorporate an artificial neural network (ANN) approach to further enhance testing power. Ultimately, the library aims to aid quantitative finance practitioners and researchers in determining the appropriateness of linear versus nonlinear modeling in financial applications.\n\n# 1. Introduction\n\nMany financial time series exhibit nonlinear dynamics that standard linear models do not capture. For quantitative finance practitioners, nonlinearity tests are crucial to decide if more advanced models such as nonlinear autoregressive models, regime-switching models, or machine learning techniques are necessary. The expanded library, hereafter referred to as fin_nln, is designed to build on the existing nln-test.py package by incorporating modules for both univariate and multivariate nonlinearity tests, as well as tests based on artificial neural networks (ANNs). Additionally, the library will include integrated support for financial data acquisition and preprocessing.\n\n# 2. Surface-Level\n\n1. **fin_nln.univariate**: \n + This module builds on the existing nlntstuniv functionality. \n + It implements tests such as Ramsey\u2019s RESET, Keenan\u2019s test, Tsay\u2019s test, and Terasvirta\u2019s test for univariate time series.\n + Enhancements will be provided to support financial time series, including flexibility in selecting lag structures.\n\n2. **fin_nln.multivariate**: \n + This module extends the functionality of the nlntstmultv module for multivariate nonlinearity testing. \n + It is designed to accept and analyze multiple related financial time series. \n + Applications include testing for nonlinear interactions among equity returns or asset classes.\n\n3. **fin_nln.ann**: \n + This module enhances the annnlntst module, implementing and optimizing ANN based tests. \n + Modifications may include additional neural network architectures or hyperparameter tuning to improve test power, particularly for financial data.\n\n4. **fin_nln.data**: \n + A new module to handle data acquisition and preprocessing. \n + Functions to download financial data from sources such as Yahoo Finance or FRED using packages like pandas-datareader or yfinance. \n + Includes typical preprocessing steps such as computing log returns, detrending, and scaling.\n\n5. **fin_nln.visualize**: \n + An optional module for creating diagnostic plots and visualizations. \n + Will include autocorrelation plots, evolution of test statistics, and plots illustrating nonlinear dynamics.\n\n# 3. Deeper Breakdown\n\n### Univariate Linearity Tests\n\n- **Ljung-Box Test** *from univariate.linearity.ljung_box_test import ljung_box_test*\n - Tests for autocorrelation in residuals (linear dependence).\n\n- **Augmented Dickey-Fuller (ADF)**\t*from univariate.linearity.adf_test import adf_test*\n - Stationarity check \u2014 helps determine linear time series behavior.\n\n- **AR Model Fit & Residual Analysis** *from univariate.linearity.fit_ar_resid import fit_ar_resid*\n - Fit AR(p) and inspect residuals for linear structure.\n\n### Univariate **Non**-Linearity Tests\n\n- **Hurst Exponent (R/S Analysis)**\t*from univariate.non-linearity.hurst_exponent import hurst_exponent*\n - Measures long memory (persistence or anti-persistence).\n\n- **BDS Test** *from univariate.non-linearity.bds_test import bds_test*\n - Detects general nonlinearity in residuals of a time series.\n\n- **Largest Lyapunov Exponent**\t*from univariate.non-linearity.lyapunov_exponent import lyapunov_exponent*\n - Detects chaotic behavior via sensitivity to initial conditions.\n\n- **Tsay Test**\t*from univariate.non-linearity.tsay_test import tsay_test*\n - A test for threshold nonlinearity in autoregressive processes.\n\n### Multivariate Linearity Tests\n\n- **VAR Model Fit**\t*from multivariate.linearity.var_model_fit*\n - Tests for linear interdependencies among variables.\n\n- **Granger Causality Test** *from multivariate.linearity.granger_test import granger_test*\n - Determines if one time series linearly predicts another.\n\n- **Cointegration Tests (Johansen)** *from multivariate.linearity.johansen_cointegration import johansen_cointegration*\n - Tests for linear long-run equilibrium relationships.\n\n### Multivariate **Non**-Linearity Tests\n\n- **Multivariate BDS Test (mBDS)** *from multivariate.non-linearity.mBDS_test import mBDS_test*\n - Extension of BDS to multivariate context.\n\n- **Mutual Information** *from multivariate.non-linearity.mutual_info import mutual_info*\n - Measures nonlinear dependence among variables.\n\n- **Nonlinear PCA / Kernel PCA** *from multivariate.non-linearity.nonlinear_pca.py import nonlinear_pca / from multivariate.non-linearity.kernel_pca import kernel_pca*\n - Uncovers nonlinear structures in multivariate data.\n\n- **Cross-Lyapunov Exponents**\t*from multivariate.non-linearity.lyapunov_exponent import lyapunov_exponent*\n - Tests chaotic synchronization across variables.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python library for detecting nonlinearity in financial time series",
"version": "0.1.0",
"project_urls": {
"Bug Reports": "https://github.com/Ross-Ede/fin_nln/issues",
"Homepage": "https://github.com/Ross-Ede/fin_nln",
"Source": "https://github.com/Ross-Ede/fin_nln"
},
"split_keywords": [
"finance",
" time-series",
" nonlinearity",
" econometrics",
" statistics"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "a19eaa54a9ddaa6e58a6e3b80d249a68286290ca282a9f6154079b59e521e1cf",
"md5": "d6902bbcace1639f1dfc642b6b81cff7",
"sha256": "0ee8cc404b1d0e411f4c7a9f54506293e8d1beff1fc56c445d1d214f0f29f019"
},
"downloads": -1,
"filename": "fin_nln-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d6902bbcace1639f1dfc642b6b81cff7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 53168,
"upload_time": "2025-08-19T17:35:36",
"upload_time_iso_8601": "2025-08-19T17:35:36.228720Z",
"url": "https://files.pythonhosted.org/packages/a1/9e/aa54a9ddaa6e58a6e3b80d249a68286290ca282a9f6154079b59e521e1cf/fin_nln-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "cc20b1e9b50083ceb1756ce505f3a49446926944c2e928c2e2f9b6b7b9c5a5fd",
"md5": "d71c9fb755022de768d8184d12a10408",
"sha256": "66b0ec03886c7bd54eb6b9c959351711bdd2547d34d0155188b012d6405bbfba"
},
"downloads": -1,
"filename": "fin_nln-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "d71c9fb755022de768d8184d12a10408",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 49947,
"upload_time": "2025-08-19T17:35:37",
"upload_time_iso_8601": "2025-08-19T17:35:37.716091Z",
"url": "https://files.pythonhosted.org/packages/cc/20/b1e9b50083ceb1756ce505f3a49446926944c2e928c2e2f9b6b7b9c5a5fd/fin_nln-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-19 17:35:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Ross-Ede",
"github_project": "fin_nln",
"github_not_found": true,
"lcname": "fin-nln"
}