quantmod 0.1.3__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. quantmod-0.1.4/.github/workflows/ci.yml +27 -0
  2. quantmod-0.1.4/.github/workflows/publish.yml +25 -0
  3. quantmod-0.1.4/.gitignore +64 -0
  4. {quantmod-0.1.3 → quantmod-0.1.4}/PKG-INFO +17 -26
  5. quantmod-0.1.4/pyproject.toml +56 -0
  6. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/__init__.py +7 -9
  7. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/db/database.py +1 -1
  8. quantmod-0.1.4/quantmod/docs/about.md +3 -0
  9. quantmod-0.1.4/quantmod/docs/changelog.md +109 -0
  10. quantmod-0.1.4/quantmod/docs/charts.md +32 -0
  11. quantmod-0.1.4/quantmod/docs/datasets.md +2 -0
  12. quantmod-0.1.4/quantmod/docs/db.md +2 -0
  13. quantmod-0.1.4/quantmod/docs/derivatives.md +1 -0
  14. quantmod-0.1.4/quantmod/docs/index.md +76 -0
  15. quantmod-0.1.4/quantmod/docs/indicators.md +2 -0
  16. quantmod-0.1.4/quantmod/docs/license.md +3 -0
  17. quantmod-0.1.4/quantmod/docs/markets.md +2 -0
  18. quantmod-0.1.4/quantmod/docs/models.md +2 -0
  19. quantmod-0.1.4/quantmod/docs/risk.md +2 -0
  20. quantmod-0.1.4/quantmod/docs/timeseries.md +2 -0
  21. quantmod-0.1.4/quantmod/docs/user-guide/examples/database.md +96 -0
  22. quantmod-0.1.4/quantmod/docs/user-guide/examples/datasets.md +13 -0
  23. quantmod-0.1.4/quantmod/docs/user-guide/examples/nseoption.md +43 -0
  24. quantmod-0.1.4/quantmod/docs/user-guide/examples/optionpricing.md +234 -0
  25. quantmod-0.1.4/quantmod/docs/user-guide/examples/performance.md +34 -0
  26. quantmod-0.1.4/quantmod/docs/user-guide/examples/risk.md +75 -0
  27. quantmod-0.1.4/quantmod/docs/user-guide/examples/stockprice.md +25 -0
  28. quantmod-0.1.4/quantmod/docs/user-guide/examples/technicals.md +30 -0
  29. quantmod-0.1.4/quantmod/docs/user-guide/examples/timeseries.md +25 -0
  30. quantmod-0.1.4/quantmod/docs/user-guide/examples/visualisation.md +107 -0
  31. quantmod-0.1.4/quantmod/docs/user-guide/installation.md +21 -0
  32. quantmod-0.1.4/quantmod/markets/yahoo.py +96 -0
  33. quantmod-0.1.4/quantmod/mkdocs.yml +144 -0
  34. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/models/__init__.py +29 -6
  35. quantmod-0.1.4/quantmod/models/blackscholes.py +65 -0
  36. quantmod-0.1.4/quantmod/models/gbs.py +723 -0
  37. quantmod-0.1.4/quantmod/models/montecarlo.py +565 -0
  38. quantmod-0.1.4/quantmod/models/optioninputs.py +104 -0
  39. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/risk/varinputs.py +16 -24
  40. quantmod-0.1.4/uv.lock +3146 -0
  41. quantmod-0.1.3/quantmod/_version.py +0 -683
  42. quantmod-0.1.3/quantmod/markets/yahoo.py +0 -164
  43. quantmod-0.1.3/quantmod/models/blackscholes.py +0 -393
  44. quantmod-0.1.3/quantmod/models/montecarlo.py +0 -136
  45. quantmod-0.1.3/quantmod/models/optioninputs.py +0 -105
  46. quantmod-0.1.3/quantmod/version.py +0 -1
  47. quantmod-0.1.3/quantmod.egg-info/PKG-INFO +0 -116
  48. quantmod-0.1.3/quantmod.egg-info/SOURCES.txt +0 -44
  49. quantmod-0.1.3/quantmod.egg-info/dependency_links.txt +0 -1
  50. quantmod-0.1.3/quantmod.egg-info/entry_points.txt +0 -2
  51. quantmod-0.1.3/quantmod.egg-info/not-zip-safe +0 -1
  52. quantmod-0.1.3/quantmod.egg-info/requires.txt +0 -13
  53. quantmod-0.1.3/quantmod.egg-info/top_level.txt +0 -1
  54. quantmod-0.1.3/setup.cfg +0 -7
  55. quantmod-0.1.3/setup.py +0 -58
  56. {quantmod-0.1.3 → quantmod-0.1.4}/LICENSE.txt +0 -0
  57. {quantmod-0.1.3 → quantmod-0.1.4}/README.md +0 -0
  58. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/charts/__init__.py +0 -0
  59. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/charts/plotting.py +0 -0
  60. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/charts/themes.py +0 -0
  61. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/datasets/__init__.py +0 -0
  62. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/datasets/data/nifty50.csv +0 -0
  63. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/datasets/data/spx.csv +0 -0
  64. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/datasets/dataloader.py +0 -0
  65. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/db/__init__.py +0 -0
  66. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/derivatives/__init__.py +0 -0
  67. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/derivatives/nse.py +0 -0
  68. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/indicators/__init__.py +0 -0
  69. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/indicators/indicators.py +0 -0
  70. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/main.py +0 -0
  71. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/markets/__init__.py +0 -0
  72. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/markets/bb.py +0 -0
  73. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/models/binomial.py +0 -0
  74. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/risk/__init__.py +0 -0
  75. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/risk/var.py +0 -0
  76. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/risk/varbacktest.py +0 -0
  77. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/timeseries/__init__.py +0 -0
  78. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/timeseries/performance.py +0 -0
  79. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/timeseries/timeseries.py +0 -0
  80. {quantmod-0.1.3 → quantmod-0.1.4}/quantmod/utils.py +0 -0
@@ -0,0 +1,27 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ name: Run tests
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up uv
18
+ uses: astral-sh/setup-uv@v3
19
+
20
+ - name: Install dependencies
21
+ run: uv sync
22
+
23
+ - name: Install pytest
24
+ run: uv pip install pytest
25
+
26
+ - name: Run tests
27
+ run: uv run pytest tests/ -v
@@ -0,0 +1,25 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ publish:
10
+ name: Build and publish
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Set up uv
17
+ uses: astral-sh/setup-uv@v3
18
+
19
+ - name: Build package
20
+ run: uv build
21
+
22
+ - name: Publish to PyPI
23
+ run: uv publish
24
+ env:
25
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,64 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyo
5
+ *.pyd
6
+ *.so
7
+
8
+ # Distribution / packaging
9
+ dist/
10
+ build/
11
+ *.egg-info/
12
+ *.egg
13
+ MANIFEST
14
+
15
+ # Virtual environments
16
+ .venv/
17
+ venv/
18
+ env/
19
+
20
+ # uv
21
+ .python-version
22
+
23
+ # MkDocs build output
24
+ site/
25
+ quantmod/site/
26
+
27
+ # Environment variables / secrets
28
+ .env
29
+ .env.*
30
+ *.env
31
+
32
+ # macOS
33
+ .DS_Store
34
+ .AppleDouble
35
+ .LSOverride
36
+
37
+ # Claude Code
38
+ .claude/
39
+
40
+ # Editors
41
+ .vscode/
42
+ .idea/
43
+ *.swp
44
+ *.swo
45
+ *~
46
+
47
+ # Jupyter
48
+ .ipynb_checkpoints/
49
+ *.ipynb
50
+
51
+ # Local scratch / examples
52
+ myexamples.py
53
+
54
+ # Testing / coverage
55
+ .pytest_cache/
56
+ .coverage
57
+ htmlcov/
58
+ .tox/
59
+
60
+ # Ruff / linting caches
61
+ .ruff_cache/
62
+
63
+ # Datasets submodule data (large CSVs tracked separately)
64
+ # quantmod/datasets/data/
@@ -1,24 +1,26 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: quantmod
3
- Version: 0.1.3
4
- Summary: Quantmod Python Package
5
- Home-page: https://kannansingaravelu.com/
6
- Author: Kannan Singaravelu
7
- Author-email: inquant@outlook.com
8
- License: Apache License 2.0
9
- Keywords: python,quant,quantmod,quantmod-python
10
- Platform: any
3
+ Version: 0.1.4
4
+ Summary: Quantitative finance toolkit for Python — markets, options, risk, and time series
5
+ Project-URL: Homepage, https://kannansingaravelu.com/quantmod/
6
+ Project-URL: Repository, https://github.com/kannansingaravelu/quantmod
7
+ Project-URL: Documentation, https://kannansingaravelu.com/quantmod/
8
+ Author-email: Kannan Singaravelu <inquant@outlook.com>
9
+ License: Apache-2.0
10
+ License-File: LICENSE.txt
11
+ Keywords: finance,options,quant,quantmod,risk,timeseries
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Financial and Insurance Industry
11
14
  Classifier: License :: OSI Approved :: Apache Software License
12
- Classifier: Programming Language :: Python :: 3.10
13
15
  Classifier: Operating System :: OS Independent
14
- Classifier: Intended Audience :: Developers
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
15
20
  Classifier: Topic :: Office/Business :: Financial
16
21
  Classifier: Topic :: Office/Business :: Financial :: Investment
17
- Classifier: Topic :: Software Development :: Libraries
18
22
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
23
  Requires-Python: >=3.10
20
- Description-Content-Type: text/markdown
21
- License-File: LICENSE.txt
22
24
  Requires-Dist: joblib
23
25
  Requires-Dist: matplotlib
24
26
  Requires-Dist: nbformat>=5.10.4
@@ -32,18 +34,7 @@ Requires-Dist: supabase>=2.27.2
32
34
  Requires-Dist: tabulate>=0.9.0
33
35
  Requires-Dist: urllib3==1.26.15
34
36
  Requires-Dist: yfinance>=1.0
35
- Dynamic: author
36
- Dynamic: author-email
37
- Dynamic: classifier
38
- Dynamic: description
39
- Dynamic: description-content-type
40
- Dynamic: home-page
41
- Dynamic: keywords
42
- Dynamic: license
43
- Dynamic: platform
44
- Dynamic: requires-dist
45
- Dynamic: requires-python
46
- Dynamic: summary
37
+ Description-Content-Type: text/markdown
47
38
 
48
39
 
49
40
  The quantmod package is inspired by the popular R package of the same name but reimagined for the modern Python data stack. It’s designed to support data scientists, analysts, and AI researchers with tools for fast, flexible data exploration and visualization. Whether you're working with time series, building machine learning pipelines, or prototyping data-driven ideas, quantmod offers a clean, intuitive interface that helps you move quickly from data to insight.
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "quantmod"
7
+ version = "0.1.4"
8
+ description = "Quantitative finance toolkit for Python — markets, options, risk, and time series"
9
+ readme = "README.md"
10
+ license = { text = "Apache-2.0" }
11
+ authors = [{ name = "Kannan Singaravelu", email = "inquant@outlook.com" }]
12
+ requires-python = ">=3.10"
13
+ keywords = ["quant", "quantmod", "finance", "options", "risk", "timeseries"]
14
+ classifiers = [
15
+ "License :: OSI Approved :: Apache Software License",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Operating System :: OS Independent",
21
+ "Intended Audience :: Developers",
22
+ "Intended Audience :: Financial and Insurance Industry",
23
+ "Topic :: Office/Business :: Financial",
24
+ "Topic :: Office/Business :: Financial :: Investment",
25
+ "Topic :: Software Development :: Libraries :: Python Modules",
26
+ ]
27
+ dependencies = [
28
+ "joblib",
29
+ "matplotlib",
30
+ "nbformat>=5.10.4",
31
+ "numpy>=2.0.2",
32
+ "pandas>=2.2.2",
33
+ "plotly>=6.1.2",
34
+ "pydantic>=2.8.2",
35
+ "scipy>=1.13.1",
36
+ "sqlalchemy>=2.0.38",
37
+ "supabase>=2.27.2",
38
+ "tabulate>=0.9.0",
39
+ "urllib3==1.26.15",
40
+ "yfinance>=1.0",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://kannansingaravelu.com/quantmod/"
45
+ Repository = "https://github.com/kannansingaravelu/quantmod"
46
+ Documentation = "https://kannansingaravelu.com/quantmod/"
47
+
48
+ [project.scripts]
49
+ inquant = "quantmod:hello"
50
+
51
+ [tool.hatch.build.targets.wheel]
52
+ packages = ["quantmod"]
53
+
54
+
55
+ [tool.hatch.build.targets.sdist]
56
+ exclude = ["tests/", ".venv/", "site/", "quantmod/site/", ".ruff_cache/"]
@@ -15,16 +15,17 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- # updated by Kannan Singaravelu on 2024-08-26
19
-
20
- # from . import _version
21
- # __version__ = _version.get_versions()['version']
22
-
23
- from . import version
18
+ from importlib.metadata import PackageNotFoundError, version
24
19
  from .main import hello
25
20
 
26
21
  from quantmod import derivatives, indicators, markets, models, timeseries, datasets
27
22
 
23
+ try:
24
+ __version__ = version("quantmod")
25
+ except PackageNotFoundError:
26
+ __version__ = "unknown"
27
+
28
+ __author__ = "Kannan Singaravelu"
28
29
 
29
30
  __all__ = [
30
31
  "hello",
@@ -36,6 +37,3 @@ __all__ = [
36
37
  "timeseries",
37
38
  "datasets",
38
39
  ]
39
-
40
- __version__ = version.version
41
- __author__ = "Kannan Singaravelu"
@@ -36,7 +36,7 @@ class QuantmodDB:
36
36
  raise ValueError("Supabase URL or Key missing")
37
37
 
38
38
  self.supabase: Client = create_client(supabase_url, supabase_key)
39
- self._instrument_cache: Dict[str, int] = {}
39
+ self._instrument_cache: Dict[str, int] = {}
40
40
 
41
41
  # ------------------------------------------------------------------
42
42
  # Instrument Registration
@@ -0,0 +1,3 @@
1
+ # About
2
+
3
+ The quantmod package is inspired by the popular R package of the same name but reimagined for the modern Python data stack. It’s designed to support data scientists, analysts, and AI researchers with tools for fast, flexible data exploration and visualization. Whether you're working with time series, building machine learning pipelines, or prototyping data-driven ideas, quantmod offers a clean, intuitive interface that helps you move quickly from data to insight.
@@ -0,0 +1,109 @@
1
+ # Change Log
2
+
3
+ ## 0.1.4
4
+
5
+ - replaced `BlackScholesOptionPricing` with Generalized Black-Scholes (GBS) framework
6
+ - added `BlackScholes`, `Merton`, `Black76`, `GarmanKohlhagen` models
7
+ - added `price_option()` convenience factory
8
+ - added `OptionGreeks` dataclass with all prices and first-order Greeks
9
+ - `BlackScholesOptionPricing` retained as a deprecated backward-compatible shim
10
+ - upgraded Monte Carlo engine (`MonteCarloOptionPricing`)
11
+ - added Sobol quasi-random sampler (`sampler='sobol'`) for faster convergence
12
+ - added antithetic variates variance reduction for pseudo-random mode
13
+ - added all four barrier types: up-and-out, up-and-in, down-and-out, down-and-in
14
+ - added American option pricing via Longstaff-Schwartz regression
15
+ - added `MonteCarloResult` dataclass (price, std error, 95% CI, metadata)
16
+ - parameters renamed: `nsims` → `n_simulations`, `timestep` → `n_steps`
17
+
18
+ 0.1.3
19
+
20
+ ---
21
+
22
+ - added db module
23
+ - updated timeseries module for pandas 2.x
24
+
25
+ 0.1.2
26
+
27
+ ---
28
+
29
+ - updated derivatives module
30
+
31
+ 0.1.1
32
+
33
+ ---
34
+
35
+ - updated derivatives module
36
+ - updated chart module
37
+
38
+ 0.1.0
39
+
40
+ ---
41
+
42
+ - updated risk module
43
+ - updated derivatives module
44
+
45
+ 0.0.9
46
+
47
+ ---
48
+
49
+ - updated pie plots
50
+ - added surface plots
51
+
52
+ 0.0.8
53
+
54
+ ---
55
+
56
+ - updated README
57
+
58
+ 0.0.7
59
+
60
+ ---
61
+
62
+ - added interactive charting module
63
+ - added indicator examples
64
+ - bug fixes
65
+
66
+ 0.0.6
67
+
68
+ ---
69
+
70
+ - updated Monte Carlo methods
71
+ - updated NSE option data module
72
+
73
+ 0.0.5
74
+
75
+ ---
76
+
77
+ - added option chain analysis for India
78
+ - added binomial option pricing model
79
+ - updated VaR calculation and backtester
80
+ - bug fixes
81
+
82
+ 0.0.4
83
+
84
+ ---
85
+
86
+ - updated multi level index for data download
87
+ - updated column positioning for data download
88
+
89
+ 0.0.3
90
+
91
+ ---
92
+
93
+ - package data included
94
+ - bug fixes
95
+
96
+ 0.0.2
97
+
98
+ ---
99
+
100
+ - added technical indicators
101
+ - bug fixes and refactoring
102
+
103
+ 0.0.1
104
+
105
+ ---
106
+
107
+ - migration from quantmod-python to quantmod
108
+ - added historical data loader
109
+ - support for SPX & NIFTY in dataloader
@@ -0,0 +1,32 @@
1
+ # Charting with quantmod
2
+
3
+ The charting module is a lightweight wrapper that combines the power of Plotly with the flexibility of Pandas, making it easy to create clean, interactive plots with minimal code.
4
+
5
+ ## Usage
6
+
7
+ ```python
8
+ import pandas as pd
9
+ from quantmod import charts
10
+
11
+ df = pd.DataFrame({...})
12
+ df.iplot(kind="line")
13
+ ```
14
+
15
+ ## Available Chart Types
16
+
17
+ - line
18
+ - scatter
19
+ - ohlc
20
+ - candlestick
21
+ - subplots
22
+ - histogram
23
+ - bar
24
+ - heatmap
25
+ - box
26
+ - pie
27
+ - treemap
28
+ - overlay
29
+ - normalized
30
+ - surface
31
+
32
+ > **Note:** Importing `quantmod.charts` automatically adds `iplot()` to all pandas DataFrames and Series.
@@ -0,0 +1,2 @@
1
+
2
+ ::: datasets
@@ -0,0 +1,2 @@
1
+
2
+ ::: db
@@ -0,0 +1 @@
1
+ ::: derivatives
@@ -0,0 +1,76 @@
1
+ # Welcome!
2
+
3
+ quantmod is inspired by the popular R package of the same name, reimagined for the modern Python data stack.
4
+
5
+ It provides a lightweight, structured toolkit for financial time-series ingestion, storage, and analysis, designed for data scientists, analysts, and AI practitioners.
6
+
7
+ quantmod emphasizes ease of use, reproducibility, and rapid experimentation, making it well-suited for exploratory research, machine-learning pipelines, and data-driven prototyping. Its clean, Pythonic interface helps users move quickly from raw market data to structured analysis and insight.
8
+
9
+
10
+ [![PyPI Downloads](https://static.pepy.tech/badge/quantmod)](https://pepy.tech/projects/quantmod)
11
+
12
+ ## User installation
13
+ The easiest way to install quantmod is using pip:
14
+
15
+ ```bash
16
+ pip install quantmod
17
+ ```
18
+
19
+ ## Modules
20
+
21
+ * [charts](charts.md)
22
+ * [database](db.md)
23
+ * [datasets](datasets.md)
24
+ * [derivatives](derivatives.md)
25
+ * [indicators](indicators.md)
26
+ * [markets](markets.md)
27
+ * [models](models.md)
28
+ * [risk](risk.md)
29
+ * [timeseries](timeseries.md)
30
+
31
+ ## Quickstart
32
+
33
+ ```py
34
+ # Retrieves market data & ticker object
35
+ from quantmod.markets import getData, getTicker
36
+
37
+ # Database module
38
+ from quantmod.db import QuantmodDB
39
+
40
+ # Charting module
41
+ import quantmod.charts
42
+
43
+ # Option pricing — GBS models (Black-Scholes, Merton, Black-76, Garman-Kohlhagen)
44
+ from quantmod.models import OptionInputs, BlackScholes, price_option
45
+
46
+ # Monte Carlo pricing (European, Asian, Barrier, American)
47
+ from quantmod.models import MonteCarloOptionPricing, OptionType, ExerciseStyle, BarrierType
48
+
49
+ # Calculates price return of different time periods
50
+ from quantmod.timeseries import *
51
+
52
+ # Technical indicators
53
+ from quantmod.indicators import ATR
54
+
55
+ # Derivatives functions
56
+ from quantmod.derivatives import maxpain
57
+
58
+ # Datasets functions
59
+ from quantmod.datasets import fetch_historical_data
60
+ ```
61
+ <br>
62
+ Note: quantmod is currently under active development, and anticipate ongoing enhancements and additions. The aim is to continually improve the package and expand its capabilities to meet the evolving needs of the community.
63
+
64
+ ## Examples
65
+ Refer to the [examples](user-guide/examples/optionpricing.md) section for more details.
66
+
67
+ ## Changelog
68
+ The list of changes to quantmod between each release can be found [here](changelog.md)
69
+
70
+ ## Community
71
+ [Join the quantmod server](https://discord.com/invite/DXQyezbJ) to share feature requests, report bugs, and discuss the package.
72
+
73
+ ## Legal
74
+ `quatmod` is distributed under the **Apache Software License**. See the [LICENSE.txt](https://www.apache.org/licenses/LICENSE-2.0.txt) file in the release for details.
75
+
76
+ The package is developed and maintained by [Kannan Singaravelu](https://kannansingaravelu.com).
@@ -0,0 +1,2 @@
1
+
2
+ ::: indicators
@@ -0,0 +1,3 @@
1
+ # Legal
2
+
3
+ `quatmod-python` is distributed under the **Apache Software License**. See the [LICENSE.txt](https://www.apache.org/licenses/LICENSE-2.0.txt) file in the release for details.
@@ -0,0 +1,2 @@
1
+
2
+ ::: markets
@@ -0,0 +1,2 @@
1
+
2
+ ::: models
@@ -0,0 +1,2 @@
1
+
2
+ ::: risk
@@ -0,0 +1,2 @@
1
+
2
+ ::: timeseries
@@ -0,0 +1,96 @@
1
+ Register, load and retrieve data from database using quantmod
2
+
3
+ After table creation, you can use the following code to register instruments with metadata and load historical data.
4
+ ```py
5
+ import os
6
+ from quantmod.db import QuantmodDB
7
+
8
+ # 1. Initialise — load credentials from environment variables
9
+ # Set these in your shell or a .env file (never hardcode in source)
10
+ # export SUPABASE_URL="https://your-project.supabase.co"
11
+ # export SUPABASE_KEY="your-service-role-key"
12
+ qm = QuantmodDB(
13
+ supabase_url=os.environ["SUPABASE_URL"],
14
+ supabase_key=os.environ["SUPABASE_KEY"],
15
+ )
16
+
17
+ # 2. Register instruments with metadata
18
+ qm.register([
19
+ {"symbol": "ITC.NS", "name": "ITC", "exchange": "NSE", "asset_class": "equity", "instrument_type": "stock"},
20
+ {"symbol": "MSFT", "name": "Microsoft", "exchange": "NASDAQ"}
21
+ ])
22
+
23
+ # 3. Get instrument details
24
+ instruments = qm.get_instrument_id( "MSFT")
25
+ print(instruments)
26
+
27
+ # 4. List all registered instruments
28
+ instruments = qm.list_instruments(["AAPL"])
29
+ instruments = qm.list_instruments(exchange="NASDAQ")
30
+ instruments = qm.list_instruments(["AAPL", "MSFT"])
31
+ print(instruments)
32
+
33
+ # Step 5: Load historical data
34
+ results = qm.load_history(["AAPL", "MSFT"], "2026-01-01", "2026-01-19")
35
+ print(results)
36
+
37
+ # Step 6: Retrieve data
38
+ prices = qm.get_prices(["AAPL", "MSFT"], start_date="2026-01-01")
39
+ print(prices.tail())
40
+
41
+ # Step 7: Get asset prices
42
+ prices = qm.get_asset_prices()
43
+ print(prices.tail())
44
+
45
+ # Step 8: Get latest prices
46
+ prices = qm.get_latest_prices()
47
+ print(prices.tail())
48
+ ```
49
+
50
+ Create below two tables with schema as shown below at supabase end before running the above code.
51
+ ```sql
52
+ -- 1. Instruments table (metadata for symbols/tickers)
53
+ CREATE TABLE IF NOT EXISTS instruments (
54
+ id BIGSERIAL PRIMARY KEY,
55
+ symbol TEXT NOT NULL UNIQUE,
56
+ name TEXT,
57
+ exchange TEXT,
58
+ asset_class TEXT, -- e.g. 'stock', 'crypto', 'forex', 'etf', 'index'
59
+ instrument_type TEXT, -- optional: 'equity', 'future', 'option', 'spot', etc.
60
+
61
+ created_at TIMESTAMPTZ DEFAULT NOW(),
62
+ updated_at TIMESTAMPTZ DEFAULT NOW()
63
+ );
64
+
65
+ -- Optional: add some useful indexes
66
+ CREATE INDEX IF NOT EXISTS idx_instruments_asset_class ON instruments(asset_class);
67
+
68
+
69
+ -- 2. Prices table (OHLCV data)
70
+ CREATE TABLE IF NOT EXISTS prices (
71
+ instrument_id BIGINT NOT NULL
72
+ REFERENCES instruments(id)
73
+ ON DELETE CASCADE, -- when instrument is deleted → delete its prices too
74
+
75
+ date DATE NOT NULL,
76
+
77
+ open DOUBLE PRECISION,
78
+ high DOUBLE PRECISION,
79
+ low DOUBLE PRECISION,
80
+ close DOUBLE PRECISION,
81
+ volume BIGINT,
82
+
83
+ -- Composite primary key (prevents duplicates)
84
+ PRIMARY KEY (instrument_id, date),
85
+
86
+ created_at TIMESTAMPTZ DEFAULT NOW(),
87
+ updated_at TIMESTAMPTZ DEFAULT NOW()
88
+ );
89
+
90
+ -- Recommended indexes for performance
91
+ CREATE INDEX idx_prices_instrument_date
92
+ ON prices(instrument_id, date DESC); -- useful for recent prices queries
93
+
94
+ CREATE INDEX idx_prices_date
95
+ ON prices(date);
96
+ ```
@@ -0,0 +1,13 @@
1
+ Fetches historical data from quantmod
2
+
3
+ ```py
4
+ import pandas as pd
5
+ from quantmod.datasets import fetch_historical_data
6
+
7
+ # Fetches historical data
8
+ df = fetch_historical_data(symbol='SPX')
9
+
10
+ # Prints the first 5 rows of the DataFrame
11
+ print(df.head())
12
+
13
+ ```