<s> from django . core . management . base import BaseCommand <EOL> from history . models import ClassifierTest <EOL> from django . conf import settings <EOL> from history . tools import print_and_log <EOL> from multiprocessing import Pool <EOL> def do_classifier_test ( name , ticker , data_set_inputs , granularity , min_back , timedelta_back ) : <EOL> try : <EOL> ct = ClassifierTest ( name = name , <EOL> type = '<STR_LIT>' , <EOL> symbol = ticker , <EOL> datasetinputs = data_set_inputs , <EOL> granularity = granularity , <EOL> minutes_back = min_back , <EOL> timedelta_back_in_granularity_increments = timedelta_back ) <EOL> ct . get_classifier ( ) <EOL> ct . save ( ) <EOL> return_data = "<STR_LIT>" . format ( name , ticker , data_set_inputs , <EOL> granularity , <EOL> min_back , <EOL> timedelta_back , <EOL> ct . percent_correct ) <EOL> print_and_log ( return_data ) <EOL> if ct . percent_correct > <NUM_LIT> or not settings . MAKE_TRADES : <EOL> ct . graph ( ct . graph_url ( ) ) <EOL> return return_data <EOL> except Exception as e : <EOL> return "<STR_LIT>" . format ( name , ticker , data_set_inputs , <EOL> granularity , <EOL> min_back , <EOL> timedelta_back , <EOL> str ( e ) ) <EOL> class Command ( BaseCommand ) : <EOL> help = '<STR_LIT>' <EOL> result_list = [ ] <EOL> def _log_results ( self , result ) : <EOL> self . result_list . append ( result ) <EOL> def handle ( self , * args , ** options ) : <EOL> pool = Pool ( settings . NUM_THREADS ) <EOL> conf = settings . TRAINER_CURRENCY_CONFIG [ '<STR_LIT>' ] <EOL> print ( "<STR_LIT>" ) <EOL> for ticker in conf [ '<STR_LIT>' ] : <EOL> for min_back in conf [ '<STR_LIT>' ] : <EOL> for granularity in conf [ '<STR_LIT>' ] : <EOL> for datasetinputs in conf [ '<STR_LIT>' ] : <EOL> for timedelta_back_in_granularity_increments in conf [ '<STR_LIT>' ] : <EOL> for name in conf [ '<STR_LIT:name>' ] : <EOL> pool . apply_async ( do_classifier_test , args = ( <EOL> name , <EOL> ticker , <EOL> datasetinputs , <EOL> granularity , <EOL> min_back , <EOL> timedelta_back_in_granularity_increments <EOL> ) , callback = self . _log_results ) <EOL> print ( "<STR_LIT>" ) <EOL> pool . close ( ) <EOL> pool . join ( ) <EOL> print ( "<STR_LIT>" ) <EOL> for result in self . result_list : <EOL> print ( result ) </s>
