numerapi 2.19.0__tar.gz → 2.20.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.
- numerapi-2.20.0/PKG-INFO +170 -0
- {numerapi-2.19.0 → numerapi-2.20.0}/numerapi/base_api.py +34 -148
- {numerapi-2.19.0 → numerapi-2.20.0}/numerapi/cli.py +0 -9
- {numerapi-2.19.0 → numerapi-2.20.0}/numerapi/cryptoapi.py +2 -0
- {numerapi-2.19.0 → numerapi-2.20.0}/numerapi/numerapi.py +0 -114
- {numerapi-2.19.0 → numerapi-2.20.0}/numerapi/signalsapi.py +1 -24
- {numerapi-2.19.0 → numerapi-2.20.0}/numerapi/utils.py +16 -1
- numerapi-2.20.0/numerapi.egg-info/PKG-INFO +170 -0
- {numerapi-2.19.0 → numerapi-2.20.0}/numerapi.egg-info/entry_points.txt +0 -1
- {numerapi-2.19.0 → numerapi-2.20.0}/setup.py +1 -1
- numerapi-2.19.0/PKG-INFO +0 -169
- numerapi-2.19.0/numerapi.egg-info/PKG-INFO +0 -169
- {numerapi-2.19.0 → numerapi-2.20.0}/LICENSE +0 -0
- {numerapi-2.19.0 → numerapi-2.20.0}/README.md +0 -0
- {numerapi-2.19.0 → numerapi-2.20.0}/numerapi/__init__.py +0 -0
- {numerapi-2.19.0 → numerapi-2.20.0}/numerapi.egg-info/SOURCES.txt +0 -0
- {numerapi-2.19.0 → numerapi-2.20.0}/numerapi.egg-info/dependency_links.txt +0 -0
- {numerapi-2.19.0 → numerapi-2.20.0}/numerapi.egg-info/requires.txt +0 -0
- {numerapi-2.19.0 → numerapi-2.20.0}/numerapi.egg-info/top_level.txt +0 -0
- {numerapi-2.19.0 → numerapi-2.20.0}/setup.cfg +0 -0
numerapi-2.20.0/PKG-INFO
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: numerapi
|
|
3
|
+
Version: 2.20.0
|
|
4
|
+
Summary: Automatically download and upload data for the Numerai machine learning competition
|
|
5
|
+
Home-page: https://github.com/uuazed/numerapi
|
|
6
|
+
Maintainer: uuazed
|
|
7
|
+
Maintainer-email: uuazed@gmail.com
|
|
8
|
+
License: MIT License
|
|
9
|
+
Platform: OS Independent
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
|
|
21
|
+
[](https://app.travis-ci.com/uuazed/numerapi)
|
|
22
|
+
[](https://codecov.io/gh/uuazed/numerapi)
|
|
23
|
+
[](https://pypi.python.org/pypi/numerapi)
|
|
24
|
+
[](https://pepy.tech/project/numerapi)
|
|
25
|
+
[](http://numerapi.readthedocs.io/en/stable/?badge=stable)
|
|
26
|
+
|
|
27
|
+
# Numerai Python API
|
|
28
|
+
Automatically download and upload data for the Numerai machine learning
|
|
29
|
+
competition.
|
|
30
|
+
|
|
31
|
+
This library is a Python client to the Numerai API. The interface is programmed
|
|
32
|
+
in Python and allows downloading the training data, uploading predictions, and
|
|
33
|
+
accessing user, submission and competitions information. It works for both, the
|
|
34
|
+
main competition and the newer Numerai Signals competition.
|
|
35
|
+
|
|
36
|
+
If you encounter a problem or have suggestions, feel free to open an issue.
|
|
37
|
+
|
|
38
|
+
# Installation
|
|
39
|
+
`pip install --upgrade numerapi`
|
|
40
|
+
|
|
41
|
+
# Usage
|
|
42
|
+
|
|
43
|
+
Numerapi can be used as a regular, importable Python module or from the command
|
|
44
|
+
line.
|
|
45
|
+
|
|
46
|
+
Some actions (like uploading predictions or staking) require a token to verify
|
|
47
|
+
that it is really you interacting with Numerai's API. These tokens consists of
|
|
48
|
+
a `public_id` and `secret_key`. Both can be obtained by login in to Numer.ai and
|
|
49
|
+
going to Account -> Custom API Keys. Tokens can be passed to the Python module
|
|
50
|
+
as parameters or you can be set via environment variables (`NUMERAI_PUBLIC_ID`
|
|
51
|
+
and `NUMERAI_SECRET_KEY`).
|
|
52
|
+
|
|
53
|
+
## Python module
|
|
54
|
+
|
|
55
|
+
### Usage example - main competition
|
|
56
|
+
|
|
57
|
+
import numerapi
|
|
58
|
+
# some API calls do not require logging in
|
|
59
|
+
napi = numerapi.NumerAPI(verbosity="info")
|
|
60
|
+
# download current dataset => also check `https://numer.ai/data`
|
|
61
|
+
napi.download_dataset("v4/train.parquet", "train.parquet")
|
|
62
|
+
# get current leaderboard
|
|
63
|
+
leaderboard = napi.get_leaderboard()
|
|
64
|
+
# check if a new round has started
|
|
65
|
+
if napi.check_new_round():
|
|
66
|
+
print("new round has started within the last 12hours!")
|
|
67
|
+
else:
|
|
68
|
+
print("no new round within the last 12 hours")
|
|
69
|
+
|
|
70
|
+
# provide api tokens
|
|
71
|
+
example_public_id = "somepublicid"
|
|
72
|
+
example_secret_key = "somesecretkey"
|
|
73
|
+
napi = numerapi.NumerAPI(example_public_id, example_secret_key)
|
|
74
|
+
|
|
75
|
+
# upload predictions
|
|
76
|
+
model_id = napi.get_models()['uuazed']
|
|
77
|
+
napi.upload_predictions("preds.csv", model_id=model_id)
|
|
78
|
+
# increase your stake by 1.2 NMR
|
|
79
|
+
napi.stake_increase(1.2)
|
|
80
|
+
|
|
81
|
+
# convert results to a pandas dataframe
|
|
82
|
+
import pandas as pd
|
|
83
|
+
df = pd.DataFrame(napi.daily_user_performances("uuazed"))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
### Usage example - Numerai Signals
|
|
87
|
+
|
|
88
|
+
import numerapi
|
|
89
|
+
|
|
90
|
+
napi = numerapi.SignalsAPI()
|
|
91
|
+
# get current leaderboard
|
|
92
|
+
leaderboard = napi.get_leaderboard()
|
|
93
|
+
|
|
94
|
+
# setup API with api tokens
|
|
95
|
+
example_public_id = "somepublicid"
|
|
96
|
+
example_secret_key = "somesecretkey"
|
|
97
|
+
napi = numerapi.SignalsAPI(example_public_id, example_secret_key)
|
|
98
|
+
|
|
99
|
+
# upload predictions
|
|
100
|
+
model_id = napi.get_models()['uuazed']
|
|
101
|
+
napi.upload_predictions("preds.csv", model_id=model_id)
|
|
102
|
+
|
|
103
|
+
# get daily performance as pandas dataframe
|
|
104
|
+
import pandas as pd
|
|
105
|
+
df = pd.DataFrame(napi.daily_user_performances("uuazed"))
|
|
106
|
+
|
|
107
|
+
# using the diagnostics tool
|
|
108
|
+
napi.upload_diagnostics("preds.csv", model_id=model_id)
|
|
109
|
+
# ... or using a pandas DataFrame directly
|
|
110
|
+
napi.upload_diagnostics(df=df, model_id=model_id)
|
|
111
|
+
# fetch results
|
|
112
|
+
napi.diagnostic(model_id)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## Command line interface
|
|
116
|
+
|
|
117
|
+
To get started with the cli interface, let's take a look at the help page:
|
|
118
|
+
|
|
119
|
+
$ numerapi --help
|
|
120
|
+
Usage: numerapi [OPTIONS] COMMAND [ARGS]...
|
|
121
|
+
|
|
122
|
+
Wrapper around the Numerai API
|
|
123
|
+
|
|
124
|
+
Options:
|
|
125
|
+
--help Show this message and exit.
|
|
126
|
+
|
|
127
|
+
Commands:
|
|
128
|
+
account Get all information about your account!
|
|
129
|
+
check-new-round Check if a new round has started within...
|
|
130
|
+
competitions Retrieves information about all...
|
|
131
|
+
current-round Get number of the current active round.
|
|
132
|
+
daily-model-performances Fetch daily performance of a model.
|
|
133
|
+
daily-submissions-performances Fetch daily performance of a user's...
|
|
134
|
+
dataset-url Fetch url of the current dataset.
|
|
135
|
+
download-dataset Download specified file for the given...
|
|
136
|
+
download-dataset-old Download dataset for the current active...
|
|
137
|
+
leaderboard Get the leaderboard.
|
|
138
|
+
list-datasets List of available data files
|
|
139
|
+
models Get map of account models!
|
|
140
|
+
profile Fetch the public profile of a user.
|
|
141
|
+
stake-decrease Decrease your stake by `value` NMR.
|
|
142
|
+
stake-drain Completely remove your stake.
|
|
143
|
+
stake-get Get stake value of a user.
|
|
144
|
+
stake-increase Increase your stake by `value` NMR.
|
|
145
|
+
submission-filenames Get filenames of your submissions
|
|
146
|
+
submit Upload predictions from file.
|
|
147
|
+
transactions List all your deposits and withdrawals.
|
|
148
|
+
user Get all information about you!...
|
|
149
|
+
version Installed numerapi version.
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
Each command has it's own help page, for example:
|
|
153
|
+
|
|
154
|
+
$ numerapi submit --help
|
|
155
|
+
Usage: numerapi submit [OPTIONS] PATH
|
|
156
|
+
|
|
157
|
+
Upload predictions from file.
|
|
158
|
+
|
|
159
|
+
Options:
|
|
160
|
+
--tournament INTEGER The ID of the tournament, defaults to 1
|
|
161
|
+
--model_id TEXT An account model UUID (required for accounts with
|
|
162
|
+
multiple models
|
|
163
|
+
|
|
164
|
+
--help Show this message and exit.
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
# API Reference
|
|
168
|
+
|
|
169
|
+
Checkout the [detailed API docs](http://numerapi.readthedocs.io/en/latest/api/numerapi.html#module-numerapi.numerapi)
|
|
170
|
+
to learn about all available methods, parameters and returned values.
|
|
@@ -46,12 +46,10 @@ class Api:
|
|
|
46
46
|
self.tournament_id = 0
|
|
47
47
|
self.global_data_dir = "."
|
|
48
48
|
|
|
49
|
-
def _login(self, public_id=None, secret_key=None):
|
|
49
|
+
def _login(self, public_id: str | None = None, secret_key: str | None = None) -> None:
|
|
50
50
|
# check env variables if not set
|
|
51
|
-
if not public_id:
|
|
52
|
-
public_id =
|
|
53
|
-
if not secret_key:
|
|
54
|
-
secret_key = os.getenv("NUMERAI_SECRET_KEY")
|
|
51
|
+
if not public_id or not secret_key:
|
|
52
|
+
public_id, secret_key = utils.load_secrets()
|
|
55
53
|
|
|
56
54
|
if public_id and secret_key:
|
|
57
55
|
self.token = (public_id, secret_key)
|
|
@@ -76,7 +74,7 @@ class Api:
|
|
|
76
74
|
|
|
77
75
|
def raw_query(self, query: str, variables: Dict = None,
|
|
78
76
|
authorization: bool = False,
|
|
79
|
-
retries: int = 3, delay: int = 5, backoff: int = 2):
|
|
77
|
+
*, retries: int = 3, delay: int = 5, backoff: int = 2):
|
|
80
78
|
"""Send a raw request to the Numerai's GraphQL API.
|
|
81
79
|
|
|
82
80
|
This function allows to build your own queries and fetch results from
|
|
@@ -391,15 +389,6 @@ class Api:
|
|
|
391
389
|
round_num = data["number"]
|
|
392
390
|
return round_num
|
|
393
391
|
|
|
394
|
-
def get_account_transactions(self) -> List:
|
|
395
|
-
"""Get all your account deposits and withdrawals.
|
|
396
|
-
|
|
397
|
-
DEPRECATED - please use `wallet_transactions` instead"
|
|
398
|
-
"""
|
|
399
|
-
self.logger.warning(
|
|
400
|
-
"DEPRECATED - please use `wallet_transactions` instead")
|
|
401
|
-
return self.wallet_transactions()
|
|
402
|
-
|
|
403
392
|
def set_bio(self, model_id: str, bio: str) -> bool:
|
|
404
393
|
"""Set bio field for a model id.
|
|
405
394
|
|
|
@@ -573,7 +562,6 @@ class Api:
|
|
|
573
562
|
Args:
|
|
574
563
|
file_path (str): CSV file with predictions that will get uploaded
|
|
575
564
|
tournament (int): ID of the tournament (optional, defaults to None)
|
|
576
|
-
-- DEPRECATED there is only one tournament nowadays
|
|
577
565
|
model_id (str): Target model UUID (required for accounts with
|
|
578
566
|
multiple models)
|
|
579
567
|
df (pandas.DataFrame): pandas DataFrame to upload, if function is
|
|
@@ -939,129 +927,12 @@ class Api:
|
|
|
939
927
|
def round_model_performances(self, username: str) -> List[Dict]:
|
|
940
928
|
"""Fetch round model performance of a user.
|
|
941
929
|
|
|
942
|
-
|
|
943
|
-
username (str)
|
|
944
|
-
|
|
945
|
-
Returns:
|
|
946
|
-
list of dicts: list of round model performance entries
|
|
947
|
-
|
|
948
|
-
For each entry in the list, there is a dict with the following
|
|
949
|
-
content:
|
|
950
|
-
|
|
951
|
-
* corr (`float`)
|
|
952
|
-
* corr20V2 (`float` or None)
|
|
953
|
-
* corr20V2Percentile (`float` or None)
|
|
954
|
-
* corr20d (`float` or None)
|
|
955
|
-
* corr20dPercentile (`float` or None)
|
|
956
|
-
* corrMultiplier (`float`)
|
|
957
|
-
* corrPercentile (`float`)
|
|
958
|
-
* corrWMetamodel (`float`)
|
|
959
|
-
* tc (`float`)
|
|
960
|
-
* tcPercentile (`float`)
|
|
961
|
-
* tcMultiplier (`float`)
|
|
962
|
-
* ic (`float`)
|
|
963
|
-
* icPercentile (`float`)
|
|
964
|
-
* fnc (`float`)
|
|
965
|
-
* fncPercentile (`float`)
|
|
966
|
-
* fncV3 (`float`)
|
|
967
|
-
* fncV3Percentile (`float`)
|
|
968
|
-
* mmc (`float`)
|
|
969
|
-
* mmc20d (`float` or None)
|
|
970
|
-
* mmc20dPercentile (`float` or None)
|
|
971
|
-
* mmcMultiplier (`float`)
|
|
972
|
-
* mmcPercentile (`float`)
|
|
973
|
-
* payout (`Decimal`)
|
|
974
|
-
* roundNumber (`int`)
|
|
975
|
-
* roundOpenTime (`datetime`)
|
|
976
|
-
* roundPayoutFactor (`Decimal`)
|
|
977
|
-
* roundResolveTime (`datetime`)
|
|
978
|
-
* roundResolved (`bool`)
|
|
979
|
-
* roundTarget (`str` or None)
|
|
980
|
-
* selectedStakeValue (`Decimal`)
|
|
981
|
-
|
|
982
|
-
Example:
|
|
983
|
-
>>> api = NumerAPI()
|
|
984
|
-
>>> api.round_model_performances("uuazed")
|
|
985
|
-
[{'corr': -0.01296840448965,
|
|
986
|
-
'corr20V2': None,
|
|
987
|
-
'corr20V2Percentile': None,
|
|
988
|
-
'corr20d': None,
|
|
989
|
-
'corr20dPercentile': None,
|
|
990
|
-
'corrMultiplier': 1.0,
|
|
991
|
-
'corrPercentile': 0.0411107104219257,
|
|
992
|
-
'corrWMetamodel': 0.51542251407092,
|
|
993
|
-
'tc': 0.1415973344,
|
|
994
|
-
'tcPercentile': 0.115398485394879,
|
|
995
|
-
'ic': 0.1415973344,
|
|
996
|
-
'icPercentile': 0.115398485394879,
|
|
997
|
-
'fnc': 0.000437631996046271,
|
|
998
|
-
'fncPercentile': 0.115398485394879,
|
|
999
|
-
'fncV3': 0.000437631996046271,
|
|
1000
|
-
'fncV3Percentile': 0.115398485394879,
|
|
1001
|
-
'mmc': -0.0152125841680981,
|
|
1002
|
-
'mmc20d': None,
|
|
1003
|
-
'mmc20dPercentile': None,
|
|
1004
|
-
...
|
|
1005
|
-
]
|
|
930
|
+
DEPRECATED - please use `round_model_performances_v2` instead
|
|
1006
931
|
"""
|
|
1007
|
-
if self.tournament_id == 8:
|
|
1008
|
-
endpoint = "v3UserProfile"
|
|
1009
|
-
elif self.tournament_id == 11:
|
|
1010
|
-
endpoint = "v2SignalsProfile"
|
|
1011
|
-
else:
|
|
1012
|
-
raise ValueError("round_model_performances is not available for ",
|
|
1013
|
-
f"tournament {self.tournament_id}")
|
|
1014
932
|
self.logger.warning(
|
|
1015
|
-
"Deprecated
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
{endpoint}(modelName: $username) {{
|
|
1019
|
-
roundModelPerformances {{
|
|
1020
|
-
corr
|
|
1021
|
-
corr20V2
|
|
1022
|
-
corr20V2Percentile
|
|
1023
|
-
corr20d
|
|
1024
|
-
corr20dPercentile
|
|
1025
|
-
corrMultiplier
|
|
1026
|
-
corrPercentile
|
|
1027
|
-
corrWMetamodel
|
|
1028
|
-
tc
|
|
1029
|
-
tcPercentile
|
|
1030
|
-
ic
|
|
1031
|
-
icPercentile
|
|
1032
|
-
fnc
|
|
1033
|
-
fncPercentile
|
|
1034
|
-
fncV3
|
|
1035
|
-
fncV3Percentile
|
|
1036
|
-
mmc
|
|
1037
|
-
mmc20d
|
|
1038
|
-
mmc20dPercentile
|
|
1039
|
-
mmcMultiplier
|
|
1040
|
-
mmcPercentile
|
|
1041
|
-
payout
|
|
1042
|
-
roundNumber
|
|
1043
|
-
roundOpenTime
|
|
1044
|
-
roundPayoutFactor
|
|
1045
|
-
roundResolveTime
|
|
1046
|
-
roundResolved
|
|
1047
|
-
roundTarget
|
|
1048
|
-
selectedStakeValue
|
|
1049
|
-
tcMultiplier
|
|
1050
|
-
}}
|
|
1051
|
-
}}
|
|
1052
|
-
}}
|
|
1053
|
-
"""
|
|
1054
|
-
arguments = {'username': username}
|
|
1055
|
-
data = self.raw_query(query, arguments)['data'][endpoint]
|
|
1056
|
-
performances = data['roundModelPerformances']
|
|
1057
|
-
# convert strings to python objects
|
|
1058
|
-
for perf in performances:
|
|
1059
|
-
utils.replace(perf, "roundOpenTime", utils.parse_datetime_string)
|
|
1060
|
-
utils.replace(perf, "roundResolveTime", utils.parse_datetime_string)
|
|
1061
|
-
utils.replace(perf, "payout", utils.parse_float_string)
|
|
1062
|
-
utils.replace(perf, "roundPayoutFactor", utils.parse_float_string)
|
|
1063
|
-
utils.replace(perf, "selectedStakeValue", utils.parse_float_string)
|
|
1064
|
-
return performances
|
|
933
|
+
"Deprecated. Checkout round_model_performances_v2.")
|
|
934
|
+
return self.round_model_performances_v2(username)
|
|
935
|
+
|
|
1065
936
|
|
|
1066
937
|
def stake_change(self, nmr, action: str = "decrease",
|
|
1067
938
|
model_id: str = None) -> Dict:
|
|
@@ -1120,9 +991,7 @@ class Api:
|
|
|
1120
991
|
"""Completely remove your stake.
|
|
1121
992
|
|
|
1122
993
|
Args:
|
|
1123
|
-
model_id (str): Target model UUID
|
|
1124
|
-
multiple models)
|
|
1125
|
-
tournament (int): ID of the tournament (optional, defaults to 8)
|
|
994
|
+
model_id (str): Target model UUID
|
|
1126
995
|
|
|
1127
996
|
Returns:
|
|
1128
997
|
dict: stake information with the following content:
|
|
@@ -1131,17 +1000,36 @@ class Api:
|
|
|
1131
1000
|
* status (`str`)
|
|
1132
1001
|
* requestedAmount (`decimal.Decimal`)
|
|
1133
1002
|
* type (`str`)
|
|
1003
|
+
* drain (`bool`)
|
|
1134
1004
|
|
|
1135
1005
|
Example:
|
|
1136
1006
|
>>> api = NumerAPI(secret_key="..", public_id="..")
|
|
1137
|
-
>>>
|
|
1138
|
-
>>> api.stake_drain(
|
|
1007
|
+
>>> model_id = api.get_models()['uuazed']
|
|
1008
|
+
>>> api.stake_drain(model_id)
|
|
1139
1009
|
{'dueDate': None,
|
|
1140
1010
|
'requestedAmount': decimal.Decimal('11000000'),
|
|
1141
1011
|
'type': 'decrease',
|
|
1142
|
-
'status': ''
|
|
1012
|
+
'status': '',
|
|
1013
|
+
'drain": True}
|
|
1143
1014
|
"""
|
|
1144
|
-
|
|
1015
|
+
query = '''
|
|
1016
|
+
mutation($drain: bool!
|
|
1017
|
+
$amount: String
|
|
1018
|
+
$modelId: String) {
|
|
1019
|
+
releaseStake(drain: $drain
|
|
1020
|
+
modelId: $modelId
|
|
1021
|
+
amount: $amount) {
|
|
1022
|
+
id
|
|
1023
|
+
dueDate
|
|
1024
|
+
status
|
|
1025
|
+
type
|
|
1026
|
+
requestedAmount
|
|
1027
|
+
drain
|
|
1028
|
+
}
|
|
1029
|
+
}'''
|
|
1030
|
+
arguments = {'drain': True, "modelId": model_id, "amount": '11000000'}
|
|
1031
|
+
raw = self.raw_query(query, arguments, authorization=True)
|
|
1032
|
+
return raw['data']['releaseStake']
|
|
1145
1033
|
|
|
1146
1034
|
def stake_decrease(self, nmr, model_id: str = None) -> Dict:
|
|
1147
1035
|
"""Decrease your stake by `value` NMR.
|
|
@@ -1179,7 +1067,6 @@ class Api:
|
|
|
1179
1067
|
model_id (str): Target model UUID (required for accounts with
|
|
1180
1068
|
multiple models)
|
|
1181
1069
|
tournament (int): ID of the tournament (optional, defaults to 8)
|
|
1182
|
-
-- DEPRECATED there is only one tournament nowadays
|
|
1183
1070
|
|
|
1184
1071
|
Returns:
|
|
1185
1072
|
dict: stake information with the following content:
|
|
@@ -1223,7 +1110,7 @@ class Api:
|
|
|
1223
1110
|
arguments = {'tournament': self.tournament_id}
|
|
1224
1111
|
# in some period in between rounds, "number: 0" returns Value error -
|
|
1225
1112
|
# "Current round not open for submissions", because there is no active
|
|
1226
|
-
# round. This is
|
|
1113
|
+
# round. This is caught by the try / except.
|
|
1227
1114
|
try:
|
|
1228
1115
|
raw = self.raw_query(query, arguments)['data']['rounds'][0]
|
|
1229
1116
|
except ValueError:
|
|
@@ -1242,7 +1129,6 @@ class Api:
|
|
|
1242
1129
|
Args:
|
|
1243
1130
|
hours (int, optional): timeframe to consider, defaults to 12
|
|
1244
1131
|
tournament (int): ID of the tournament (optional)
|
|
1245
|
-
-- DEPRECATED this is now automatically filled
|
|
1246
1132
|
|
|
1247
1133
|
Returns:
|
|
1248
1134
|
bool: True if a new round has started, False otherwise.
|
|
@@ -1264,7 +1150,7 @@ class Api:
|
|
|
1264
1150
|
arguments = {'tournament': tournament}
|
|
1265
1151
|
# in some period in between rounds, "number: 0" returns Value error -
|
|
1266
1152
|
# "Current round not open for submissions", because there is no active
|
|
1267
|
-
# round. This is
|
|
1153
|
+
# round. This is caught by the try / except.
|
|
1268
1154
|
try:
|
|
1269
1155
|
raw = self.raw_query(query, arguments)['data']['rounds'][0]
|
|
1270
1156
|
except ValueError:
|
|
@@ -112,15 +112,6 @@ def check_new_round(hours=12, tournament=8):
|
|
|
112
112
|
click.echo(int(napi.check_new_round(hours=hours, tournament=tournament)))
|
|
113
113
|
|
|
114
114
|
|
|
115
|
-
@cli.command()
|
|
116
|
-
@click.option(
|
|
117
|
-
'--model_id', type=str, default=None,
|
|
118
|
-
help="An account model UUID (required for accounts with multiple models")
|
|
119
|
-
def user(model_id):
|
|
120
|
-
"""Get all information about you! DEPRECATED - use account"""
|
|
121
|
-
click.echo(prettify(napi.get_user(model_id)))
|
|
122
|
-
|
|
123
|
-
|
|
124
115
|
@cli.command()
|
|
125
116
|
def account():
|
|
126
117
|
"""Get all information about your account!"""
|
|
@@ -28,7 +28,6 @@ class NumerAPI(base_api.Api):
|
|
|
28
28
|
|
|
29
29
|
Args:
|
|
30
30
|
tournament (int, optional): ID of the tournament, defaults to 8
|
|
31
|
-
-- DEPRECATED there is only one tournament nowadays
|
|
32
31
|
|
|
33
32
|
Returns:
|
|
34
33
|
list of dicts: list of rounds
|
|
@@ -81,7 +80,6 @@ class NumerAPI(base_api.Api):
|
|
|
81
80
|
|
|
82
81
|
Args:
|
|
83
82
|
tournament (int): optionally filter by ID of the tournament
|
|
84
|
-
-- DEPRECATED there is only one tournament nowadays
|
|
85
83
|
round_num (int): optionally filter round number
|
|
86
84
|
model_id (str): Target model UUID (required for accounts with
|
|
87
85
|
multiple models)
|
|
@@ -134,112 +132,6 @@ class NumerAPI(base_api.Api):
|
|
|
134
132
|
filenames.sort(key=lambda f: (f['round_num'], f['tournament']))
|
|
135
133
|
return filenames
|
|
136
134
|
|
|
137
|
-
def get_user(self, model_id: str = None) -> Dict:
|
|
138
|
-
"""Get all information about you! DEPRECATED
|
|
139
|
-
|
|
140
|
-
Args:
|
|
141
|
-
model_id (str): Target model UUID (required for accounts with
|
|
142
|
-
multiple models)
|
|
143
|
-
|
|
144
|
-
Returns:
|
|
145
|
-
dict: user information including the following fields:
|
|
146
|
-
|
|
147
|
-
* assignedEthAddress (`str`)
|
|
148
|
-
* availableNmr (`decimal.Decimal`)
|
|
149
|
-
* availableUsd (`decimal.Decimal`)
|
|
150
|
-
* banned (`bool`)
|
|
151
|
-
* email (`str`)
|
|
152
|
-
* id (`str`)
|
|
153
|
-
* insertedAt (`datetime`)
|
|
154
|
-
* mfaEnabled (`bool`)
|
|
155
|
-
* status (`str`)
|
|
156
|
-
* username (`str`)
|
|
157
|
-
* country (`str)
|
|
158
|
-
* apiTokens (`list`) each with the following fields:
|
|
159
|
-
* name (`str`)
|
|
160
|
-
* public_id (`str`)
|
|
161
|
-
* scopes (`list of str`)
|
|
162
|
-
* v2Stake
|
|
163
|
-
* status (`str`)
|
|
164
|
-
* txHash (`str`)
|
|
165
|
-
|
|
166
|
-
Example:
|
|
167
|
-
>>> api = NumerAPI(secret_key="..", public_id="..")
|
|
168
|
-
>>> model = api.get_models()['uuazed']
|
|
169
|
-
>>> api.get_user(model)
|
|
170
|
-
{'apiTokens': [
|
|
171
|
-
{'name': 'tokenname',
|
|
172
|
-
'public_id': 'BLABLA',
|
|
173
|
-
'scopes': ['upload_submission', 'stake', ..]
|
|
174
|
-
}, ..],
|
|
175
|
-
'assignedEthAddress': '0x0000000000000000000000000001',
|
|
176
|
-
'availableNmr': Decimal('99.01'),
|
|
177
|
-
'availableUsd': Decimal('9.47'),
|
|
178
|
-
'banned': False,
|
|
179
|
-
'email': 'username@example.com',
|
|
180
|
-
'country': 'US',
|
|
181
|
-
'id': '1234-ABC..',
|
|
182
|
-
'insertedAt': datetime.datetime(2018, 1, 1, 2, 16, 48),
|
|
183
|
-
'mfaEnabled': False,
|
|
184
|
-
'status': 'VERIFIED',
|
|
185
|
-
'username': 'cool username',
|
|
186
|
-
'v2Stake': None
|
|
187
|
-
}
|
|
188
|
-
"""
|
|
189
|
-
self.logger.warning("Method get_user is DEPRECATED, use get_account")
|
|
190
|
-
query = """
|
|
191
|
-
query($modelId: String) {
|
|
192
|
-
user(modelId: $modelId) {
|
|
193
|
-
username
|
|
194
|
-
banned
|
|
195
|
-
assignedEthAddress
|
|
196
|
-
availableNmr
|
|
197
|
-
availableUsd
|
|
198
|
-
email
|
|
199
|
-
id
|
|
200
|
-
mfaEnabled
|
|
201
|
-
status
|
|
202
|
-
country
|
|
203
|
-
insertedAt
|
|
204
|
-
apiTokens {
|
|
205
|
-
name
|
|
206
|
-
public_id
|
|
207
|
-
scopes
|
|
208
|
-
}
|
|
209
|
-
v2Stake {
|
|
210
|
-
status
|
|
211
|
-
txHash
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
"""
|
|
216
|
-
arguments = {'modelId': model_id}
|
|
217
|
-
data = self.raw_query(
|
|
218
|
-
query, arguments, authorization=True)['data']['user']
|
|
219
|
-
# convert strings to python objects
|
|
220
|
-
utils.replace(data, "insertedAt", utils.parse_datetime_string)
|
|
221
|
-
utils.replace(data, "availableUsd", utils.parse_float_string)
|
|
222
|
-
utils.replace(data, "availableNmr", utils.parse_float_string)
|
|
223
|
-
return data
|
|
224
|
-
|
|
225
|
-
def submission_status(self, model_id: str = None) -> None:
|
|
226
|
-
"""submission status of the last submission associated with the account
|
|
227
|
-
|
|
228
|
-
DEPRECATED numerai no longer provides this data. This will be removed
|
|
229
|
-
in one of the next versions
|
|
230
|
-
|
|
231
|
-
Args:
|
|
232
|
-
model_id (str): Target model UUID (required for accounts with
|
|
233
|
-
multiple models)
|
|
234
|
-
|
|
235
|
-
Example:
|
|
236
|
-
>>> napi = NumerAPI(secret_key="..", public_id="..")
|
|
237
|
-
>>> model_id = napi.get_models()['uuazed']
|
|
238
|
-
>>> napi.submission_status(model_id)
|
|
239
|
-
"""
|
|
240
|
-
_ = model_id
|
|
241
|
-
self.logger.warning("Method submission_status is DEPRECATED and will be removed soon.")
|
|
242
|
-
|
|
243
135
|
def get_leaderboard(self, limit: int = 50, offset: int = 0) -> List[Dict]:
|
|
244
136
|
"""Get the current model leaderboard
|
|
245
137
|
|
|
@@ -423,12 +315,6 @@ class NumerAPI(base_api.Api):
|
|
|
423
315
|
utils.replace(data, "startDate", utils.parse_datetime_string)
|
|
424
316
|
return data
|
|
425
317
|
|
|
426
|
-
def daily_user_performances(self, username: str) -> List[Dict]:
|
|
427
|
-
"""DEPRECATED"""
|
|
428
|
-
self.logger.warning("Method daily_user_performances is DEPRECATED, "
|
|
429
|
-
"use daily_model_performances")
|
|
430
|
-
return self.daily_model_performances(username)
|
|
431
|
-
|
|
432
318
|
def daily_model_performances(self, username: str) -> List[Dict]:
|
|
433
319
|
"""Fetch daily performance of a user.
|
|
434
320
|
|
|
@@ -133,7 +133,7 @@ class SignalsAPI(base_api.Api):
|
|
|
133
133
|
mutation($filename: String!
|
|
134
134
|
$modelId: String
|
|
135
135
|
$triggerId: String
|
|
136
|
-
$
|
|
136
|
+
$dataDatestamp: Int) {
|
|
137
137
|
createSignalsSubmission(filename: $filename
|
|
138
138
|
modelId: $modelId
|
|
139
139
|
triggerId: $triggerId
|
|
@@ -151,23 +151,6 @@ class SignalsAPI(base_api.Api):
|
|
|
151
151
|
create = self.raw_query(create_query, arguments, authorization=True)
|
|
152
152
|
return create['data']['createSignalsSubmission']['id']
|
|
153
153
|
|
|
154
|
-
def submission_status(self, model_id: str = None) -> None:
|
|
155
|
-
"""submission status of the last submission associated with the account
|
|
156
|
-
|
|
157
|
-
DEPRECATED numerai no longer provides this data. This will be removed
|
|
158
|
-
in one of the next versions
|
|
159
|
-
|
|
160
|
-
Args:
|
|
161
|
-
model_id (str)
|
|
162
|
-
|
|
163
|
-
Example:
|
|
164
|
-
>>> api = SignalsAPI(secret_key="..", public_id="..")
|
|
165
|
-
>>> model_id = api.get_models()['uuazed']
|
|
166
|
-
>>> api.submission_status(model_id)
|
|
167
|
-
"""
|
|
168
|
-
_ = model_id
|
|
169
|
-
self.logger.warning("Method submission_status is DEPRECATED and will be removed soon.")
|
|
170
|
-
|
|
171
154
|
def public_user_profile(self, username: str) -> Dict:
|
|
172
155
|
"""Fetch the public Numerai Signals profile of a user.
|
|
173
156
|
|
|
@@ -301,12 +284,6 @@ class SignalsAPI(base_api.Api):
|
|
|
301
284
|
path = self.download_dataset("signals/v1.0/live.parquet")
|
|
302
285
|
return pd.read_parquet(path).numerai_ticker.tolist()
|
|
303
286
|
|
|
304
|
-
def download_validation_data(self) -> None:
|
|
305
|
-
"""download CSV file with historical targets and ticker universe
|
|
306
|
-
"""
|
|
307
|
-
self.logger.warning("'download_validation_data' is DEPRECATED.")
|
|
308
|
-
self.logger.warning("Please use 'download_dataset' and 'list_datasets'")
|
|
309
|
-
|
|
310
287
|
def stake_get(self, username) -> decimal.Decimal:
|
|
311
288
|
"""get current stake for a given users
|
|
312
289
|
|
|
@@ -16,6 +16,21 @@ import tqdm
|
|
|
16
16
|
logger = logging.getLogger(__name__)
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
def load_secrets() -> tuple:
|
|
20
|
+
"""load secrets from environment variables or dotenv file"""
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
from dotenv import load_dotenv # pylint: disable-msg=import-outside-toplevel
|
|
24
|
+
load_dotenv()
|
|
25
|
+
except ImportError:
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
public_id = os.getenv("NUMERAI_PUBLIC_ID")
|
|
29
|
+
secret_key = os.getenv("NUMERAI_SECRET_KEY")
|
|
30
|
+
|
|
31
|
+
return public_id, secret_key
|
|
32
|
+
|
|
33
|
+
|
|
19
34
|
def parse_datetime_string(string: str) -> Optional[datetime.datetime]:
|
|
20
35
|
"""try to parse string to datetime object"""
|
|
21
36
|
if string is None:
|
|
@@ -91,7 +106,7 @@ def download_file(url: str, dest_path: str, show_progress_bars: bool = True):
|
|
|
91
106
|
|
|
92
107
|
|
|
93
108
|
def post_with_err_handling(url: str, body: str, headers: Dict,
|
|
94
|
-
timeout: Optional[int] = None,
|
|
109
|
+
*, timeout: Optional[int] = None,
|
|
95
110
|
retries: int = 3, delay: int = 1, backoff: int = 2
|
|
96
111
|
) -> Dict:
|
|
97
112
|
"""send `post` request and handle (some) errors that might occur"""
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: numerapi
|
|
3
|
+
Version: 2.20.0
|
|
4
|
+
Summary: Automatically download and upload data for the Numerai machine learning competition
|
|
5
|
+
Home-page: https://github.com/uuazed/numerapi
|
|
6
|
+
Maintainer: uuazed
|
|
7
|
+
Maintainer-email: uuazed@gmail.com
|
|
8
|
+
License: MIT License
|
|
9
|
+
Platform: OS Independent
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
|
|
21
|
+
[](https://app.travis-ci.com/uuazed/numerapi)
|
|
22
|
+
[](https://codecov.io/gh/uuazed/numerapi)
|
|
23
|
+
[](https://pypi.python.org/pypi/numerapi)
|
|
24
|
+
[](https://pepy.tech/project/numerapi)
|
|
25
|
+
[](http://numerapi.readthedocs.io/en/stable/?badge=stable)
|
|
26
|
+
|
|
27
|
+
# Numerai Python API
|
|
28
|
+
Automatically download and upload data for the Numerai machine learning
|
|
29
|
+
competition.
|
|
30
|
+
|
|
31
|
+
This library is a Python client to the Numerai API. The interface is programmed
|
|
32
|
+
in Python and allows downloading the training data, uploading predictions, and
|
|
33
|
+
accessing user, submission and competitions information. It works for both, the
|
|
34
|
+
main competition and the newer Numerai Signals competition.
|
|
35
|
+
|
|
36
|
+
If you encounter a problem or have suggestions, feel free to open an issue.
|
|
37
|
+
|
|
38
|
+
# Installation
|
|
39
|
+
`pip install --upgrade numerapi`
|
|
40
|
+
|
|
41
|
+
# Usage
|
|
42
|
+
|
|
43
|
+
Numerapi can be used as a regular, importable Python module or from the command
|
|
44
|
+
line.
|
|
45
|
+
|
|
46
|
+
Some actions (like uploading predictions or staking) require a token to verify
|
|
47
|
+
that it is really you interacting with Numerai's API. These tokens consists of
|
|
48
|
+
a `public_id` and `secret_key`. Both can be obtained by login in to Numer.ai and
|
|
49
|
+
going to Account -> Custom API Keys. Tokens can be passed to the Python module
|
|
50
|
+
as parameters or you can be set via environment variables (`NUMERAI_PUBLIC_ID`
|
|
51
|
+
and `NUMERAI_SECRET_KEY`).
|
|
52
|
+
|
|
53
|
+
## Python module
|
|
54
|
+
|
|
55
|
+
### Usage example - main competition
|
|
56
|
+
|
|
57
|
+
import numerapi
|
|
58
|
+
# some API calls do not require logging in
|
|
59
|
+
napi = numerapi.NumerAPI(verbosity="info")
|
|
60
|
+
# download current dataset => also check `https://numer.ai/data`
|
|
61
|
+
napi.download_dataset("v4/train.parquet", "train.parquet")
|
|
62
|
+
# get current leaderboard
|
|
63
|
+
leaderboard = napi.get_leaderboard()
|
|
64
|
+
# check if a new round has started
|
|
65
|
+
if napi.check_new_round():
|
|
66
|
+
print("new round has started within the last 12hours!")
|
|
67
|
+
else:
|
|
68
|
+
print("no new round within the last 12 hours")
|
|
69
|
+
|
|
70
|
+
# provide api tokens
|
|
71
|
+
example_public_id = "somepublicid"
|
|
72
|
+
example_secret_key = "somesecretkey"
|
|
73
|
+
napi = numerapi.NumerAPI(example_public_id, example_secret_key)
|
|
74
|
+
|
|
75
|
+
# upload predictions
|
|
76
|
+
model_id = napi.get_models()['uuazed']
|
|
77
|
+
napi.upload_predictions("preds.csv", model_id=model_id)
|
|
78
|
+
# increase your stake by 1.2 NMR
|
|
79
|
+
napi.stake_increase(1.2)
|
|
80
|
+
|
|
81
|
+
# convert results to a pandas dataframe
|
|
82
|
+
import pandas as pd
|
|
83
|
+
df = pd.DataFrame(napi.daily_user_performances("uuazed"))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
### Usage example - Numerai Signals
|
|
87
|
+
|
|
88
|
+
import numerapi
|
|
89
|
+
|
|
90
|
+
napi = numerapi.SignalsAPI()
|
|
91
|
+
# get current leaderboard
|
|
92
|
+
leaderboard = napi.get_leaderboard()
|
|
93
|
+
|
|
94
|
+
# setup API with api tokens
|
|
95
|
+
example_public_id = "somepublicid"
|
|
96
|
+
example_secret_key = "somesecretkey"
|
|
97
|
+
napi = numerapi.SignalsAPI(example_public_id, example_secret_key)
|
|
98
|
+
|
|
99
|
+
# upload predictions
|
|
100
|
+
model_id = napi.get_models()['uuazed']
|
|
101
|
+
napi.upload_predictions("preds.csv", model_id=model_id)
|
|
102
|
+
|
|
103
|
+
# get daily performance as pandas dataframe
|
|
104
|
+
import pandas as pd
|
|
105
|
+
df = pd.DataFrame(napi.daily_user_performances("uuazed"))
|
|
106
|
+
|
|
107
|
+
# using the diagnostics tool
|
|
108
|
+
napi.upload_diagnostics("preds.csv", model_id=model_id)
|
|
109
|
+
# ... or using a pandas DataFrame directly
|
|
110
|
+
napi.upload_diagnostics(df=df, model_id=model_id)
|
|
111
|
+
# fetch results
|
|
112
|
+
napi.diagnostic(model_id)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## Command line interface
|
|
116
|
+
|
|
117
|
+
To get started with the cli interface, let's take a look at the help page:
|
|
118
|
+
|
|
119
|
+
$ numerapi --help
|
|
120
|
+
Usage: numerapi [OPTIONS] COMMAND [ARGS]...
|
|
121
|
+
|
|
122
|
+
Wrapper around the Numerai API
|
|
123
|
+
|
|
124
|
+
Options:
|
|
125
|
+
--help Show this message and exit.
|
|
126
|
+
|
|
127
|
+
Commands:
|
|
128
|
+
account Get all information about your account!
|
|
129
|
+
check-new-round Check if a new round has started within...
|
|
130
|
+
competitions Retrieves information about all...
|
|
131
|
+
current-round Get number of the current active round.
|
|
132
|
+
daily-model-performances Fetch daily performance of a model.
|
|
133
|
+
daily-submissions-performances Fetch daily performance of a user's...
|
|
134
|
+
dataset-url Fetch url of the current dataset.
|
|
135
|
+
download-dataset Download specified file for the given...
|
|
136
|
+
download-dataset-old Download dataset for the current active...
|
|
137
|
+
leaderboard Get the leaderboard.
|
|
138
|
+
list-datasets List of available data files
|
|
139
|
+
models Get map of account models!
|
|
140
|
+
profile Fetch the public profile of a user.
|
|
141
|
+
stake-decrease Decrease your stake by `value` NMR.
|
|
142
|
+
stake-drain Completely remove your stake.
|
|
143
|
+
stake-get Get stake value of a user.
|
|
144
|
+
stake-increase Increase your stake by `value` NMR.
|
|
145
|
+
submission-filenames Get filenames of your submissions
|
|
146
|
+
submit Upload predictions from file.
|
|
147
|
+
transactions List all your deposits and withdrawals.
|
|
148
|
+
user Get all information about you!...
|
|
149
|
+
version Installed numerapi version.
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
Each command has it's own help page, for example:
|
|
153
|
+
|
|
154
|
+
$ numerapi submit --help
|
|
155
|
+
Usage: numerapi submit [OPTIONS] PATH
|
|
156
|
+
|
|
157
|
+
Upload predictions from file.
|
|
158
|
+
|
|
159
|
+
Options:
|
|
160
|
+
--tournament INTEGER The ID of the tournament, defaults to 1
|
|
161
|
+
--model_id TEXT An account model UUID (required for accounts with
|
|
162
|
+
multiple models
|
|
163
|
+
|
|
164
|
+
--help Show this message and exit.
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
# API Reference
|
|
168
|
+
|
|
169
|
+
Checkout the [detailed API docs](http://numerapi.readthedocs.io/en/latest/api/numerapi.html#module-numerapi.numerapi)
|
|
170
|
+
to learn about all available methods, parameters and returned values.
|
numerapi-2.19.0/PKG-INFO
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: numerapi
|
|
3
|
-
Version: 2.19.0
|
|
4
|
-
Summary: Automatically download and upload data for the Numerai machine learning competition
|
|
5
|
-
Home-page: https://github.com/uuazed/numerapi
|
|
6
|
-
Maintainer: uuazed
|
|
7
|
-
Maintainer-email: uuazed@gmail.com
|
|
8
|
-
License: MIT License
|
|
9
|
-
Description: [](https://app.travis-ci.com/uuazed/numerapi)
|
|
10
|
-
[](https://codecov.io/gh/uuazed/numerapi)
|
|
11
|
-
[](https://pypi.python.org/pypi/numerapi)
|
|
12
|
-
[](https://pepy.tech/project/numerapi)
|
|
13
|
-
[](http://numerapi.readthedocs.io/en/stable/?badge=stable)
|
|
14
|
-
|
|
15
|
-
# Numerai Python API
|
|
16
|
-
Automatically download and upload data for the Numerai machine learning
|
|
17
|
-
competition.
|
|
18
|
-
|
|
19
|
-
This library is a Python client to the Numerai API. The interface is programmed
|
|
20
|
-
in Python and allows downloading the training data, uploading predictions, and
|
|
21
|
-
accessing user, submission and competitions information. It works for both, the
|
|
22
|
-
main competition and the newer Numerai Signals competition.
|
|
23
|
-
|
|
24
|
-
If you encounter a problem or have suggestions, feel free to open an issue.
|
|
25
|
-
|
|
26
|
-
# Installation
|
|
27
|
-
`pip install --upgrade numerapi`
|
|
28
|
-
|
|
29
|
-
# Usage
|
|
30
|
-
|
|
31
|
-
Numerapi can be used as a regular, importable Python module or from the command
|
|
32
|
-
line.
|
|
33
|
-
|
|
34
|
-
Some actions (like uploading predictions or staking) require a token to verify
|
|
35
|
-
that it is really you interacting with Numerai's API. These tokens consists of
|
|
36
|
-
a `public_id` and `secret_key`. Both can be obtained by login in to Numer.ai and
|
|
37
|
-
going to Account -> Custom API Keys. Tokens can be passed to the Python module
|
|
38
|
-
as parameters or you can be set via environment variables (`NUMERAI_PUBLIC_ID`
|
|
39
|
-
and `NUMERAI_SECRET_KEY`).
|
|
40
|
-
|
|
41
|
-
## Python module
|
|
42
|
-
|
|
43
|
-
### Usage example - main competition
|
|
44
|
-
|
|
45
|
-
import numerapi
|
|
46
|
-
# some API calls do not require logging in
|
|
47
|
-
napi = numerapi.NumerAPI(verbosity="info")
|
|
48
|
-
# download current dataset => also check `https://numer.ai/data`
|
|
49
|
-
napi.download_dataset("v4/train.parquet", "train.parquet")
|
|
50
|
-
# get current leaderboard
|
|
51
|
-
leaderboard = napi.get_leaderboard()
|
|
52
|
-
# check if a new round has started
|
|
53
|
-
if napi.check_new_round():
|
|
54
|
-
print("new round has started within the last 12hours!")
|
|
55
|
-
else:
|
|
56
|
-
print("no new round within the last 12 hours")
|
|
57
|
-
|
|
58
|
-
# provide api tokens
|
|
59
|
-
example_public_id = "somepublicid"
|
|
60
|
-
example_secret_key = "somesecretkey"
|
|
61
|
-
napi = numerapi.NumerAPI(example_public_id, example_secret_key)
|
|
62
|
-
|
|
63
|
-
# upload predictions
|
|
64
|
-
model_id = napi.get_models()['uuazed']
|
|
65
|
-
napi.upload_predictions("preds.csv", model_id=model_id)
|
|
66
|
-
# increase your stake by 1.2 NMR
|
|
67
|
-
napi.stake_increase(1.2)
|
|
68
|
-
|
|
69
|
-
# convert results to a pandas dataframe
|
|
70
|
-
import pandas as pd
|
|
71
|
-
df = pd.DataFrame(napi.daily_user_performances("uuazed"))
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
### Usage example - Numerai Signals
|
|
75
|
-
|
|
76
|
-
import numerapi
|
|
77
|
-
|
|
78
|
-
napi = numerapi.SignalsAPI()
|
|
79
|
-
# get current leaderboard
|
|
80
|
-
leaderboard = napi.get_leaderboard()
|
|
81
|
-
|
|
82
|
-
# setup API with api tokens
|
|
83
|
-
example_public_id = "somepublicid"
|
|
84
|
-
example_secret_key = "somesecretkey"
|
|
85
|
-
napi = numerapi.SignalsAPI(example_public_id, example_secret_key)
|
|
86
|
-
|
|
87
|
-
# upload predictions
|
|
88
|
-
model_id = napi.get_models()['uuazed']
|
|
89
|
-
napi.upload_predictions("preds.csv", model_id=model_id)
|
|
90
|
-
|
|
91
|
-
# get daily performance as pandas dataframe
|
|
92
|
-
import pandas as pd
|
|
93
|
-
df = pd.DataFrame(napi.daily_user_performances("uuazed"))
|
|
94
|
-
|
|
95
|
-
# using the diagnostics tool
|
|
96
|
-
napi.upload_diagnostics("preds.csv", model_id=model_id)
|
|
97
|
-
# ... or using a pandas DataFrame directly
|
|
98
|
-
napi.upload_diagnostics(df=df, model_id=model_id)
|
|
99
|
-
# fetch results
|
|
100
|
-
napi.diagnostic(model_id)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
## Command line interface
|
|
104
|
-
|
|
105
|
-
To get started with the cli interface, let's take a look at the help page:
|
|
106
|
-
|
|
107
|
-
$ numerapi --help
|
|
108
|
-
Usage: numerapi [OPTIONS] COMMAND [ARGS]...
|
|
109
|
-
|
|
110
|
-
Wrapper around the Numerai API
|
|
111
|
-
|
|
112
|
-
Options:
|
|
113
|
-
--help Show this message and exit.
|
|
114
|
-
|
|
115
|
-
Commands:
|
|
116
|
-
account Get all information about your account!
|
|
117
|
-
check-new-round Check if a new round has started within...
|
|
118
|
-
competitions Retrieves information about all...
|
|
119
|
-
current-round Get number of the current active round.
|
|
120
|
-
daily-model-performances Fetch daily performance of a model.
|
|
121
|
-
daily-submissions-performances Fetch daily performance of a user's...
|
|
122
|
-
dataset-url Fetch url of the current dataset.
|
|
123
|
-
download-dataset Download specified file for the given...
|
|
124
|
-
download-dataset-old Download dataset for the current active...
|
|
125
|
-
leaderboard Get the leaderboard.
|
|
126
|
-
list-datasets List of available data files
|
|
127
|
-
models Get map of account models!
|
|
128
|
-
profile Fetch the public profile of a user.
|
|
129
|
-
stake-decrease Decrease your stake by `value` NMR.
|
|
130
|
-
stake-drain Completely remove your stake.
|
|
131
|
-
stake-get Get stake value of a user.
|
|
132
|
-
stake-increase Increase your stake by `value` NMR.
|
|
133
|
-
submission-filenames Get filenames of your submissions
|
|
134
|
-
submit Upload predictions from file.
|
|
135
|
-
transactions List all your deposits and withdrawals.
|
|
136
|
-
user Get all information about you!...
|
|
137
|
-
version Installed numerapi version.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
Each command has it's own help page, for example:
|
|
141
|
-
|
|
142
|
-
$ numerapi submit --help
|
|
143
|
-
Usage: numerapi submit [OPTIONS] PATH
|
|
144
|
-
|
|
145
|
-
Upload predictions from file.
|
|
146
|
-
|
|
147
|
-
Options:
|
|
148
|
-
--tournament INTEGER The ID of the tournament, defaults to 1
|
|
149
|
-
--model_id TEXT An account model UUID (required for accounts with
|
|
150
|
-
multiple models
|
|
151
|
-
|
|
152
|
-
--help Show this message and exit.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
# API Reference
|
|
156
|
-
|
|
157
|
-
Checkout the [detailed API docs](http://numerapi.readthedocs.io/en/latest/api/numerapi.html#module-numerapi.numerapi)
|
|
158
|
-
to learn about all available methods, parameters and returned values.
|
|
159
|
-
|
|
160
|
-
Platform: OS Independent
|
|
161
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
162
|
-
Classifier: Environment :: Console
|
|
163
|
-
Classifier: Intended Audience :: Science/Research
|
|
164
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
165
|
-
Classifier: Operating System :: OS Independent
|
|
166
|
-
Classifier: Programming Language :: Python
|
|
167
|
-
Classifier: Programming Language :: Python :: 3
|
|
168
|
-
Classifier: Topic :: Scientific/Engineering
|
|
169
|
-
Description-Content-Type: text/markdown
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: numerapi
|
|
3
|
-
Version: 2.19.0
|
|
4
|
-
Summary: Automatically download and upload data for the Numerai machine learning competition
|
|
5
|
-
Home-page: https://github.com/uuazed/numerapi
|
|
6
|
-
Maintainer: uuazed
|
|
7
|
-
Maintainer-email: uuazed@gmail.com
|
|
8
|
-
License: MIT License
|
|
9
|
-
Description: [](https://app.travis-ci.com/uuazed/numerapi)
|
|
10
|
-
[](https://codecov.io/gh/uuazed/numerapi)
|
|
11
|
-
[](https://pypi.python.org/pypi/numerapi)
|
|
12
|
-
[](https://pepy.tech/project/numerapi)
|
|
13
|
-
[](http://numerapi.readthedocs.io/en/stable/?badge=stable)
|
|
14
|
-
|
|
15
|
-
# Numerai Python API
|
|
16
|
-
Automatically download and upload data for the Numerai machine learning
|
|
17
|
-
competition.
|
|
18
|
-
|
|
19
|
-
This library is a Python client to the Numerai API. The interface is programmed
|
|
20
|
-
in Python and allows downloading the training data, uploading predictions, and
|
|
21
|
-
accessing user, submission and competitions information. It works for both, the
|
|
22
|
-
main competition and the newer Numerai Signals competition.
|
|
23
|
-
|
|
24
|
-
If you encounter a problem or have suggestions, feel free to open an issue.
|
|
25
|
-
|
|
26
|
-
# Installation
|
|
27
|
-
`pip install --upgrade numerapi`
|
|
28
|
-
|
|
29
|
-
# Usage
|
|
30
|
-
|
|
31
|
-
Numerapi can be used as a regular, importable Python module or from the command
|
|
32
|
-
line.
|
|
33
|
-
|
|
34
|
-
Some actions (like uploading predictions or staking) require a token to verify
|
|
35
|
-
that it is really you interacting with Numerai's API. These tokens consists of
|
|
36
|
-
a `public_id` and `secret_key`. Both can be obtained by login in to Numer.ai and
|
|
37
|
-
going to Account -> Custom API Keys. Tokens can be passed to the Python module
|
|
38
|
-
as parameters or you can be set via environment variables (`NUMERAI_PUBLIC_ID`
|
|
39
|
-
and `NUMERAI_SECRET_KEY`).
|
|
40
|
-
|
|
41
|
-
## Python module
|
|
42
|
-
|
|
43
|
-
### Usage example - main competition
|
|
44
|
-
|
|
45
|
-
import numerapi
|
|
46
|
-
# some API calls do not require logging in
|
|
47
|
-
napi = numerapi.NumerAPI(verbosity="info")
|
|
48
|
-
# download current dataset => also check `https://numer.ai/data`
|
|
49
|
-
napi.download_dataset("v4/train.parquet", "train.parquet")
|
|
50
|
-
# get current leaderboard
|
|
51
|
-
leaderboard = napi.get_leaderboard()
|
|
52
|
-
# check if a new round has started
|
|
53
|
-
if napi.check_new_round():
|
|
54
|
-
print("new round has started within the last 12hours!")
|
|
55
|
-
else:
|
|
56
|
-
print("no new round within the last 12 hours")
|
|
57
|
-
|
|
58
|
-
# provide api tokens
|
|
59
|
-
example_public_id = "somepublicid"
|
|
60
|
-
example_secret_key = "somesecretkey"
|
|
61
|
-
napi = numerapi.NumerAPI(example_public_id, example_secret_key)
|
|
62
|
-
|
|
63
|
-
# upload predictions
|
|
64
|
-
model_id = napi.get_models()['uuazed']
|
|
65
|
-
napi.upload_predictions("preds.csv", model_id=model_id)
|
|
66
|
-
# increase your stake by 1.2 NMR
|
|
67
|
-
napi.stake_increase(1.2)
|
|
68
|
-
|
|
69
|
-
# convert results to a pandas dataframe
|
|
70
|
-
import pandas as pd
|
|
71
|
-
df = pd.DataFrame(napi.daily_user_performances("uuazed"))
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
### Usage example - Numerai Signals
|
|
75
|
-
|
|
76
|
-
import numerapi
|
|
77
|
-
|
|
78
|
-
napi = numerapi.SignalsAPI()
|
|
79
|
-
# get current leaderboard
|
|
80
|
-
leaderboard = napi.get_leaderboard()
|
|
81
|
-
|
|
82
|
-
# setup API with api tokens
|
|
83
|
-
example_public_id = "somepublicid"
|
|
84
|
-
example_secret_key = "somesecretkey"
|
|
85
|
-
napi = numerapi.SignalsAPI(example_public_id, example_secret_key)
|
|
86
|
-
|
|
87
|
-
# upload predictions
|
|
88
|
-
model_id = napi.get_models()['uuazed']
|
|
89
|
-
napi.upload_predictions("preds.csv", model_id=model_id)
|
|
90
|
-
|
|
91
|
-
# get daily performance as pandas dataframe
|
|
92
|
-
import pandas as pd
|
|
93
|
-
df = pd.DataFrame(napi.daily_user_performances("uuazed"))
|
|
94
|
-
|
|
95
|
-
# using the diagnostics tool
|
|
96
|
-
napi.upload_diagnostics("preds.csv", model_id=model_id)
|
|
97
|
-
# ... or using a pandas DataFrame directly
|
|
98
|
-
napi.upload_diagnostics(df=df, model_id=model_id)
|
|
99
|
-
# fetch results
|
|
100
|
-
napi.diagnostic(model_id)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
## Command line interface
|
|
104
|
-
|
|
105
|
-
To get started with the cli interface, let's take a look at the help page:
|
|
106
|
-
|
|
107
|
-
$ numerapi --help
|
|
108
|
-
Usage: numerapi [OPTIONS] COMMAND [ARGS]...
|
|
109
|
-
|
|
110
|
-
Wrapper around the Numerai API
|
|
111
|
-
|
|
112
|
-
Options:
|
|
113
|
-
--help Show this message and exit.
|
|
114
|
-
|
|
115
|
-
Commands:
|
|
116
|
-
account Get all information about your account!
|
|
117
|
-
check-new-round Check if a new round has started within...
|
|
118
|
-
competitions Retrieves information about all...
|
|
119
|
-
current-round Get number of the current active round.
|
|
120
|
-
daily-model-performances Fetch daily performance of a model.
|
|
121
|
-
daily-submissions-performances Fetch daily performance of a user's...
|
|
122
|
-
dataset-url Fetch url of the current dataset.
|
|
123
|
-
download-dataset Download specified file for the given...
|
|
124
|
-
download-dataset-old Download dataset for the current active...
|
|
125
|
-
leaderboard Get the leaderboard.
|
|
126
|
-
list-datasets List of available data files
|
|
127
|
-
models Get map of account models!
|
|
128
|
-
profile Fetch the public profile of a user.
|
|
129
|
-
stake-decrease Decrease your stake by `value` NMR.
|
|
130
|
-
stake-drain Completely remove your stake.
|
|
131
|
-
stake-get Get stake value of a user.
|
|
132
|
-
stake-increase Increase your stake by `value` NMR.
|
|
133
|
-
submission-filenames Get filenames of your submissions
|
|
134
|
-
submit Upload predictions from file.
|
|
135
|
-
transactions List all your deposits and withdrawals.
|
|
136
|
-
user Get all information about you!...
|
|
137
|
-
version Installed numerapi version.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
Each command has it's own help page, for example:
|
|
141
|
-
|
|
142
|
-
$ numerapi submit --help
|
|
143
|
-
Usage: numerapi submit [OPTIONS] PATH
|
|
144
|
-
|
|
145
|
-
Upload predictions from file.
|
|
146
|
-
|
|
147
|
-
Options:
|
|
148
|
-
--tournament INTEGER The ID of the tournament, defaults to 1
|
|
149
|
-
--model_id TEXT An account model UUID (required for accounts with
|
|
150
|
-
multiple models
|
|
151
|
-
|
|
152
|
-
--help Show this message and exit.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
# API Reference
|
|
156
|
-
|
|
157
|
-
Checkout the [detailed API docs](http://numerapi.readthedocs.io/en/latest/api/numerapi.html#module-numerapi.numerapi)
|
|
158
|
-
to learn about all available methods, parameters and returned values.
|
|
159
|
-
|
|
160
|
-
Platform: OS Independent
|
|
161
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
162
|
-
Classifier: Environment :: Console
|
|
163
|
-
Classifier: Intended Audience :: Science/Research
|
|
164
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
165
|
-
Classifier: Operating System :: OS Independent
|
|
166
|
-
Classifier: Programming Language :: Python
|
|
167
|
-
Classifier: Programming Language :: Python :: 3
|
|
168
|
-
Classifier: Topic :: Scientific/Engineering
|
|
169
|
-
Description-Content-Type: text/markdown
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|