numerapi 2.21.0__py3-none-any.whl → 2.23.0.dev0__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.
- numerapi/base_api.py +206 -1
- numerapi/cryptoapi.py +39 -0
- {numerapi-2.21.0.dist-info → numerapi-2.23.0.dev0.dist-info}/METADATA +1 -1
- numerapi-2.23.0.dev0.dist-info/RECORD +14 -0
- {numerapi-2.21.0.dist-info → numerapi-2.23.0.dev0.dist-info}/WHEEL +1 -1
- numerapi-2.21.0.dist-info/RECORD +0 -14
- {numerapi-2.21.0.dist-info → numerapi-2.23.0.dev0.dist-info}/entry_points.txt +0 -0
- {numerapi-2.21.0.dist-info → numerapi-2.23.0.dev0.dist-info}/licenses/LICENSE +0 -0
- {numerapi-2.21.0.dist-info → numerapi-2.23.0.dev0.dist-info}/top_level.txt +0 -0
numerapi/base_api.py
CHANGED
|
@@ -383,6 +383,211 @@ class Api:
|
|
|
383
383
|
}
|
|
384
384
|
return mapping
|
|
385
385
|
|
|
386
|
+
def v3_stake_auth(
|
|
387
|
+
self,
|
|
388
|
+
submission_id: str,
|
|
389
|
+
staker: str,
|
|
390
|
+
amount: float | str | None = None,
|
|
391
|
+
max_amount: float | str | None = None,
|
|
392
|
+
) -> Dict:
|
|
393
|
+
"""Issue a staking v3 authorization for a selected submission.
|
|
394
|
+
|
|
395
|
+
Args:
|
|
396
|
+
submission_id (str): submission id for the selected submission
|
|
397
|
+
staker (str): staker wallet address
|
|
398
|
+
amount (float or str, optional): max stake amount for the
|
|
399
|
+
authorization. Retained as a backwards-compatible alias for
|
|
400
|
+
`max_amount`.
|
|
401
|
+
max_amount (float or str, optional): max stake amount for the
|
|
402
|
+
authorization.
|
|
403
|
+
|
|
404
|
+
Returns:
|
|
405
|
+
dict: authorization payload with the following fields:
|
|
406
|
+
|
|
407
|
+
* authorizationSigner (`str`)
|
|
408
|
+
* authorizationDigest (`str`)
|
|
409
|
+
* chainId (`str`)
|
|
410
|
+
* deadline (`str`)
|
|
411
|
+
* maxAmount (`str`)
|
|
412
|
+
* amount (`str`) alias for `maxAmount`
|
|
413
|
+
* modelId (`str`)
|
|
414
|
+
* nmrAddress (`str`)
|
|
415
|
+
* nonce (`str`)
|
|
416
|
+
* roundId (`str`)
|
|
417
|
+
* signature (`str`)
|
|
418
|
+
* staker (`str`)
|
|
419
|
+
* stakingAddress (`str`)
|
|
420
|
+
* submissionId (`str`)
|
|
421
|
+
* submissionHash (`str`)
|
|
422
|
+
* tournamentId (`str`)
|
|
423
|
+
"""
|
|
424
|
+
if (amount is None) == (max_amount is None):
|
|
425
|
+
raise ValueError("Provide exactly one of amount or max_amount.")
|
|
426
|
+
|
|
427
|
+
max_amount = max_amount if max_amount is not None else amount
|
|
428
|
+
query = """
|
|
429
|
+
mutation($submissionId: ID!, $staker: String!, $maxAmount: String!) {
|
|
430
|
+
v3StakeAuth(
|
|
431
|
+
submissionId: $submissionId
|
|
432
|
+
staker: $staker
|
|
433
|
+
maxAmount: $maxAmount
|
|
434
|
+
) {
|
|
435
|
+
authorizationSigner
|
|
436
|
+
authorizationDigest
|
|
437
|
+
chainId
|
|
438
|
+
deadline
|
|
439
|
+
maxAmount
|
|
440
|
+
modelId
|
|
441
|
+
nmrAddress
|
|
442
|
+
nonce
|
|
443
|
+
roundId
|
|
444
|
+
signature
|
|
445
|
+
staker
|
|
446
|
+
stakingAddress
|
|
447
|
+
submissionId
|
|
448
|
+
submissionHash
|
|
449
|
+
tournamentId
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
"""
|
|
453
|
+
arguments = {
|
|
454
|
+
"submissionId": submission_id,
|
|
455
|
+
"staker": staker,
|
|
456
|
+
"maxAmount": str(max_amount),
|
|
457
|
+
}
|
|
458
|
+
authorization = self.raw_query(query, arguments, authorization=True)["data"][
|
|
459
|
+
"v3StakeAuth"
|
|
460
|
+
]
|
|
461
|
+
authorization["amount"] = authorization["maxAmount"]
|
|
462
|
+
return authorization
|
|
463
|
+
|
|
464
|
+
def v3_stake_config(self) -> Dict:
|
|
465
|
+
"""Fetch staking v3 contract configuration.
|
|
466
|
+
|
|
467
|
+
Returns:
|
|
468
|
+
dict: staking v3 configuration with the following fields:
|
|
469
|
+
|
|
470
|
+
* address (`str`)
|
|
471
|
+
* authorizationSigner (`str`)
|
|
472
|
+
* nmrAddress (`str`)
|
|
473
|
+
* owner (`str`)
|
|
474
|
+
* paused (`bool`)
|
|
475
|
+
* pendingOwner (`str`)
|
|
476
|
+
* serviceWallet (`str`)
|
|
477
|
+
"""
|
|
478
|
+
query = """
|
|
479
|
+
query {
|
|
480
|
+
v3StakeConfig {
|
|
481
|
+
address
|
|
482
|
+
authorizationSigner
|
|
483
|
+
nmrAddress
|
|
484
|
+
owner
|
|
485
|
+
paused
|
|
486
|
+
pendingOwner
|
|
487
|
+
serviceWallet
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
"""
|
|
491
|
+
return self.raw_query(query, authorization=True)["data"]["v3StakeConfig"]
|
|
492
|
+
|
|
493
|
+
def v3_stake_round(self, round_id: int | str) -> Dict:
|
|
494
|
+
"""Fetch staking v3 round status by round id.
|
|
495
|
+
|
|
496
|
+
Args:
|
|
497
|
+
round_id (int or str): round id
|
|
498
|
+
|
|
499
|
+
Returns:
|
|
500
|
+
dict: staking v3 round data with the following fields:
|
|
501
|
+
|
|
502
|
+
* closeTime (`str`)
|
|
503
|
+
* merkleRoot (`str`)
|
|
504
|
+
* openTime (`str`)
|
|
505
|
+
* payoutFactor (`str`)
|
|
506
|
+
* remainingBurn (`str`)
|
|
507
|
+
* remainingPayout (`str`)
|
|
508
|
+
* resolveTime (`str`)
|
|
509
|
+
* resolved (`bool`)
|
|
510
|
+
* roundId (`str`)
|
|
511
|
+
* stakeCap (`str`)
|
|
512
|
+
* stakeThreshold (`str`)
|
|
513
|
+
* state (`str`)
|
|
514
|
+
* totalPayout (`str`)
|
|
515
|
+
* totalStaked (`str`)
|
|
516
|
+
* tournamentId (`str`)
|
|
517
|
+
"""
|
|
518
|
+
query = """
|
|
519
|
+
query($roundId: String!) {
|
|
520
|
+
v3StakeRound(roundId: $roundId) {
|
|
521
|
+
closeTime
|
|
522
|
+
merkleRoot
|
|
523
|
+
openTime
|
|
524
|
+
payoutFactor
|
|
525
|
+
remainingBurn
|
|
526
|
+
remainingPayout
|
|
527
|
+
resolveTime
|
|
528
|
+
resolved
|
|
529
|
+
roundId
|
|
530
|
+
stakeCap
|
|
531
|
+
stakeThreshold
|
|
532
|
+
state
|
|
533
|
+
totalPayout
|
|
534
|
+
totalStaked
|
|
535
|
+
tournamentId
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
"""
|
|
539
|
+
arguments = {"roundId": str(round_id)}
|
|
540
|
+
return self.raw_query(query, arguments, authorization=True)["data"][
|
|
541
|
+
"v3StakeRound"
|
|
542
|
+
]
|
|
543
|
+
|
|
544
|
+
def v3_stake_claim(self, round_id: int | str, model_id: str, staker: str) -> Dict:
|
|
545
|
+
"""Fetch a staking v3 claim proof for a model and staker.
|
|
546
|
+
|
|
547
|
+
Args:
|
|
548
|
+
round_id (int or str): round id
|
|
549
|
+
model_id (str): model id
|
|
550
|
+
staker (str): staker wallet address
|
|
551
|
+
|
|
552
|
+
Returns:
|
|
553
|
+
dict: claim payload with the following fields:
|
|
554
|
+
|
|
555
|
+
* apiModelId (`str`)
|
|
556
|
+
* burnAmountWei (`str`)
|
|
557
|
+
* merkleRoot (`str`)
|
|
558
|
+
* modelId (`str`)
|
|
559
|
+
* payoutAmountWei (`str`)
|
|
560
|
+
* proof (`list` of `str`)
|
|
561
|
+
* roundId (`str`)
|
|
562
|
+
* staker (`str`)
|
|
563
|
+
* submissionId (`str`)
|
|
564
|
+
* tournamentId (`str`)
|
|
565
|
+
"""
|
|
566
|
+
query = """
|
|
567
|
+
query($roundId: String!, $modelId: ID!, $staker: String!) {
|
|
568
|
+
v3StakeClaim(roundId: $roundId, modelId: $modelId, staker: $staker) {
|
|
569
|
+
apiModelId
|
|
570
|
+
burnAmountWei
|
|
571
|
+
merkleRoot
|
|
572
|
+
modelId
|
|
573
|
+
payoutAmountWei
|
|
574
|
+
proof
|
|
575
|
+
roundId
|
|
576
|
+
staker
|
|
577
|
+
submissionId
|
|
578
|
+
tournamentId
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
"""
|
|
582
|
+
arguments = {
|
|
583
|
+
"roundId": str(round_id),
|
|
584
|
+
"modelId": model_id,
|
|
585
|
+
"staker": staker,
|
|
586
|
+
}
|
|
587
|
+
return self.raw_query(query, arguments, authorization=True)["data"][
|
|
588
|
+
"v3StakeClaim"
|
|
589
|
+
]
|
|
590
|
+
|
|
386
591
|
def get_current_round(self, tournament: int | None = None) -> int | None:
|
|
387
592
|
"""Get number of the current active round.
|
|
388
593
|
|
|
@@ -1200,7 +1405,7 @@ class Api:
|
|
|
1200
1405
|
return False
|
|
1201
1406
|
if raw is None:
|
|
1202
1407
|
return False
|
|
1203
|
-
open_time = utils.parse_datetime_string(raw[
|
|
1408
|
+
open_time = utils.parse_datetime_string(raw["openTime"])
|
|
1204
1409
|
now = datetime.datetime.now(tz=pytz.utc)
|
|
1205
1410
|
is_new_round = open_time > now - datetime.timedelta(hours=hours)
|
|
1206
1411
|
return is_new_round
|
numerapi/cryptoapi.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"""API for Numerai Crypto"""
|
|
2
2
|
|
|
3
|
+
from typing import List, Dict
|
|
3
4
|
from numerapi import base_api
|
|
5
|
+
from numerapi import utils
|
|
6
|
+
|
|
4
7
|
|
|
5
8
|
class CryptoAPI(base_api.Api):
|
|
6
9
|
""""API for Numerai Crypto"""
|
|
@@ -8,3 +11,39 @@ class CryptoAPI(base_api.Api):
|
|
|
8
11
|
def __init__(self, *args, **kwargs):
|
|
9
12
|
base_api.Api.__init__(self, *args, **kwargs)
|
|
10
13
|
self.tournament_id = 12
|
|
14
|
+
|
|
15
|
+
def get_leaderboard(self, limit: int = 50, offset: int = 0) -> List[Dict]:
|
|
16
|
+
"""Get the current Numerai Crypto leaderboard with a reduced set of fields.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
list of dicts: each dict contains only the requested fields:
|
|
20
|
+
- nmrStaked
|
|
21
|
+
- rank
|
|
22
|
+
- username
|
|
23
|
+
- corrRep
|
|
24
|
+
- mmcRep
|
|
25
|
+
- return_1_day
|
|
26
|
+
- return_52_weeks
|
|
27
|
+
- return_13_weeks
|
|
28
|
+
"""
|
|
29
|
+
query = '''
|
|
30
|
+
query($limit: Int!
|
|
31
|
+
$offset: Int!) {
|
|
32
|
+
cryptosignalsLeaderboard(limit: $limit
|
|
33
|
+
offset: $offset) {
|
|
34
|
+
nmrStaked
|
|
35
|
+
rank
|
|
36
|
+
username
|
|
37
|
+
corrRep
|
|
38
|
+
mmcRep
|
|
39
|
+
return_1_day
|
|
40
|
+
return_52_weeks
|
|
41
|
+
return_13_weeks
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
'''
|
|
45
|
+
arguments = {'limit': limit, 'offset': offset}
|
|
46
|
+
data = self.raw_query(query, arguments)['data']['cryptosignalsLeaderboard']
|
|
47
|
+
for item in data:
|
|
48
|
+
utils.replace(item, "nmrStaked", utils.parse_float_string)
|
|
49
|
+
return data
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
numerapi/__init__.py,sha256=okDA4NGjUj1Q8bDJg4T1t0LTf_S3GPbXCdw8gla7_VU,449
|
|
2
|
+
numerapi/base_api.py,sha256=pSSPpcb4WAfg-cg6MG8WdDR00wCY4Aryopw2G7GU5G0,65707
|
|
3
|
+
numerapi/cli.py,sha256=oaATypyxS0mlW2Uouby6Srq0DxWkouBg63uiXJY-QHM,8206
|
|
4
|
+
numerapi/cryptoapi.py,sha256=J9fAEhiaEfpvRCiDsSJz8rlazKD-4nkJRJ85f09jGp0,1502
|
|
5
|
+
numerapi/numerapi.py,sha256=cyTpNGRKr4BqK2jKA2Rj540tjyykpV3axz-6jLm1Flo,12323
|
|
6
|
+
numerapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
numerapi/signalsapi.py,sha256=inKwMvuIWNGcDFzzdhqRO1RIms_qz1d7lkwA2dzvAoQ,10188
|
|
8
|
+
numerapi/utils.py,sha256=YgXujHyE1TLTf5v1pspcVAX89SQI3Zl3vMcbNlHZJDs,4688
|
|
9
|
+
numerapi-2.23.0.dev0.dist-info/licenses/LICENSE,sha256=BnOIJOdxTIxmbNPf_ZmCXqepXDTRWad1nQf9eYk-eSg,1056
|
|
10
|
+
numerapi-2.23.0.dev0.dist-info/METADATA,sha256=D4tQpOSFKvPuZepaQNHCL6pyzxOOhBe9dPBy11M9xlE,7041
|
|
11
|
+
numerapi-2.23.0.dev0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
12
|
+
numerapi-2.23.0.dev0.dist-info/entry_points.txt,sha256=P7RHLytfftNPE14vRxml52-UEkyuAviRegWTID4a_ig,46
|
|
13
|
+
numerapi-2.23.0.dev0.dist-info/top_level.txt,sha256=7f4lKNQqRDEGaDXGIqRQCx-rU5pNl6ZgbXz864F1uXY,9
|
|
14
|
+
numerapi-2.23.0.dev0.dist-info/RECORD,,
|
numerapi-2.21.0.dist-info/RECORD
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
numerapi/__init__.py,sha256=okDA4NGjUj1Q8bDJg4T1t0LTf_S3GPbXCdw8gla7_VU,449
|
|
2
|
-
numerapi/base_api.py,sha256=vbR14JxijAeDGI5vTNa0TL1HKHO_hM0X9Ysq9W28emA,59280
|
|
3
|
-
numerapi/cli.py,sha256=oaATypyxS0mlW2Uouby6Srq0DxWkouBg63uiXJY-QHM,8206
|
|
4
|
-
numerapi/cryptoapi.py,sha256=HrvBHaI-rGtBHJDo7rbBTN-tmKLXpWuzEAAifJWs-Ag,253
|
|
5
|
-
numerapi/numerapi.py,sha256=cyTpNGRKr4BqK2jKA2Rj540tjyykpV3axz-6jLm1Flo,12323
|
|
6
|
-
numerapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
numerapi/signalsapi.py,sha256=inKwMvuIWNGcDFzzdhqRO1RIms_qz1d7lkwA2dzvAoQ,10188
|
|
8
|
-
numerapi/utils.py,sha256=YgXujHyE1TLTf5v1pspcVAX89SQI3Zl3vMcbNlHZJDs,4688
|
|
9
|
-
numerapi-2.21.0.dist-info/licenses/LICENSE,sha256=BnOIJOdxTIxmbNPf_ZmCXqepXDTRWad1nQf9eYk-eSg,1056
|
|
10
|
-
numerapi-2.21.0.dist-info/METADATA,sha256=gY9Tp4vO7HQAAGztLdop_vremPyNbjemUW9JL5PUYBM,7036
|
|
11
|
-
numerapi-2.21.0.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
|
12
|
-
numerapi-2.21.0.dist-info/entry_points.txt,sha256=P7RHLytfftNPE14vRxml52-UEkyuAviRegWTID4a_ig,46
|
|
13
|
-
numerapi-2.21.0.dist-info/top_level.txt,sha256=7f4lKNQqRDEGaDXGIqRQCx-rU5pNl6ZgbXz864F1uXY,9
|
|
14
|
-
numerapi-2.21.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|