How to use the numerapi.NumerAPI function in numerapi

To help you get started, we’ve selected a few numerapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uuazed / numerapi / tests / test_numerapi.py View on Github external
def api_fixture():
    api = numerapi.NumerAPI(verbosity='DEBUG')
    return api
github numerai / numerox / numerox / numerai.py View on Github external
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
github uuazed / numerapi / example.py View on Github external
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)
github numerai / numerai-cli / numerai_compute / cli.py View on Github external
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.'''
        )
github numerai / numerox / numerox / leaderboard.py View on Github external
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
github uuazed / numerapi / numerapi / cli.py View on Github external
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')
github numerai / numerox / numerox / numerai.py View on Github external
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
github numerai / numerox / numerox / numerai.py View on Github external
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