Пример #1
0
def main():
    # set example username and round
    example_username = "******"
    example_round = 51

    # set up paths for download of dataset and upload of predictions
    now = datetime.now().strftime("%Y%m%d")
    dataset_parent_folder = "./dataset"
    dataset_name = "numerai_dataset_{0}/example_predictions.csv".format(now)
    dataset_path = "{0}/{1}".format(dataset_parent_folder, dataset_name)

    # most API calls do not require logging in
    napi = NumerAPI(verbosity="info")

    # log in
    credentials = napi.login()
    print(json.dumps(credentials, indent=2))

    # download current dataset
    dl_succeeded = napi.download_current_dataset(
        dest_path=dataset_parent_folder, unzip=True)
    print("download succeeded: " + str(dl_succeeded))

    # get competitions (returned data is too long to print practically)
    # all_competitions = napi.get_all_competitions()
    # current_competition = napi.get_competition()
    # example_competition = napi.get_competition(round_id=example_round)

    # get user earnings per round
    user_earnings = napi.get_earnings_per_round()
    print("user earnings:")
    print(user_earnings)
    example_earnings = napi.get_earnings_per_round(username=example_username)
    print("example earnings:")
    print(example_earnings)

    # get scores for user
    personal_scores = napi.get_scores_for_user()
    print("personal scores:")
    print(personal_scores)
    other_scores = napi.get_scores_for_user(username=example_username)
    print("other scores:")
    print(other_scores)

    # get user information
    current_user = napi.get_user()
    print("current user:"******"example user:"******"submission:")
    print(json.dumps(submission, indent=2))

    # upload predictions
    ul_succeeded = napi.upload_predictions(dataset_path)
    print("upload succeeded: " + str(ul_succeeded))
Пример #2
0
#!/usr/bin/env python

from numerapi.numerapi import NumerAPI

# Most API calls don't require logging in:
napi = NumerAPI()

print("Downloading the current dataset...")
napi.download_current_dataset(dest_path='.', unzip=True)

# User-specific information
username = '******'
print("Getting information about user {}...".format(username))
print(napi.get_user(username))
print(napi.get_scores(username))
print(napi.get_earnings_per_round(username))

# Get the leaderboard for the current round of the competition
print(napi.get_new_leaderboard())

# Get the leaderboard for previous rounds of the competition
print(napi.get_new_leaderboard(40))

# Uploading predicitons to your account require your credentials:
# napi.credentials = ("YOUR_EMAIL", "YOUR_PASSWORD")
# napi.upload_prediction('./numerai_datasets/example_predictions.csv')