本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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
示例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'
示例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)
示例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)
示例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)
示例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)