Code Monkey home page Code Monkey logo

Comments (6)

danpaquin avatar danpaquin commented on May 20, 2024 1

Great callout @trecchia . I will get working on this after all additional endpoints are supported.

from coinbasepro-python.

danpaquin avatar danpaquin commented on May 20, 2024 1

This has been completed. Thank you for your help @trecchia. See below for my implementation. I will be closing this out in 48 hours if there are no more issues.

import GDAX, time
class myWebsocketClient(GDAX.WebsocketClient):
    def onOpen(self):
        self.type = "heartbeat"
        self.url = "wss://ws-feed.gdax.com/"
        self.products = ["BTC-USD", "ETH-USD"]
        self.MessageCount = 0
        print "Lets count the messages!"
    def onMessage(self, msg):
        if msg['type'] == "heartbeat":
            print(msg)
        #else:
            #print "Message type:", msg["type"], "\t@ %.3f" % float(msg["price"])
        self.MessageCount += 1
    def onClose(self):
        print("-- Goodbye! --")

wsClient = myWebsocketClient()
wsClient.start()
#print (wsClient.url, wsClient.products)
# Do some logic with the data
while (wsClient.MessageCount < 500 and not wsClient.stop):
    time.sleep(1)
    print ("\nMessageCount =", "%i \n" % wsClient.MessageCount)
wsClient.close()

from coinbasepro-python.

danpaquin avatar danpaquin commented on May 20, 2024

Please see the commit mentioned here. I have added this functionality, but when I send the message to the websocket server, no responses are received.

from coinbasepro-python.

danpaquin avatar danpaquin commented on May 20, 2024

Hi @trecchia -- After making this change, I am still having trouble receiving messages. I attempted this in my original testing, but have committed this for your review. I apologize for the late response and not tagging the most recent commit with this issue.

from coinbasepro-python.

its-sarin avatar its-sarin commented on May 20, 2024

Hey @danpaquin, so I think the problem is using "is" for equality comparison. Because "is" is an identity comparison, I believe it won't consider those two strings to be True and thus neither condition is actually met. Try changing it to:

        if self.type == "subscribe":
            sub_params['product_ids'] = self.products
        elif self.type == "heartbeat":
            sub_params['on'] = "true"

That said, another thing I noticed when attempting to get this to work myself was that you need to send two separate messages to GDAX in order for it to work. So you'd need to do a self.ws.send(json.dumps(sub_params)) twice- once for the product subscription and another for the heartbeat. Let me know if this makes sense/helps!

from coinbasepro-python.

its-sarin avatar its-sarin commented on May 20, 2024

Yep this did it- working on my end with these changes. Thank you!

from coinbasepro-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.