quantjourney-bidask 0.9.3__tar.gz → 1.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.
Files changed (38) hide show
  1. {quantjourney_bidask-0.9.3 → quantjourney_bidask-1.0}/PKG-INFO +93 -35
  2. {quantjourney_bidask-0.9.3 → quantjourney_bidask-1.0}/README.md +91 -33
  3. quantjourney_bidask-1.0/data/fetch.py +399 -0
  4. quantjourney_bidask-1.0/examples/animated_spread_monitor.py +528 -0
  5. quantjourney_bidask-1.0/examples/basic_spread_estimation.py +193 -0
  6. {quantjourney_bidask-0.9.3 → quantjourney_bidask-1.0}/examples/crypto_spread_comparison.py +256 -193
  7. quantjourney_bidask-1.0/examples/liquidity_risk_monitor.py +105 -0
  8. {quantjourney_bidask-0.9.3 → quantjourney_bidask-1.0}/examples/simple_data_example.py +81 -46
  9. quantjourney_bidask-1.0/examples/threshold_alert_monitor.py +269 -0
  10. quantjourney_bidask-0.9.3/examples/realtime_spread_monitor.py → quantjourney_bidask-1.0/examples/websocket_realtime_demo.py +292 -188
  11. {quantjourney_bidask-0.9.3 → quantjourney_bidask-1.0}/pyproject.toml +2 -2
  12. quantjourney_bidask-1.0/quantjourney_bidask/__init__.py +34 -0
  13. quantjourney_bidask-1.0/quantjourney_bidask/_compare_edge.py +152 -0
  14. quantjourney_bidask-1.0/quantjourney_bidask/edge.py +174 -0
  15. quantjourney_bidask-1.0/quantjourney_bidask/edge_expanding.py +51 -0
  16. quantjourney_bidask-1.0/quantjourney_bidask/edge_hft.py +126 -0
  17. quantjourney_bidask-1.0/quantjourney_bidask/edge_rolling.py +99 -0
  18. {quantjourney_bidask-0.9.3 → quantjourney_bidask-1.0}/quantjourney_bidask.egg-info/SOURCES.txt +6 -9
  19. quantjourney_bidask-0.9.3/data/fetch.py +0 -258
  20. quantjourney_bidask-0.9.3/examples/animated_spread_monitor.py +0 -301
  21. quantjourney_bidask-0.9.3/examples/liquidity_risk_monitor.py +0 -72
  22. quantjourney_bidask-0.9.3/examples/spread_estimator.py +0 -153
  23. quantjourney_bidask-0.9.3/examples/spread_monitor.py +0 -208
  24. quantjourney_bidask-0.9.3/examples/stock_liquidity_risk.py +0 -47
  25. quantjourney_bidask-0.9.3/examples/visualization.py +0 -142
  26. quantjourney_bidask-0.9.3/quantjourney_bidask/__init__.py +0 -8
  27. quantjourney_bidask-0.9.3/quantjourney_bidask/_version.py +0 -7
  28. quantjourney_bidask-0.9.3/quantjourney_bidask/data_fetcher.py +0 -160
  29. quantjourney_bidask-0.9.3/quantjourney_bidask/edge.py +0 -152
  30. quantjourney_bidask-0.9.3/quantjourney_bidask/edge_expanding.py +0 -65
  31. quantjourney_bidask-0.9.3/quantjourney_bidask/edge_rolling.py +0 -208
  32. quantjourney_bidask-0.9.3/quantjourney_bidask/websocket_fetcher.py +0 -308
  33. {quantjourney_bidask-0.9.3 → quantjourney_bidask-1.0}/CHANGELOG.md +0 -0
  34. {quantjourney_bidask-0.9.3 → quantjourney_bidask-1.0}/LICENSE +0 -0
  35. {quantjourney_bidask-0.9.3 → quantjourney_bidask-1.0}/MANIFEST.in +0 -0
  36. {quantjourney_bidask-0.9.3 → quantjourney_bidask-1.0}/docs/usage_examples.ipynb +0 -0
  37. {quantjourney_bidask-0.9.3 → quantjourney_bidask-1.0}/requirements.txt +0 -0
  38. {quantjourney_bidask-0.9.3 → quantjourney_bidask-1.0}/setup.cfg +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantjourney-bidask
3
- Version: 0.9.3
3
+ Version: 1.0
4
4
  Summary: Efficient bid-ask spread estimator from OHLC prices
5
5
  Author-email: Jakub Polec <jakub@quantjourney.pro>
6
- License-Expression: MIT
6
+ License: MIT
7
7
  Project-URL: Homepage, https://github.com/QuantJourneyOrg/qj_bidask
8
8
  Project-URL: Repository, https://github.com/QuantJourneyOrg/qj_bidask
9
9
  Project-URL: Bug Tracker, https://github.com/QuantJourneyOrg/qj_bidask/issues
@@ -41,9 +41,13 @@ Dynamic: license-file
41
41
 
42
42
  # QuantJourney Bid-Ask Spread Estimator
43
43
 
44
- ![PyPI](https://img.shields.io/pypi/v/quantjourney-bidask)
45
- ![License](https://img.shields.io/github/license/quantjourney/bidask)
46
- ![Tests](https://img.shields.io/github/workflow/status/quantjourney/bidask/Test)
44
+ ![Build Status](https://github.com/QuantJourneyOrg/qj_bidask/actions/workflows/test.yml/badge.svg)
45
+ [![PyPi Version](https://img.shields.io/pypi/v/quantjourney-bidask.svg)](https://pypi.org/project/quantjourney-bidask/)
46
+ [![Python Versions](https://img.shields.io/pypi/pyversions/quantjourney-bidask.svg)](https://pypi.org/project/quantjourney-bidask/)
47
+ [![Downloads](https://pepy.tech/badge/quantjourney-bidask)](https://pepy.tech/project/quantjourney-bidask)
48
+ [![License](https://img.shields.io/github/license/QuantJourneyOrg/qj_bidask.svg)](https://github.com/QuantJourneyOrg/qj_bidask/blob/main/LICENSE)
49
+ [![GitHub Stars](https://img.shields.io/github/stars/QuantJourneyOrg/qj_bidask?style=social)](https://github.com/QuantJourneyOrg/qj_bidask)
50
+
47
51
 
48
52
  The `quantjourney-bidask` library provides an efficient estimator for calculating bid-ask spreads from open, high, low, and close (OHLC) prices, based on the methodology described in:
49
53
 
@@ -51,6 +55,8 @@ The `quantjourney-bidask` library provides an efficient estimator for calculatin
51
55
 
52
56
  This library is designed for quantitative finance professionals, researchers, and traders who need accurate and computationally efficient spread estimates for equities, cryptocurrencies, and other assets.
53
57
 
58
+ 🚀 **Part of the [QuantJourney](https://quantjourney.substack.com/) ecosystem** - The framework with advanced quantitative finance tools and insights!
59
+
54
60
  ## Features
55
61
 
56
62
  - **Efficient Spread Estimation**: Implements the EDGE estimator for single, rolling, and expanding windows.
@@ -62,6 +68,62 @@ This library is designed for quantitative finance professionals, researchers, an
62
68
  - **Comprehensive Tests**: Extensive unit tests with known test cases from the original paper.
63
69
  - **Clear Documentation**: Detailed docstrings and usage examples.
64
70
 
71
+ ## Examples and Visualizations
72
+
73
+ The package includes comprehensive examples with beautiful visualizations:
74
+
75
+ ### Spread Monitor Results
76
+ ![Spread Monitor](https://raw.githubusercontent.com/QuantJourneyOrg/qj_bidask/refs/heads/main/_output/spread_monitor_results.png)
77
+
78
+ ### Basic Data Analysis
79
+ ![Crypto Spread Analysis](https://raw.githubusercontent.com/QuantJourneyOrg/qj_bidask/ad49bd78c82ab1c44561d0f2e707ae304575a147/_output/crypto_spread_comprehensive_analysis.png)
80
+
81
+ ### Crypto Spread Comparison
82
+ ![Crypto Spread Comparison](https://raw.githubusercontent.com/QuantJourneyOrg/qj_bidask/refs/heads/main/_output/crypto_spread_comparison.png)
83
+
84
+ ## FAQ
85
+
86
+ ### What exactly does the estimator compute?
87
+ The estimator returns the root mean square effective spread over the sample period. This quantifies the average transaction cost implied by bid-ask spreads, based on open, high, low, and close (OHLC) prices.
88
+
89
+ ### What is unique about this implementation?
90
+ This package includes a heavily optimized and enhanced implementation of the estimator proposed by Ardia, Guidotti, and Kroencke (2024). It features:
91
+
92
+ - Robust numerical handling of non-positive or missing prices
93
+ - Floating-point-safe comparisons using configurable epsilon
94
+ - Vectorized log-return computations for faster evaluation
95
+ - Improved error detection and early exits for invalid OHLC structures
96
+ - Efficient rolling and expanding spread estimators
97
+
98
+ These improvements make the estimator suitable for large-scale usage in backtesting, live monitoring, and production pipelines.
99
+
100
+ ### What is the minimum number of observations?
101
+ At least 3 valid observations are required.
102
+
103
+ ### How should I choose the window size or frequency?
104
+ Short windows (e.g. a few days) reflect local spread conditions but may be noisy. Longer windows (e.g. 1 year) reduce variance but smooth over changes. For intraday use, minute-level frequency is recommended if the asset trades frequently.
105
+
106
+ **Rule of thumb**: ensure on average ≥2 trades per interval.
107
+
108
+ ### Can I use intraday or tick data?
109
+ Yes — the estimator supports intraday OHLC data directly. For tick data, resample into OHLC format first (e.g., using pandas resample).
110
+
111
+ ### What if I get NaN results?
112
+ The estimator may return NaN if:
113
+
114
+ - Input prices are inconsistent (e.g. high < low)
115
+ - There are too many missing or invalid values
116
+ - Probability thresholds are not met (e.g. insufficient variance in prices)
117
+ - Spread variance is non-positive
118
+
119
+ In these cases, re-examine your input or adjust the sampling frequency.
120
+
121
+ ### What's the difference between edge() and edge_rolling()?
122
+ - `edge()` computes a point estimate over a static sample.
123
+ - `edge_rolling()` computes rolling window estimates, optimized for speed.
124
+
125
+ Both use the same core logic and yield identical results on valid, complete data.
126
+
65
127
  ## Installation
66
128
 
67
129
  Install the library via pip:
@@ -178,10 +240,13 @@ monitor.start_monitoring("1m")
178
240
 
179
241
  ```python
180
242
  # Run the real-time dashboard
181
- python examples/realtime_spread_monitor.py --mode dashboard
243
+ python examples/websocket_realtime_demo.py --mode dashboard
244
+
245
+ # Or console mode
246
+ python examples/websocket_realtime_demo.py --mode console
182
247
 
183
- # Or console mode
184
- python examples/realtime_spread_monitor.py --mode console
248
+ # Quick 30-second BTC websocket demo
249
+ python examples/animated_spread_monitor.py
185
250
  ```
186
251
 
187
252
  ## Project Structure
@@ -190,42 +255,32 @@ python examples/realtime_spread_monitor.py --mode console
190
255
  quantjourney_bidask/
191
256
  ├── quantjourney_bidask/ # Main library code
192
257
  │ ├── __init__.py
193
- │ ├── edge.py # Core EDGE estimator
258
+ │ ├── edge.py # Core EDGE estimator
259
+ │ ├── edge_hft.py # EDGE estimator optimised HFT-version
194
260
  │ ├── edge_rolling.py # Rolling window estimation
195
261
  │ └── edge_expanding.py # Expanding window estimation
196
262
  ├── data/
197
263
  │ └── fetch.py # Simplified data fetcher for examples
198
264
  ├── examples/ # Comprehensive usage examples
199
265
  │ ├── simple_data_example.py # Basic usage demonstration
200
- │ ├── spread_estimator.py # Spread estimation examples
266
+ │ ├── basic_spread_estimation.py # Core spread estimation examples
201
267
  │ ├── animated_spread_monitor.py # Animated visualizations
202
268
  │ ├── crypto_spread_comparison.py # Crypto spread analysis
203
269
  │ ├── liquidity_risk_monitor.py # Risk monitoring
204
- │ ├── realtime_spread_monitor.py # Live monitoring dashboard
205
- │ └── stock_liquidity_risk.py # Stock liquidity analysis
270
+ │ ├── websocket_realtime_demo.py # Live websocket monitoring demo
271
+ │ └── threshold_alert_monitor.py # Threshold-based spread alerts
206
272
  ├── tests/ # Unit tests (GitHub only)
207
273
  │ ├── test_edge.py
208
274
  │ ├── test_edge_rolling.py
275
+ │ └── test_edge_expanding.py
209
276
  │ └── test_data_fetcher.py
277
+ │ └── testestimators.py
210
278
  └── _output/ # Example output images
211
279
  ├── simple_data_example.png
212
280
  ├── crypto_spread_comparison.png
213
281
  └── spread_estimator_results.png
214
282
  ```
215
283
 
216
- ## Examples and Visualizations
217
-
218
- The package includes comprehensive examples with beautiful visualizations:
219
-
220
- ### Basic Data Analysis
221
- ![Crypto Spread Analysis](https://raw.githubusercontent.com/QuantJourneyOrg/qj_bidask/ad49bd78c82ab1c44561d0f2e707ae304575a147/_output/crypto_spread_comprehensive_analysis.png)
222
-
223
- ### Crypto Spread Comparison
224
- ![Crypto Spread Comparison](https://raw.githubusercontent.com/QuantJourneyOrg/qj_bidask/refs/heads/main/_output/crypto_spread_comparison.png)
225
-
226
- ### Spread Estimation Results
227
- ![Spread Estimator Results](https://raw.githubusercontent.com/QuantJourneyOrg/qj_bidask/refs/heads/main/_output/spread_estimator_results.png)
228
-
229
284
  ### Running Examples
230
285
 
231
286
  After installing via pip, examples are included in the package:
@@ -250,19 +305,20 @@ Or clone the repository for full access to examples and tests:
250
305
  git clone https://github.com/QuantJourneyOrg/qj_bidask
251
306
  cd qj_bidask
252
307
  python examples/simple_data_example.py
253
- python examples/spread_estimator.py
308
+ python examples/basic_spread_estimation.py
309
+ python examples/animated_spread_monitor.py # 30s real BTC websocket demo
254
310
  python examples/crypto_spread_comparison.py
255
311
  ```
256
312
 
257
313
  ### Available Examples
258
314
 
259
315
  - **`simple_data_example.py`** - Basic usage with stock and crypto data
260
- - **`spread_estimator.py`** - Core spread estimation functionality
261
- - **`animated_spread_monitor.py`** - Real-time animated visualizations
262
- - **`crypto_spread_comparison.py`** - Multi-asset crypto analysis
316
+ - **`basic_spread_estimation.py`** - Core spread estimation functionality
317
+ - **`animated_spread_monitor.py`** - Real-time animated visualizations with 30s websocket demo
318
+ - **`crypto_spread_comparison.py`** - Multi-asset crypto analysis and comparison
263
319
  - **`liquidity_risk_monitor.py`** - Risk monitoring and alerts
264
- - **`realtime_spread_monitor.py`** - Live websocket monitoring dashboard
265
- - **`stock_liquidity_risk.py`** - Stock-specific liquidity analysis
320
+ - **`websocket_realtime_demo.py`** - Live websocket monitoring dashboard
321
+ - **`threshold_alert_monitor.py`** - Threshold-based spread alerts and monitoring
266
322
 
267
323
  ## Testing and Development
268
324
 
@@ -297,7 +353,8 @@ python -m pytest tests/test_data_fetcher.py -v
297
353
 
298
354
  # Run examples
299
355
  python examples/simple_data_example.py
300
- python examples/spread_estimator.py
356
+ python examples/basic_spread_estimation.py
357
+ python examples/animated_spread_monitor.py # Real BTC websocket demo
301
358
  ```
302
359
 
303
360
  ### Package vs Repository
@@ -312,9 +369,9 @@ python examples/spread_estimator.py
312
369
  - `edge_rolling(df, window, min_periods=None)`: Rolling window estimation
313
370
  - `edge_expanding(df, min_periods=3)`: Expanding window estimation
314
371
 
315
- ### Data Fetching (`data/fetch.py`)
372
+ ### Data Fetching (`data/fetch.py`) - Examples & Demos
316
373
 
317
- - `DataFetcher()`: Main data fetcher class
374
+ - `DataFetcher()`: Simplified data fetcher class for examples
318
375
  - `get_stock_data(ticker, period, interval)`: Fetch stock data from Yahoo Finance
319
376
  - `get_crypto_data(symbol, exchange, timeframe, limit)`: Fetch crypto data via CCXT (async)
320
377
  - `stream_btc_data(duration_seconds)`: Stream BTC data via websocket (async)
@@ -370,7 +427,8 @@ pip install -e ".[dev]"
370
427
  pytest
371
428
 
372
429
  # Run examples
373
- python examples/realtime_spread_monitor.py
430
+ python examples/animated_spread_monitor.py # 30s real BTC websocket demo
431
+ python examples/websocket_realtime_demo.py # Full dashboard
374
432
  ```
375
433
 
376
434
  ## Support
@@ -1,8 +1,12 @@
1
1
  # QuantJourney Bid-Ask Spread Estimator
2
2
 
3
- ![PyPI](https://img.shields.io/pypi/v/quantjourney-bidask)
4
- ![License](https://img.shields.io/github/license/quantjourney/bidask)
5
- ![Tests](https://img.shields.io/github/workflow/status/quantjourney/bidask/Test)
3
+ ![Build Status](https://github.com/QuantJourneyOrg/qj_bidask/actions/workflows/test.yml/badge.svg)
4
+ [![PyPi Version](https://img.shields.io/pypi/v/quantjourney-bidask.svg)](https://pypi.org/project/quantjourney-bidask/)
5
+ [![Python Versions](https://img.shields.io/pypi/pyversions/quantjourney-bidask.svg)](https://pypi.org/project/quantjourney-bidask/)
6
+ [![Downloads](https://pepy.tech/badge/quantjourney-bidask)](https://pepy.tech/project/quantjourney-bidask)
7
+ [![License](https://img.shields.io/github/license/QuantJourneyOrg/qj_bidask.svg)](https://github.com/QuantJourneyOrg/qj_bidask/blob/main/LICENSE)
8
+ [![GitHub Stars](https://img.shields.io/github/stars/QuantJourneyOrg/qj_bidask?style=social)](https://github.com/QuantJourneyOrg/qj_bidask)
9
+
6
10
 
7
11
  The `quantjourney-bidask` library provides an efficient estimator for calculating bid-ask spreads from open, high, low, and close (OHLC) prices, based on the methodology described in:
8
12
 
@@ -10,6 +14,8 @@ The `quantjourney-bidask` library provides an efficient estimator for calculatin
10
14
 
11
15
  This library is designed for quantitative finance professionals, researchers, and traders who need accurate and computationally efficient spread estimates for equities, cryptocurrencies, and other assets.
12
16
 
17
+ 🚀 **Part of the [QuantJourney](https://quantjourney.substack.com/) ecosystem** - The framework with advanced quantitative finance tools and insights!
18
+
13
19
  ## Features
14
20
 
15
21
  - **Efficient Spread Estimation**: Implements the EDGE estimator for single, rolling, and expanding windows.
@@ -21,6 +27,62 @@ This library is designed for quantitative finance professionals, researchers, an
21
27
  - **Comprehensive Tests**: Extensive unit tests with known test cases from the original paper.
22
28
  - **Clear Documentation**: Detailed docstrings and usage examples.
23
29
 
30
+ ## Examples and Visualizations
31
+
32
+ The package includes comprehensive examples with beautiful visualizations:
33
+
34
+ ### Spread Monitor Results
35
+ ![Spread Monitor](https://raw.githubusercontent.com/QuantJourneyOrg/qj_bidask/refs/heads/main/_output/spread_monitor_results.png)
36
+
37
+ ### Basic Data Analysis
38
+ ![Crypto Spread Analysis](https://raw.githubusercontent.com/QuantJourneyOrg/qj_bidask/ad49bd78c82ab1c44561d0f2e707ae304575a147/_output/crypto_spread_comprehensive_analysis.png)
39
+
40
+ ### Crypto Spread Comparison
41
+ ![Crypto Spread Comparison](https://raw.githubusercontent.com/QuantJourneyOrg/qj_bidask/refs/heads/main/_output/crypto_spread_comparison.png)
42
+
43
+ ## FAQ
44
+
45
+ ### What exactly does the estimator compute?
46
+ The estimator returns the root mean square effective spread over the sample period. This quantifies the average transaction cost implied by bid-ask spreads, based on open, high, low, and close (OHLC) prices.
47
+
48
+ ### What is unique about this implementation?
49
+ This package includes a heavily optimized and enhanced implementation of the estimator proposed by Ardia, Guidotti, and Kroencke (2024). It features:
50
+
51
+ - Robust numerical handling of non-positive or missing prices
52
+ - Floating-point-safe comparisons using configurable epsilon
53
+ - Vectorized log-return computations for faster evaluation
54
+ - Improved error detection and early exits for invalid OHLC structures
55
+ - Efficient rolling and expanding spread estimators
56
+
57
+ These improvements make the estimator suitable for large-scale usage in backtesting, live monitoring, and production pipelines.
58
+
59
+ ### What is the minimum number of observations?
60
+ At least 3 valid observations are required.
61
+
62
+ ### How should I choose the window size or frequency?
63
+ Short windows (e.g. a few days) reflect local spread conditions but may be noisy. Longer windows (e.g. 1 year) reduce variance but smooth over changes. For intraday use, minute-level frequency is recommended if the asset trades frequently.
64
+
65
+ **Rule of thumb**: ensure on average ≥2 trades per interval.
66
+
67
+ ### Can I use intraday or tick data?
68
+ Yes — the estimator supports intraday OHLC data directly. For tick data, resample into OHLC format first (e.g., using pandas resample).
69
+
70
+ ### What if I get NaN results?
71
+ The estimator may return NaN if:
72
+
73
+ - Input prices are inconsistent (e.g. high < low)
74
+ - There are too many missing or invalid values
75
+ - Probability thresholds are not met (e.g. insufficient variance in prices)
76
+ - Spread variance is non-positive
77
+
78
+ In these cases, re-examine your input or adjust the sampling frequency.
79
+
80
+ ### What's the difference between edge() and edge_rolling()?
81
+ - `edge()` computes a point estimate over a static sample.
82
+ - `edge_rolling()` computes rolling window estimates, optimized for speed.
83
+
84
+ Both use the same core logic and yield identical results on valid, complete data.
85
+
24
86
  ## Installation
25
87
 
26
88
  Install the library via pip:
@@ -137,10 +199,13 @@ monitor.start_monitoring("1m")
137
199
 
138
200
  ```python
139
201
  # Run the real-time dashboard
140
- python examples/realtime_spread_monitor.py --mode dashboard
202
+ python examples/websocket_realtime_demo.py --mode dashboard
203
+
204
+ # Or console mode
205
+ python examples/websocket_realtime_demo.py --mode console
141
206
 
142
- # Or console mode
143
- python examples/realtime_spread_monitor.py --mode console
207
+ # Quick 30-second BTC websocket demo
208
+ python examples/animated_spread_monitor.py
144
209
  ```
145
210
 
146
211
  ## Project Structure
@@ -149,42 +214,32 @@ python examples/realtime_spread_monitor.py --mode console
149
214
  quantjourney_bidask/
150
215
  ├── quantjourney_bidask/ # Main library code
151
216
  │ ├── __init__.py
152
- │ ├── edge.py # Core EDGE estimator
217
+ │ ├── edge.py # Core EDGE estimator
218
+ │ ├── edge_hft.py # EDGE estimator optimised HFT-version
153
219
  │ ├── edge_rolling.py # Rolling window estimation
154
220
  │ └── edge_expanding.py # Expanding window estimation
155
221
  ├── data/
156
222
  │ └── fetch.py # Simplified data fetcher for examples
157
223
  ├── examples/ # Comprehensive usage examples
158
224
  │ ├── simple_data_example.py # Basic usage demonstration
159
- │ ├── spread_estimator.py # Spread estimation examples
225
+ │ ├── basic_spread_estimation.py # Core spread estimation examples
160
226
  │ ├── animated_spread_monitor.py # Animated visualizations
161
227
  │ ├── crypto_spread_comparison.py # Crypto spread analysis
162
228
  │ ├── liquidity_risk_monitor.py # Risk monitoring
163
- │ ├── realtime_spread_monitor.py # Live monitoring dashboard
164
- │ └── stock_liquidity_risk.py # Stock liquidity analysis
229
+ │ ├── websocket_realtime_demo.py # Live websocket monitoring demo
230
+ │ └── threshold_alert_monitor.py # Threshold-based spread alerts
165
231
  ├── tests/ # Unit tests (GitHub only)
166
232
  │ ├── test_edge.py
167
233
  │ ├── test_edge_rolling.py
234
+ │ └── test_edge_expanding.py
168
235
  │ └── test_data_fetcher.py
236
+ │ └── testestimators.py
169
237
  └── _output/ # Example output images
170
238
  ├── simple_data_example.png
171
239
  ├── crypto_spread_comparison.png
172
240
  └── spread_estimator_results.png
173
241
  ```
174
242
 
175
- ## Examples and Visualizations
176
-
177
- The package includes comprehensive examples with beautiful visualizations:
178
-
179
- ### Basic Data Analysis
180
- ![Crypto Spread Analysis](https://raw.githubusercontent.com/QuantJourneyOrg/qj_bidask/ad49bd78c82ab1c44561d0f2e707ae304575a147/_output/crypto_spread_comprehensive_analysis.png)
181
-
182
- ### Crypto Spread Comparison
183
- ![Crypto Spread Comparison](https://raw.githubusercontent.com/QuantJourneyOrg/qj_bidask/refs/heads/main/_output/crypto_spread_comparison.png)
184
-
185
- ### Spread Estimation Results
186
- ![Spread Estimator Results](https://raw.githubusercontent.com/QuantJourneyOrg/qj_bidask/refs/heads/main/_output/spread_estimator_results.png)
187
-
188
243
  ### Running Examples
189
244
 
190
245
  After installing via pip, examples are included in the package:
@@ -209,19 +264,20 @@ Or clone the repository for full access to examples and tests:
209
264
  git clone https://github.com/QuantJourneyOrg/qj_bidask
210
265
  cd qj_bidask
211
266
  python examples/simple_data_example.py
212
- python examples/spread_estimator.py
267
+ python examples/basic_spread_estimation.py
268
+ python examples/animated_spread_monitor.py # 30s real BTC websocket demo
213
269
  python examples/crypto_spread_comparison.py
214
270
  ```
215
271
 
216
272
  ### Available Examples
217
273
 
218
274
  - **`simple_data_example.py`** - Basic usage with stock and crypto data
219
- - **`spread_estimator.py`** - Core spread estimation functionality
220
- - **`animated_spread_monitor.py`** - Real-time animated visualizations
221
- - **`crypto_spread_comparison.py`** - Multi-asset crypto analysis
275
+ - **`basic_spread_estimation.py`** - Core spread estimation functionality
276
+ - **`animated_spread_monitor.py`** - Real-time animated visualizations with 30s websocket demo
277
+ - **`crypto_spread_comparison.py`** - Multi-asset crypto analysis and comparison
222
278
  - **`liquidity_risk_monitor.py`** - Risk monitoring and alerts
223
- - **`realtime_spread_monitor.py`** - Live websocket monitoring dashboard
224
- - **`stock_liquidity_risk.py`** - Stock-specific liquidity analysis
279
+ - **`websocket_realtime_demo.py`** - Live websocket monitoring dashboard
280
+ - **`threshold_alert_monitor.py`** - Threshold-based spread alerts and monitoring
225
281
 
226
282
  ## Testing and Development
227
283
 
@@ -256,7 +312,8 @@ python -m pytest tests/test_data_fetcher.py -v
256
312
 
257
313
  # Run examples
258
314
  python examples/simple_data_example.py
259
- python examples/spread_estimator.py
315
+ python examples/basic_spread_estimation.py
316
+ python examples/animated_spread_monitor.py # Real BTC websocket demo
260
317
  ```
261
318
 
262
319
  ### Package vs Repository
@@ -271,9 +328,9 @@ python examples/spread_estimator.py
271
328
  - `edge_rolling(df, window, min_periods=None)`: Rolling window estimation
272
329
  - `edge_expanding(df, min_periods=3)`: Expanding window estimation
273
330
 
274
- ### Data Fetching (`data/fetch.py`)
331
+ ### Data Fetching (`data/fetch.py`) - Examples & Demos
275
332
 
276
- - `DataFetcher()`: Main data fetcher class
333
+ - `DataFetcher()`: Simplified data fetcher class for examples
277
334
  - `get_stock_data(ticker, period, interval)`: Fetch stock data from Yahoo Finance
278
335
  - `get_crypto_data(symbol, exchange, timeframe, limit)`: Fetch crypto data via CCXT (async)
279
336
  - `stream_btc_data(duration_seconds)`: Stream BTC data via websocket (async)
@@ -329,7 +386,8 @@ pip install -e ".[dev]"
329
386
  pytest
330
387
 
331
388
  # Run examples
332
- python examples/realtime_spread_monitor.py
389
+ python examples/animated_spread_monitor.py # 30s real BTC websocket demo
390
+ python examples/websocket_realtime_demo.py # Full dashboard
333
391
  ```
334
392
 
335
393
  ## Support