everestapi 0.1.2__py3-none-any.whl

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.
everestapi/__init__.py ADDED
@@ -0,0 +1,32 @@
1
+ """EverestAPI — Python SDK for the EverestQuant prediction tournament platform."""
2
+
3
+ __version__ = "0.1.2"
4
+
5
+ from everestapi.client import EverestAPI, EverestError
6
+ from everestapi.types import (
7
+ FeatureResponse,
8
+ Instrument,
9
+ LeaderboardEntry,
10
+ LeaderboardResponse,
11
+ Score,
12
+ ScoresResponse,
13
+ StakeBalance,
14
+ StakeResponse,
15
+ Submission,
16
+ UniverseResponse,
17
+ )
18
+
19
+ __all__ = [
20
+ "EverestAPI",
21
+ "EverestError",
22
+ "FeatureResponse",
23
+ "Instrument",
24
+ "LeaderboardEntry",
25
+ "LeaderboardResponse",
26
+ "Score",
27
+ "ScoresResponse",
28
+ "StakeBalance",
29
+ "StakeResponse",
30
+ "Submission",
31
+ "UniverseResponse",
32
+ ]
everestapi/__main__.py ADDED
@@ -0,0 +1,5 @@
1
+ """Allow running as ``python -m everestapi``."""
2
+
3
+ from everestapi.cli import cli
4
+
5
+ cli()
everestapi/cli.py ADDED
@@ -0,0 +1,246 @@
1
+ """EverestAPI CLI — command-line interface for the EverestQuant tournament platform.
2
+
3
+ Usage:
4
+ everestapi health
5
+ everestapi download-data --universe futures --split train
6
+ everestapi submit --model my-model --file predictions.csv
7
+ everestapi leaderboard --period 30d
8
+ everestapi scores --model my-model --days 30
9
+ everestapi rounds --tournament equities
10
+ everestapi credits
11
+ everestapi register --name my-agent --email me@example.com
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import sys
18
+
19
+ import click
20
+
21
+ from everestapi import EverestAPI, EverestError, __version__
22
+
23
+
24
+ def _get_api(api_key: str | None = None) -> EverestAPI:
25
+ return EverestAPI(api_key=api_key or "")
26
+
27
+
28
+ def _print_json(data: dict) -> None:
29
+ click.echo(json.dumps(data, indent=2))
30
+
31
+
32
+ @click.group()
33
+ @click.version_option(__version__, prog_name="everestapi")
34
+ def cli() -> None:
35
+ """EverestQuant tournament CLI."""
36
+
37
+
38
+ @cli.command()
39
+ @click.option("--api-key", envvar="EVEREST_API_KEY", default=None)
40
+ def health(api_key: str | None) -> None:
41
+ """Check API health."""
42
+ api = _get_api(api_key)
43
+ try:
44
+ _print_json(api.health())
45
+ except EverestError as e:
46
+ click.echo(f"Error: {e}", err=True)
47
+ sys.exit(1)
48
+
49
+
50
+ @cli.command("download-data")
51
+ @click.option("--universe", "-u", default="futures", help="Universe (futures/equities)")
52
+ @click.option("--split", "-s", default="train", help="Split (train/validation/test/live)")
53
+ @click.option("--output", "-o", default=None, help="Output file path")
54
+ @click.option("--api-key", envvar="EVEREST_API_KEY", default=None)
55
+ def download_data(universe: str, split: str, output: str | None, api_key: str | None) -> None:
56
+ """Download tournament dataset."""
57
+ api = _get_api(api_key)
58
+ try:
59
+ path = api.download_dataset(universe=universe, split=split, output_path=output)
60
+ click.echo(f"Downloaded to {path}")
61
+ except EverestError as e:
62
+ click.echo(f"Error: {e}", err=True)
63
+ sys.exit(1)
64
+
65
+
66
+ @cli.command("download-benchmark")
67
+ @click.option("--universe", "-u", default="futures")
68
+ @click.option("--split", "-s", default="validation")
69
+ @click.option("--version", "-v", default="v0")
70
+ @click.option("--output", "-o", default=None)
71
+ @click.option("--api-key", envvar="EVEREST_API_KEY", default=None)
72
+ def download_benchmark(universe: str, split: str, version: str, output: str | None, api_key: str | None) -> None:
73
+ """Download benchmark model predictions."""
74
+ api = _get_api(api_key)
75
+ try:
76
+ path = api.download_benchmark(universe=universe, split=split, version=version, output_path=output)
77
+ click.echo(f"Downloaded to {path}")
78
+ except EverestError as e:
79
+ click.echo(f"Error: {e}", err=True)
80
+ sys.exit(1)
81
+
82
+
83
+ @cli.command()
84
+ @click.option("--model", "-m", required=True, help="Model identifier")
85
+ @click.option(
86
+ "--file", "-f", "file_path",
87
+ required=True,
88
+ help="Predictions file (.parquet or .csv). Parquet recommended.",
89
+ )
90
+ @click.option("--tournament", "-t", default="equities", help="Tournament (equities/futures)")
91
+ @click.option("--api-key", envvar="EVEREST_API_KEY", default=None)
92
+ def submit(model: str, file_path: str, tournament: str, api_key: str | None) -> None:
93
+ """Submit predictions from a Parquet or CSV file.
94
+
95
+ Parquet is recommended — float precision round-trips cleanly and uploads are
96
+ smaller. The file must have `ticker` (str) and `score` (float in [-1, 1])
97
+ columns, one row per universe instrument.
98
+ """
99
+ api = _get_api(api_key)
100
+ ext = file_path.rsplit(".", 1)[-1].lower() if "." in file_path else ""
101
+
102
+ try:
103
+ if ext == "parquet":
104
+ result = api.submit_predictions_file(
105
+ model_name=model, file_path=file_path, tournament=tournament,
106
+ )
107
+ elif ext == "csv":
108
+ import csv as _csv
109
+
110
+ with open(file_path) as f:
111
+ rows = list(_csv.DictReader(f))
112
+
113
+ if tournament == "futures":
114
+ preds = {row["instrument_id"]: float(row["prediction"]) for row in rows}
115
+ result = api.submit_futures_predictions(model_id=model, predictions=preds)
116
+ else:
117
+ preds_list = [
118
+ {"ticker": row["ticker"], "score": float(row["score"])}
119
+ for row in rows
120
+ ]
121
+ result = api.submit_predictions(model_id=model, predictions=preds_list)
122
+ else:
123
+ click.echo(
124
+ f"Error: unsupported file extension {ext!r}. Use .parquet or .csv.",
125
+ err=True,
126
+ )
127
+ sys.exit(1)
128
+
129
+ _print_json(result)
130
+ except (EverestError, KeyError, FileNotFoundError) as e:
131
+ click.echo(f"Error: {e}", err=True)
132
+ sys.exit(1)
133
+
134
+
135
+ @cli.command()
136
+ @click.option("--period", "-p", default="30d", help="Period (7d/30d/90d/all)")
137
+ @click.option("--tournament", "-t", default="equities", help="Tournament (equities/futures)")
138
+ @click.option("--api-key", envvar="EVEREST_API_KEY", default=None)
139
+ def leaderboard(period: str, tournament: str, api_key: str | None) -> None:
140
+ """Show tournament leaderboard."""
141
+ api = _get_api(api_key)
142
+ try:
143
+ if tournament == "futures":
144
+ data = api.get_futures_leaderboard(period=period)
145
+ else:
146
+ data = api.get_leaderboard(period=period)
147
+ _print_json(data)
148
+ except EverestError as e:
149
+ click.echo(f"Error: {e}", err=True)
150
+ sys.exit(1)
151
+
152
+
153
+ @cli.command()
154
+ @click.option("--model", "-m", required=True, help="Model identifier")
155
+ @click.option("--days", "-d", default=30, help="Look-back window")
156
+ @click.option("--api-key", envvar="EVEREST_API_KEY", default=None)
157
+ def scores(model: str, days: int, api_key: str | None) -> None:
158
+ """Show scoring results for a model."""
159
+ api = _get_api(api_key)
160
+ try:
161
+ _print_json(api.get_scores(model_id=model, days=days))
162
+ except EverestError as e:
163
+ click.echo(f"Error: {e}", err=True)
164
+ sys.exit(1)
165
+
166
+
167
+ @cli.command()
168
+ @click.option("--model", "-m", required=True, help="Model identifier")
169
+ @click.option("--api-key", envvar="EVEREST_API_KEY", default=None)
170
+ def diagnostics(model: str, api_key: str | None) -> None:
171
+ """Show per-round diagnostics for a model."""
172
+ api = _get_api(api_key)
173
+ try:
174
+ _print_json(api.get_round_diagnostics(model_id=model))
175
+ except EverestError as e:
176
+ click.echo(f"Error: {e}", err=True)
177
+ sys.exit(1)
178
+
179
+
180
+ @cli.command()
181
+ @click.option("--tournament", "-t", default="equities", help="Tournament (equities/futures)")
182
+ @click.option("--limit", "-n", default=10, help="Number of rounds")
183
+ @click.option("--api-key", envvar="EVEREST_API_KEY", default=None)
184
+ def rounds(tournament: str, limit: int, api_key: str | None) -> None:
185
+ """List tournament rounds."""
186
+ api = _get_api(api_key)
187
+ try:
188
+ _print_json(api.get_rounds(tournament=tournament, limit=limit))
189
+ except EverestError as e:
190
+ click.echo(f"Error: {e}", err=True)
191
+ sys.exit(1)
192
+
193
+
194
+ @cli.command()
195
+ @click.option("--api-key", envvar="EVEREST_API_KEY", default=None)
196
+ def credits(api_key: str | None) -> None:
197
+ """Check compute credit balance."""
198
+ api = _get_api(api_key)
199
+ try:
200
+ _print_json(api.get_compute_credits())
201
+ except EverestError as e:
202
+ click.echo(f"Error: {e}", err=True)
203
+ sys.exit(1)
204
+
205
+
206
+ @cli.command()
207
+ @click.option("--model", "-m", required=True, help="Model identifier")
208
+ @click.option("--api-key", envvar="EVEREST_API_KEY", default=None)
209
+ def stake_balance(model: str, api_key: str | None) -> None:
210
+ """Show stake balance and pending payouts."""
211
+ api = _get_api(api_key)
212
+ try:
213
+ _print_json(api.get_stake_balance(model_id=model))
214
+ except EverestError as e:
215
+ click.echo(f"Error: {e}", err=True)
216
+ sys.exit(1)
217
+
218
+
219
+ @cli.command()
220
+ @click.option("--name", "-n", required=True, help="Agent name")
221
+ @click.option("--email", "-e", required=True, help="Recovery email")
222
+ def register(name: str, email: str) -> None:
223
+ """Register a new agent (no API key needed)."""
224
+ api = _get_api()
225
+ try:
226
+ result = api.register(name=name, email=email)
227
+ click.echo("Registration successful!")
228
+ click.echo(f" Agent ID: {result['agent_id']}")
229
+ click.echo(f" API Key: {result['api_key']} (save this — shown once)")
230
+ click.echo(f"\nSet your API key:")
231
+ click.echo(f" export EVEREST_API_KEY={result['api_key']}")
232
+ except EverestError as e:
233
+ click.echo(f"Error: {e}", err=True)
234
+ sys.exit(1)
235
+
236
+
237
+ @cli.command()
238
+ @click.option("--api-key", envvar="EVEREST_API_KEY", default=None)
239
+ def universe(api_key: str | None) -> None:
240
+ """Show current tournament universe."""
241
+ api = _get_api(api_key)
242
+ try:
243
+ _print_json(api.get_universe())
244
+ except EverestError as e:
245
+ click.echo(f"Error: {e}", err=True)
246
+ sys.exit(1)