Package: pybotters
pybottersAn advanced API client for python botters. This project is in Japanese.📌 Descriptionpybottersis a Python library for仮想通貨 botter (crypto bot traders).This library is anHTTP and WebSocket API client.
It has the following features, making it useful for developing a trading bot.🚀 Features✨ HTTP / WebSocket ClientAutomatic authenticationfor private APIs.WebSocketautomatic reconnectionandautomatic heartbeat.A client based onaiohttp.✨ DataStoreWebSocket message data handler.Processing of differential datasuch as order book updatesHigh-speed data processingand querying✨ Other ExperiencesSupport for type hints.Asynchronous programming usingasyncio.Discord community.🏦 ExchangesNameAPI authDataStoreExchange API docsbitFlyer✅✅LinkGMO Coin✅✅Linkbitbank✅✅LinkCoincheck✅✅LinkBybit✅✅LinkBinance✅✅LinkOKX✅✅LinkPhemex✅✅LinkBitget✅✅LinkMEXC✅No supportLinkKuCoin✅✅LinkBitMEX✅✅Link🐍 RequiresPython 3.8+🔧 InstallationFromPyPI(stable version):pipinstallpybottersFromGitHub(latest version):pipinstallgit+https://github.com/pybotters/pybotters.git📝 UsageExample of bitFlyer API:HTTP APINew interface from version 1.0:Fetch API.More simple request/response.importasyncioimportpybottersapis={"bitflyer":["YOUER_BITFLYER_API_KEY","YOUER_BITFLYER_API_SECRET"],}asyncdefmain():asyncwithpybotters.Client(apis=apis,base_url="https://api.bitflyer.com")asclient:# Fetch balancer=awaitclient.fetch("GET","/v1/me/getbalance")print(r.response.status,r.response.reason,r.response.url)print(r.data)# Create orderCREATE_ORDER=False# Set to `True` if you are trying to create an order.ifCREATE_ORDER:r=awaitclient.fetch("POST","/v1/me/sendchildorder",data={"product_code":"BTC_JPY","child_order_type":"MARKET","side":"BUY","size":0.001,},)print(r.response.status,r.response.reason,r.response.url)print(r.data)asyncio.run(main())aiohttp-based API.importasyncioimportpybottersapis={"bitflyer":["YOUER_BITFLYER_API_KEY","YOUER_BITFLYER_API_SECRET"],}asyncdefmain():asyncwithpybotters.Client(apis=apis,base_url="https://api.bitflyer.com")asclient:# Fetch balanceasyncwithclient.get("/v1/me/getbalance")asresp:data=awaitresp.json()print(resp.status,resp.reason)print(data)# Create orderCREATE_ORDER=False# Set to `True` if you are trying to create an order.ifCREATE_ORDER:asyncwithclient.post("/v1/me/sendchildorder",data={"product_code":"BTC_JPY","child_order_type":"MARKET","side":"BUY","size":0.001,},)asresp:data=awaitresp.json()print(data)asyncio.run(main())WebSocket APIimportasyncioimportpybottersasyncdefmain():asyncwithpybotters.Client()asclient:# Create a Queuewsqueue=pybotters.WebSocketQueue()# Connect to WebSocket and subscribe to Tickerawaitclient.ws_connect("wss://ws.lightstream.bitflyer.com/json-rpc",send_json={"method":"subscribe","params":{"channel":"lightning_ticker_BTC_JPY"},},hdlr_json=wsqueue.onmessage,)# Iterate message (Ctrl+C to break)asyncformsginwsqueue:print(msg)try:asyncio.run(main())exceptKeyboardInterrupt:passDataStoreimportasyncioimportpybottersasyncdefmain():asyncwithpybotters.Client()asclient:# Create DataStorestore=pybotters.bitFlyerDataStore()# Connect to WebSocket and subscribe to Boardawaitclient.ws_connect("wss://ws.lightstream.bitflyer.com/json-rpc",send_json=[{"method":"subscribe","params":{"channel":"lightning_board_snapshot_BTC_JPY"},},{"method":"subscribe","params":{"channel":"lightning_board_BTC_JPY"},},],hdlr_json=store.onmessage,)# Watch for the best prices on Board. (Ctrl+C to break)withstore.board.watch()asstream:asyncforchangeinstream:board=store.board.sorted(limit=2)print(board)try:asyncio.run(main())exceptKeyboardInterrupt:pass📖 Documentation🔗https://pybotters.readthedocs.io/ja/stable/(Japanese)🗽 LicenseMIT💖 AuthorPlease sponsor me!:X:Discord: