Skip to content

Commit

Permalink
Merge pull request #128 from bybit-exchange/fix_general_issues
Browse files Browse the repository at this point in the history
Fix some HTTP endpoint issues and add new endpoints
  • Loading branch information
dextertd authored Apr 18, 2023
2 parents 9f5a7bb + ba9f4db commit 6c50a98
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## [5.2.0] - 2023-04-18
### Added
- New asset endpoints: `set_deposit_account()`, `get_internal_deposit_records()`, `get_withdrawable_amount()`

### Fixed
- Ensure that `legacy` submodule is packaged by `setup.py`
- Fix non-UTA (normal account) spot margin trading endpoints
- Fix wrong request method for `set_dcp()`


## [5.1.1] - 2023-04-06
Expand Down
2 changes: 1 addition & 1 deletion pybit/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "5.1.1"
VERSION = "5.2.0"
54 changes: 54 additions & 0 deletions pybit/_v5_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,25 @@ def get_allowed_deposit_coin_info(self, **kwargs):
auth=True,
)

def set_deposit_account(self, **kwargs):
"""Set auto transfer account after deposit. The same function as the setting for Deposit on web GUI
Required args:
accountType (string): Account type: UNIFIED,SPOT,OPTION,CONTRACT,FUND
Returns:
Request results as dictionary.
Additional information:
https://bybit-exchange.github.io/docs/v5/asset/set-deposit-acct
"""
return self._submit_request(
method="POST",
path=f"{self.endpoint}{Asset.SET_DEPOSIT_ACCOUNT}",
query=kwargs,
auth=True,
)

def get_deposit_records(self, **kwargs):
"""Query deposit records.
Expand Down Expand Up @@ -302,6 +321,22 @@ def get_sub_deposit_records(self, **kwargs):
auth=True,
)

def get_internal_deposit_records(self, **kwargs):
"""Query deposit records within the Bybit platform. These transactions are not on the blockchain.
Returns:
Request results as dictionary.
Additional information:
https://bybit-exchange.github.io/docs/v5/asset/internal-deposit-record
"""
return self._submit_request(
method="GET",
path=f"{self.endpoint}{Asset.GET_INTERNAL_DEPOSIT_RECORDS}",
query=kwargs,
auth=True,
)

def get_master_deposit_address(self, **kwargs):
"""Query the deposit address information of MASTER account.
Expand Down Expand Up @@ -373,6 +408,25 @@ def get_withdrawal_records(self, **kwargs):
auth=True,
)

def get_withdrawable_amount(self, **kwargs):
"""Get withdrawable amount
Required args:
coin (string): Coin name
Returns:
Request results as dictionary.
Additional information:
https://bybit-exchange.github.io/docs/v5/asset/delay-amount
"""
return self._submit_request(
method="GET",
path=f"{self.endpoint}{Asset.GET_WITHDRAWABLE_AMOUNT}",
query=kwargs,
auth=True,
)

def withdraw(self, **kwargs):
"""Withdraw assets from your Bybit account. You can make an off-chain transfer if the target wallet address is from Bybit. This means that no blockchain fee will be charged.
Expand Down
2 changes: 1 addition & 1 deletion pybit/_v5_trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def set_dcp(self, **kwargs):
https://bybit-exchange.github.io/docs/v5/order/dcp
"""
return self._submit_request(
method="GET",
method="POST",
path=f"{self.endpoint}{Trade.SET_DCP}",
query=kwargs,
auth=True,
Expand Down
3 changes: 3 additions & 0 deletions pybit/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ class Asset(str, Enum):
"/v5/asset/transfer/query-universal-transfer-list"
)
GET_ALLOWED_DEPOSIT_COIN_INFO = "/v5/asset/deposit/query-allowed-list"
SET_DEPOSIT_ACCOUNT = "/v5/asset/deposit/deposit-to-account"
GET_DEPOSIT_RECORDS = "/v5/asset/deposit/query-record"
GET_SUB_ACCOUNT_DEPOSIT_RECORDS = (
"/v5/asset/deposit/query-sub-member-record"
)
GET_INTERNAL_DEPOSIT_RECORDS = "/v5/asset/deposit/query-internal-record"
GET_MASTER_DEPOSIT_ADDRESS = "/v5/asset/deposit/query-address"
GET_SUB_DEPOSIT_ADDRESS = "/v5/asset/deposit/query-sub-member-address"
GET_COIN_INFO = "/v5/asset/coin/query-info"
GET_WITHDRAWAL_RECORDS = "/v5/asset/withdraw/query-record"
GET_WITHDRAWABLE_AMOUNT = "/v5/asset/withdraw/withdrawable-amount"
WITHDRAW = "/v5/asset/withdraw/create"
CANCEL_WITHDRAWAL = "/v5/asset/withdraw/cancel"

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='pybit',
version='5.1.1',
version='5.2.0',
description='Python3 Bybit HTTP/WebSocket API Connector',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 6c50a98

Please sign in to comment.