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

Commit

Permalink
CoinbasePro.plug Patch for 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
teleprint-me committed Jan 6, 2022
1 parent 2478abe commit d2d0fef
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
5 changes: 3 additions & 2 deletions coinbase_pro/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ def key(self) -> str:
def name(self):
return "coinbase_pro"

def plug(self, name: str, value: object):
setattr(self, name, value)
def plug(self, cls: object, name: str):
instance = cls(self.messenger)
setattr(self, name, instance)


def get_messenger(settings: dict = None) -> Messenger:
Expand Down
24 changes: 22 additions & 2 deletions docs/01-Quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ We should get the same result as before when we execute the sample code.

## Subscriber and CoinbasePro.plug

The `Subscriber` and `CoinbasePro` class allow you to create your own extensible classes. If we find there is not a class or method that supports a particular pattern or solution, then we can create out own instead and easily attach it to a `client` instance.
The `Subscriber` and `CoinbasePro` classes allow you to create your own extensible classes. If we find there is not a class or method that supports a particular pattern or solution, then we can create out own instead and easily attach it to a `client` instance.

```python
#!/usr/bin/env python
Expand All @@ -520,12 +520,32 @@ class History(Subscriber):


client = get_client(get_settings("settings.json")["box"])
client.plug("history", History(client.messenger))
client.plug(History, "history")
responses = client.history.list_({"product_id": "BTC-USD", "limit": 25})
print("[History]")
pprint(responses[0][0])
```

Expected Output

```sh
$ python cbot
[History]
{'created_at': '2022-01-06T20:16:07.397858Z',
'fee': '0.4849978179585000',
'liquidity': 'T',
'order_id': '7319a3a3-2f2c-452f-9792-2d78fc5969fb',
'price': '44185.71000000',
'product_id': 'BTC-USD',
'profile_id': 'fcada388-d6f6-47fe-8826-5afbceaf197c',
'settled': True,
'side': 'buy',
'size': '0.00219527',
'trade_id': 37319261,
'usd_volume': '96.9995635917000000',
'user_id': '5ee38d9688d076112365883f'}
```

_Note: The `CoinbasePro.plug` method is currently experimental and should improve over time. Changes should be expected as the methods implementation is improved._

## Notes
Expand Down
4 changes: 3 additions & 1 deletion docs/04-Client.md
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,13 @@ A property that returns the client label.
### CoinbasePro.plug

```python
CoinbasePro.plug(name: str, value: object)
CoinbasePro.plug(cls: object, name: str)
```

A method used to attach 3rd party classes to extend the clients functionality.

_Note: This method is experimental and is subject to change._

## get_messenger

```python
Expand Down

0 comments on commit d2d0fef

Please sign in to comment.