numerapi 2.20.2__tar.gz → 2.20.4__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.2 → numerapi-2.20.4}/PKG-INFO +1 -1
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi/base_api.py +24 -25
- numerapi-2.20.4/numerapi/py.typed +0 -0
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi/signalsapi.py +3 -3
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi/utils.py +6 -7
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi.egg-info/PKG-INFO +1 -1
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi.egg-info/SOURCES.txt +1 -0
- {numerapi-2.20.2 → numerapi-2.20.4}/setup.py +2 -2
- {numerapi-2.20.2 → numerapi-2.20.4}/LICENSE +0 -0
- {numerapi-2.20.2 → numerapi-2.20.4}/README.md +0 -0
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi/__init__.py +0 -0
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi/cli.py +0 -0
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi/cryptoapi.py +0 -0
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi/numerapi.py +0 -0
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi.egg-info/dependency_links.txt +0 -0
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi.egg-info/entry_points.txt +0 -0
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi.egg-info/requires.txt +0 -0
- {numerapi-2.20.2 → numerapi-2.20.4}/numerapi.egg-info/top_level.txt +0 -0
- {numerapi-2.20.2 → numerapi-2.20.4}/setup.cfg +0 -0
|
@@ -72,7 +72,7 @@ class Api:
|
|
|
72
72
|
self.logger.error(msg)
|
|
73
73
|
return msg
|
|
74
74
|
|
|
75
|
-
def raw_query(self, query: str, variables: Dict = None,
|
|
75
|
+
def raw_query(self, query: str, variables: Dict | None = None,
|
|
76
76
|
authorization: bool = False,
|
|
77
77
|
*, retries: int = 3, delay: int = 5, backoff: int = 2):
|
|
78
78
|
"""Send a raw request to the Numerai's GraphQL API.
|
|
@@ -131,7 +131,7 @@ class Api:
|
|
|
131
131
|
raise ValueError(err)
|
|
132
132
|
return result
|
|
133
133
|
|
|
134
|
-
def list_datasets(self, round_num: int = None) -> List[str]:
|
|
134
|
+
def list_datasets(self, round_num: int | None = None) -> List[str]:
|
|
135
135
|
"""List of available data files
|
|
136
136
|
|
|
137
137
|
Args:
|
|
@@ -158,8 +158,8 @@ class Api:
|
|
|
158
158
|
return self.raw_query(query, args)['data']['listDatasets']
|
|
159
159
|
|
|
160
160
|
def download_dataset(self, filename: str = None,
|
|
161
|
-
dest_path: str = None,
|
|
162
|
-
round_num: int = None) ->
|
|
161
|
+
dest_path: str | None = None,
|
|
162
|
+
round_num: int | None = None) -> str:
|
|
163
163
|
""" Download specified file for the given round.
|
|
164
164
|
|
|
165
165
|
Args:
|
|
@@ -358,7 +358,7 @@ class Api:
|
|
|
358
358
|
}
|
|
359
359
|
return mapping
|
|
360
360
|
|
|
361
|
-
def get_current_round(self, tournament: int = None) -> int:
|
|
361
|
+
def get_current_round(self, tournament: int | None = None) -> int | None:
|
|
362
362
|
"""Get number of the current active round.
|
|
363
363
|
|
|
364
364
|
Args:
|
|
@@ -554,9 +554,9 @@ class Api:
|
|
|
554
554
|
authorization=True)['data'][endpoint]
|
|
555
555
|
|
|
556
556
|
def upload_diagnostics(self, file_path: str = "predictions.csv",
|
|
557
|
-
tournament: int = None,
|
|
558
|
-
model_id: str = None,
|
|
559
|
-
df: pd.DataFrame = None) -> str:
|
|
557
|
+
tournament: int | None = None,
|
|
558
|
+
model_id: str | None = None,
|
|
559
|
+
df: pd.DataFrame | None = None) -> str:
|
|
560
560
|
"""Upload predictions to diagnostics from file.
|
|
561
561
|
|
|
562
562
|
Args:
|
|
@@ -611,7 +611,7 @@ class Api:
|
|
|
611
611
|
diagnostics_id = create['data']['createDiagnostics']['id']
|
|
612
612
|
return diagnostics_id
|
|
613
613
|
|
|
614
|
-
def diagnostics(self, model_id: str, diagnostics_id: str = None) -> Dict:
|
|
614
|
+
def diagnostics(self, model_id: str, diagnostics_id: str | None = None) -> Dict:
|
|
615
615
|
"""Fetch results of diagnostics run
|
|
616
616
|
|
|
617
617
|
Args:
|
|
@@ -935,7 +935,7 @@ class Api:
|
|
|
935
935
|
|
|
936
936
|
|
|
937
937
|
def stake_change(self, nmr, action: str = "decrease",
|
|
938
|
-
model_id: str = None) -> Dict:
|
|
938
|
+
model_id: str | None = None) -> Dict:
|
|
939
939
|
"""Change stake by `value` NMR.
|
|
940
940
|
|
|
941
941
|
Args:
|
|
@@ -1031,7 +1031,7 @@ class Api:
|
|
|
1031
1031
|
raw = self.raw_query(query, arguments, authorization=True)
|
|
1032
1032
|
return raw['data']['releaseStake']
|
|
1033
1033
|
|
|
1034
|
-
def stake_decrease(self, nmr, model_id: str = None) -> Dict:
|
|
1034
|
+
def stake_decrease(self, nmr, model_id: str | None = None) -> Dict:
|
|
1035
1035
|
"""Decrease your stake by `value` NMR.
|
|
1036
1036
|
|
|
1037
1037
|
Args:
|
|
@@ -1059,7 +1059,7 @@ class Api:
|
|
|
1059
1059
|
"""
|
|
1060
1060
|
return self.stake_change(nmr, 'decrease', model_id)
|
|
1061
1061
|
|
|
1062
|
-
def stake_increase(self, nmr, model_id: str = None) -> Dict:
|
|
1062
|
+
def stake_increase(self, nmr, model_id: str | None = None) -> Dict:
|
|
1063
1063
|
"""Increase your stake by `value` NMR.
|
|
1064
1064
|
|
|
1065
1065
|
Args:
|
|
@@ -1123,12 +1123,11 @@ class Api:
|
|
|
1123
1123
|
is_open = open_time < now < deadline
|
|
1124
1124
|
return is_open
|
|
1125
1125
|
|
|
1126
|
-
def check_new_round(self, hours: int = 12
|
|
1126
|
+
def check_new_round(self, hours: int = 12) -> bool:
|
|
1127
1127
|
"""Check if a new round has started within the last `hours`.
|
|
1128
1128
|
|
|
1129
1129
|
Args:
|
|
1130
1130
|
hours (int, optional): timeframe to consider, defaults to 12
|
|
1131
|
-
tournament (int): ID of the tournament (optional)
|
|
1132
1131
|
|
|
1133
1132
|
Returns:
|
|
1134
1133
|
bool: True if a new round has started, False otherwise.
|
|
@@ -1146,8 +1145,7 @@ class Api:
|
|
|
1146
1145
|
}
|
|
1147
1146
|
}
|
|
1148
1147
|
'''
|
|
1149
|
-
|
|
1150
|
-
arguments = {'tournament': tournament}
|
|
1148
|
+
arguments = {'tournament': self.tournament_id}
|
|
1151
1149
|
# in some period in between rounds, "number: 0" returns Value error -
|
|
1152
1150
|
# "Current round not open for submissions", because there is no active
|
|
1153
1151
|
# round. This is caught by the try / except.
|
|
@@ -1301,10 +1299,10 @@ class Api:
|
|
|
1301
1299
|
return res
|
|
1302
1300
|
|
|
1303
1301
|
def model_upload(self, file_path: str,
|
|
1304
|
-
tournament: int = None,
|
|
1305
|
-
model_id: str = None,
|
|
1306
|
-
data_version: str = None,
|
|
1307
|
-
docker_image: str = None) -> str:
|
|
1302
|
+
tournament: int | None = None,
|
|
1303
|
+
model_id: str | None = None,
|
|
1304
|
+
data_version: str | None = None,
|
|
1305
|
+
docker_image: str | None = None) -> str:
|
|
1308
1306
|
"""Upload pickled model to numerai.
|
|
1309
1307
|
|
|
1310
1308
|
Args:
|
|
@@ -1471,8 +1469,9 @@ class Api:
|
|
|
1471
1469
|
utils.replace(data, "insertedAt", utils.parse_datetime_string)
|
|
1472
1470
|
return data
|
|
1473
1471
|
|
|
1474
|
-
def download_submission(self, submission_id: str = None,
|
|
1475
|
-
model_id: str
|
|
1472
|
+
def download_submission(self, submission_id: str | None = None,
|
|
1473
|
+
model_id: str | None = None,
|
|
1474
|
+
dest_path: str | None = None) -> str:
|
|
1476
1475
|
""" Download previous submissions from numerai
|
|
1477
1476
|
|
|
1478
1477
|
Args:
|
|
@@ -1516,9 +1515,9 @@ class Api:
|
|
|
1516
1515
|
return path
|
|
1517
1516
|
|
|
1518
1517
|
def upload_predictions(self, file_path: str = "predictions.csv",
|
|
1519
|
-
model_id: str = None,
|
|
1520
|
-
df: pd.DataFrame = None,
|
|
1521
|
-
data_datestamp: int = None,
|
|
1518
|
+
model_id: str | None = None,
|
|
1519
|
+
df: pd.DataFrame | None = None,
|
|
1520
|
+
data_datestamp: int | None = None,
|
|
1522
1521
|
timeout: Union[None, float, Tuple[float, float]] = (10, 600)
|
|
1523
1522
|
) -> str:
|
|
1524
1523
|
"""Upload predictions from file.
|
|
File without changes
|
|
@@ -80,9 +80,9 @@ class SignalsAPI(base_api.Api):
|
|
|
80
80
|
return data
|
|
81
81
|
|
|
82
82
|
def upload_predictions(self, file_path: str = "predictions.csv",
|
|
83
|
-
model_id: str = None,
|
|
84
|
-
df: pd.DataFrame = None,
|
|
85
|
-
data_datestamp: int = None,
|
|
83
|
+
model_id: str | None = None,
|
|
84
|
+
df: pd.DataFrame | None = None,
|
|
85
|
+
data_datestamp: int | None = None,
|
|
86
86
|
timeout: Union[None, float, Tuple[float, float]] = (10, 600)
|
|
87
87
|
) -> str:
|
|
88
88
|
"""Upload predictions from file.
|
|
@@ -7,7 +7,6 @@ import time
|
|
|
7
7
|
import datetime
|
|
8
8
|
import uuid
|
|
9
9
|
import json
|
|
10
|
-
from typing import Optional, Dict
|
|
11
10
|
|
|
12
11
|
import dateutil.parser
|
|
13
12
|
import requests
|
|
@@ -31,14 +30,14 @@ def load_secrets() -> tuple:
|
|
|
31
30
|
return public_id, secret_key
|
|
32
31
|
|
|
33
32
|
|
|
34
|
-
def parse_datetime_string(string: str) ->
|
|
33
|
+
def parse_datetime_string(string: str) -> datetime.datetime | None:
|
|
35
34
|
"""try to parse string to datetime object"""
|
|
36
35
|
if string is None:
|
|
37
36
|
return None
|
|
38
37
|
return dateutil.parser.parse(string)
|
|
39
38
|
|
|
40
39
|
|
|
41
|
-
def parse_float_string(string: str) ->
|
|
40
|
+
def parse_float_string(string: str) -> decimal.Decimal | None:
|
|
42
41
|
"""try to parse string to decimal.Decimal object"""
|
|
43
42
|
if string is None:
|
|
44
43
|
return None
|
|
@@ -49,7 +48,7 @@ def parse_float_string(string: str) -> Optional[float]:
|
|
|
49
48
|
return val
|
|
50
49
|
|
|
51
50
|
|
|
52
|
-
def replace(dictionary:
|
|
51
|
+
def replace(dictionary: dict, key: str, function):
|
|
53
52
|
"""apply a function to dict item"""
|
|
54
53
|
if dictionary is not None and key in dictionary:
|
|
55
54
|
dictionary[key] = function(dictionary[key])
|
|
@@ -105,10 +104,10 @@ def download_file(url: str, dest_path: str, show_progress_bars: bool = True):
|
|
|
105
104
|
return dest_path
|
|
106
105
|
|
|
107
106
|
|
|
108
|
-
def post_with_err_handling(url: str, body: str, headers:
|
|
109
|
-
*, timeout:
|
|
107
|
+
def post_with_err_handling(url: str, body: str, headers: dict,
|
|
108
|
+
*, timeout: int | None = None,
|
|
110
109
|
retries: int = 3, delay: int = 1, backoff: int = 2
|
|
111
|
-
) ->
|
|
110
|
+
) -> dict:
|
|
112
111
|
"""send `post` request and handle (some) errors that might occur"""
|
|
113
112
|
try:
|
|
114
113
|
resp = requests.post(url, json=body, headers=headers, timeout=timeout)
|
|
@@ -6,7 +6,7 @@ def load(path):
|
|
|
6
6
|
return open(path, 'r').read()
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
numerapi_version = '2.20.
|
|
9
|
+
numerapi_version = '2.20.4'
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
classifiers = [
|
|
@@ -33,7 +33,7 @@ if __name__ == "__main__":
|
|
|
33
33
|
platforms="OS Independent",
|
|
34
34
|
classifiers=classifiers,
|
|
35
35
|
license='MIT License',
|
|
36
|
-
package_data={'
|
|
36
|
+
package_data={'numerapi': ['LICENSE', 'README.md', "py.typed"]},
|
|
37
37
|
packages=find_packages(exclude=['tests']),
|
|
38
38
|
install_requires=["requests", "pytz", "python-dateutil",
|
|
39
39
|
"tqdm>=4.29.1", "click>=7.0", "pandas>=1.1.0"],
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|