def download_data(api: numerapi.NumerAPI, keys): if int(keys['LATEST_ROUND']) == api.get_current_round(): return int(keys['LATEST_ROUND']) else: LATEST_ROUND = api.get_current_round() api.download_current_dataset('./data') return LATEST_ROUND
def downloadNumeraiData(): # set up paths for download of dataset and upload of predictions dataset_parent_folder = "./datasets/" # We don't need to login in order to download the dataset napi = NumerAPI(verbosity="info") # download current dataset napi.download_current_dataset(dest_path=dataset_parent_folder, unzip=True) sp.call("mv " + dataset_parent_folder + "/*.zip ZipFiles/", shell=True) sp.call("rm " + dataset_parent_folder + "/*/example*")
def test_download_current_dataset(api: NumerAPI): directory = None csv_files = ['numerai_tournament_data.csv', 'numerai_training_data.csv'] try: path = api.download_current_dataset(unzip=True) assert os.path.exists(path) directory = path.replace(".zip", "") for csv_file in csv_files: final_path_name = os.path.join(directory, csv_file) assert os.path.exists(final_path_name) finally: if directory is not None: for csv_file in csv_files: os.remove(os.path.join(directory, csv_file)) os.removedirs(os.path.join(directory, 'numerai_dataset')) os.remove('%s.zip' % directory)
# import dependencies from numerapi import NumerAPI from os import environ, path, getcwd from yaml import safe_load # Load your API keys and model from config.yml with open("config.yml", "r") as yml: numerai_conf = safe_load(yml) # Set your API keys and model_id public_id = numerai_conf["public_id"] if numerai_conf["public_id"] is not None else environ['NUMERAI_PUBLIC_ID'] secret_key = numerai_conf["secret_key"] if numerai_conf["secret_key"] is not None else environ['NUMERAI_SECRET_KEY'] model_id = numerai_conf["model_id"] if numerai_conf["model_id"] is not None else environ['NUMERAI_MODEL_ID'] napi = NumerAPI(public_id=public_id, secret_key=secret_key, verbosity="info") current_round = napi.get_current_round() dest_path = numerai_conf["dest_path"] if numerai_conf["dest_path"] is not None else environ['NUMERAI_DEST_PATH'] if not dest_path: dest_path=environ['PWD'] path_numerai_dataset = f'{dest_path}/numerai_dataset_{current_round}' # Download and unzip the tournament dataset of current round if not path.isdir(path_numerai_dataset): napi.download_current_dataset(dest_path=dest_path, unzip=True) # Upload example_predictions.csv submission_id = napi.upload_predictions(f'{path_numerai_dataset}/example_predictions.csv', model_id=model_id)