@@ -240,16 +240,19 @@ wsClient.close()
240240### WebsocketClient + Mongodb
241241The ``` WebsocketClient ``` now supports data gathering via MongoDB. Given a
242242MongoDB collection, the ``` WebsocketClient ``` will stream results directly into
243- the database collection.
243+ the database collection.
244244``` python
245245# import PyMongo and connect to a local, running Mongo instance
246246from pymongo import MongoClient
247+ import gdax
247248mongo_client = MongoClient(' mongodb://localhost:27017/' )
249+
248250# specify the database and collection
249251db = mongo_client.cryptocurrency_database
250252BTC_collection = db.BTC_collection
253+
251254# instantiate a WebsocketClient instance, with a Mongo collection as a parameter
252- wsClient = WebsocketClient(url = " wss://ws-feed.gdax.com" , products = " BTC-USD" ,
255+ wsClient = gdax. WebsocketClient(url = " wss://ws-feed.gdax.com" , products = " BTC-USD" ,
253256 mongo_collection = BTC_collection , should_print = False )
254257wsClient.start()
255258```
@@ -261,9 +264,9 @@ can react to the data streaming in. The current client is a template used for
261264illustration purposes only.
262265
263266
264- - onOpen - called once, * immediately before* the socket connection is made, this
267+ - onOpen - called once, * immediately before* the socket connection is made, this
265268is where you want to add initial parameters.
266- - onMessage - called once for every message that arrives and accepts one
269+ - onMessage - called once for every message that arrives and accepts one
267270argument that contains the message of dict type.
268271- onClose - called once after the websocket has been closed.
269272- close - call this method to close the websocket connection (do not overwrite).
0 commit comments