Historic_Crypto icon indicating copy to clipboard operation
Historic_Crypto copied to clipboard

Needs updating to Coinbase Advanced

Open asdsadsaasd12312132 opened this issue 2 years ago • 4 comments

Coinbase Pro is shutting down and migrating to Coinbase Advanced. This needs to be updated to use Coinbase Advanced.

asdsadsaasd12312132 avatar Jan 17 '23 00:01 asdsadsaasd12312132

Agreed - I just saw the below article

I have limited time to work on this presently, but happy to merge any PR's which provide similar functionality for the new version.

David-Woroniuk avatar Jan 17 '23 12:01 David-Woroniuk

@David-Woroniuk i'm a noob doing classwork and like that this was so easy to use. could u point me to what i'd need to modify within the code in order to update it to work with coinbase advanced? i'd like to give it a shot.

damian-robinson avatar Feb 12 '23 17:02 damian-robinson

This library seems to match up very closely to the Advanced Trade "Get Candles" endpoint. I will do more research in the coming weeks. This is a good place to start.

https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getcandles

tripster202 avatar Apr 06 '23 21:04 tripster202

Not sure if anyone's looking at this but here some sample code

import pandas as pd
import http.client
import json
from datetime import datetime

# Convert datetime to Unix timestamp
start = int(datetime.strptime("2024-09-11 00:00:00", '%Y-%m-%d %H:%M:%S').timestamp())
end = int(datetime.strptime("2024-09-13 00:00:00", '%Y-%m-%d %H:%M:%S').timestamp())

# Establish connection
conn = http.client.HTTPSConnection("api.coinbase.com")
payload = ''
headers = {
    'Content-Type': 'application/json'
}

# Make request
conn.request("GET", f"/api/v3/brokerage/market/products/BTC-USD/candles?start={start}&end={end}&granularity=FIFTEEN_MINUTE&limit=28", payload, headers)
res = conn.getresponse()
data = res.read()

# Decode and parse JSON data
decoded_data = data.decode("utf-8")
parsed_data = json.loads(decoded_data)
df = pd.DataFrame.from_dict(parsed_data['candles'])

start low high open close volume
0 1726164900 58302.48 58469.57 58328.29 58425.29 130.32612593
1 1726164000 58250.46 58419.57 58399.26 58328.2 116.9112028
2 1726163100 58224.39 58428.02 58226.17 58395.4 141.87815135
3 1726162200 58094.04 58316.75 58135.94 58223.87 128.29996901
4 1726161300 58117.49 58298 58138.72 58142.36 129.08781992

asherp avatar Sep 12 '24 18:09 asherp