forked from sammchardy/python-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65e2397
commit cad16ce
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from binance.depthcache import DepthCache | ||
import pytest | ||
|
||
TEST_SYMBOL = "BNBBTC" | ||
|
||
|
||
@pytest.fixture | ||
def fresh_cache(): | ||
return DepthCache(TEST_SYMBOL) | ||
|
||
|
||
def test_add_bids(fresh_cache): | ||
"""Verify basic functionality for adding a bid to the cache""" | ||
high_bid = [0.111, 489] | ||
mid_bid = [0.018, 300] | ||
low_bid = [0.001, 100] | ||
for bid in [high_bid, low_bid, mid_bid]: | ||
fresh_cache.add_bid(bid) | ||
|
||
bids = fresh_cache.get_bids() | ||
|
||
assert len(bids) == 3 | ||
|
||
assert bids == sorted(bids, reverse=True) | ||
|
||
|
||
def test_add_asks(fresh_cache): | ||
"""Verify basic functionality for adding an ask to the cache""" | ||
high_ask = [0.111, 489] | ||
mid_ask = [0.018, 300] | ||
low_ask = [0.001, 100] | ||
|
||
for ask in [high_ask, low_ask, mid_ask]: | ||
fresh_cache.add_ask(ask) | ||
|
||
asks = fresh_cache.get_asks() | ||
|
||
# Three asks should be in the cache | ||
assert len(asks) == 3 | ||
|
||
# Lowest ask price should be first (ascending order) | ||
assert asks == sorted(asks) |