Ejemplo n.º 1
0
async def _report(strategy):
    global error_complete
    try:
        while True:
            await asyncio.sleep(1)
            if error_complete == 1:
                return
            clock = strategy.portfolio.context.clock
            if clock.current_timestamp > clock.end_timestamp:
                clock.run_end = time.time()
                strategy.portfolio.context.completed_time = round(
                    clock.run_end - clock.run_start, 4)
                # print('【handle总耗时】:{} s'.format(strategy.portfolio.context.completed_time))
                strategy.simple_report()
                strategy.complete_report()
                break

            if strategy.frequency in ['d', '1d', 'day', '1day']:
                if clock.bars > Config.bars_length():  #这个在分钟线里怎么解决出错的问题
                    clock.reset_bars()
                    strategy.simple_report()
            elif strategy.frequency in ['m', '1m', 'min', 'minute']:
                if clock.bars > Config.bars_length_1m():
                    clock.reset_bars()
                    strategy.simple_report()

            elif strategy.frequency in ['5m', '5mins', '5minutes']:
                if clock.bars > Config.bars_length_5m():
                    clock.reset_bars()
                    strategy.simple_report()

    except Exception as e:
        error_complete = 1
        raise e
Ejemplo n.º 2
0
async def _report(strategy):
    global error_complete
    try:
        while True:
            await asyncio.sleep(1)
            if error_complete == 1:
                return
            clock = strategy.portfolio.context.clock
            if clock.current_timestamp > clock.end_timestamp:
                clock.run_end = time.time()
                strategy.portfolio.context.completed_time = round(
                    clock.run_end - clock.run_start, 4)
                # print('【handle总耗时】:{} s'.format(strategy.portfolio.context.completed_time))
                strategy.simple_report()
                strategy.complete_report()
                break
            if clock.bars > Config.bars_length():
                clock.reset_bars()
                strategy.simple_report()
    except Exception as e:
        error_complete = 1
        raise e