Skip to content

Commit

Permalink
update_available updated to handle unwanted update
Browse files Browse the repository at this point in the history
closes #32
  • Loading branch information
liampauling committed Mar 11, 2017
1 parent 13d779a commit 61550ec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion betfairlightweight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@


__title__ = 'betfairlightweight'
__version__ = '0.9.9'
__version__ = '0.9.10'
__author__ = 'Liam Pauling'
3 changes: 2 additions & 1 deletion betfairlightweight/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@ def update_available(available, book_update, deletion_select):
updated = True
break

if not updated:
if not updated and book[deletion_select] != 0:
# handles betfair bug, http://forum.bdp.betfair.com/showthread.php?t=3351
available.append(book)
8 changes: 8 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ def test_update_available_new_replace(self):
update_available(current, book_update, 2)
assert current == expected

# tests handling of betfair bug, http://forum.bdp.betfair.com/showthread.php?t=3351
book_update = [[2, 0, 0], [1, 1.01, 9835.74], [0, 1.02, 1126.22]]
current = [[1, 1.01, 9835.74], [0, 1.02, 1126.22]]
expected = [[1, 1.01, 9835.74], [0, 1.02, 1126.22]]

update_available(current, book_update, 2)
assert current == expected

def test_update_available_new_remove(self):
book_update = [[27, 0]]
current = [[27, 0.95], [13, 28.01], [1.02, 1157.21]]
Expand Down

0 comments on commit 61550ec

Please sign in to comment.