Example #1
0
    def test_should_handle_only_buy_price_or_only_sell_price(self):
        # when
        price_feed = WebSocketPriceFeed(FakeFeed({"buyPrice": "120.75"}))
        # then
        assert (price_feed.get_price().buy_price == Wad.from_number(120.75))
        assert (price_feed.get_price().sell_price is None)

        # when
        price_feed = WebSocketPriceFeed(FakeFeed({"sellPrice": "130.75"}))
        # then
        assert (price_feed.get_price().buy_price is None)
        assert (price_feed.get_price().sell_price == Wad.from_number(130.75))
Example #2
0
    def test_should_default_to_price_if_no_buy_price_or_no_sell_price(self):
        # when
        price_feed = WebSocketPriceFeed(FakeFeed({"price": "125.0", "buyPrice": "120.75"}))
        # then
        assert(price_feed.get_price().buy_price == Wad.from_number(120.75))
        assert(price_feed.get_price().sell_price == Wad.from_number(125.0))

        # when
        price_feed = WebSocketPriceFeed(FakeFeed({"price": "125.0", "sellPrice": "130.75"}))
        # then
        assert(price_feed.get_price().buy_price == Wad.from_number(125.0))
        assert(price_feed.get_price().sell_price == Wad.from_number(130.75))
    def test_should_handle_only_buy_price_or_only_sell_price(self):
        # when
        price_feed = WebSocketPriceFeed(FakeFeed({"buyPrice": "120.75"}))
        # then
        assert(price_feed.get_price().buy_price == Wad.from_number(120.75))
        assert(price_feed.get_price().sell_price is None)

        # when
        price_feed = WebSocketPriceFeed(FakeFeed({"sellPrice": "130.75"}))
        # then
        assert(price_feed.get_price().buy_price is None)
        assert(price_feed.get_price().sell_price == Wad.from_number(130.75))
    def test_should_default_to_price_if_no_buy_price_or_no_sell_price(self):
        # when
        price_feed = WebSocketPriceFeed(FakeFeed({"price": "125.0", "buyPrice": "120.75"}))
        # then
        assert(price_feed.get_price().buy_price == Wad.from_number(120.75))
        assert(price_feed.get_price().sell_price == Wad.from_number(125.0))

        # when
        price_feed = WebSocketPriceFeed(FakeFeed({"price": "125.0", "sellPrice": "130.75"}))
        # then
        assert(price_feed.get_price().buy_price == Wad.from_number(125.0))
        assert(price_feed.get_price().sell_price == Wad.from_number(130.75))
Example #5
0
    def test_should_handle_no_price(self):
        # when
        price_feed = WebSocketPriceFeed(FakeFeed({}))

        # then
        assert (price_feed.get_price().buy_price is None)
        assert (price_feed.get_price().sell_price is None)
Example #6
0
    def test_should_use_individual_buy_and_sell_prices_if_both_available(self):
        # when
        price_feed = WebSocketPriceFeed(FakeFeed({"buyPrice": "120.75", "sellPrice": "130.75"}))

        # then
        assert(price_feed.get_price().buy_price == Wad.from_number(120.75))
        assert(price_feed.get_price().sell_price == Wad.from_number(130.75))
Example #7
0
    def test_should_use_same_buy_and_sell_price_if_only_one_price_available(self):
        # when
        price_feed = WebSocketPriceFeed(FakeFeed({"price": "125.75"}))

        # then
        assert(price_feed.get_price().buy_price == Wad.from_number(125.75))
        assert(price_feed.get_price().sell_price == Wad.from_number(125.75))
    def test_should_use_individual_buy_and_sell_prices_if_both_available(self):
        # when
        price_feed = WebSocketPriceFeed(FakeFeed({"buyPrice": "120.75", "sellPrice": "130.75"}))

        # then
        assert(price_feed.get_price().buy_price == Wad.from_number(120.75))
        assert(price_feed.get_price().sell_price == Wad.from_number(130.75))
    def test_should_use_same_buy_and_sell_price_if_only_one_price_available(self):
        # when
        price_feed = WebSocketPriceFeed(FakeFeed({"price": "125.75"}))

        # then
        assert(price_feed.get_price().buy_price == Wad.from_number(125.75))
        assert(price_feed.get_price().sell_price == Wad.from_number(125.75))
    def test_should_handle_no_price(self):
        # when
        price_feed = WebSocketPriceFeed(FakeFeed({}))

        # then
        assert(price_feed.get_price().buy_price is None)
        assert(price_feed.get_price().sell_price is None)