简体   繁体   English

Gdax沙箱Websocket API未返回正确价格

[英]Gdax sandbox Websocket API not returning correct prices

I am currently using gdax api python example as found here: https://github.com/danpaquin/gdax-python for learning purposes using the gdax sandbox API. 我目前正在使用gdax api python示例,例如: https : //github.com/danpaquin/gdax-python,用于使用gdax沙箱API进行学习。

I am trying to get real time trade prices from the sandbox through wss://ws-feed-public.sandbox.gdax.com using the following code: 我正在尝试使用以下代码通过wss://ws-feed-public.sandbox.gdax.com从沙盒中获取实时交易价格:

import gdax, time
class myWebsocketClient(gdax.WebsocketClient):
    def on_open(self):
        self.url = "wss://ws-feed-public.sandbox.gdax.com"
        self.products = ["LTC-USD"]
        self.message_count = 0
        print("Lets count the messages!")
    def on_message(self, msg):
        self.message_count += 1
        if 'price' in msg and 'type' in msg:
            print ("Message type:", msg["type"],
                   "\t@ {:.3f}".format(float(msg["price"])))
    def on_close(self):
        print("-- Goodbye! --")

wsClient = myWebsocketClient()
wsClient.start()
print(wsClient.url, wsClient.products)
while (wsClient.message_count < 500):
    print ("\nmessage_count =", "{} \n".format(wsClient.message_count))
    time.sleep(1)
wsClient.close()

However, the prices I am getting are almost always 10,000USD , and not the price shown on the gdax sandbox website: https://public.sandbox.gdax.com/ 但是,我得到的价格几乎总是10,000USD,而不是gdax沙箱网站上显示的价格: https ://public.sandbox.gdax.com/

When using the actual gdax websocket url: wss://ws-feed.gdax.com/, the prices seem correct. 使用实际的gdax websocket网址:wss://ws-feed.gdax.com/时,价格似乎正确。

I wonder what the problem is. 我想知道是什么问题。 Do we need a different approach to get the real time feed from sandbox? 我们是否需要其他方法来从沙箱获取实时提要?

thanks for your help! 谢谢你的帮助!

The issue is that the sandbox only does btc-usd. 问题是沙盒仅执行btc-usd。 If you run your code with BTC-USD in place of LTC-USD it will print out. 如果您使用BTC-USD代替LTC-USD来运行代码,它将打印出来。 other than that it works fine. 除此之外,它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM