openbb-technical 1.6.2__tar.gz → 2.0.0__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.
- openbb_technical-2.0.0/.gitignore +65 -0
- openbb_technical-2.0.0/PKG-INFO +90 -0
- openbb_technical-2.0.0/README.md +75 -0
- openbb_technical-2.0.0/docs/README.md +32 -0
- {openbb_technical-1.6.2 → openbb_technical-2.0.0}/openbb_technical/helpers.py +19 -31
- openbb_technical-2.0.0/openbb_technical/indicators/__init__.py +37 -0
- openbb_technical-2.0.0/openbb_technical/indicators/oscillators.py +880 -0
- openbb_technical-2.0.0/openbb_technical/indicators/overlays.py +1386 -0
- openbb_technical-2.0.0/openbb_technical/indicators/relative_rotation.py +40 -0
- openbb_technical-2.0.0/openbb_technical/indicators/statistics.py +974 -0
- openbb_technical-2.0.0/openbb_technical/indicators/structure.py +387 -0
- openbb_technical-2.0.0/openbb_technical/indicators/trend.py +495 -0
- openbb_technical-2.0.0/openbb_technical/indicators/volatility.py +599 -0
- openbb_technical-2.0.0/openbb_technical/indicators/volume.py +338 -0
- openbb_technical-2.0.0/openbb_technical/multi/__init__.py +16 -0
- openbb_technical-2.0.0/openbb_technical/multi/catalog.py +464 -0
- openbb_technical-2.0.0/openbb_technical/multi/compose.py +230 -0
- openbb_technical-2.0.0/openbb_technical/multi/correlation.py +314 -0
- openbb_technical-2.0.0/openbb_technical/multi/screen.py +338 -0
- {openbb_technical-1.6.2 → openbb_technical-2.0.0}/openbb_technical/relative_rotation.py +31 -28
- openbb_technical-2.0.0/openbb_technical/router.py +15 -0
- openbb_technical-2.0.0/openbb_technical/signals/__init__.py +33 -0
- openbb_technical-2.0.0/openbb_technical/signals/breakouts.py +193 -0
- openbb_technical-2.0.0/openbb_technical/signals/crossovers.py +178 -0
- openbb_technical-2.0.0/openbb_technical/signals/divergences.py +303 -0
- openbb_technical-2.0.0/openbb_technical/signals/patterns.py +257 -0
- openbb_technical-2.0.0/openbb_technical/signals/regime.py +192 -0
- openbb_technical-2.0.0/openbb_technical/signals/thresholds.py +242 -0
- {openbb_technical-1.6.2 → openbb_technical-2.0.0}/openbb_technical/technical_views.py +53 -37
- openbb_technical-2.0.0/pyproject.toml +97 -0
- openbb_technical-1.6.2/PKG-INFO +0 -38
- openbb_technical-1.6.2/README.md +0 -17
- openbb_technical-1.6.2/openbb_technical/technical_router.py +0 -1916
- openbb_technical-1.6.2/pyproject.toml +0 -24
- {openbb_technical-1.6.2 → openbb_technical-2.0.0}/openbb_technical/__init__.py +0 -0
- {openbb_technical-1.6.2 → openbb_technical-2.0.0}/openbb_technical/py.typed +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# General
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.pyc
|
|
4
|
+
.DS_Store
|
|
5
|
+
*.env
|
|
6
|
+
.venv
|
|
7
|
+
venv*/
|
|
8
|
+
venv
|
|
9
|
+
.vscode
|
|
10
|
+
*.ipynb
|
|
11
|
+
env/
|
|
12
|
+
venv/
|
|
13
|
+
!notebooks/jupyter/.gitkeep
|
|
14
|
+
.python-version
|
|
15
|
+
.mypy_cache
|
|
16
|
+
.ruff_cache
|
|
17
|
+
.pytest_cache
|
|
18
|
+
iframe_figures/
|
|
19
|
+
exports/*
|
|
20
|
+
.idea
|
|
21
|
+
.coverage
|
|
22
|
+
.scannerwork
|
|
23
|
+
htmlcov
|
|
24
|
+
**/.ipynb_checkpoints
|
|
25
|
+
*.swp
|
|
26
|
+
*.http
|
|
27
|
+
.coverage.*
|
|
28
|
+
*_tests.csv
|
|
29
|
+
*_sdk_audit.csv
|
|
30
|
+
!build/docker/compose.env
|
|
31
|
+
.dccache
|
|
32
|
+
*rome.json
|
|
33
|
+
**/node_modules/*
|
|
34
|
+
.cursorignore
|
|
35
|
+
darts_logs/
|
|
36
|
+
custom_imports/*.csv
|
|
37
|
+
custom_imports/*/*.csv
|
|
38
|
+
cache/
|
|
39
|
+
lightning_logs/
|
|
40
|
+
*/mocked_path
|
|
41
|
+
*.pem
|
|
42
|
+
|
|
43
|
+
# CLI
|
|
44
|
+
*.pyo
|
|
45
|
+
**/dist/*
|
|
46
|
+
build/cli
|
|
47
|
+
build/nsis/app
|
|
48
|
+
DMG/*
|
|
49
|
+
*.dmg
|
|
50
|
+
*.sh
|
|
51
|
+
cli/openbb_cli/assets/styles/user/*
|
|
52
|
+
|
|
53
|
+
# Platform
|
|
54
|
+
openbb_platform/core/openbb/package/*
|
|
55
|
+
openbb_platform/core/openbb/.build.lock
|
|
56
|
+
**/assets/*.json.xz
|
|
57
|
+
|
|
58
|
+
# Dev Container env
|
|
59
|
+
obb/*
|
|
60
|
+
|
|
61
|
+
# OpenBB Distribution
|
|
62
|
+
!build/conda/installer/*.sh
|
|
63
|
+
*.pkg
|
|
64
|
+
*.exe
|
|
65
|
+
build/conda/tmp
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: openbb-technical
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Technical Analysis extension for OpenBB
|
|
5
|
+
Project-URL: Homepage, https://openbb.co
|
|
6
|
+
Project-URL: Repository, https://github.com/OpenBB-finance/OpenBB
|
|
7
|
+
Author-email: OpenBB Team <hello@openbb.co>
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Requires-Python: <4,>=3.10
|
|
10
|
+
Requires-Dist: openbb-core[pandas]>=2.0.0
|
|
11
|
+
Requires-Dist: pandas-ta-openbb>=0.4.23
|
|
12
|
+
Requires-Dist: scipy>=1.11
|
|
13
|
+
Requires-Dist: statsmodels>=0.14
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# OpenBB Technical Analysis Extension
|
|
17
|
+
|
|
18
|
+
This extension provides Technical Analysis tools for the OpenBB Platform.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
To install the extension, run the following command in this folder:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install openbb-technical
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Documentation available [here](https://docs.openbb.co/odp/python/extensions/data-processing/technical)
|
|
29
|
+
|
|
30
|
+
| Endpoint | Category | Description |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| `bbands` | overlay | Bollinger Bands — mean +/- N standard deviations. |
|
|
33
|
+
| `dema` | overlay | Double-smoothed exponential moving average. |
|
|
34
|
+
| `donchian` | overlay | Donchian channel — rolling high/low envelope. |
|
|
35
|
+
| `ema` | overlay | Exponential moving average. |
|
|
36
|
+
| `frama` | overlay | Fractal Adaptive Moving Average — speed varies with fractal dimension. |
|
|
37
|
+
| `hma` | overlay | Hull moving average — reduced lag. |
|
|
38
|
+
| `ichimoku` | overlay | Ichimoku Cloud — five-line trend system. |
|
|
39
|
+
| `kama` | overlay | Kaufman Adaptive Moving Average — speed varies with efficiency. |
|
|
40
|
+
| `kc` | overlay | Keltner Channels — ATR-scaled envelope around an EMA. |
|
|
41
|
+
| `sma` | overlay | Simple moving average. |
|
|
42
|
+
| `supertrend` | overlay | SuperTrend — ATR-anchored trailing band. |
|
|
43
|
+
| `tema` | overlay | Triple-smoothed exponential moving average. |
|
|
44
|
+
| `vwma` | overlay | Volume-weighted moving average. |
|
|
45
|
+
| `wma` | overlay | Weighted moving average — linear weights. |
|
|
46
|
+
| `zlma` | overlay | Zero-lag exponential moving average. |
|
|
47
|
+
| `awesome_oscillator` | oscillator | Bill Williams' AO — 5/34 SMA difference of midpoints. |
|
|
48
|
+
| `cci` | oscillator | Commodity Channel Index — deviation from typical-price MA. |
|
|
49
|
+
| `cg` | oscillator | Center of Gravity oscillator (Ehlers). |
|
|
50
|
+
| `fisher` | oscillator | Fisher Transform — Gaussian-shaped oscillator. |
|
|
51
|
+
| `mfi` | oscillator | Money Flow Index — volume-weighted RSI. |
|
|
52
|
+
| `rsi` | oscillator | Relative Strength Index — momentum oscillator (0-100). |
|
|
53
|
+
| `stoch` | oscillator | Stochastic Oscillator — %K and %D bounded 0-100. |
|
|
54
|
+
| `trix` | oscillator | Triple-smoothed rate of change — noise-filtered momentum. |
|
|
55
|
+
| `ultimate_oscillator` | oscillator | Three-window weighted momentum oscillator. |
|
|
56
|
+
| `williams_r` | oscillator | Williams %R — momentum bounded -100 to 0. |
|
|
57
|
+
| `adx` | trend | Average Directional Index — trend strength (0-100). |
|
|
58
|
+
| `aroon` | trend | Aroon Up/Down — bars since highest high / lowest low. |
|
|
59
|
+
| `choppiness` | trend | Choppiness Index — trending vs. ranging classifier. |
|
|
60
|
+
| `di` | trend | Directional Indicators (+DI, -DI) — bullish/bearish pressure. |
|
|
61
|
+
| `macd` | trend | MACD — fast/slow EMA difference plus signal line and histogram. |
|
|
62
|
+
| `ad` | volume | Accumulation/Distribution Line — volume weighted by close-location. |
|
|
63
|
+
| `adosc` | volume | Chaikin A/D Oscillator — fast EMA minus slow EMA of A/D. |
|
|
64
|
+
| `obv` | volume | On-Balance Volume — cumulative signed volume. |
|
|
65
|
+
| `vwap` | volume | Volume-Weighted Average Price, anchored. |
|
|
66
|
+
| `atr` | volatility | Average True Range — Wilder's volatility measure. |
|
|
67
|
+
| `cones` | volatility | Volatility cones — per-window realised vs. historical band. |
|
|
68
|
+
| `realized_volatility` | volatility | Annualised rolling realised volatility (one of six estimators). |
|
|
69
|
+
| `realized_volatility_compare` | volatility | All six realised-volatility estimators side by side. |
|
|
70
|
+
| `demark` | structure | DeMark sequential — 9-bar setup count for exhaustion. |
|
|
71
|
+
| `fib` | structure | Fibonacci retracement levels between a swing high and low. |
|
|
72
|
+
| `pivot_points` | structure | Pivot-point support/resistance under multiple methods. |
|
|
73
|
+
| `autocorrelation` | stats | ACF + PACF with significance bands. |
|
|
74
|
+
| `clenow` | stats | Clenow Volatility-Adjusted Momentum (R^2 * regression slope). |
|
|
75
|
+
| `drawdown` | stats | Cumulative-return drawdown plus running peak and duration. |
|
|
76
|
+
| `hurst` | stats | Hurst exponent (R/S and DFA) — long-memory diagnostic. |
|
|
77
|
+
| `returns_stats` | stats | Distributional and risk-adjusted return statistics. |
|
|
78
|
+
| `stationarity` | stats | ADF + KPSS unit-root and stationarity tests. |
|
|
79
|
+
| `breakouts` | signal | Channel-breakout events (Donchian or Bollinger). |
|
|
80
|
+
| `candlestick_patterns` | signal | Single- and two-bar candlestick pattern detection. |
|
|
81
|
+
| `crossovers` | signal | Fast/slow moving-average crossover events. |
|
|
82
|
+
| `divergences` | signal | Bullish/bearish/hidden divergences between price and an oscillator. |
|
|
83
|
+
| `oscillator_signals` | signal | Oscillator overbought/oversold regime + crossing events. |
|
|
84
|
+
| `regime` | signal | Trend-strength regime classification + transitions. |
|
|
85
|
+
| `correlation` | multi | Rolling pairwise correlation of returns across symbols. |
|
|
86
|
+
| `correlation_matrix` | multi | Snapshot correlation matrix across every symbol. |
|
|
87
|
+
| `indicators` | multi | Programmatic catalog of all registered endpoints. |
|
|
88
|
+
| `multi` | multi | Run many indicators on one series and merge by date. |
|
|
89
|
+
| `relative_rotation` | multi | JdK RS-Ratio + RS-Momentum vs. a benchmark (RRG). |
|
|
90
|
+
| `screen` | multi | Filter a multi-symbol basket by indicator-driven predicates. |
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# OpenBB Technical Analysis Extension
|
|
2
|
+
|
|
3
|
+
This extension provides Technical Analysis tools for the OpenBB Platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
To install the extension, run the following command in this folder:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install openbb-technical
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Documentation available [here](https://docs.openbb.co/odp/python/extensions/data-processing/technical)
|
|
14
|
+
|
|
15
|
+
| Endpoint | Category | Description |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| `bbands` | overlay | Bollinger Bands — mean +/- N standard deviations. |
|
|
18
|
+
| `dema` | overlay | Double-smoothed exponential moving average. |
|
|
19
|
+
| `donchian` | overlay | Donchian channel — rolling high/low envelope. |
|
|
20
|
+
| `ema` | overlay | Exponential moving average. |
|
|
21
|
+
| `frama` | overlay | Fractal Adaptive Moving Average — speed varies with fractal dimension. |
|
|
22
|
+
| `hma` | overlay | Hull moving average — reduced lag. |
|
|
23
|
+
| `ichimoku` | overlay | Ichimoku Cloud — five-line trend system. |
|
|
24
|
+
| `kama` | overlay | Kaufman Adaptive Moving Average — speed varies with efficiency. |
|
|
25
|
+
| `kc` | overlay | Keltner Channels — ATR-scaled envelope around an EMA. |
|
|
26
|
+
| `sma` | overlay | Simple moving average. |
|
|
27
|
+
| `supertrend` | overlay | SuperTrend — ATR-anchored trailing band. |
|
|
28
|
+
| `tema` | overlay | Triple-smoothed exponential moving average. |
|
|
29
|
+
| `vwma` | overlay | Volume-weighted moving average. |
|
|
30
|
+
| `wma` | overlay | Weighted moving average — linear weights. |
|
|
31
|
+
| `zlma` | overlay | Zero-lag exponential moving average. |
|
|
32
|
+
| `awesome_oscillator` | oscillator | Bill Williams' AO — 5/34 SMA difference of midpoints. |
|
|
33
|
+
| `cci` | oscillator | Commodity Channel Index — deviation from typical-price MA. |
|
|
34
|
+
| `cg` | oscillator | Center of Gravity oscillator (Ehlers). |
|
|
35
|
+
| `fisher` | oscillator | Fisher Transform — Gaussian-shaped oscillator. |
|
|
36
|
+
| `mfi` | oscillator | Money Flow Index — volume-weighted RSI. |
|
|
37
|
+
| `rsi` | oscillator | Relative Strength Index — momentum oscillator (0-100). |
|
|
38
|
+
| `stoch` | oscillator | Stochastic Oscillator — %K and %D bounded 0-100. |
|
|
39
|
+
| `trix` | oscillator | Triple-smoothed rate of change — noise-filtered momentum. |
|
|
40
|
+
| `ultimate_oscillator` | oscillator | Three-window weighted momentum oscillator. |
|
|
41
|
+
| `williams_r` | oscillator | Williams %R — momentum bounded -100 to 0. |
|
|
42
|
+
| `adx` | trend | Average Directional Index — trend strength (0-100). |
|
|
43
|
+
| `aroon` | trend | Aroon Up/Down — bars since highest high / lowest low. |
|
|
44
|
+
| `choppiness` | trend | Choppiness Index — trending vs. ranging classifier. |
|
|
45
|
+
| `di` | trend | Directional Indicators (+DI, -DI) — bullish/bearish pressure. |
|
|
46
|
+
| `macd` | trend | MACD — fast/slow EMA difference plus signal line and histogram. |
|
|
47
|
+
| `ad` | volume | Accumulation/Distribution Line — volume weighted by close-location. |
|
|
48
|
+
| `adosc` | volume | Chaikin A/D Oscillator — fast EMA minus slow EMA of A/D. |
|
|
49
|
+
| `obv` | volume | On-Balance Volume — cumulative signed volume. |
|
|
50
|
+
| `vwap` | volume | Volume-Weighted Average Price, anchored. |
|
|
51
|
+
| `atr` | volatility | Average True Range — Wilder's volatility measure. |
|
|
52
|
+
| `cones` | volatility | Volatility cones — per-window realised vs. historical band. |
|
|
53
|
+
| `realized_volatility` | volatility | Annualised rolling realised volatility (one of six estimators). |
|
|
54
|
+
| `realized_volatility_compare` | volatility | All six realised-volatility estimators side by side. |
|
|
55
|
+
| `demark` | structure | DeMark sequential — 9-bar setup count for exhaustion. |
|
|
56
|
+
| `fib` | structure | Fibonacci retracement levels between a swing high and low. |
|
|
57
|
+
| `pivot_points` | structure | Pivot-point support/resistance under multiple methods. |
|
|
58
|
+
| `autocorrelation` | stats | ACF + PACF with significance bands. |
|
|
59
|
+
| `clenow` | stats | Clenow Volatility-Adjusted Momentum (R^2 * regression slope). |
|
|
60
|
+
| `drawdown` | stats | Cumulative-return drawdown plus running peak and duration. |
|
|
61
|
+
| `hurst` | stats | Hurst exponent (R/S and DFA) — long-memory diagnostic. |
|
|
62
|
+
| `returns_stats` | stats | Distributional and risk-adjusted return statistics. |
|
|
63
|
+
| `stationarity` | stats | ADF + KPSS unit-root and stationarity tests. |
|
|
64
|
+
| `breakouts` | signal | Channel-breakout events (Donchian or Bollinger). |
|
|
65
|
+
| `candlestick_patterns` | signal | Single- and two-bar candlestick pattern detection. |
|
|
66
|
+
| `crossovers` | signal | Fast/slow moving-average crossover events. |
|
|
67
|
+
| `divergences` | signal | Bullish/bearish/hidden divergences between price and an oscillator. |
|
|
68
|
+
| `oscillator_signals` | signal | Oscillator overbought/oversold regime + crossing events. |
|
|
69
|
+
| `regime` | signal | Trend-strength regime classification + transitions. |
|
|
70
|
+
| `correlation` | multi | Rolling pairwise correlation of returns across symbols. |
|
|
71
|
+
| `correlation_matrix` | multi | Snapshot correlation matrix across every symbol. |
|
|
72
|
+
| `indicators` | multi | Programmatic catalog of all registered endpoints. |
|
|
73
|
+
| `multi` | multi | Run many indicators on one series and merge by date. |
|
|
74
|
+
| `relative_rotation` | multi | JdK RS-Ratio + RS-Momentum vs. a benchmark (RRG). |
|
|
75
|
+
| `screen` | multi | Filter a multi-symbol basket by indicator-driven predicates. |
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# openbb-technical Documentation
|
|
2
|
+
|
|
3
|
+
The technical extension exposes ~60 endpoints organised into four families:
|
|
4
|
+
|
|
5
|
+
| Family | What it does | URL prefix |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `indicators/*` | Single-symbol overlays, oscillators, trend, volume, volatility, structure, statistics | `/` (root) |
|
|
8
|
+
| `signals/*` | Event detectors: crossovers, divergences, breakouts, candlestick patterns, regime | `/signals/` |
|
|
9
|
+
| `multi/*` | Multi-symbol correlation, screening, relative-rotation, multi-indicator composition, catalog | `/` (root, except `correlation_matrix` and `screen` which expose `multi.*`) |
|
|
10
|
+
| `relative_rotation` | JdK RS-Ratio + RS-Momentum for a benchmark-anchored basket | `/` (root) |
|
|
11
|
+
|
|
12
|
+
Every endpoint is reachable through three transports:
|
|
13
|
+
|
|
14
|
+
1. **Python**: `from openbb import obb; obb.technical.<endpoint>(...)`
|
|
15
|
+
2. **HTTP**: `POST http://localhost:8000/api/v1/technical/<endpoint>` (run `openbb-api` to start the server)
|
|
16
|
+
3. **CLI**: `openbb -i` then `/technical/<endpoint>`
|
|
17
|
+
|
|
18
|
+
## Where to start
|
|
19
|
+
|
|
20
|
+
- **First time?** [getting-started.md](./getting-started.md) shows installation, the three transports, and a 5-line example for each.
|
|
21
|
+
- **Building a strategy?** [user-guides/01-indicators.md](./user-guides/01-indicators.md) covers single-symbol indicator workflows.
|
|
22
|
+
- **Want trade signals?** [user-guides/02-signals.md](./user-guides/02-signals.md) covers the signals subrouter.
|
|
23
|
+
- **Working with a basket?** [user-guides/03-multi-symbol.md](./user-guides/03-multi-symbol.md) covers correlation, screening, and Relative Rotation Graphs.
|
|
24
|
+
- **Composing pipelines?** [user-guides/04-composition-and-discovery.md](./user-guides/04-composition-and-discovery.md) covers the `multi` and `indicators` (catalog) endpoints.
|
|
25
|
+
- **Looking up a specific endpoint?** [api-reference.md](./api-reference.md) lists every endpoint with its parameters, output columns, and a one-line description.
|
|
26
|
+
|
|
27
|
+
## Conventions
|
|
28
|
+
|
|
29
|
+
- **Input**: every data-consuming endpoint accepts the same shapes — `list[Data]`, `list[dict]`, `pandas.DataFrame`, `pandas.Series`, or `numpy.ndarray`. The library converts between them automatically.
|
|
30
|
+
- **Output**: every endpoint returns an `OBBject`. The numeric payload is on `.results` as a list of typed Pydantic models.
|
|
31
|
+
- **Validation**: every endpoint validates its inputs through a `XxxQueryParams` Pydantic class and emits its rows through a `XxxData` (or `XxxEvent`/`XxxSignal`) class. The class docstrings carry full NumPy-format `Parameters` and `Returns` sections.
|
|
32
|
+
- **Discovery**: the `indicators` endpoint introspects the registered router and returns a structured catalog — useful for building UI pickers, OpenAPI clients, or LLM tool-calls without hard-coding endpoint names.
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"""Technical Analysis Helpers."""
|
|
2
2
|
|
|
3
|
-
# pylint: disable=too-many-arguments,too-many-locals,too-many-positional-arguments
|
|
4
|
-
|
|
5
3
|
from typing import TYPE_CHECKING, Any, Literal
|
|
6
4
|
from warnings import warn
|
|
7
5
|
|
|
@@ -50,7 +48,6 @@ def parkinson(
|
|
|
50
48
|
DataFrame : results
|
|
51
49
|
Dataframe with results.
|
|
52
50
|
"""
|
|
53
|
-
# pylint: disable=import-outside-toplevel
|
|
54
51
|
from numpy import log
|
|
55
52
|
|
|
56
53
|
if window < 1:
|
|
@@ -106,7 +103,6 @@ def standard_deviation(
|
|
|
106
103
|
DataFrame : results
|
|
107
104
|
Dataframe with results.
|
|
108
105
|
"""
|
|
109
|
-
# pylint: disable=import-outside-toplevel
|
|
110
106
|
from numpy import log, sqrt
|
|
111
107
|
|
|
112
108
|
if window < 2:
|
|
@@ -162,7 +158,6 @@ def garman_klass(
|
|
|
162
158
|
DataFrame : results
|
|
163
159
|
Dataframe with results.
|
|
164
160
|
"""
|
|
165
|
-
# pylint: disable=import-outside-toplevel
|
|
166
161
|
from numpy import log
|
|
167
162
|
|
|
168
163
|
if window < 1:
|
|
@@ -226,7 +221,6 @@ def hodges_tompkins(
|
|
|
226
221
|
>>> data = obb.equity.price.historical('BTC-USD')
|
|
227
222
|
>>> df = obb.technical.hodges_tompkins(data, is_crypto = True)
|
|
228
223
|
"""
|
|
229
|
-
# pylint: disable=import-outside-toplevel
|
|
230
224
|
from numpy import log, sqrt
|
|
231
225
|
|
|
232
226
|
if window < 2:
|
|
@@ -287,7 +281,6 @@ def rogers_satchell(
|
|
|
287
281
|
Series : results
|
|
288
282
|
Pandas Series with results.
|
|
289
283
|
"""
|
|
290
|
-
# pylint: disable=import-outside-toplevel
|
|
291
284
|
from numpy import log
|
|
292
285
|
|
|
293
286
|
if window < 1:
|
|
@@ -347,7 +340,6 @@ def yang_zhang(
|
|
|
347
340
|
DataFrame : results
|
|
348
341
|
Dataframe with results.
|
|
349
342
|
"""
|
|
350
|
-
# pylint: disable=import-outside-toplevel
|
|
351
343
|
from numpy import log, sqrt
|
|
352
344
|
|
|
353
345
|
if window < 2:
|
|
@@ -407,7 +399,6 @@ def calculate_cones(
|
|
|
407
399
|
trading_periods: int | None = None,
|
|
408
400
|
) -> "DataFrame":
|
|
409
401
|
"""Calculate Cones."""
|
|
410
|
-
# pylint: disable=import-outside-toplevel
|
|
411
402
|
from pandas import DataFrame
|
|
412
403
|
|
|
413
404
|
estimator = DataFrame()
|
|
@@ -441,7 +432,7 @@ def calculate_cones(
|
|
|
441
432
|
}
|
|
442
433
|
|
|
443
434
|
for window in windows:
|
|
444
|
-
estimator = model_functions[model](
|
|
435
|
+
estimator = model_functions[model](
|
|
445
436
|
window=window,
|
|
446
437
|
data=data,
|
|
447
438
|
is_crypto=is_crypto,
|
|
@@ -451,12 +442,12 @@ def calculate_cones(
|
|
|
451
442
|
if estimator.empty:
|
|
452
443
|
continue
|
|
453
444
|
|
|
454
|
-
min_.append(estimator.min())
|
|
455
|
-
max_.append(estimator.max())
|
|
456
|
-
median.append(estimator.median())
|
|
457
|
-
top_q.append(estimator.quantile(quantiles[1]))
|
|
458
|
-
bottom_q.append(estimator.quantile(quantiles[0]))
|
|
459
|
-
realized.append(estimator.iloc[-1])
|
|
445
|
+
min_.append(estimator.min())
|
|
446
|
+
max_.append(estimator.max())
|
|
447
|
+
median.append(estimator.median())
|
|
448
|
+
top_q.append(estimator.quantile(quantiles[1]))
|
|
449
|
+
bottom_q.append(estimator.quantile(quantiles[0]))
|
|
450
|
+
realized.append(estimator.iloc[-1])
|
|
460
451
|
|
|
461
452
|
allowed_windows.append(window)
|
|
462
453
|
|
|
@@ -501,27 +492,25 @@ def clenow_momentum(
|
|
|
501
492
|
Series:
|
|
502
493
|
Values for best fit line
|
|
503
494
|
"""
|
|
504
|
-
|
|
505
|
-
from numpy import arange, exp, log
|
|
495
|
+
from numpy import arange, exp, log, polyfit
|
|
506
496
|
from pandas import Series
|
|
507
|
-
from sklearn.linear_model import LinearRegression
|
|
508
497
|
|
|
509
498
|
if len(values) < window:
|
|
510
499
|
raise ValueError(f"Calculation asks for at least last {window} days of data")
|
|
511
500
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
501
|
+
y = log(values[-window:].to_numpy(dtype=float))
|
|
502
|
+
x = arange(len(y))
|
|
503
|
+
coef, intercept = polyfit(x, y, 1)
|
|
504
|
+
fit = coef * x + intercept
|
|
516
505
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
annualized_coef = (exp(coef) ** 252
|
|
506
|
+
r2 = (
|
|
507
|
+
0.0
|
|
508
|
+
if y.max() == y.min()
|
|
509
|
+
else float(1 - ((y - fit) ** 2).sum() / ((y - y.mean()) ** 2).sum())
|
|
510
|
+
)
|
|
511
|
+
annualized_coef = float(exp(coef) ** 252 - 1)
|
|
523
512
|
|
|
524
|
-
return r2, annualized_coef, Series(
|
|
513
|
+
return r2, annualized_coef, Series(fit)
|
|
525
514
|
|
|
526
515
|
|
|
527
516
|
def calculate_fib_levels(
|
|
@@ -559,7 +548,6 @@ def calculate_fib_levels(
|
|
|
559
548
|
max_pr: float
|
|
560
549
|
Price at max point
|
|
561
550
|
"""
|
|
562
|
-
# pylint: disable=import-outside-toplevel
|
|
563
551
|
from pandas import DataFrame
|
|
564
552
|
|
|
565
553
|
if close_col not in data.columns:
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Indicators sub-package."""
|
|
2
|
+
|
|
3
|
+
from openbb_core.app.router import Router
|
|
4
|
+
|
|
5
|
+
from openbb_technical.indicators import (
|
|
6
|
+
oscillators,
|
|
7
|
+
overlays,
|
|
8
|
+
relative_rotation,
|
|
9
|
+
statistics,
|
|
10
|
+
structure,
|
|
11
|
+
trend,
|
|
12
|
+
volatility,
|
|
13
|
+
volume,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
router = Router(prefix="", description="Technical indicators.")
|
|
17
|
+
router.include_router(overlays.router)
|
|
18
|
+
router.include_router(oscillators.router)
|
|
19
|
+
router.include_router(trend.router)
|
|
20
|
+
router.include_router(volume.router)
|
|
21
|
+
router.include_router(volatility.router)
|
|
22
|
+
router.include_router(structure.router)
|
|
23
|
+
router.include_router(statistics.router)
|
|
24
|
+
router.include_router(relative_rotation.router)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"overlays",
|
|
29
|
+
"oscillators",
|
|
30
|
+
"relative_rotation",
|
|
31
|
+
"router",
|
|
32
|
+
"statistics",
|
|
33
|
+
"structure",
|
|
34
|
+
"trend",
|
|
35
|
+
"volatility",
|
|
36
|
+
"volume",
|
|
37
|
+
]
|