Skip to main content

Python3 Bybit HTTP/WebSocket API Connector

Project description

pybit

All Contributors

contributions welcome Build Status

Python3 API connector for Bybit's HTTP and Websockets APIs.

About

Put simply, pybit (Python + Bybit) is a lightweight one-stop-shop module for the Bybit HTTP and WebSocket APIs. I was personally never a fan of auto-generated connectors that used a mosh-pit of various modules you didn't want (sorry, bravado) and wanted to build my own Python3-dedicated connector with very little external resources. The goal of the connector is to provide traders and developers with an easy-to-use high-performing module that has an active issue and discussion board leading to consistent improvements.

Development

As a user of the module myself, pybit is being actively developed, especially since Bybit is making changes and improvements to their API on a daily basis (we're still missing some key functions such as bulk order submission or withdrawals). pybit uses requests and websocket-client for its methods, alongside other built-in modules. Anyone is welcome to branch/fork the repository and add their own upgrades. If you think you've made substantial improvements to the module, submit a pull request and I'll gladly take a look.

Installation

pybit requires Python 3.6.1 or higher. The module can be installed manually or via PyPI with pip:

pip install pybit

How to Use

You can retrieve the HTTP and WebSocket classes like so:

from pybit import HTTP, WebSocket

Create an HTTP session and connect via WebSocket:

session = HTTP(test_net=False, api_key='...', api_secret='...')
ws = WebSocket(
    endpoint='wss://stream.bybit.com/realtime', 
    subscriptions=['order', 'position'], 
    api_key='...', 
    api_secret='...'
)

Information can be sent to, or retrieved from, the Bybit APIs:

# Get orderbook.
session.get_orderbook(symbol='BTCUSD')
# Place three long orders.
for i in [5000, 5500, 6000]:
    session.place_active_order(
        symbol='BTCUSD', 
        order_type='Limit', 
        side='Buy', 
        qty=100, 
        price=i
    )
# Check on your order and position through WebSocket.
ws.fetch(['order', 'position'])

Check out the example python files for more information on available endpoints and methods.

Contact

You can reach out to me via Telegram: @verataveritatis. I'm pretty active on the BybitAPI Telegram group chat.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


verata-veritatis

💻 📖

tconley

🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

Project details


Release history Release notifications | RSS feed

This version

1.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybit-1.0.1.tar.gz (15.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page