• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python testcommon.runtest函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中testcommon.runtest函数的典型用法代码示例。如果您正苦于以下问题:Python runtest函数的具体用法?Python runtest怎么用?Python runtest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了runtest函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_run

def test_run(main=False):
    # for i in [True, False]:
    for rstype in [True, False]:
        if rstype:
            runonces = [True]
        else:
            runonces = [True, False]

        for runonce in runonces:
            data = testcommon.getdata(0)

            if rstype:
                data = bt.DataResampler(
                    dataname=data,
                    timeframe=bt.TimeFrame.Weeks,
                    compression=1)
            else:
                data.resample(
                    timeframe=bt.TimeFrame.Weeks,
                    compression=1)

            datas = [data]
            testcommon.runtest(datas,
                               testcommon.TestStrategy,
                               main=main,
                               runonce=runonce,
                               plot=main,
                               chkind=chkind,
                               chkmin=chkmin,
                               chkvals=chkvals,
                               chkargs=chkargs)
开发者ID:adriantorrie,项目名称:backtrader,代码行数:31,代码来源:test_data_resample.py


示例2: test_run

def test_run(main=False):
    for i in [True, False]:
        data = testcommon.getdata(0)

        if i:
            data = bt.DataReplayer(
                dataname=data,
                timeframe=bt.TimeFrame.Weeks,
                compression=1)
        else:
            data.replay(
                timeframe=bt.TimeFrame.Weeks,
                compression=1)

        datas = [data]
        testcommon.runtest(datas,
                           testcommon.TestStrategy,
                           main=main,
                           plot=main,
                           chkind=chkind,
                           chkmin=chkmin,
                           chkvals=chkvals,
                           chknext=chknext,
                           chkargs=chkargs,
                           runonce=False, preload=False)
开发者ID:adriantorrie,项目名称:backtrader,代码行数:25,代码来源:test_data_replay.py


示例3: test_run

def test_run(main=False):
    datas = [testcommon.getdata(i) for i in range(chkdatas)]
    testcommon.runtest(datas,
                       TestStrategy,
                       printdata=main,
                       printops=main,
                       plot=main)
开发者ID:nicoddemus,项目名称:backtrader,代码行数:7,代码来源:test_strategy_unoptimized.py


示例4: test_run

def test_run(main=False):
    datas = [testcommon.getdata(i) for i in range(chkdatas)]
    testcommon.runtest(datas,
                       testcommon.TestStrategy,
                       main=main,
                       plot=main,
                       chkind=chkind,
                       chkmin=chkmin,
                       chkvals=chkvals)
开发者ID:adriantorrie,项目名称:backtrader,代码行数:9,代码来源:test_ind_wmaenvelope.py


示例5: test_run

def test_run(main=False):
    for stlike in [False, True]:
        datas = [testcommon.getdata(i) for i in range(chkdatas)]
        testcommon.runtest(datas,
                           TestStrategy,
                           printdata=main,
                           printops=main,
                           stocklike=stlike,
                           plot=main)
开发者ID:Aulla,项目名称:backtrader,代码行数:9,代码来源:test_strategy_unoptimized.py


示例6: test_run

def test_run(main=False):
    for runonce in [True, False]:
        data = testcommon.getdata(0)
        data.resample(timeframe=bt.TimeFrame.Weeks, compression=1)

        datas = [data]
        testcommon.runtest(datas,
                           testcommon.TestStrategy,
                           main=main,
                           runonce=runonce,
                           plot=main,
                           chkind=chkind,
                           chkmin=chkmin,
                           chkvals=chkvals,
                           chkargs=chkargs)
开发者ID:michaelcjl,项目名称:backtrader,代码行数:15,代码来源:test_data_resample.py


示例7: test_run

def test_run(main=False):
    datas = [testcommon.getdata(i) for i in range(chkdatas)]
    cerebros = testcommon.runtest(datas,
                                  TestStrategy,
                                  main=main,
                                  plot=main,
                                  writer=(bt.WriterStringIO, dict(csv=True)))

    for cerebro in cerebros:
        writer = cerebro.runwriters[0]
        if main:
            # writer.out.seek(0)
            for l in writer.out:
                print(l.rstrip('\r\n'))

        else:
            lines = iter(writer.out)
            l = next(lines).rstrip('\r\n')
            assert l == '=' * 79

            count = 0
            while True:
                l = next(lines).rstrip('\r\n')
                if l[0] == '=':
                    break
                count += 1

            assert count == 256  # header + 256 lines data
开发者ID:adriantorrie,项目名称:backtrader,代码行数:28,代码来源:test_writer.py


示例8: test_run

def test_run(main=False):
    datas = [testcommon.getdata(i) for i in range(chkdatas)]
    cerebros = testcommon.runtest(datas,
                                  TestStrategy,
                                  printdata=main,
                                  stocklike=False,
                                  printops=main,
                                  plot=main,
                                  analyzer=(bt.analyzers.TimeReturn,
                                            dict(timeframe=bt.TimeFrame.Years))
                                  )

    for cerebro in cerebros:
        strat = cerebro.runstrats[0][0]  # no optimization, only 1
        analyzer = strat.analyzers[0]  # only 1
        analysis = analyzer.get_analysis()
        if main:
            print(analysis)
            print(str(analysis[next(iter(analysis.keys()))]))
        else:
            # Handle different precision
            if PY2:
                sval = '0.2795'
            else:
                sval = '0.2794999999999983'

            assert str(analysis[next(iter(analysis.keys()))]) == sval
开发者ID:aaron8tang,项目名称:backtrader,代码行数:27,代码来源:test_analyzer-timereturn.py


示例9: test_run

def test_run(main=False):
    datas = [testcommon.getdata(i) for i in range(chkdatas)]

    for maxtrades in [None, 0, 1]:
        cerebros = testcommon.runtest(datas,
                                      TestStrategy,
                                      printdata=main,
                                      stocklike=False,
                                      maxtrades=maxtrades,
                                      printops=main,
                                      plot=main,
                                      analyzer=(bt.analyzers.SQN, {}))

        for cerebro in cerebros:
            strat = cerebro.runstrats[0][0]  # no optimization, only 1
            analyzer = strat.analyzers[0]  # only 1
            analysis = analyzer.get_analysis()
            if main:
                print(analysis)
                print(str(analysis.sqn))
            else:
                if maxtrades == 0 or maxtrades == 1:
                    assert analysis.sqn == 0
                    assert analysis.trades == maxtrades
                else:
                    # Handle different precision
                    assert str(analysis.sqn)[0:14] == '0.912550316439'
                    assert str(analysis.trades) == '11'
开发者ID:aaron8tang,项目名称:backtrader,代码行数:28,代码来源:test_analyzer-sqn.py


示例10: test_run

def test_run(main=False, exbar=False):
    data = testcommon.getdata(0)
    data.replay(timeframe=bt.TimeFrame.Weeks, compression=1)
    datas = [data]
    testcommon.runtest(datas,
                       testcommon.TestStrategy,
                       main=main,
                       plot=main,
                       chkind=chkind,
                       chkmin=chkmin,
                       chkvals=chkvals,
                       chknext=chknext,
                       chkargs=chkargs,
                       runonce=False,
                       preload=False,
                       exbar=exbar)
开发者ID:Aulla,项目名称:backtrader,代码行数:16,代码来源:test_data_replay.py


示例11: test_run

def test_run(main=False):
    datas = [testcommon.getdata(i) for i in range(chkdatas)]
    testcommon.runtest(datas,
                       TestStrategy,
                       optimize=True,
                       period=xrange(5, 45),
                       printdata=main,
                       printops=main,
                       plot=False)

    if not main:
        assert CHKVALUES == _chkvalues
        assert CHKCASH == _chkcash

    else:
        print(_chkvalues)
        print(_chkcash)
开发者ID:AldrichChen,项目名称:backtrader,代码行数:17,代码来源:test_strategy_optimized.py


示例12: test_run

def test_run(main=False):
    data = testcommon.getdata(0)

    data = bt.DataResampler(
        data=data,
        timeframe=bt.TimeFrame.Weeks,
        compression=1)

    datas = [data]
    testcommon.runtest(datas,
                       testcommon.TestStrategy,
                       main=main,
                       plot=main,
                       chkind=chkind,
                       chkmin=chkmin,
                       chkvals=chkvals,
                       chkargs=chkargs)
开发者ID:nicoddemus,项目名称:backtrader,代码行数:17,代码来源:test_data_resample.py


示例13: test_run

def test_run(main=False):
    global _chkvalues
    global _chkcash

    for runonce in [True, False]:
        for preload in [True, False]:
            for exbar in [True, False, -1, -2]:
                _chkvalues = list()
                _chkcash = list()

                datas = [testcommon.getdata(i) for i in range(chkdatas)]
                testcommon.runtest(datas,
                                   TestStrategy,
                                   runonce=runonce,
                                   preload=preload,
                                   exbar=exbar,
                                   optimize=True,
                                   period=range(5, 45),
                                   printdata=main,
                                   printops=main,
                                   plot=False)

                if not main:
                    assert CHKVALUES == _chkvalues
                    assert CHKCASH == _chkcash

                else:
                    print('*' * 50)
                    print(CHKVALUES == _chkvalues)
                    print('-' * 50)
                    print(CHKVALUES)
                    print('-' * 50)
                    print(_chkvalues)
                    print('*' * 50)
                    print(CHKCASH == _chkcash)
                    print('-' * 50)
                    print(CHKCASH)
                    print('-' * 50)
                    print(_chkcash)
开发者ID:Aulla,项目名称:backtrader,代码行数:39,代码来源:test_strategy_optimized.py



注:本文中的testcommon.runtest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.TestDriverBase类代码示例发布时间:2022-05-27
下一篇:
Python testcommon.getdata函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap