Giter Club home page Giter Club logo

numerapi's Introduction

Build Status codecov PyPI

Numerai Python API

Automatically download and upload data for the Numerai machine learning competition.

This library is a Python client to the Numerai API. The interface is programmed in Python and allows downloading the training data, uploading predictions, and accessing user, submission and competitions information.

If you encounter a problem or have suggestions, feel free to open an issue.

Installation

pip install --upgrade numerapi

Usage

See example.py. You can run it as ./example.py

Some actions (like uploading predictions or staking) requires a token to verify that it is really you interacting with Numerai's API. These tokens consists of a public_id and secret_key. Both can be obtained by login in to Numer.ai and going to Account -> Custom API Keys.

Documentation

Layout

Parameters and return values are given with Python types. Dictionary keys are given in quotes; other names to the left of colons are for reference convenience only. In particular, lists of dicts have names for the dicts; these names will not show up in the actual data, only the actual dict data itself.

download_current_dataset

Parameters

  • dest_path (str, optional, default: .): destination folder for the dataset
  • dest_filename (str, optional, default: numerai_dataset_<round number>.zip)
  • unzip (bool, optional, default: True): indication of whether the training data should be unzipped

Return Values

  • path (string): location of the downloaded dataset

get_dataset_url

Fetch url of the current dataset.

Return Values

  • url (str): url of the current dataset

get_leaderboard

retrieves the leaderboard for the given round

Parameters

  • round_num (int, optional, defaults to current round): The round you are interested in.

Return Values

  • participants (list): information about all competitors
    • participants (dict)
      • "concordance" (dict)
        • "pending" (bool)
        • "value" (bool)
      • "originality" (dict)
        • "pending" (bool)
        • "value" (bool)
      • "consistency" (float)
      • "liveLogloss" (float or None)
      • "validationLogloss" (float)
      • "paymentGeneral" (dict or None)
        • "nmrAmount" (float)
        • "usdAmount" (float)
      • "paymentStaking" (dict or None)
        • "nmrAmount" (float)
        • "usdAmount" (float)
      • "submissionId" (str)
      • "totalPayments" (dict)
        • "nmrAmount" (float)
        • "usdAmount" (float)
      • "username" (str)

get_staking_leaderboard

retrieves the leaderboard of the staking competition for the given round

Parameters

  • round_num (int, optional, defaults to current round): The round you are interested in.

Return Values

  • stakes (list): information about all competitors
    • participants (dict)
      • "username" (str)
      • "consistency" (float)
      • "liveLogloss" (float or None)
      • "validationLogloss" (float)
      • "stake" (dict)
        • "confidence" (float)
        • "insertedAt" (datetime)
        • "soc" (float)
        • "txHash" (str)
        • "value" (float)

get_competitions

Return Values

  • all_competitions (list): information about all competitions
    • competition (dict)
      • "datasetId" (str)
      • "number" (int)
      • "openTime" (datetime)
      • "resolveTime" (datetime)
      • "resolvedGeneral" (bool)
      • "resolvedStaking" (bool)

get_current_round

Return Values

  • number (int): number of the current round

get_submission_ids

get dict with username->submission_id mapping

Return Values

  • submission_ids (dict)
    • "username" (str)
    • "submissionId" (str): ID of submission

submission_status

submission status of the given submission_id or the last submission done within the same session.

Parameters

  • submission_id (str, optional, default: None)

Return Values

  • status (dict)
    • "concordance" (dict):
      • "pending" (bool)
      • "value" (bool): whether the submission is concordant
    • "originality" (dict)
      • "pending" (bool)
      • "value" (bool): whether the submission is original
    • "consistency" (float): consistency of the submission
    • "validation_logloss" (float): amount of logloss for the submission

upload_predictions

Parameters

  • file_path (str): path to CSV of predictions (e.g. "path/to/file/prediction.csv")

Return Values

  • submission_id: ID of submission

get_user

Return Values

  • user (dict)
    • "apiTokens" (list)
      • token (dict)
        • "name" (str)
        • "public_id" (str)
        • "scopes" (list)
          • scope (str)
    • "assignedEthAddress" (str)
    • "availableNmr" (float)
    • "availableUsd" (float)
    • "banned" (bool)
    • "email" (str)
    • "id" (str)
    • "insertedAt" (datetime)
    • "mfaEnabled" (bool)
    • "status" (str)
    • "username" (str)

get_payments

Return Values

  • payments (list)
    • payment (dict)
      • "nmrAmount" (float)
      • "usdAmount" (float)
      • "tournament" (str)
      • "round" (dict)
        • "number" (int)
        • "openTime" (datetime)
        • "resolveTime" (datetime)
        • "resolvedGeneral" (bool)
        • "resolvedStaking" (bool)

get_transactions

Return Values

  • transactions (dict)
    • "nmrDeposits" (list)
      • nmrDeposit (dict)
        • "from" (str)
        • "id" (str)
        • "posted" (bool)
        • "status" (str)
        • "to" (str)
        • "txHash" (str)
        • "value" (float)
    • "nmrWithdrawals" (list)
      • nmrWithdrawal (dict)
        • "from" (str)
        • "id" (str)
        • "posted" (bool)
        • "status" (str)
        • "to" (str)
        • "txHash" (str)
        • "value" (float)
    • "usdWithdrawals" (list)
      • usdWithdrawal (dict)
        • "confirmTime" (datetime or None)
        • "ethAmount" (str)
        • "from" (str)
        • "posted" (bool)
        • "sendTime" (datetime)
        • "status" (str)
        • "to" (str)
        • "txHash" (str)
        • "usdAmount" (float)

stake

participate in the staking competition

Parameters

  • confidence (float)
  • value (float): the amount of NMR you want to stake

Return Values

  • stake (dict)
    • "id" (str)
    • "status" (str)
    • "txHash" (str)
    • "value" (float)

get_stakes

Return Values

  • stakes (list)
    • stake (dict)
      • "confidence" (float)
      • "roundNumber" (int)
      • "soc" (float)
      • "insertedAt" (str (datetime))
      • "staker" (str): NMR adress used for staking
      • "status" (str)
      • "txHash" (str)
      • "value" (float)

raw_query

This function allows to build your own queries and fetch results from Numerai's GraphQL API. Checkout https://medium.com/numerai/getting-started-with-numerais-new-tournament-api-77396e895e72 for an introduction.

Parameters

  • query (str)
  • variables (dict, optional)
  • authorization (bool, optional, default: False): indicates if a token is required

Return Values

  • data (dict)

check_new_round

Checks if a new round has started recently.

Parameters

  • hour (int, optional): timeframe to consider

Return Value

  • is_new_round (bool)

check_submission_successful

Check if the last submission passes concordance, originality and consistency tests

Parameters

  • submission_id (str, optional, default: None)

Return Value

  • success (bool)

numerapi's People

Contributors

uuazed avatar wsteitz avatar xanderdunn avatar atreichel avatar philipcmonk avatar mangstad avatar dhj-io avatar kwgoodman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.