A small Python wrapper around pybit for simple Bybit spot BTC/ETH market
orders.
Install from PyPI once the first release is published:
pip install ezbybitFor local development:
python -m pip install -e .from ezbybit import BybitClient
client = BybitClient(
api_key="YOUR_BYBIT_API_KEY",
api_secret="YOUR_BYBIT_API_SECRET",
testnet=True,
)
print(client.get_available_budget_usdt())Place a market buy order using 80% of available USDT:
response = client.buy("BTC")
print(response)
response = client.buy("ETH")
print(response)Sell available BTC or ETH:
response = client.sell("BTC")
print(response)
response = client.sell("ETH")
print(response)By default, buy() uses 80% of available USDT. Pass a different ratio with
Decimal:
from decimal import Decimal
response = client.buy("ETH", Decimal("0.5"))You can also run the local example with environment variables:
export BYBIT_API_KEY="YOUR_BYBIT_API_KEY"
export BYBIT_API_SECRET="YOUR_BYBIT_API_SECRET"
python examples/basic.pyThe package also installs a small CLI:
ezbybit --versionpython -m pip install --upgrade build twine
python -m build
python -m twine check dist/*Publish to TestPyPI first:
python -m twine upload --repository testpypi dist/*Then publish to PyPI:
python -m twine upload dist/*