Async trading library based on asyncio. Coding trading systems has never been more fun!
Crypto exchange APIs are often callback-oriented. This makes coding a nightmare and will distract you from your most important goal of developing a winning strategy.
aiotrading is here to solve this problem. Using it, interacting with exchanges will be as much fun as the following example:
from aiotrading import CandleStreamfrom aiotrading.exchange import BinanceFuturesasync with BinanceFutures() as exchange:async with CandleStream(exchange, 'btcusdt', '3m') as stream:for i in range(10):candle = await stream.read()log.info(candle)
Sample output of this code example is:
connecting to exchange: binance-futuresopening candle stream btcusdt@3mcandle btcusdt, 3m, t:2021-01-30 11:39:00, o:33795.69, h:33800.00, l:33789.99, c:33795.18, v:4.164candle btcusdt, 3m, t:2021-01-30 11:39:00, o:33795.69, h:33800.00, l:33789.99, c:33799.76, v:4.481candle btcusdt, 3m, t:2021-01-30 11:39:00, o:33795.69, h:33800.00, l:33789.99, c:33797.73, v:4.741candle btcusdt, 3m, t:2021-01-30 11:39:00, o:33795.69, h:33800.00, l:33789.99, c:33797.47, v:5.132candle btcusdt, 3m, t:2021-01-30 11:39:00, o:33795.69, h:33800.89, l:33789.99, c:33797.39, v:5.520candle btcusdt, 3m, t:2021-01-30 11:39:00, o:33795.69, h:33800.89, l:33789.99, c:33797.38, v:5.605candle btcusdt, 3m, t:2021-01-30 11:39:00, o:33795.69, h:33800.89, l:33789.99, c:33797.39, v:6.000candle btcusdt, 3m, t:2021-01-30 11:39:00, o:33795.69, h:33807.99, l:33789.99, c:33806.80, v:16.562candle btcusdt, 3m, t:2021-01-30 11:39:00, o:33795.69, h:33807.99, l:33789.99, c:33797.70, v:16.590candle btcusdt, 3m, t:2021-01-30 11:39:00, o:33795.69, h:33807.99, l:33789.99, c:33794.60, v:17.342closing candle stream btcusdt@3mdisconnecting from exchange: binance-futures
pip3 install aiotrading
aiotrading is at its early stage of development. It currently supports a subset of Binance exchange API services. More services will be supported in the future. It is designed in a way that other exchanges can be supported easily.