简体   繁体   English

如何通过Coinbase Python API获得Litecoin价格?

[英]How do I get Litecoin prices with Coinbase Python API?

client.get_spot_price(currency='EUR')

该行将给我当前的比特币价格,但是如何找到莱特币和以太坊价格?

You need to pass the correct currency_pair as seen in the docs 您需要传递文档中所示的正确的currency_pair

client.get_spot_price(currency_pair='LTC-EUR')

EDIT 编辑

This seems to be a bug noted on github . 这似乎是github上指出的错误。 For a quick fix, you can modify the client.py file by chaning this function 为了快速修复,您可以通过更改此功能来修改client.py文件

def get_spot_price(self, **params):
    """https://developers.coinbase.com/api/v2#get-spot-price"""
    response = self._get('v2', 'prices','spot', data=params)
    return self._make_api_object(response, APIObject)

to this 对此

def get_spot_price(self, **params):
    """https://developers.coinbase.com/api/v2#get-spot-price"""
    currency_pair = params['currency_pair']
    response = self._get('v2', 'prices', currency_pair,'spot', data=params)
    return self._make_api_object(response, APIObject)

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

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