Skip to content

Commit c467ccc

Browse files
committed
默认合约测试
1 parent 9be9cb0 commit c467ccc

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎tests/test_engine.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,5 +345,26 @@ def on_bar(self, ctx):
345345
logger.info('on_symbol, on_bar 时间对齐测试成功!')
346346

347347

348+
class TestDefaultPContract(unittest.TestCase):
349+
350+
def test_case(self):
351+
class DemoStrategy(Strategy):
352+
353+
def on_init(self, ctx):
354+
"""初始化数据"""
355+
return
356+
357+
def on_bar(self, ctx):
358+
assert(ctx.open == ctx['TWODAY.TEST-5.Second'].open)
359+
assert(ctx.close == ctx['TWODAY.TEST-5.Second'].close)
360+
assert(ctx.high == ctx['TWODAY.TEST-5.Second'].high)
361+
assert(ctx.low == ctx['TWODAY.TEST-5.Second'].low)
362+
363+
set_symbols(['TWODAY.TEST-5.Second', 'TWODAY.TEST-1.Minute'])
364+
add_strategy([DemoStrategy('A1')])
365+
logger.info("默认合约测试成功!")
366+
run()
367+
368+
348369
if __name__ == '__main__':
349370
unittest.main()

0 commit comments

Comments
 (0)