Esempio n. 1
0
 
 # create Queues
 queue = BufferedQueue()
 result = Queue()
 
 p1 = Process(target=process_func, args=[queue, result])
 p2 = Process(target=process_func, args=[queue, result])
 p1.setStoppable(True); p2.setStoppable(True)
 p1.start(); p2.start()
 
 while len(ok_strats) != wanted_output and batch_runs < max_batch_runs:
     
     task_id = len(tasks)
     strategy_id = len(strategies_args)
     batch_tasks = []
     batch_args = random_strategies_generator(number=batch_nr, 
                         exclude=strategies_args)
     strategies_args.extend(batch_args) 
 
     # create tasks for this batch
     for args in batch_args:
         strategy_id_task_map[strategy_id] = []
         for day in days:
             task = {'strategy_id': strategy_id, 'strategy_args': args, 
                     'day': day.timetuple()[:3], 'ticker': ticker_details, 
                     'task_id': task_id}
             tasks[task_id] = task
             strategy_id_task_map[strategy_id].append(task_id)
             batch_tasks.append(task)
             task_id += 1
         strategy_results[strategy_id] = 0
         strategy_id += 1
Esempio n. 2
0
from signals import random_strategies_generator
from tickdata import get_random_week_triplet, random_day_generator

ticker_map = {
    "ES": {'increment': 0.25, 'commission': 0.1, 'start': (2006, 1, 1),
           'end': (2007, 1, 1), 'hours': ((8,30), (14,45))},
}

if __name__ == '__main__':
    
    symbol = "ES"
    ticker_details = ticker_map.get(symbol)
    ticker_details.update({'symbol': symbol})
    
    nr_strategies = 1000
    strategy_args = random_strategies_generator(number=nr_strategies) 
    
    #sdt = datetime(*ticker_details['start'])
    #edt = datetime(*ticker_details['end'])
    #days = random_day_generator(symbol, sdt, edt, nr_days)
    prev_w, cur_w, next_w = get_random_week_triplet("ES")
    
    # -- map --
    # step 1, get strategies that work in the current week    
    days = cur_w
    nr_days = len(days)
    print "step 1 started at %s" % str(datetime.now())
    # create tasks
    tasks = {}
    task_id = 1
    strategy_id = 0
Esempio n. 3
0
if __name__ == '__main__':
    
    from datetime import datetime
    import time
    
    from signals import strategy_builder, tops_signal_params_generator
    from signals import random_strategies_generator, create_strategy_map
    from tickdata import ES_ticks
    from ticker import Ticker
    from utils import random_weekday
    
    from simulation import SimulationRunner
    
    tops_signal_args = tops_signal_params_generator()
    nr_of_strategies = 10
    random_strategy_args = random_strategies_generator(tops_signal_args, 
                                                       output=nr_of_strategies)
    strategy_map = create_strategy_map(random_strategy_args)
    
    # setup
    start = datetime(2004, 1, 1)
    end   = datetime(2007, 1, 1)
    
    ticks = None
    print "picking random weekday..."
    while not ticks:
        weekday = random_weekday(start, end)
        print "random weekday: %s" % str(weekday)
        ticks = ES_ticks(weekday)
        if not ticks: print "no ticks found for: %s, trying again..." % str(weekday)
    print "tick data loaded..."