Reputation: 165
I'm new to Python and API and am trying to start with some basics like making a list/plot of old BTC prices. I imported the Coinbase Wallet Client and used client.get_historic_prices()
, which gave me a list of the price at midnight UTC for 365 days.
How can I adjust the parameters to get different date ranges and data resolution, for example each minute for two years? Is there a way to search the historic values of buy, sell, and spot separately?
from coinbase.wallet.client import Client
hist_price = client.get_historic_prices()
xx=[]
yy=[]
for ii in range(365):
xx.append(ii*-1) # x coordinate being "days ago"
yy.append(float(hist_price['prices'][ii]['price']))
Returns (this is just from a print statement of print(hist_price['prices'][0:3]
). So it's midnight once a day.
prices
length = 365
{
"price": "974.39",
"time": "2017-02-01T00:00:00Z"
}
{
"price": "944.29",
"time": "2017-01-31T00:00:00Z"
}
{
"price": "920.47",
"time": "2017-01-30T00:00:00Z"
}
Upvotes: 3
Views: 3378
Reputation: 2698
Get_historic_prices is not clearly documented anywhere. This is a mini guide of what I have managed to discover about it and its usage. It's not much but it should be somewhere.
get_historic_prices supports one argument called period which can take the following values:
Each of them except all
returns approximately a list of 360 price points distributed more or less uniformly in the previous hour (day, week, month, year respectively).
all
returns a list of price points one for each day at 00:00:00 UTC (i think).
get_historic_prices
should also support a currency_pair
argument as do the get_buy_price
, get_sell_price
, and get_spot_price
do. Unfortunately, although I have submitted a PR, it has not been merged yet.
Upvotes: 1