Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #77 from verata-veritatis/fix_spot_get_active_order
Browse files Browse the repository at this point in the history
Fix spot get active order
  • Loading branch information
dextertd authored Dec 30, 2021
2 parents 1628025 + 230038f commit c4e945d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ 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).

## [1.3.4] - 2021-12-30
### Added
- `endpoint` arg to `get_active_order()`

### Fixed
- A Websocket test case, by raising an exception instead of logging

## [1.3.3] - 2021-12-24
- Improve `get_risk_limit()`
- Fixed: call this endpoint without authentication
Expand Down
24 changes: 15 additions & 9 deletions pybit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from json.decoder import JSONDecodeError

# Versioning.
VERSION = '1.3.3'
VERSION = '1.3.4'


class HTTP:
Expand Down Expand Up @@ -514,24 +514,30 @@ def place_active_order_bulk(self, orders: list, max_in_parallel=10):
executor.shutdown()
return [execution.result() for execution in executions]

def get_active_order(self, **kwargs):
def get_active_order(self, endpoint="", **kwargs):
"""
Gets an active order. For more information, see
https://bybit-exchange.github.io/docs/inverse/#t-getactive.
:param kwargs: See
https://bybit-exchange.github.io/docs/inverse/#t-getactive.
:param endpoint: The endpoint path, such as "/spot/v1/order".
This allows the user to choose between which endpoint to use to
fetch a spot order.
:returns: Request results as dictionary.
"""

if self.spot is True or kwargs.get('spot', '') is True:
suffix = '/spot/v1/history-orders'
elif kwargs.get('symbol', '').endswith('USDT'):
suffix = '/private/linear/order/list'
elif kwargs.get('symbol', '')[-2:].isdigit():
suffix = '/futures/private/order/list'
if endpoint:
suffix = endpoint
else:
suffix = '/v2/private/order/list'
if self.spot is True or kwargs.get('spot', '') is True:
suffix = '/spot/v1/history-orders'
elif kwargs.get('symbol', '').endswith('USDT'):
suffix = '/private/linear/order/list'
elif kwargs.get('symbol', '')[-2:].isdigit():
suffix = '/futures/private/order/list'
else:
suffix = '/v2/private/order/list'

return self._submit_request(
method='GET',
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='1.3.3',
version='1.3.4',
description='Python3 Bybit HTTP/WebSocket API Connector',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit c4e945d

Please sign in to comment.