Skip to content

Commit

Permalink
Bitpanda order update via streams (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
nardew authored Apr 21, 2021
1 parent f64ba1c commit 05b4ea6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html

## [Pending release]

## [3.10.0] - 2021-04-21

### Added

- `bitpanda` supports update of orders via streams (see `BitpandaWebsocket.py:UpdateOrderMessage`)

## [3.9.0] - 2021-03-14

### Added
Expand Down Expand Up @@ -107,7 +113,8 @@ The project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html

The official release of `cryptoxlib-aio`.

[Pending release]: https://github.com/nardew/cryptoxlib-aio/compare/3.9.0...HEAD
[Pending release]: https://github.com/nardew/cryptoxlib-aio/compare/3.10.0...HEAD
[3.9.0]: https://github.com/nardew/cryptoxlib-aio/compare/3.9.0...3.10.0
[3.9.0]: https://github.com/nardew/cryptoxlib-aio/compare/3.8.1...3.9.0
[3.8.1]: https://github.com/nardew/cryptoxlib-aio/compare/3.8.0...3.8.1
[3.8.0]: https://github.com/nardew/cryptoxlib-aio/compare/3.7.0...3.8.0
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cryptoxlib-aio 3.9.0
# cryptoxlib-aio 3.10.0

![](https://img.shields.io/badge/python-3.6-blue.svg) ![](https://img.shields.io/badge/python-3.7-blue.svg) ![](https://img.shields.io/badge/python-3.8-blue.svg)

Expand All @@ -12,11 +12,9 @@

---

### What's new in version 3.9.0
### What's new in version 3.10.0

- testnet endpoints for `binance`
- customizable API clusters available for `binance`
- new price tickers added to `bitvavo`
- `bitpanda` supports update of orders via streams (see `BitpandaWebsocket.py:UpdateOrderMessage`)

For the full history of changes see [CHANGELOG](https://github.com/nardew/cryptoxlib-aio/blob/master/CHANGELOG.md).

Expand Down
23 changes: 23 additions & 0 deletions cryptoxlib/clients/bitpanda/BitpandaWebsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,27 @@ def to_json(self):
if self.client_id is not None:
ret['client_id'] = self.client_id

return ret


class UpdateOrderMessage(WebsocketOutboundMessage):
def __init__(self, amount: str, order_id: str = None, client_id: str = None):
self.amount = amount
self.order_id = order_id
self.client_id = client_id

def to_json(self):
ret = {
"type": "UPDATE_ORDER",
"order": {
"amount": self.amount
}
}

if self.order_id is not None:
ret['order']['order_id'] = self.order_id

if self.client_id is not None:
ret['order']['client_id'] = self.client_id

return ret
8 changes: 7 additions & 1 deletion examples/bitpanda_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from cryptoxlib.clients.bitpanda.enums import TimeUnit, OrderSide, OrderType
from cryptoxlib.clients.bitpanda.BitpandaWebsocket import AccountSubscription, PricesSubscription, \
OrderbookSubscription, CandlesticksSubscription, CandlesticksSubscriptionParams, MarketTickerSubscription, \
TradingSubscription, OrdersSubscription, ClientWebsocketHandle, CreateOrderMessage, CancelOrderMessage
TradingSubscription, OrdersSubscription, ClientWebsocketHandle, CreateOrderMessage, CancelOrderMessage, \
UpdateOrderMessage
from cryptoxlib.version_conversions import async_run

LOG = logging.getLogger("cryptoxlib")
Expand Down Expand Up @@ -45,6 +46,11 @@ async def orders_update(response: dict, websocket: ClientWebsocketHandle) -> Non
order_id = "d44cf37a-335d-4936-9336-4c7944cd00ec"
))

await websocket.send(UpdateOrderMessage(
amount = "1",
order_id = "d44cf37a-335d-4936-9336-4c7944cd00ec"
))


async def run():
api_key = os.environ['BITPANDAAPIKEY']
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setuptools.setup(
name="cryptoxlib-aio",
version="3.9.0",
version="3.10.0",
author="nardew",
author_email="cryptoxlib.aio@gmail.com",
description="Cryptoexchange asynchronous python client",
Expand Down

0 comments on commit 05b4ea6

Please sign in to comment.