Disabled filtering for previous candles

api-breakage
Morty Space 4 years ago
parent 73946d49bb
commit 3d83084f23
  1. 6
      src/cryptocom/exchange/market.py
  2. 20
      tests/test_market.py

@ -96,15 +96,11 @@ class Exchange:
raise ValueError(f"Provide Period enum not {period}")
channels = [f"candlestick.{period}.{pair.name}" for pair in pairs]
prev_time = {}
async for data in self.api.listen("market", *channels):
pair = self.pairs[data["instrument_name"]]
for candle in data["data"]:
current_time = int(candle["t"] / 1000)
if pair not in prev_time or current_time > prev_time[pair]:
yield Candle.from_api(pair, candle)
prev_time[pair] = current_time
yield Candle.from_api(pair, candle)
async def listen_trades(self, *pairs: List[Pair]) -> MarketTrade:
channels = [f"trade.{pair.name}" for pair in pairs]

@ -1,4 +1,3 @@
import async_timeout
import pytest
import cryptocom.exchange as cro
@ -62,16 +61,15 @@ async def test_get_candles(exchange: cro.Exchange):
async def test_listen_candles(exchange: cro.Exchange):
candles = {}
pairs = (cro.pairs.CRO_USDC, cro.pairs.USDC_USDT, cro.pairs.BTC_USDT)
default_count = 1
async with async_timeout.timeout(130):
async for candle in exchange.listen_candles(cro.Period.MINS, *pairs):
candles.setdefault(candle.pair, 0)
candles[candle.pair] += 1
if all(v == default_count for v in candles.values()) and len(
candles
) == len(pairs):
break
default_count = 2
async for candle in exchange.listen_candles(cro.Period.MINS, *pairs):
candles.setdefault(candle.pair, 0)
candles[candle.pair] += 1
if all(v == default_count for v in candles.values()) and len(
candles
) == len(pairs):
break
for pair in pairs:
assert candles[pair] == default_count

Loading…
Cancel
Save