Package: cryptoxlib-aio
cryptoxlib-aio 5.3.0cryptoxlib-aiois a compact Python library providing access to REST and WEBSOCKET API of selected crypto exchanges.cryptoxlib-aiois designed as an asynchronous library utilizing modern features of Python and those of supporting asynchronous libraries (mainlyaiohttp).What's been recently addedpython3.10supportedcoinmatecryptoexchange added!bitpandacancellation of all orders via websocketsbinanceBSwap (liquidity pools) endpointsbinanceleveraged token endpointsbinanceCOIN-M futures endpointsbinancemargin and USDS-M futures endpointsFor the full history of changes seeCHANGELOG.Main missionToday there are numerous existing libraries targeting similar audience ascryptoxlib-aio. In order to achieve the broadest coverage of exchanges the supported API is often limited, the most apparent example being lack ofwebsockets.The mission ofcryptoxlib-aiois to:serve as a single entry point for various crypto exchangesprovide full REST API as well as full implementation of exchange'swebsockets. For free and without subscription plans.Full support of websockets is the corner stone ofcryptoxlib-aiowhich attempts to setcryptoxlib-aioapart from existing solutions which either do not provide websocket support or do not provide it for free.You will also find out that our subject of interest are often exchanges not enjoying a seat in the mainstream crypto libraries and this is a way for them to reach developers community.Disclaimer: By no means we are suggesting that existing libraries are inferior tocryptoxlib-aio, they just appeal to different endusers.Featuresaccess to REST API as well as full support of websockets for selected exchanges (given websockets are provided by the exchange)automatic connection management (reconnecting after remote termination, ...)bundling of channelslean architecture making it straightforward to implement API of a new exchangefully asynchronous design aiming for the best performanceready-made bundled examples for each exchange and productList of supported exchangesAs mentioned earlier, all exchanges listed below include full support for websockets.NameDocsAAXAPIBiboxAPIBiboxEuropeAPIBinance (spot, margin, USDS-M futures, COIN-M futures, BLVT, BSwap)APIBitforexAPIBitpanda ProAPIBitvavoAPIBTSEAPICoinmateAPIEterbaseAPIHitBTCAPILiquidAPIUnlike REST API which is rather uniform across crypto exchanges websockets are often very exchange-specific and hence very time consuming to implement (which is the reason why they are not offered so broadly). Thereforecryptoxlib-aiocomes at the cost of the number of exchanges it covers. This is in line with our ideology quality over quantity.The list of supported exchanges will grow without any specific pattern, usually driven by personal needs. If there is a high demand for a new exchange/feature to be added, there is a high chance for it to happen (but not guranteed). For business related inquiries concerning customized changes tailored for the client please reach out via e-mail mentioned in the contacts.Installationpipinstallcryptoxlib-aioIn case you want to install the latest version from the repo, usepipinstallgit+https://github.com/nardew/cryptoxlib-aio.git@masterExamplesBITPANDAbitpanda=CryptoXLib.create_bitpanda_client(api_key)print("Account balance:")awaitbitpanda.get_account_balances()print("Order book:")awaitbitpanda.get_order_book(Pair("BTC","EUR"))print("Create limit order:")awaitbitpanda.create_limit_order(Pair("BTC","EUR"),OrderSide.BUY,"10000","1")# Create first bundle of subscriptionsbitpanda.compose_subscriptions([AccountSubscription(),PricesSubscription([Pair("BTC","EUR")]),OrderbookSubscription([Pair("BTC","EUR")],"50",callbacks=[order_book_update]),CandlesticksSubscription([CandlesticksSubscriptionParams(Pair("BTC","EUR"),TimeUnit.MINUTES,1)]),MarketTickerSubscription([Pair("BTC","EUR")])])# Bundle another subscriptions into a separate websocketbitpanda.compose_subscriptions([OrderbookSubscription([Pair("ETH","EUR")],"3",callbacks=[order_book_update]),])# Execute all websockets asynchronouslyawaitbitpanda.start_websockets()BINANCE# SPOT REST APIclient=CryptoXLib.create_binance_client(api_key,sec_key)print("Exchange info:")awaitclient.get_exchange_info()print("Order book:")awaitclient.get_orderbook(pair=Pair('ETH','BTC'),limit=enums.DepthLimit.L_5)print("Create limit order:")awaitclient.create_order(Pair("ETH","BTC"),side=enums.OrderSide.BUY,type=enums.OrderType.LIMIT,quantity="1",price="0",time_in_force=enums.TimeInForce.GOOD_TILL_CANCELLED,new_order_response_type=enums.OrderResponseType.FULL)# SPOT WEBSOCKETS# Bundle several subscriptions into a single websocketclient.compose_subscriptions([OrderBookTickerSubscription(callbacks=[orderbook_ticker_update]),OrderBookSymbolTickerSubscription(pair=Pair("BTC","USDT"),callbacks=[orderbook_ticker_update]),TradeSubscription(pair=Pair('ETH','BTC'),callbacks=[trade_update]),CandlestickSubscription(Pair('BTC','USDT'),Interval.I_1MIN,callbacks=[candlestick_update])])# Bundle another subscriptions into a separate websocketclient.compose_subscriptions([AccountSubscription(callbacks=[account_update])])# Execute all websockets asynchronouslyawaitclient.start_websockets()# LEVERAGED TOKENS REST APIclient=CryptoXLib.create_binance_client(api_key,sec_key)print("BLVT symbol info:")awaitclient.get_blvt_info()print("Subscribe BTCUP:")awaitclient.blvt_subscribe("BTCUP","500000000")print("Redeem BTCUP:")awaitclient.blvt_redeem("BTCUP","500000000")# MARGIN REST APIclient=CryptoXLib.create_binance_client(api_key,sec_key)print("All margin assets:")awaitclient.get_margin_all_assets()print("Margin account balance:")awaitclient.get_margin_account()# USDS-M futures REST APIclient=CryptoXLib.create_binance_usds_m_futures_client(api_key,sec_key)print("Index price candlesticks:")awaitclient.get_index_price_candlesticks(pair=Pair('BTC','USDT'),interval=enums.Interval.I_1MIN)print("Index info:")awaitclient.get_index_info(pair=Pair('DEFI','USDT'))# COIN-M futures REST APIclient=CryptoXLib.create_binance_coin_m_futures_client(api_key,sec_key)awaitclient.create_order(symbol='BTCUSD_PERP',side=enums.OrderSide.BUY,type=enums.OrderType.LIMIT,quantity="1",price="0",time_in_force=enums.TimeInForce.GOOD_TILL_CANCELLED,new_order_response_type=enums.OrderResponseType.FULL)# BinanceSwap REST APIclient=CryptoXLib.create_binance_client(api_key,sec_key)print('Swap pools:')awaitclient.get_bswap_pools()print('Add liquidity:')awaitclient.bswap_add_liquidity(0,'BTC','10000000')print('Swap:')awaitclient.bswap_swap(Pair('BTC','USDT'),'100000000000')Examples for every exchange and product can be found in the folderexamples.Contactto report issues, bugs, docu corrections or to propose new features use preferably Github Issuesfor topics requiring more personal approach feel free to send an e-mail toSupportIf you like the library and you feel like you want to support its further development, enhancements and bugfixing, then it will be of great help and most appreciated if you:file bugs, proposals, pull requests, ...spread the worddonate an arbitrary tipBTC:3GJPT6H6WeuTWR2KwDSEN5qyJq95LEErzfETH:0xC7d8673Ee1B01f6F10e40aA416a1b0A746eaBe68Binance Smart Chain tokens:0xe37FaB52ed4c1C9a3d80896f2001Cb3284a1b619XMR:87vdCaWFN2YJEk3HKVJNaPBFsuwZTJocRfpGJ747dPQrFcrs6SQTmA3XDGyWUPoALuNnXezEbJXkbY8Y4VSxG4ReEFqxy5m