alphainfo 1.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.
- alphainfo-1.0.0/.gitignore +59 -0
- alphainfo-1.0.0/LICENSE +21 -0
- alphainfo-1.0.0/MANIFEST.in +5 -0
- alphainfo-1.0.0/PKG-INFO +248 -0
- alphainfo-1.0.0/README.md +202 -0
- alphainfo-1.0.0/alphainfo/__init__.py +72 -0
- alphainfo-1.0.0/alphainfo/client.py +883 -0
- alphainfo-1.0.0/alphainfo/exceptions.py +61 -0
- alphainfo-1.0.0/alphainfo/models.py +315 -0
- alphainfo-1.0.0/alphainfo/py.typed +0 -0
- alphainfo-1.0.0/alphainfo.egg-info/PKG-INFO +248 -0
- alphainfo-1.0.0/alphainfo.egg-info/SOURCES.txt +21 -0
- alphainfo-1.0.0/alphainfo.egg-info/dependency_links.txt +1 -0
- alphainfo-1.0.0/alphainfo.egg-info/requires.txt +8 -0
- alphainfo-1.0.0/alphainfo.egg-info/top_level.txt +1 -0
- alphainfo-1.0.0/examples/__init__.py +8 -0
- alphainfo-1.0.0/examples/async_example.py +95 -0
- alphainfo-1.0.0/examples/error_handling.py +143 -0
- alphainfo-1.0.0/examples/quickstart.py +121 -0
- alphainfo-1.0.0/pyproject.toml +79 -0
- alphainfo-1.0.0/setup.cfg +4 -0
- alphainfo-1.0.0/setup.py +65 -0
- alphainfo-1.0.0/tests/test_sdk.py +409 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
|
|
27
|
+
# PyInstaller
|
|
28
|
+
*.manifest
|
|
29
|
+
*.spec
|
|
30
|
+
|
|
31
|
+
# Unit test / coverage reports
|
|
32
|
+
htmlcov/
|
|
33
|
+
.tox/
|
|
34
|
+
.coverage
|
|
35
|
+
.coverage.*
|
|
36
|
+
.cache
|
|
37
|
+
nosetests.xml
|
|
38
|
+
coverage.xml
|
|
39
|
+
*.cover
|
|
40
|
+
.hypothesis/
|
|
41
|
+
.pytest_cache/
|
|
42
|
+
|
|
43
|
+
# Virtual environments
|
|
44
|
+
venv/
|
|
45
|
+
ENV/
|
|
46
|
+
env/
|
|
47
|
+
|
|
48
|
+
# IDE
|
|
49
|
+
.vscode/
|
|
50
|
+
.idea/
|
|
51
|
+
*.swp
|
|
52
|
+
*.swo
|
|
53
|
+
*~
|
|
54
|
+
.DS_Store
|
|
55
|
+
|
|
56
|
+
# Environment variables
|
|
57
|
+
.env
|
|
58
|
+
.env.local
|
|
59
|
+
.env.*.local
|
alphainfo-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 QGI Quantum Systems LTDA
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
alphainfo-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: alphainfo
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python client for alphainfo.io — Structural Regime Detection API
|
|
5
|
+
Home-page: https://github.com/alphainfo-io/python-sdk
|
|
6
|
+
Author: alphainfo.io
|
|
7
|
+
Author-email: "alphainfo.io" <support@alphainfo.io>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://alphainfo.io
|
|
10
|
+
Project-URL: Documentation, https://alphainfo.io/docs
|
|
11
|
+
Project-URL: Repository, https://github.com/alphainfo-io/python-sdk
|
|
12
|
+
Project-URL: Changelog, https://alphainfo.io/changelog
|
|
13
|
+
Keywords: alphainfo,structural-analysis,regime-detection,time-series,anomaly-detection,signal-processing
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
17
|
+
Classifier: Intended Audience :: Science/Research
|
|
18
|
+
Classifier: Intended Audience :: Healthcare Industry
|
|
19
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
20
|
+
Classifier: Operating System :: OS Independent
|
|
21
|
+
Classifier: Programming Language :: Python
|
|
22
|
+
Classifier: Programming Language :: Python :: 3
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
29
|
+
Classifier: Topic :: Scientific/Engineering
|
|
30
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
31
|
+
Classifier: Typing :: Typed
|
|
32
|
+
Requires-Python: >=3.8
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
License-File: LICENSE
|
|
35
|
+
Requires-Dist: httpx>=0.25.0
|
|
36
|
+
Provides-Extra: dev
|
|
37
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
38
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
39
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
40
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
41
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
42
|
+
Dynamic: author
|
|
43
|
+
Dynamic: home-page
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
Dynamic: requires-python
|
|
46
|
+
|
|
47
|
+
# alphainfo
|
|
48
|
+
|
|
49
|
+
**Python client for the [alphainfo](https://alphainfo.io) Structural Intelligence API.**
|
|
50
|
+
|
|
51
|
+
Detect structural regime changes in time series — biomedical signals, financial markets, energy grids, seismic data, IoT sensors, and more. No model training required.
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from alphainfo import AlphaInfo
|
|
55
|
+
|
|
56
|
+
client = AlphaInfo(api_key="ai_your_key")
|
|
57
|
+
result = client.analyze(signal=ecg_data, sampling_rate=360.0, domain="biomedical")
|
|
58
|
+
|
|
59
|
+
print(result.confidence_band) # 'stable', 'transition', or 'unstable'
|
|
60
|
+
print(result.structural_score) # 0.0 to 1.0
|
|
61
|
+
print(result.analysis_id) # UUID for audit trail
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install alphainfo
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Requires Python 3.8+. Only dependency: [httpx](https://www.python-httpx.org/).
|
|
71
|
+
|
|
72
|
+
## Quick Start
|
|
73
|
+
|
|
74
|
+
### 1. Get your API key
|
|
75
|
+
|
|
76
|
+
Sign up at [alphainfo.io/register](https://alphainfo.io/register) — free tier includes 50 analyses/month.
|
|
77
|
+
|
|
78
|
+
### 2. Analyze a signal
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from alphainfo import AlphaInfo
|
|
82
|
+
|
|
83
|
+
client = AlphaInfo(api_key="ai_your_key")
|
|
84
|
+
|
|
85
|
+
# Any time series: ECG, market prices, sensor readings, power grid...
|
|
86
|
+
result = client.analyze(
|
|
87
|
+
signal=[1.2, 1.3, 1.1, 2.8, 3.1, 3.0, ...],
|
|
88
|
+
sampling_rate=250.0,
|
|
89
|
+
domain="biomedical",
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
if result.change_detected:
|
|
93
|
+
print(f"Regime change detected! Band: {result.confidence_band}")
|
|
94
|
+
print(f"Structural score: {result.structural_score:.3f}")
|
|
95
|
+
print(f"Audit ID: {result.analysis_id}")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 3. Analyze market data
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
# The API fetches market data automatically
|
|
102
|
+
market = client.analyze_market("AAPL", interval="1d")
|
|
103
|
+
print(f"AAPL regime: {market.confidence_band}")
|
|
104
|
+
print(f"Score: {market.structural_score:.3f}")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 4. Batch analysis
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
# Analyze up to 100 signals in one call
|
|
111
|
+
batch = client.analyze_batch(
|
|
112
|
+
signals=[signal_1, signal_2, signal_3],
|
|
113
|
+
sampling_rate=1000.0,
|
|
114
|
+
domain="sensors",
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
for item in batch.results:
|
|
118
|
+
if item.success:
|
|
119
|
+
print(f"Signal {item.index}: {item.confidence_band} ({item.structural_score:.3f})")
|
|
120
|
+
else:
|
|
121
|
+
print(f"Signal {item.index}: error — {item.error}")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 5. Multi-channel (vector) analysis
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
# Multi-lead ECG, multi-axis accelerometer, etc.
|
|
128
|
+
vector = client.analyze_vector(
|
|
129
|
+
channels={
|
|
130
|
+
"lead_I": ecg_lead_1,
|
|
131
|
+
"lead_II": ecg_lead_2,
|
|
132
|
+
"lead_III": ecg_lead_3,
|
|
133
|
+
},
|
|
134
|
+
sampling_rate=360.0,
|
|
135
|
+
domain="biomedical",
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
print(f"Aggregated score: {vector.structural_score:.3f}")
|
|
139
|
+
for name, ch in vector.channels.items():
|
|
140
|
+
print(f" {name}: {ch.confidence_band}")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 6. Audit trail
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
# Replay any past analysis
|
|
147
|
+
replay = client.audit_replay("550e8400-e29b-41d4-a716-446655440000")
|
|
148
|
+
print(f"Original score: {replay.output['structural_score']}")
|
|
149
|
+
|
|
150
|
+
# List recent analyses
|
|
151
|
+
history = client.audit_list(limit=10)
|
|
152
|
+
for entry in history:
|
|
153
|
+
print(f"{entry.analysis_id} — {entry.structural_score}")
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Async Support
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from alphainfo import AsyncAlphaInfo
|
|
160
|
+
|
|
161
|
+
async with AsyncAlphaInfo(api_key="ai_your_key") as client:
|
|
162
|
+
result = await client.analyze(signal=data, sampling_rate=250.0)
|
|
163
|
+
market = await client.analyze_market("BTC-USD")
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
All methods available on `AlphaInfo` are also available on `AsyncAlphaInfo`.
|
|
167
|
+
|
|
168
|
+
## Error Handling
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from alphainfo import AlphaInfo, AuthError, RateLimitError, ValidationError
|
|
172
|
+
|
|
173
|
+
client = AlphaInfo(api_key="ai_your_key")
|
|
174
|
+
|
|
175
|
+
try:
|
|
176
|
+
result = client.analyze(signal=data, sampling_rate=250.0)
|
|
177
|
+
except AuthError:
|
|
178
|
+
print("Invalid API key")
|
|
179
|
+
except RateLimitError as e:
|
|
180
|
+
print(f"Rate limited. Retry after {e.retry_after}s")
|
|
181
|
+
except ValidationError as e:
|
|
182
|
+
print(f"Invalid input: {e.message}")
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Exception hierarchy:**
|
|
186
|
+
|
|
187
|
+
| Exception | HTTP Code | When |
|
|
188
|
+
|-----------|-----------|------|
|
|
189
|
+
| `AuthError` | 401 | Invalid or missing API key |
|
|
190
|
+
| `ValidationError` | 400, 413 | Bad input or signal too large |
|
|
191
|
+
| `RateLimitError` | 429 | Quota or concurrency limit exceeded |
|
|
192
|
+
| `NotFoundError` | 404 | Analysis ID not found (audit) |
|
|
193
|
+
| `APIError` | 5xx | Server error |
|
|
194
|
+
| `TimeoutError` | — | Request timed out after retries |
|
|
195
|
+
| `NetworkError` | — | Connection failed |
|
|
196
|
+
|
|
197
|
+
All inherit from `AlphaInfoError`.
|
|
198
|
+
|
|
199
|
+
## Configuration
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
client = AlphaInfo(
|
|
203
|
+
api_key="ai_your_key",
|
|
204
|
+
base_url="https://alphainfo.io", # default
|
|
205
|
+
timeout=30.0, # seconds (default)
|
|
206
|
+
max_retries=3, # automatic retry on transient errors
|
|
207
|
+
)
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
The client automatically retries on:
|
|
211
|
+
- Network timeouts and connection errors
|
|
212
|
+
- HTTP 429 (rate limits) — respects `Retry-After` header
|
|
213
|
+
- HTTP 5xx (server errors)
|
|
214
|
+
|
|
215
|
+
Non-retryable errors (401, 400, 404) are raised immediately.
|
|
216
|
+
|
|
217
|
+
## Rate Limit Info
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
result = client.analyze(signal=data, sampling_rate=250.0)
|
|
221
|
+
info = client.rate_limit_info
|
|
222
|
+
if info:
|
|
223
|
+
print(f"Remaining: {info.remaining}/{info.limit}")
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Domains
|
|
227
|
+
|
|
228
|
+
| Domain | Use case |
|
|
229
|
+
|--------|----------|
|
|
230
|
+
| `generic` | Default — works for any signal |
|
|
231
|
+
| `biomedical` | ECG, EEG, EMG, SpO2 |
|
|
232
|
+
| `finance` | Market prices, returns, volume |
|
|
233
|
+
| `energy` | Power grid frequency, load |
|
|
234
|
+
| `seismic` | Earthquake, vibration sensors |
|
|
235
|
+
| `sensors` | IoT, industrial sensors |
|
|
236
|
+
| `mlops` | Model drift, data quality |
|
|
237
|
+
| `security` | Network traffic, intrusion |
|
|
238
|
+
| `industrial` | Machinery, SCADA |
|
|
239
|
+
|
|
240
|
+
## Links
|
|
241
|
+
|
|
242
|
+
- [API Documentation](https://alphainfo.io/docs)
|
|
243
|
+
- [Benchmarks](https://alphainfo.io/benchmarks)
|
|
244
|
+
- [Dashboard](https://alphainfo.io/dashboard)
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
MIT
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# alphainfo
|
|
2
|
+
|
|
3
|
+
**Python client for the [alphainfo](https://alphainfo.io) Structural Intelligence API.**
|
|
4
|
+
|
|
5
|
+
Detect structural regime changes in time series — biomedical signals, financial markets, energy grids, seismic data, IoT sensors, and more. No model training required.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from alphainfo import AlphaInfo
|
|
9
|
+
|
|
10
|
+
client = AlphaInfo(api_key="ai_your_key")
|
|
11
|
+
result = client.analyze(signal=ecg_data, sampling_rate=360.0, domain="biomedical")
|
|
12
|
+
|
|
13
|
+
print(result.confidence_band) # 'stable', 'transition', or 'unstable'
|
|
14
|
+
print(result.structural_score) # 0.0 to 1.0
|
|
15
|
+
print(result.analysis_id) # UUID for audit trail
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install alphainfo
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Requires Python 3.8+. Only dependency: [httpx](https://www.python-httpx.org/).
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
### 1. Get your API key
|
|
29
|
+
|
|
30
|
+
Sign up at [alphainfo.io/register](https://alphainfo.io/register) — free tier includes 50 analyses/month.
|
|
31
|
+
|
|
32
|
+
### 2. Analyze a signal
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from alphainfo import AlphaInfo
|
|
36
|
+
|
|
37
|
+
client = AlphaInfo(api_key="ai_your_key")
|
|
38
|
+
|
|
39
|
+
# Any time series: ECG, market prices, sensor readings, power grid...
|
|
40
|
+
result = client.analyze(
|
|
41
|
+
signal=[1.2, 1.3, 1.1, 2.8, 3.1, 3.0, ...],
|
|
42
|
+
sampling_rate=250.0,
|
|
43
|
+
domain="biomedical",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
if result.change_detected:
|
|
47
|
+
print(f"Regime change detected! Band: {result.confidence_band}")
|
|
48
|
+
print(f"Structural score: {result.structural_score:.3f}")
|
|
49
|
+
print(f"Audit ID: {result.analysis_id}")
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 3. Analyze market data
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
# The API fetches market data automatically
|
|
56
|
+
market = client.analyze_market("AAPL", interval="1d")
|
|
57
|
+
print(f"AAPL regime: {market.confidence_band}")
|
|
58
|
+
print(f"Score: {market.structural_score:.3f}")
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 4. Batch analysis
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
# Analyze up to 100 signals in one call
|
|
65
|
+
batch = client.analyze_batch(
|
|
66
|
+
signals=[signal_1, signal_2, signal_3],
|
|
67
|
+
sampling_rate=1000.0,
|
|
68
|
+
domain="sensors",
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
for item in batch.results:
|
|
72
|
+
if item.success:
|
|
73
|
+
print(f"Signal {item.index}: {item.confidence_band} ({item.structural_score:.3f})")
|
|
74
|
+
else:
|
|
75
|
+
print(f"Signal {item.index}: error — {item.error}")
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 5. Multi-channel (vector) analysis
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
# Multi-lead ECG, multi-axis accelerometer, etc.
|
|
82
|
+
vector = client.analyze_vector(
|
|
83
|
+
channels={
|
|
84
|
+
"lead_I": ecg_lead_1,
|
|
85
|
+
"lead_II": ecg_lead_2,
|
|
86
|
+
"lead_III": ecg_lead_3,
|
|
87
|
+
},
|
|
88
|
+
sampling_rate=360.0,
|
|
89
|
+
domain="biomedical",
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
print(f"Aggregated score: {vector.structural_score:.3f}")
|
|
93
|
+
for name, ch in vector.channels.items():
|
|
94
|
+
print(f" {name}: {ch.confidence_band}")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 6. Audit trail
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
# Replay any past analysis
|
|
101
|
+
replay = client.audit_replay("550e8400-e29b-41d4-a716-446655440000")
|
|
102
|
+
print(f"Original score: {replay.output['structural_score']}")
|
|
103
|
+
|
|
104
|
+
# List recent analyses
|
|
105
|
+
history = client.audit_list(limit=10)
|
|
106
|
+
for entry in history:
|
|
107
|
+
print(f"{entry.analysis_id} — {entry.structural_score}")
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Async Support
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from alphainfo import AsyncAlphaInfo
|
|
114
|
+
|
|
115
|
+
async with AsyncAlphaInfo(api_key="ai_your_key") as client:
|
|
116
|
+
result = await client.analyze(signal=data, sampling_rate=250.0)
|
|
117
|
+
market = await client.analyze_market("BTC-USD")
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
All methods available on `AlphaInfo` are also available on `AsyncAlphaInfo`.
|
|
121
|
+
|
|
122
|
+
## Error Handling
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from alphainfo import AlphaInfo, AuthError, RateLimitError, ValidationError
|
|
126
|
+
|
|
127
|
+
client = AlphaInfo(api_key="ai_your_key")
|
|
128
|
+
|
|
129
|
+
try:
|
|
130
|
+
result = client.analyze(signal=data, sampling_rate=250.0)
|
|
131
|
+
except AuthError:
|
|
132
|
+
print("Invalid API key")
|
|
133
|
+
except RateLimitError as e:
|
|
134
|
+
print(f"Rate limited. Retry after {e.retry_after}s")
|
|
135
|
+
except ValidationError as e:
|
|
136
|
+
print(f"Invalid input: {e.message}")
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Exception hierarchy:**
|
|
140
|
+
|
|
141
|
+
| Exception | HTTP Code | When |
|
|
142
|
+
|-----------|-----------|------|
|
|
143
|
+
| `AuthError` | 401 | Invalid or missing API key |
|
|
144
|
+
| `ValidationError` | 400, 413 | Bad input or signal too large |
|
|
145
|
+
| `RateLimitError` | 429 | Quota or concurrency limit exceeded |
|
|
146
|
+
| `NotFoundError` | 404 | Analysis ID not found (audit) |
|
|
147
|
+
| `APIError` | 5xx | Server error |
|
|
148
|
+
| `TimeoutError` | — | Request timed out after retries |
|
|
149
|
+
| `NetworkError` | — | Connection failed |
|
|
150
|
+
|
|
151
|
+
All inherit from `AlphaInfoError`.
|
|
152
|
+
|
|
153
|
+
## Configuration
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
client = AlphaInfo(
|
|
157
|
+
api_key="ai_your_key",
|
|
158
|
+
base_url="https://alphainfo.io", # default
|
|
159
|
+
timeout=30.0, # seconds (default)
|
|
160
|
+
max_retries=3, # automatic retry on transient errors
|
|
161
|
+
)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The client automatically retries on:
|
|
165
|
+
- Network timeouts and connection errors
|
|
166
|
+
- HTTP 429 (rate limits) — respects `Retry-After` header
|
|
167
|
+
- HTTP 5xx (server errors)
|
|
168
|
+
|
|
169
|
+
Non-retryable errors (401, 400, 404) are raised immediately.
|
|
170
|
+
|
|
171
|
+
## Rate Limit Info
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
result = client.analyze(signal=data, sampling_rate=250.0)
|
|
175
|
+
info = client.rate_limit_info
|
|
176
|
+
if info:
|
|
177
|
+
print(f"Remaining: {info.remaining}/{info.limit}")
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Domains
|
|
181
|
+
|
|
182
|
+
| Domain | Use case |
|
|
183
|
+
|--------|----------|
|
|
184
|
+
| `generic` | Default — works for any signal |
|
|
185
|
+
| `biomedical` | ECG, EEG, EMG, SpO2 |
|
|
186
|
+
| `finance` | Market prices, returns, volume |
|
|
187
|
+
| `energy` | Power grid frequency, load |
|
|
188
|
+
| `seismic` | Earthquake, vibration sensors |
|
|
189
|
+
| `sensors` | IoT, industrial sensors |
|
|
190
|
+
| `mlops` | Model drift, data quality |
|
|
191
|
+
| `security` | Network traffic, intrusion |
|
|
192
|
+
| `industrial` | Machinery, SCADA |
|
|
193
|
+
|
|
194
|
+
## Links
|
|
195
|
+
|
|
196
|
+
- [API Documentation](https://alphainfo.io/docs)
|
|
197
|
+
- [Benchmarks](https://alphainfo.io/benchmarks)
|
|
198
|
+
- [Dashboard](https://alphainfo.io/dashboard)
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
MIT
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""
|
|
2
|
+
alphainfo — Python client for the Structural Intelligence API
|
|
3
|
+
|
|
4
|
+
Detect structural regime changes in time series data: biomedical signals,
|
|
5
|
+
financial markets, energy grids, seismic data, IoT sensors, and more.
|
|
6
|
+
|
|
7
|
+
Quick start:
|
|
8
|
+
>>> from alphainfo import AlphaInfo
|
|
9
|
+
>>> client = AlphaInfo(api_key="ai_your_key")
|
|
10
|
+
>>> result = client.analyze(signal=[...], sampling_rate=250.0)
|
|
11
|
+
>>> print(result.confidence_band) # 'stable', 'transition', or 'unstable'
|
|
12
|
+
|
|
13
|
+
Async:
|
|
14
|
+
>>> from alphainfo import AsyncAlphaInfo
|
|
15
|
+
>>> async with AsyncAlphaInfo(api_key="ai_your_key") as client:
|
|
16
|
+
... result = await client.analyze(signal=[...], sampling_rate=250.0)
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from .client import AlphaInfo, AsyncAlphaInfo
|
|
20
|
+
from .models import (
|
|
21
|
+
AnalysisResult,
|
|
22
|
+
AuditReplay,
|
|
23
|
+
AuditSummary,
|
|
24
|
+
BatchItemResult,
|
|
25
|
+
BatchResult,
|
|
26
|
+
ChannelResult,
|
|
27
|
+
HealthStatus,
|
|
28
|
+
MarketResult,
|
|
29
|
+
PlanInfo,
|
|
30
|
+
RateLimitInfo,
|
|
31
|
+
VectorResult,
|
|
32
|
+
)
|
|
33
|
+
from .exceptions import (
|
|
34
|
+
AlphaInfoError,
|
|
35
|
+
APIError,
|
|
36
|
+
AuthError,
|
|
37
|
+
NetworkError,
|
|
38
|
+
NotFoundError,
|
|
39
|
+
RateLimitError,
|
|
40
|
+
TimeoutError,
|
|
41
|
+
ValidationError,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
__version__ = "1.0.0"
|
|
45
|
+
__all__ = [
|
|
46
|
+
# Clients
|
|
47
|
+
"AlphaInfo",
|
|
48
|
+
"AsyncAlphaInfo",
|
|
49
|
+
# Result models
|
|
50
|
+
"AnalysisResult",
|
|
51
|
+
"MarketResult",
|
|
52
|
+
"BatchResult",
|
|
53
|
+
"BatchItemResult",
|
|
54
|
+
"VectorResult",
|
|
55
|
+
"ChannelResult",
|
|
56
|
+
# Audit
|
|
57
|
+
"AuditReplay",
|
|
58
|
+
"AuditSummary",
|
|
59
|
+
# Infrastructure
|
|
60
|
+
"HealthStatus",
|
|
61
|
+
"PlanInfo",
|
|
62
|
+
"RateLimitInfo",
|
|
63
|
+
# Exceptions
|
|
64
|
+
"AlphaInfoError",
|
|
65
|
+
"APIError",
|
|
66
|
+
"AuthError",
|
|
67
|
+
"NetworkError",
|
|
68
|
+
"NotFoundError",
|
|
69
|
+
"RateLimitError",
|
|
70
|
+
"TimeoutError",
|
|
71
|
+
"ValidationError",
|
|
72
|
+
]
|