如何使用Coinbase Python API获得Litecoin价格?

时间:2017-08-16 18:27:43

标签: python coinbase-api

client.get_spot_price(currency='EUR')

此行将为我提供当前的比特币价格,但我如何找到Litecoin和Etherum价格?

1 个答案:

答案 0 :(得分:0)

您需要传递docs

中所示的正确currency_pair
client.get_spot_price(currency_pair='LTC-EUR')

修改

这似乎是github上提到的错误。要快速修复,可以通过修改此函数来修改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)

到这个

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)