Exemplo n.º 1
0
 
 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..."
 
 tt0 = time.time()
 for id, map in strategy_map.items():
     t = Ticker(increment=0.25, commission=0.1)
     strategy = strategy_builder(map['params'])
     t0 = time.time()
     simulation = SimulationRunner(t, ticks, strategy)
     orders = simulation.run()
     t1 = time.time()
     map['orders'] = orders
     map['simulation_time'] = t1 - t0
     print "tested strategy: %s" % id
 tt1 = time.time()
 print "running %s simulations took %s seconds" % (nr_of_strategies, 
                                                   repr(tt1 - tt0))
 
 reduced_map = {}
 for id, map in strategy_map.items():
     orders = map['orders']
     deltas = [details['delta'] for details in orders.values() 
               if details.get('delta')]
     negatives = [delta for delta in deltas if delta <= 0]