Skip to content

Commit

Permalink
fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuizi7 committed Oct 19, 2018
1 parent cc6faf1 commit 6fa698c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/api/test_api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,15 @@ def handle_bar(context, bar_dict):
elif context.counter == 15:
buy_close("RB1701", 2)

if 1 <= context.counter < 5:
if context.counter == 1:
pos = get_positions()[0]
assert_position(pos, "000001.XSHE", POSITION_DIRECTION.LONG, 300, 0, context.expected_avg_price)
elif 1 < context.counter < 5:
pos = get_positions()[0]
assert_position(pos, "000001.XSHE", POSITION_DIRECTION.LONG, 0, 300, context.expected_avg_price)
elif 5 <= context.counter < 10:
pos = get_position("000001.XSHE", POSITION_DIRECTION.LONG)
assert_position(pos, "000001.XSHE", POSITION_DIRECTION.LONG, 200, 0, context.expected_avg_price)
assert_position(pos, "000001.XSHE", POSITION_DIRECTION.LONG, 0, 200, context.expected_avg_price)
elif context.counter == 10:
pos = get_position("RB1701", POSITION_DIRECTION.SHORT)
assert_position(pos, "RB1701", POSITION_DIRECTION.SHORT, 5, 0, context.expected_avg_price)
Expand Down

0 comments on commit 6fa698c

Please sign in to comment.