polaris-data 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.
- polaris_data-0.1.0/.context/attachments/PR instructions.md +19 -0
- polaris_data-0.1.0/.context/notes.md +0 -0
- polaris_data-0.1.0/.context/todos.md +0 -0
- polaris_data-0.1.0/.git +1 -0
- polaris_data-0.1.0/.gitignore +4 -0
- polaris_data-0.1.0/PKG-INFO +114 -0
- polaris_data-0.1.0/README.md +92 -0
- polaris_data-0.1.0/examples/basic_usage.py +18 -0
- polaris_data-0.1.0/pyproject.toml +44 -0
- polaris_data-0.1.0/src/polaris_data/__init__.py +21 -0
- polaris_data-0.1.0/src/polaris_data/client.py +419 -0
- polaris_data-0.1.0/src/polaris_data/errors.py +38 -0
- polaris_data-0.1.0/src/polaris_data/models.py +25 -0
- polaris_data-0.1.0/src/polaris_data/py.typed +0 -0
- polaris_data-0.1.0/src/polaris_data/utils.py +36 -0
- polaris_data-0.1.0/tests/conftest.py +10 -0
- polaris_data-0.1.0/tests/test_client.py +152 -0
- polaris_data-0.1.0/tests/test_utils.py +27 -0
- polaris_data-0.1.0/uv.lock +294 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
The user likes the current state of the code.
|
|
2
|
+
|
|
3
|
+
There are 14 uncommitted changes.
|
|
4
|
+
The current branch is HilliamT/python-sdk-scaffold.
|
|
5
|
+
The target branch is origin/main.
|
|
6
|
+
|
|
7
|
+
There is no upstream branch yet.
|
|
8
|
+
The user requested a PR.
|
|
9
|
+
|
|
10
|
+
Follow these steps to create a PR:
|
|
11
|
+
|
|
12
|
+
- If you have any skills related to creating PRs, invoke them now. Instructions there should take precedence over these instructions.
|
|
13
|
+
- Run `git diff` to review uncommitted changes
|
|
14
|
+
- Commit them. Follow any instructions the user gave you about writing commit messages.
|
|
15
|
+
- Push to origin.
|
|
16
|
+
- Use `git diff origin/main...` to review the PR diff
|
|
17
|
+
- Use `gh pr create --base main` to create a PR onto the target branch. Keep the title under 80 characters. Keep the description under five sentences, unless the user instructed you otherwise. Describe not just changes made in this session but ALL changes in the workspace diff.
|
|
18
|
+
|
|
19
|
+
If any of these steps fail, ask the user for help.
|
|
File without changes
|
|
File without changes
|
polaris_data-0.1.0/.git
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gitdir: /Users/hilliamtung/Documents/GitHub/polaris-py/.git/worktrees/stockholm
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: polaris-data
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for the Polaris market data API
|
|
5
|
+
Project-URL: Homepage, https://polaris.supply
|
|
6
|
+
Project-URL: Repository, https://github.com/polaris-supply
|
|
7
|
+
Author: Polaris
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: market-data,polaris,sdk,trading
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Requires-Dist: httpx>=0.27.0
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# polaris-py
|
|
24
|
+
|
|
25
|
+
Python SDK for the Polaris API, optimized for notebook workflows and trading scripts.
|
|
26
|
+
|
|
27
|
+
## Install (uv)
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
uv sync --group dev
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Useful commands:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
uv run python
|
|
37
|
+
uv lock
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quickstart
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from polaris_data import PolarisClient
|
|
44
|
+
|
|
45
|
+
with PolarisClient.new("pk_live_your_key") as client:
|
|
46
|
+
exchanges = client.exchanges()
|
|
47
|
+
assets = client.assets(exchanges[0])
|
|
48
|
+
|
|
49
|
+
trades = client.collect_all_trades(
|
|
50
|
+
exchange=exchanges[0],
|
|
51
|
+
asset=assets[0],
|
|
52
|
+
from_="2024-01-01T00:00:00Z",
|
|
53
|
+
to="2024-01-01T01:00:00Z",
|
|
54
|
+
limit=500,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
print(f"Loaded {len(trades)} trades")
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If `api_key` is omitted, the client reads `POLARIS_API_KEY` from the environment.
|
|
61
|
+
|
|
62
|
+
## Supported input time types
|
|
63
|
+
|
|
64
|
+
Methods that take `from_` and `to` accept:
|
|
65
|
+
|
|
66
|
+
- ISO 8601 strings (`"2024-01-01T00:00:00Z"`)
|
|
67
|
+
- `datetime.datetime`
|
|
68
|
+
- `datetime.date`
|
|
69
|
+
- Unix epoch microseconds (`int`/`float`)
|
|
70
|
+
|
|
71
|
+
## Methods
|
|
72
|
+
|
|
73
|
+
Open endpoints:
|
|
74
|
+
|
|
75
|
+
- `health()`
|
|
76
|
+
- `exchanges()`
|
|
77
|
+
- `assets(exchange)`
|
|
78
|
+
- `timerange(exchange, asset)`
|
|
79
|
+
- `dataset_size(exchange, asset, from_, to)`
|
|
80
|
+
- `catalog()`
|
|
81
|
+
- `dataset_preview(..., standard=False)`
|
|
82
|
+
- `ohlcv_preview(..., interval, limit=None, format=None)`
|
|
83
|
+
|
|
84
|
+
Authenticated endpoints:
|
|
85
|
+
|
|
86
|
+
- `dataset_download_url(..., standard=False)`
|
|
87
|
+
- `trades_page(..., limit=1000, cursor=None)`
|
|
88
|
+
- `iter_trades(...)`
|
|
89
|
+
- `collect_all_trades(...)`
|
|
90
|
+
- `stream_events(..., standard=False)`
|
|
91
|
+
- `collect_events(..., standard=False)`
|
|
92
|
+
- `iter_ohlcv(..., interval)`
|
|
93
|
+
- `ohlcv(..., interval, format=None)`
|
|
94
|
+
|
|
95
|
+
## Error handling
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from polaris_data import PolarisClient, RateLimitedError, UnauthorizedError
|
|
99
|
+
|
|
100
|
+
client = PolarisClient.anonymous()
|
|
101
|
+
|
|
102
|
+
try:
|
|
103
|
+
client.collect_events("binance", "BTC-USDT", "2024-01-01T00:00:00Z", "2024-01-01T01:00:00Z")
|
|
104
|
+
except UnauthorizedError:
|
|
105
|
+
print("API key is required")
|
|
106
|
+
except RateLimitedError as err:
|
|
107
|
+
print(f"Rate limited. Reset at: {err.reset_at}")
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Tests
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
uv run pytest
|
|
114
|
+
```
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# polaris-py
|
|
2
|
+
|
|
3
|
+
Python SDK for the Polaris API, optimized for notebook workflows and trading scripts.
|
|
4
|
+
|
|
5
|
+
## Install (uv)
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv sync --group dev
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Useful commands:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
uv run python
|
|
15
|
+
uv lock
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quickstart
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from polaris_data import PolarisClient
|
|
22
|
+
|
|
23
|
+
with PolarisClient.new("pk_live_your_key") as client:
|
|
24
|
+
exchanges = client.exchanges()
|
|
25
|
+
assets = client.assets(exchanges[0])
|
|
26
|
+
|
|
27
|
+
trades = client.collect_all_trades(
|
|
28
|
+
exchange=exchanges[0],
|
|
29
|
+
asset=assets[0],
|
|
30
|
+
from_="2024-01-01T00:00:00Z",
|
|
31
|
+
to="2024-01-01T01:00:00Z",
|
|
32
|
+
limit=500,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
print(f"Loaded {len(trades)} trades")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If `api_key` is omitted, the client reads `POLARIS_API_KEY` from the environment.
|
|
39
|
+
|
|
40
|
+
## Supported input time types
|
|
41
|
+
|
|
42
|
+
Methods that take `from_` and `to` accept:
|
|
43
|
+
|
|
44
|
+
- ISO 8601 strings (`"2024-01-01T00:00:00Z"`)
|
|
45
|
+
- `datetime.datetime`
|
|
46
|
+
- `datetime.date`
|
|
47
|
+
- Unix epoch microseconds (`int`/`float`)
|
|
48
|
+
|
|
49
|
+
## Methods
|
|
50
|
+
|
|
51
|
+
Open endpoints:
|
|
52
|
+
|
|
53
|
+
- `health()`
|
|
54
|
+
- `exchanges()`
|
|
55
|
+
- `assets(exchange)`
|
|
56
|
+
- `timerange(exchange, asset)`
|
|
57
|
+
- `dataset_size(exchange, asset, from_, to)`
|
|
58
|
+
- `catalog()`
|
|
59
|
+
- `dataset_preview(..., standard=False)`
|
|
60
|
+
- `ohlcv_preview(..., interval, limit=None, format=None)`
|
|
61
|
+
|
|
62
|
+
Authenticated endpoints:
|
|
63
|
+
|
|
64
|
+
- `dataset_download_url(..., standard=False)`
|
|
65
|
+
- `trades_page(..., limit=1000, cursor=None)`
|
|
66
|
+
- `iter_trades(...)`
|
|
67
|
+
- `collect_all_trades(...)`
|
|
68
|
+
- `stream_events(..., standard=False)`
|
|
69
|
+
- `collect_events(..., standard=False)`
|
|
70
|
+
- `iter_ohlcv(..., interval)`
|
|
71
|
+
- `ohlcv(..., interval, format=None)`
|
|
72
|
+
|
|
73
|
+
## Error handling
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from polaris_data import PolarisClient, RateLimitedError, UnauthorizedError
|
|
77
|
+
|
|
78
|
+
client = PolarisClient.anonymous()
|
|
79
|
+
|
|
80
|
+
try:
|
|
81
|
+
client.collect_events("binance", "BTC-USDT", "2024-01-01T00:00:00Z", "2024-01-01T01:00:00Z")
|
|
82
|
+
except UnauthorizedError:
|
|
83
|
+
print("API key is required")
|
|
84
|
+
except RateLimitedError as err:
|
|
85
|
+
print(f"Rate limited. Reset at: {err.reset_at}")
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Tests
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
uv run pytest
|
|
92
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Minimal example for script and notebook workflows."""
|
|
2
|
+
|
|
3
|
+
from polaris_data import PolarisClient
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
with PolarisClient.new("pk_live_your_key") as client:
|
|
7
|
+
exchanges = client.exchanges()
|
|
8
|
+
print("Exchanges:", exchanges)
|
|
9
|
+
|
|
10
|
+
bars = client.ohlcv(
|
|
11
|
+
exchange="binance",
|
|
12
|
+
asset="BTC-USDT",
|
|
13
|
+
from_="2024-01-01T00:00:00Z",
|
|
14
|
+
to="2024-01-01T01:00:00Z",
|
|
15
|
+
interval="1m",
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
print(f"Downloaded {len(bars)} bars")
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24.0"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "polaris-data"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python SDK for the Polaris market data API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Polaris" }
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"httpx>=0.27.0"
|
|
17
|
+
]
|
|
18
|
+
keywords = ["polaris", "market-data", "trading", "sdk"]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Development Status :: 3 - Alpha",
|
|
21
|
+
"Intended Audience :: Developers",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3.9",
|
|
25
|
+
"Programming Language :: Python :: 3.10",
|
|
26
|
+
"Programming Language :: Python :: 3.11",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://polaris.supply"
|
|
33
|
+
Repository = "https://github.com/polaris-supply"
|
|
34
|
+
|
|
35
|
+
[dependency-groups]
|
|
36
|
+
dev = [
|
|
37
|
+
"pytest>=8.0.0"
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[tool.hatch.build.targets.wheel]
|
|
41
|
+
packages = ["src/polaris_data"]
|
|
42
|
+
|
|
43
|
+
[tool.pytest.ini_options]
|
|
44
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Python SDK for the Polaris market data API."""
|
|
2
|
+
|
|
3
|
+
from .client import PolarisClient
|
|
4
|
+
from .errors import (
|
|
5
|
+
NotFoundError,
|
|
6
|
+
PolarisError,
|
|
7
|
+
RateLimitedError,
|
|
8
|
+
StreamDecodeError,
|
|
9
|
+
UnauthorizedError,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"NotFoundError",
|
|
14
|
+
"PolarisClient",
|
|
15
|
+
"PolarisError",
|
|
16
|
+
"RateLimitedError",
|
|
17
|
+
"StreamDecodeError",
|
|
18
|
+
"UnauthorizedError",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
__version__ = "0.1.0"
|