tardis-dev / tardis-python

Python client for tardis.dev - historical tick-level cryptocurrency market data replay API.
https://tardis.dev
Mozilla Public License 2.0
113 stars 16 forks source link

replay() might get stuck #13

Closed OlafvdSpek closed 2 months ago

OlafvdSpek commented 2 months ago
minutes_diff = int(round((to_date - from_date).total_seconds() / 60))

This might round down, causing the downloader to exit one slice too soon. The consumer doesn't catch this and keeps waiting.

async def replay():
    tardis_client = TardisClient(api_key=TARDIS_API_KEY, cache_dir='./cache')
    from_date = '2024-07-29'
    to_date = '2024-07-29T14:15:28'

    a = datetime.fromisoformat(from_date)
    b = datetime.fromisoformat(to_date)

    print((b - a).total_seconds() / 60)
    print(int(round((b - a).total_seconds() / 60)))

    return tardis_client.replay(
        exchange='binance-futures',
        from_date=from_date,
        to_date=to_date,
        filters=[
          Channel(name='depth', symbols=['xrpusdt']),
        ],
    )

async def main() -> None:
    logging.basicConfig(level=logging.DEBUG, format=f'%(asctime)s %(levelname)8s: %(filename)s:%(lineno)s: %(funcName)s: %(message)s')

    async for t, m in await replay():
        continue

if __name__ == '__main__':
    asyncio.run(main())
OlafvdSpek commented 2 months ago

minute=0 isn't right is it?