Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nardew committed Feb 4, 2020
1 parent 3d0d966 commit 90168a9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 29 deletions.
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html

## [Pending release]

## [1.0.2] - 2020-02-04

### Changed

- Bugfix: Fix 'from' and 'to' timestamps in `get_account_orders` and `get_account_trades` REST calls
- Bugfix: Handle subscription error due to invalid credentials properly

## [1.0.1] - 2020-02-01

### Changed
Expand All @@ -24,6 +31,7 @@ The project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html

- __Important!!!__ REST response body is not returned as a string anymore but as a dictionary instead. If you did `json.loads(response['response'])` before, now use only `response['response']`.

[Pending release]: https://github.com/nardew/bitpanda-aio/compare/1.0.1...HEAD
[1.0.0]: https://github.com/nardew/bitpanda-aio/compare/0.1.0...1.0.0
[1.0.1]: https://github.com/nardew/bitpanda-aio/compare/1.0.0...1.0.1
[Pending release]: https://github.com/nardew/bitpanda-aio/compare/1.0.2...HEAD
[1.0.2]: https://github.com/nardew/bitpanda-aio/compare/1.0.1...1.0.2
[1.0.1]: https://github.com/nardew/bitpanda-aio/compare/1.0.0...1.0.1
[1.0.0]: https://github.com/nardew/bitpanda-aio/compare/0.1.0...1.0.0
28 changes: 8 additions & 20 deletions bitpanda/BitpandaClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,18 @@ async def get_account_orders(self, from_timestamp : datetime.datetime = None, to
pair : Pair = None, with_cancelled_and_rejected : str = None, with_just_filled_inactive : str = None,
max_page_size : str = None, cursor : str = None) -> dict:
params = BitpandaClient._clean_request_params({
"from": from_timestamp,
"to": to_timestamp,
"instrument_code": pair,
"with_cancelled_and_rejected": with_cancelled_and_rejected,
"with_just_filled_inactive": with_just_filled_inactive,
"max_page_size": max_page_size,
"cursor": cursor,
})

try:
params["from"] = params["from"].astimezone(pytz.utc).isoformat()
except KeyError:
pass
if from_timestamp is not None:
params["from"] = from_timestamp.astimezone(pytz.utc).isoformat()

try:
params["to"] = params["to"].astimezone(pytz.utc).isoformat()
except KeyError:
pass
if to_timestamp is not None:
params["to"] = to_timestamp.astimezone(pytz.utc).isoformat()

return await self._create_get("account/orders", params = params, headers = self._get_header_api_key())

Expand All @@ -72,22 +66,16 @@ async def get_account_order_trades(self, order_id : str) -> dict:
async def get_account_trades(self, from_timestamp : datetime.datetime = None, to_timestamp : datetime.datetime = None,
pair : Pair = None, max_page_size : str = None, cursor : str = None) -> dict:
params = BitpandaClient._clean_request_params({
"from": from_timestamp,
"to": to_timestamp,
"instrument_code": pair,
"max_page_size": max_page_size,
"cursor": cursor,
})

try:
params["from"] = params["from"].astimezone(pytz.utc).isoformat()
except KeyError:
pass
if from_timestamp is not None:
params["from"] = from_timestamp.astimezone(pytz.utc).isoformat()

try:
params["to"] = params["to"].astimezone(pytz.utc).isoformat()
except KeyError:
pass
if to_timestamp is not None:
params["to"] = to_timestamp.astimezone(pytz.utc).isoformat()

return await self._create_get("account/trades", params = params, headers = self._get_header_api_key())

Expand Down
10 changes: 5 additions & 5 deletions bitpanda/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ async def run(self) -> None:
response = json.loads(await websocket.recv())
LOG.debug(f"< {response}")

# subscription positive response
if response['type'] == "SUBSCRIPTIONS":
LOG.info(f"Subscription confirmed for channels [" + ",".join([channel["name"] for channel in response["channels"]]) + "]")

# subscription negative response
elif response['type'] == "ERROR":
if "error" in response or response['type'] == "ERROR":
raise Exception(f"Subscription error. Request [{json.dumps(subscription_message)}] Response [{json.dumps(response)}]")

# subscription positive response
elif response['type'] == "SUBSCRIPTIONS":
LOG.info(f"Subscription confirmed for channels [" + ",".join([channel["name"] for channel in response["channels"]]) + "]")

# remote termination with an opportunity to reconnect
elif response["type"] == "CONNECTION_CLOSING":
LOG.warning(f"Server is performing connection termination with an opportunity to reconnect.")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="bitpanda-aio",
version="1.0.1",
version="1.0.2",
author="nardew",
author_email="[email protected]",
description="Bitpanda Global Exchange API asynchronous python client",
Expand Down

0 comments on commit 90168a9

Please sign in to comment.