Skip to main content

Python3 Bybit HTTP/WebSocket API Connector

Project description

pybit

All Contributors

Build Status Build Status Build Status contributions welcome

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(
    endpoint='https://api.bybit.com', 
    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.orderbook(symbol='BTCUSD')

# Create five long orders.
orders = [{
    'symbol': 'BTCUSD', 
    'order_type': 'Limit', 
    'side': 'Buy', 
    'qty': 100, 
    'price': i,
    'time_in_force': 'GoodTillCancel'
} for i in [5000, 5500, 6000, 6500, 7000]]

# Submit the orders in bulk.
session.place_active_order_bulk(orders)

# Check on your order and position through WebSocket.
ws.fetch('order')
ws.fetch('position')

Check out the example python files for more information on available endpoints and methods, and more documentation on the HTTP methods can be found here: https://github.com/verata-veritatis/pybit/blob/master/docs/HTTP.md.

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

💻 📖

APF20

💻

Cameron Harder-Hutton

💻

Todd Conley

🤔

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

Project details


Release history Release notifications | RSS feed

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.1.10.tar.gz (20.7 kB view details)

Uploaded Source

File details

Details for the file pybit-1.1.10.tar.gz.

File metadata

  • Download URL: pybit-1.1.10.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for pybit-1.1.10.tar.gz
Algorithm Hash digest
SHA256 01d91f89057b09308f0a1233179be9d0bd01cdd3a0277b26af28b14ff6d11351
MD5 a2b013193dfa7c2deca1fd40dac0a825
BLAKE2b-256 14619e65477d8a0a8b221219805c41fd50d8b8cddc00b2bbe9c5b3b391798dbc

See more details on using hashes here.

Supported by

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