Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use equity field for balance in Unified Account API #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ezname
Copy link

@ezname ezname commented Jan 19, 2025

Fix balance handling for Bybit Unified Account API

Issue

The current implementation uses availableToWithdraw field from the Bybit API response to get account balance. However, with the Unified Account API, this field is often returned as an empty string, causing the code to fail when trying to convert it to float.

Fix

Modified get_asset_balance method to use the equity field instead of availableToWithdraw. The equity field is consistently populated with the correct balance value in the Unified Account API response.

Changes

  • Updated get_asset_balance method in bybit_store.py to use equity instead of availableToWithdraw
  • Improved code formatting for better readability

Testing

Tested with Bybit Unified Account using both spot and linear perpetual markets. The fix allows the code to properly retrieve account balances and proceed with trading operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant