@@ -68,9 +68,12 @@ print(polo.marketTradeHist('BTC_ETH'))
6868print (polo.returnTradeHistory(' BTC_ETH' ))
6969```
7070
71+ You can also not use the 'helper' methods at all and use ` poloniex.PoloniexBase ` which only has ` returnMarketHist ` , ` __call__ ` to make rest api calls.
72+
7173#### Websocket Usage:
72- Right now, the easiest way to use the websocket api is making a child class like so:
74+ To connect to the websocket api just create a child class of ` PoloniexSocketed ` like so:
7375``` python
76+ import poloniex
7477import logging
7578
7679logging.basicConfig()
@@ -112,6 +115,36 @@ sock = MySocket()
112115sock.logger.setLevel(logging.DEBUG )
113116# start the websocket thread and subsribe to '24hvolume'
114117sock.startws(subscribe = [' 24hvolume' ])
118+ # give the socket some time init
119+ poloniex.sleep(5 )
120+ # this won't work:
121+ # sock.subscribe('ticker')
122+ # use channel id to un/sub
123+ sock.subscribe(' 1002' )
124+ poloniex.sleep(1 )
125+ # unsub from ticker
126+ sock.unsubscribe(' 1002' )
127+ poloniex.sleep(4 )
128+ sock.stopws()
129+
130+ ```
131+
132+ ```
133+ INFO:poloniex:Websocket thread started
134+ DEBUG:poloniex:Subscribed to 24hvolume
135+ [1010]
136+ DEBUG:poloniex:Subscribed to ticker
137+ [241, '86.59997298', '86.68262835', '85.69590501', '0.01882321', '22205.56419338', '258.30264061', 0, '87.31843098', '82.81638725']
138+ ...
139+ ...
140+ [254, '5.89427014', '6.14542299', '5.92000026', '-0.03420118', '9978.11197201', '1649.83975863', 0, '6.19642428', '5.74631502']
141+ DEBUG:poloniex:Unsubscribed to ticker
142+ [1010]
143+ [1010]
144+ [1010]
145+ ['2019-06-07 04:16', 2331, {'BTC': '2182.115', 'ETH': '490.635', 'XMR': '368.983', 'USDT': '7751402.061', 'USDC': '5273463.730'}]
146+ DEBUG:poloniex:Websocket Closed
147+ INFO:poloniex:Websocket thread stopped/joined
115148```
116149
117150** More examples of how to use websocket push API can be found [ here] ( https://github.com/s4w3d0ff/python-poloniex/tree/master/examples ) .**
0 commit comments