This repository has been archived by the owner on Jul 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add usage example, installation instructions and some description
nlsdfnbch
committed
Dec 8, 2017
1 parent
8dbcbe5
commit b357464
Showing
1 changed file
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,50 @@ | ||
# hitbtc | ||
HitBTC Websocket API 2.0 Client written in Python 3 | ||
HitBTC Websocket API 2.0 Client written in Python 3. | ||
|
||
|
||
The client supplies data both visually via console, as well as python objects via its `HitBTC.recv()`. | ||
It's important to note that this does not receive data from the API directly - | ||
instead, the data is pulled from a `queue.Queue` object, which defaults to a length of | ||
100 items. So only the last 100 messages will be cached - either make sure you process the messages | ||
fast enough, or increas the length of the queue (can be done by passing the `q_maxsize` kwarg on | ||
instantiation). | ||
|
||
By default, data is unpacked - that means you will never see the raw `JSONRPC` message | ||
(this, too, can be turned off by passing `raw=True` upon initialization). This will, however, also | ||
turn off all handling of error messages etc. | ||
|
||
For an in-depth description of the client and its methods, please see the documenation at | ||
[readthedocs.org](http://hitbtc-websocket-api-20-client.readthedocs.io/en/latest/) | ||
|
||
|
||
# Installation | ||
|
||
Stable: `pip install hitbtc` | ||
Release Candidate: `pip install --pre hitbtc` | ||
|
||
# Example Usage | ||
|
||
```python | ||
import time | ||
import queue | ||
from hitbtc import HitBTC | ||
c = HitBTC() | ||
c.start() # start the websocket connection | ||
time.sleep(2) # Give the socket some time to connect | ||
c.subscribe_ticker('ETHBTC') # Subscribe to ticker data for the pair ETHBTC | ||
|
||
while True: | ||
try: | ||
data = c.recv() | ||
except queue.Empty: | ||
continue | ||
|
||
# process data from websocket | ||
... | ||
|
||
c.stop() | ||
``` | ||
|
||
|
||
|
||
|
||
Reference at: | ||
http://hitbtc-websocket-api-20-client.readthedocs.io/en/latest/reference.html# |