Ejemplo n.º 1
0
def backtestingE(setting_bt,
                 StartTime='',
                 EndTime='',
                 slippage=0,
                 optimism=False,
                 mode='T',
                 q=False):
    """回测单个策略"""
    try:
        return backtesting(setting_bt, StartTime, EndTime, slippage, optimism,
                           mode, q)
    except Exception, e:
        print(u'回测策略出错:%s' % e)
        print 'traceback.print_exc():'
        traceback.print_exc()
        return setting_bt['name'], {}, 0
Ejemplo n.º 2
0
def backtestingPerfE(setting_bt,
                     StartTime='',
                     EndTime='',
                     slippage=0,
                     optimism=False,
                     mode='T',
                     q=False):
    """回测单个策略,同时分析性能"""
    try:
        p = cProfile.Profile()
        p.enable()
        res = backtesting(setting_bt, StartTime, EndTime, slippage, optimism,
                          mode, q)
        p.disable()
        p.create_stats()
        stats = pstats.Stats(p)
        stats.sort_stats('tottime').print_stats(20)
        return res
    except Exception, e:
        print(u'回测策略出错:%s' % e)
        print 'traceback.print_exc():'
        traceback.print_exc()
        return setting_bt['name'], {}, 0