dataquery-sdk 0.0.8__tar.gz → 0.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 (32) hide show
  1. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/CHANGELOG.md +4 -1
  2. dataquery_sdk-0.1.0/PKG-INFO +507 -0
  3. dataquery_sdk-0.1.0/README.md +438 -0
  4. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/__init__.py +1 -1
  5. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/cli.py +55 -1
  6. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/client.py +207 -399
  7. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/config.py +4 -4
  8. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/dataquery.py +81 -41
  9. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/models.py +136 -11
  10. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/rate_limiter.py +61 -3
  11. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/utils.py +242 -49
  12. dataquery_sdk-0.1.0/dataquery_sdk.egg-info/PKG-INFO +507 -0
  13. dataquery_sdk-0.0.8/PKG-INFO +0 -996
  14. dataquery_sdk-0.0.8/README.md +0 -927
  15. dataquery_sdk-0.0.8/dataquery_sdk.egg-info/PKG-INFO +0 -996
  16. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/CONTRIBUTING.md +0 -0
  17. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/LICENSE +0 -0
  18. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/MANIFEST.in +0 -0
  19. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/auth.py +0 -0
  20. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/auto_download.py +0 -0
  21. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/connection_pool.py +0 -0
  22. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/exceptions.py +0 -0
  23. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/logging_config.py +0 -0
  24. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/py.typed +0 -0
  25. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery/retry.py +0 -0
  26. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery_sdk.egg-info/SOURCES.txt +0 -0
  27. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery_sdk.egg-info/dependency_links.txt +0 -0
  28. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery_sdk.egg-info/entry_points.txt +0 -0
  29. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery_sdk.egg-info/requires.txt +0 -0
  30. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/dataquery_sdk.egg-info/top_level.txt +0 -0
  31. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/pyproject.toml +0 -0
  32. {dataquery_sdk-0.0.8 → dataquery_sdk-0.1.0}/setup.cfg +0 -0
@@ -13,4 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
13
  - Comprehensive test suite with coverage reporting
14
14
  ## [0.0.8] - 2025-10-21
15
15
  - Made label and expression parameters optional in attribute api response
16
-
16
+ ## [0.0.9] - 2025-12-09
17
+ - Perfomance optimizations
18
+ ## [0.1.0] - 2025-12-10
19
+ Time serires data made optional
@@ -0,0 +1,507 @@
1
+ Metadata-Version: 2.4
2
+ Name: dataquery-sdk
3
+ Version: 0.1.0
4
+ Summary: Python SDK for DATAQUERY Data API - Query, download, and check availability of economic data files
5
+ Author-email: DATAQUERY SDK Team <support@dataquery.com>
6
+ Project-URL: Homepage, https://github.com/dataquery/dataquery-sdk
7
+ Project-URL: Bug Tracker, https://github.com/dataquery/dataquery-sdk/issues
8
+ Project-URL: Documentation, https://github.com/dataquery/dataquery-sdk/wiki
9
+ Project-URL: Source Code, https://github.com/dataquery/dataquery-sdk
10
+ Keywords: dataquery,data,api,economic,financial,download,async,oauth,rate-limiting,sdk
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Financial and Insurance Industry
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: Office/Business :: Financial
24
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
25
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: aiohttp<4.0.0,>=3.8.0
30
+ Requires-Dist: pydantic<3.0.0,>=2.0.0
31
+ Requires-Dist: structlog>=23.0.0
32
+ Requires-Dist: python-dotenv>=1.0.0
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
35
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
36
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
37
+ Requires-Dist: black>=23.0.0; extra == "dev"
38
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
39
+ Requires-Dist: mypy>=1.5.0; extra == "dev"
40
+ Requires-Dist: isort>=5.12.0; extra == "dev"
41
+ Requires-Dist: pre-commit>=3.0.0; extra == "dev"
42
+ Requires-Dist: pip-audit>=2.7.0; extra == "dev"
43
+ Requires-Dist: build>=1.3.0; extra == "dev"
44
+ Requires-Dist: twine>=4.0.0; extra == "dev"
45
+ Provides-Extra: docs
46
+ Requires-Dist: mkdocs>=1.5.0; extra == "docs"
47
+ Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
48
+ Requires-Dist: mkdocstrings[python]>=0.24.0; extra == "docs"
49
+ Requires-Dist: mike>=1.1.0; extra == "docs"
50
+ Provides-Extra: pandas
51
+ Requires-Dist: pandas>=2.0.0; extra == "pandas"
52
+ Provides-Extra: all
53
+ Requires-Dist: pytest>=7.0.0; extra == "all"
54
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "all"
55
+ Requires-Dist: pytest-cov>=4.0.0; extra == "all"
56
+ Requires-Dist: black>=23.0.0; extra == "all"
57
+ Requires-Dist: flake8>=6.0.0; extra == "all"
58
+ Requires-Dist: mypy>=1.5.0; extra == "all"
59
+ Requires-Dist: isort>=5.12.0; extra == "all"
60
+ Requires-Dist: pre-commit>=3.0.0; extra == "all"
61
+ Requires-Dist: mkdocs>=1.5.0; extra == "all"
62
+ Requires-Dist: mkdocs-material>=9.0.0; extra == "all"
63
+ Requires-Dist: mkdocstrings[python]>=0.24.0; extra == "all"
64
+ Requires-Dist: mike>=1.1.0; extra == "all"
65
+ Requires-Dist: pandas>=2.0.0; extra == "all"
66
+ Requires-Dist: pip-audit>=2.7.0; extra == "all"
67
+ Requires-Dist: build>=1.3.0; extra == "all"
68
+ Dynamic: license-file
69
+
70
+ # DataQuery SDK
71
+
72
+ Professional Python SDK for the DataQuery API - High-performance data access with parallel downloads, time series queries, and seamless OAuth 2.0 authentication.
73
+
74
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
75
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
76
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
77
+
78
+ ## Features
79
+
80
+ - **High-Performance Downloads**: Parallel file downloads with automatic retry and progress tracking
81
+ - **Time Series Queries**: Query data by expressions, instruments, or groups with flexible filtering
82
+ - **OAuth 2.0 Authentication**: Automatic token management and refresh
83
+ - **Connection Pooling**: Optimized HTTP connections with configurable rate limiting
84
+ - **Pandas Integration**: Direct conversion to DataFrames for analysis
85
+ - **Async & Sync APIs**: Use async/await or synchronous methods based on your needs
86
+
87
+ ## Installation
88
+
89
+ ```bash
90
+ pip install dataquery-sdk
91
+ ```
92
+
93
+ ## Quick Start
94
+
95
+ ### 1. Configure Credentials
96
+
97
+ Set your API credentials as environment variables:
98
+
99
+ ```bash
100
+ export DATAQUERY_CLIENT_ID="your_client_id"
101
+ export DATAQUERY_CLIENT_SECRET="your_client_secret"
102
+ ```
103
+
104
+ Or create a `.env` file in your project directory:
105
+
106
+ ```env
107
+ DATAQUERY_CLIENT_ID=your_client_id
108
+ DATAQUERY_CLIENT_SECRET=your_client_secret
109
+ ```
110
+
111
+ ### 2. Download Files
112
+
113
+ **Synchronous (Python Scripts)**
114
+
115
+ ```python
116
+ from dataquery import DataQuery
117
+
118
+ # Download all files for a date range
119
+ with DataQuery() as dq:
120
+ results = dq.run_group_download(
121
+ group_id="JPMAQS_GENERIC_RETURNS",
122
+ start_date="20250101",
123
+ end_date="20250131",
124
+ destination_dir="./data"
125
+ )
126
+ print(f"Downloaded {results['successful_downloads']} files")
127
+ ```
128
+
129
+ **Asynchronous (Jupyter Notebooks)**
130
+
131
+ ```python
132
+ from dataquery import DataQuery
133
+
134
+ # Download all files for a date range
135
+ async with DataQuery() as dq:
136
+ results = await dq.run_group_download_async(
137
+ group_id="JPMAQS_GENERIC_RETURNS",
138
+ start_date="20250101",
139
+ end_date="20250131",
140
+ destination_dir="./data"
141
+ )
142
+ print(f"Downloaded {results['successful_downloads']} files")
143
+ ```
144
+
145
+ ### 3. Query Time Series Data
146
+
147
+ ```python
148
+ from dataquery import DataQuery
149
+
150
+ async with DataQuery() as dq:
151
+ # Query by expression
152
+ result = await dq.get_expressions_time_series_async(
153
+ expressions=["DB(MTE,IRISH EUR 1.100 15-May-2029 LON,,IE00BH3SQ895,MIDPRC)"],
154
+ start_date="20240101",
155
+ end_date="20240131"
156
+ )
157
+
158
+ # Convert to pandas DataFrame
159
+ df = dq.to_dataframe(result)
160
+ print(df.head())
161
+ ```
162
+
163
+ ### 4. Discover Available Data
164
+
165
+ ```python
166
+ from dataquery import DataQuery
167
+
168
+ async with DataQuery() as dq:
169
+ # List all available groups
170
+ groups = await dq.list_groups_async(limit=100)
171
+
172
+ # Convert to DataFrame for easy viewing
173
+ groups_df = dq.to_dataframe(groups)
174
+ print(groups_df[['group_id', 'group_name', 'description']])
175
+ ```
176
+
177
+ ## Common Use Cases
178
+
179
+ ### Download Single File
180
+
181
+ ```python
182
+ from dataquery import DataQuery
183
+ from pathlib import Path
184
+
185
+ async with DataQuery() as dq:
186
+ result = await dq.download_file_async(
187
+ file_group_id="JPMAQS_GENERIC_RETURNS",
188
+ file_datetime="20250115",
189
+ destination_path=Path("./downloads")
190
+ )
191
+ print(f"Downloaded: {result.local_path}")
192
+ ```
193
+
194
+ ### Query with Filters
195
+
196
+ ```python
197
+ async with DataQuery() as dq:
198
+ # Get time series for Ireland bonds only
199
+ result = await dq.get_group_time_series_async(
200
+ group_id="FI_GO_BO_EA",
201
+ attributes=["MIDPRC", "REPO_1M"],
202
+ filter="country(IRL)",
203
+ start_date="20240101",
204
+ end_date="20240131"
205
+ )
206
+
207
+ df = dq.to_dataframe(result)
208
+ ```
209
+
210
+ ### Search for Instruments
211
+
212
+ ```python
213
+ async with DataQuery() as dq:
214
+ # Search for instruments by keywords
215
+ results = await dq.search_instruments_async(
216
+ group_id="FI_GO_BO_EA",
217
+ keywords="irish"
218
+ )
219
+
220
+ # Use the results to query time series
221
+ instrument_ids = [inst.instrument_id for inst in results.instruments[:5]]
222
+ data = await dq.get_instrument_time_series_async(
223
+ instruments=instrument_ids,
224
+ attributes=["MIDPRC"],
225
+ start_date="20240101",
226
+ end_date="20240131"
227
+ )
228
+ ```
229
+
230
+ ## Performance Optimization
231
+
232
+ ### Parallel Downloads
233
+
234
+ ```python
235
+ async with DataQuery() as dq:
236
+ # Download multiple files concurrently with parallel chunks
237
+ results = await dq.run_group_download_async(
238
+ group_id="JPMAQS_GENERIC_RETURNS",
239
+ start_date="20250101",
240
+ end_date="20250131",
241
+ destination_dir="./data",
242
+ max_concurrent=5, # Download 5 files simultaneously
243
+ num_parts=4 # Split each file into 4 parallel chunks
244
+ )
245
+ ```
246
+
247
+ **Recommended Settings:**
248
+ - `max_concurrent`: 3-5 (concurrent file downloads)
249
+ - `num_parts`: 2-8 (parallel chunks per file)
250
+
251
+ ### Rate Limiting
252
+
253
+ Configure rate limits to avoid API throttling:
254
+
255
+ ```python
256
+ from dataquery import DataQuery, ClientConfig
257
+
258
+ config = ClientConfig(
259
+ client_id="your_client_id",
260
+ client_secret="your_client_secret",
261
+ rate_limit_rpm=300, # Requests per minute
262
+ max_retries=3,
263
+ timeout=60.0
264
+ )
265
+
266
+ async with DataQuery(config=config) as dq:
267
+ # Your code here
268
+ pass
269
+ ```
270
+
271
+ ## Configuration
272
+
273
+ ### Environment Variables
274
+
275
+ ```bash
276
+ # Required
277
+ DATAQUERY_CLIENT_ID=your_client_id
278
+ DATAQUERY_CLIENT_SECRET=your_client_secret
279
+
280
+ # Optional - API Endpoints
281
+ DATAQUERY_BASE_URL=https://api-developer.jpmorgan.com
282
+ DATAQUERY_FILES_BASE_URL=https://api-strm-gw01.jpmchase.com
283
+
284
+ # Optional - Performance
285
+ DATAQUERY_MAX_RETRIES=3
286
+ DATAQUERY_TIMEOUT=60
287
+ DATAQUERY_RATE_LIMIT_RPM=300
288
+ ```
289
+
290
+ ### Programmatic Configuration
291
+
292
+ ```python
293
+ from dataquery import DataQuery, ClientConfig
294
+
295
+ config = ClientConfig(
296
+ client_id="your_client_id",
297
+ client_secret="your_client_secret",
298
+ base_url="https://api-developer.jpmorgan.com",
299
+ max_retries=3,
300
+ timeout=60.0,
301
+ rate_limit_rpm=300
302
+ )
303
+
304
+ async with DataQuery(config=config) as dq:
305
+ # Your code here
306
+ pass
307
+ ```
308
+
309
+ ## Error Handling
310
+
311
+ ```python
312
+ from dataquery import DataQuery
313
+ from dataquery.exceptions import (
314
+ DataQueryError,
315
+ AuthenticationError,
316
+ NotFoundError,
317
+ RateLimitError
318
+ )
319
+
320
+ async def safe_query():
321
+ try:
322
+ async with DataQuery() as dq:
323
+ result = await dq.get_expressions_time_series_async(
324
+ expressions=["DB(...)"],
325
+ start_date="20240101",
326
+ end_date="20240131"
327
+ )
328
+ return result
329
+ except AuthenticationError as e:
330
+ print(f"Authentication failed: {e}")
331
+ except NotFoundError as e:
332
+ print(f"Resource not found: {e}")
333
+ except RateLimitError as e:
334
+ print(f"Rate limit exceeded: {e}")
335
+ except DataQueryError as e:
336
+ print(f"API error: {e}")
337
+ except Exception as e:
338
+ print(f"Unexpected error: {e}")
339
+ ```
340
+
341
+ ## Date Formats
342
+
343
+ ### Absolute Dates
344
+
345
+ ```python
346
+ start_date="20240101" # YYYYMMDD format
347
+ end_date="20241231"
348
+ ```
349
+
350
+ ### Relative Dates
351
+
352
+ ```python
353
+ start_date="TODAY" # Today
354
+ start_date="TODAY-1D" # Yesterday
355
+ start_date="TODAY-1W" # 1 week ago
356
+ start_date="TODAY-1M" # 1 month ago
357
+ start_date="TODAY-1Y" # 1 year ago
358
+ ```
359
+
360
+ ## Calendar Conventions
361
+
362
+ | Calendar | Description | Use Case |
363
+ |----------|-------------|----------|
364
+ | `CAL_WEEKDAYS` | Monday-Friday | International data (recommended) |
365
+ | `CAL_USBANK` | US banking days | US-only data (default) |
366
+ | `CAL_WEEKDAY_NOHOLIDAY` | All weekdays | Generic business days |
367
+ | `CAL_DEFAULT` | Calendar day | Include weekends |
368
+
369
+ ## Examples
370
+
371
+ The `examples/` directory contains comprehensive examples:
372
+
373
+ - **File Downloads**: Single file, batch downloads, availability checks
374
+ - **Time Series**: Expressions, instruments, groups with filters
375
+ - **Discovery**: Search instruments, list groups, get attributes
376
+ - **Advanced**: Grid data, auto-download, custom progress tracking
377
+
378
+ Run an example:
379
+
380
+ ```bash
381
+ python examples/files/download_file.py
382
+ python examples/expressions/get_expressions_time_series.py
383
+ ```
384
+
385
+ ## CLI Usage
386
+
387
+ The SDK includes a command-line interface:
388
+
389
+ ```bash
390
+ # Download files
391
+ dataquery download --group-id JPMAQS_GENERIC_RETURNS \
392
+ --start-date 20250101 \
393
+ --end-date 20250131 \
394
+ --destination ./data
395
+
396
+ # List groups
397
+ dataquery list-groups --limit 100
398
+
399
+ # Check file availability
400
+ dataquery check-availability --file-group-id JPMAQS_GENERIC_RETURNS \
401
+ --date 20250115
402
+ ```
403
+
404
+ ## API Reference
405
+
406
+ ### Core Methods
407
+
408
+ **File Downloads**
409
+ - `download_file_async()` - Download a single file
410
+ - `run_group_download_async()` - Download all files in a date range
411
+ - `list_available_files_async()` - Check file availability
412
+
413
+ **Time Series Queries**
414
+ - `get_expressions_time_series_async()` - Query by expression
415
+ - `get_instrument_time_series_async()` - Query by instrument ID
416
+ - `get_group_time_series_async()` - Query entire group with filters
417
+
418
+ **Discovery**
419
+ - `list_groups_async()` - List available data groups
420
+ - `search_instruments_async()` - Search for instruments
421
+ - `list_instruments_async()` - List all instruments in a group
422
+ - `get_group_attributes_async()` - Get available attributes
423
+ - `get_group_filters_async()` - Get available filters
424
+
425
+ **Utilities**
426
+ - `to_dataframe()` - Convert any response to pandas DataFrame
427
+ - `health_check_async()` - Check API health
428
+ - `get_stats()` - Get connection and rate limit statistics
429
+
430
+ For detailed API documentation, see the [API Reference](docs/api/README.md).
431
+
432
+ ## Requirements
433
+
434
+ - Python 3.10 or higher
435
+ - Dependencies:
436
+ - `aiohttp>=3.8.0` - Async HTTP client
437
+ - `pydantic>=2.0.0` - Data validation
438
+ - `structlog>=23.0.0` - Structured logging
439
+ - `python-dotenv>=1.0.0` - Environment variable management
440
+
441
+ Optional:
442
+ - `pandas>=2.0.0` - For DataFrame conversion
443
+
444
+ ## Development
445
+
446
+ ### Setup Development Environment
447
+
448
+ ```bash
449
+ # Clone the repository
450
+ git clone https://github.com/dataquery/dataquery-sdk.git
451
+ cd dataquery-sdk
452
+
453
+ # Create virtual environment
454
+ python -m venv .venv
455
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
456
+
457
+ # Install development dependencies
458
+ pip install -e ".[dev]"
459
+
460
+ # Install pre-commit hooks
461
+ pre-commit install
462
+ ```
463
+
464
+ ### Run Tests
465
+
466
+ ```bash
467
+ # Run all tests
468
+ pytest tests/ -v
469
+
470
+ # Run with coverage
471
+ pytest tests/ --cov=dataquery --cov-report=html
472
+
473
+ # Run specific test file
474
+ pytest tests/test_client.py -v
475
+ ```
476
+
477
+ ### Code Quality
478
+
479
+ ```bash
480
+ # Format code
481
+ black dataquery/ tests/
482
+
483
+ # Check linting
484
+ flake8 dataquery/ tests/ examples/
485
+
486
+ # Type checking
487
+ mypy dataquery/
488
+ ```
489
+
490
+ ## Contributing
491
+
492
+ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
493
+
494
+ ## License
495
+
496
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
497
+
498
+ ## Support
499
+
500
+ For issues and questions:
501
+ - **GitHub Issues**: [Report a bug](https://github.com/dataquery/dataquery-sdk/issues)
502
+ - **Documentation**: [Read the docs](https://github.com/dataquery/dataquery-sdk/wiki)
503
+ - **Email**: support@dataquery.com
504
+
505
+ ## Changelog
506
+
507
+ See [CHANGELOG.md](CHANGELOG.md) for version history and release notes.