Closed Staubgeborener closed 6 years ago
Okay, it seems that there is no fertife version and this must be written by myself. I noticed that granularity=86400
is buggy. Instead of the values from the last 24 hours, values from a year ago will be returned. In the example of Bitcoin, there are values around the ~3000$ (over a year ago). Anyway, I have the historical prices (last 60 seconds) calculate to an average sum and after that i compared this with the current BTC value. These should be nearly the same, but here appears a difference of about 200 €.
a = [your list of prices]
len(a) # 351
sum(a)/len(a) # 3767.1698290598315
=> This should be something between 10k and 12k. But like is said, here are values in the list from the last year (?).
from coinbase.wallet.client import Client
from coinbase.wallet.model import APIObject
import gdax
api_key = 'apikey'
api_secret = 'apisecret'
version = '2017-12-15'
client = Client(api_key, api_secret, api_version=version)
public_client = gdax.PublicClient()
for i in xrange(1,4):
if i == 1:
currency_pair = 'BTC-EUR'
elif i == 2:
currency_pair = 'ETH-EUR'
elif i == 3:
currency_pair = 'LTC-EUR'
params = {'currency_pair': currency_pair}
response = client._get('v2', 'prices', currency_pair, 'spot', data=params)
price = client._make_api_object(response, APIObject)
response = client._get('v2', 'prices', currency_pair, 'buy', data=params)
buy = client._make_api_object(response, APIObject)
response = client._get('v2', 'prices', currency_pair, 'sell', data=params)
sell = client._make_api_object(response, APIObject)
print '%s %s %s' % (price.amount, sell.amount, buy.amount)
old_price = public_client.get_product_historic_rates(currency_pair, granularity=60)
for i in xrange(1,6):
print sum(map(lambda x: x[i], old_price)) / len(old_price)
The output:
11408.42 11291.34 11522.79 #(prices for: spot, buy, sell)
11603.9409117 #low
11616.7141595 #high
11610.3703704 #open
11611.8169516 #close
1.24746706396 #volume
Also see reddit.
Hey @Staubgeborener, thanks for the report.
Since this appears to be an issue with values returned from the API (and not an issue with this Python package), please contact our support team to assist with this issue. Thanks!
Is there any way to display the 'percentage change since yesterday' with the coinbase API?
I tried something like this to get the historic prices of BTC, so i can add the values together and calculate the percentage share with this. Maybe there is an easier way.
Anyway, even that does not work, because I get a list and can not parse the individual price.
And even if this works, that only shows me the value of the past hour in 10 seconds steps. While we're at it, can this somehow be used to show the value of a specific given day?