Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def api_fixture():
api = numerapi.NumerAPI(verbosity='DEBUG')
return api
def round_dates():
"The dates each round was opened and resolved as a Dataframe."
napi = NumerAPI(verbosity='warn')
dates = napi.get_competitions(tournament=1)
dates = pd.DataFrame(dates)[['number', 'openTime', 'resolveTime']]
rename_map = {
'number': 'round',
'openTime': 'open',
'resolveTime': 'resolve'
}
dates = dates.rename(rename_map, axis=1)
for item in ('open', 'resolve'):
date = dates[item].tolist()
date = [d.date() for d in date]
dates[item] = date
dates = dates.set_index('round')
dates = dates.sort_index()
return dates
def main():
# set example username and round
example_public_id = "somepublicid"
example_secret_key = "somesecretkey"
# some API calls do not require logging in
napi = numerapi.NumerAPI(verbosity="info")
# download current dataset
napi.download_current_dataset(unzip=True)
# get competitions
all_competitions = napi.get_competitions()
# get leaderboard for the current round
leaderboard = napi.get_leaderboard()
# leaderboard for a historic round
leaderboard_67 = napi.get_leaderboard(round_num=67)
# check if a new round has started
if napi.check_new_round():
print("new round has started wihtin the last 24hours!")
else:
print("no new round within the last 24 hours")
# provide api tokens
napi = NumerAPI(example_public_id, example_secret_key)
def check_numerai_validity(key_id, secret):
try:
napi = numerapi.NumerAPI(key_id, secret)
napi.get_account()
return True
except Exception:
raise exception_with_msg(
'''Numerai keys seem to be invalid. Make sure you've entered them correctly.'''
)
nmrAmount
usdAmount
}
stake {
value
confidence
soc
}
stakeResolution {
destroyed
}
}
}
}
'''
napi = NumerAPI(verbosity='warn')
if round_number is None:
round_number = get_current_round_number(tournament)
arguments = {'number': round_number, 'tournament': tournament}
leaderboard = napi.raw_query(query, arguments)
leaderboard = leaderboard['data']['rounds'][0]['leaderboard']
return leaderboard
from __future__ import absolute_import
import pprint
import click
import numerapi
napi = numerapi.NumerAPI()
def prettify(stuff):
pp = pprint.PrettyPrinter(indent=4)
return pp.pformat(stuff)
@click.group()
def cli():
"""Wrapper around the Numerai API"""
pass
@cli.command()
@click.option('--tournament', default=8,
help='The ID of the tournament, defaults to 8')
def upload_status(upload_id, public_id, secret_key, model_id=None):
"Dictionary containing the status of upload"
napi = NumerAPI(public_id=public_id,
secret_key=secret_key,
verbosity='warning')
status_raw = napi.submission_status(upload_id, model_id=model_id)
status = {}
for key, value in status_raw.items():
if isinstance(value, dict):
value = value['value']
status[key] = value
return status
def get_user_names():
"A list containing all Numerai users, past and present."
q = '''
query {
rankings(limit:100000, offset:0)
{
username
}
}
'''
napi = NumerAPI()
users = napi.raw_query(q)
users = [x['username'] for x in users['data']['rankings']]
return users