Mike1:
def send_request(method, path, payload, params=''):
auth = Auth()
headers = auth(method + path + payload)[0]
conn = http.client.HTTPSConnection('api.coinbase.com')
conn.request(method, path + params, payload, headers)
data = json.loads(conn.getresponse().read())
return data
def list_accounts(currency=None, uuid=None, balance=None):
method = 'GET'
path = '/api/v3/brokerage/accounts'
payload = ''
data = send_request(method, path, payload, params='?limit=250')
if currency == None:
print(data)
elif currency != None:
for i in data["accounts"]:
if i["currency"] == currency:
uuid = i["uuid"]
balance = i["available_balance"]["value"]
return uuid, balance
def get_account(uuid):
method = 'GET'
path = '/api/v3/brokerage/accounts/' + uuid
payload = ''
data = send_request(method, path, payload)
print(data)
I ran your code to get the balances. You are awesome. Do you have any instagram or youtube that I can follow? You have been a serious big help.
Mike1
April 16, 2023, 9:56pm
42
I donāt have any social media. Iāll probably set something up at some point though. Wouldnāt converting USD to USDC be the same as converting BTC to USD, so basically creating an order?
No, because you cannot trade USDC. it is not in advanced trading.
Mike1
April 23, 2023, 9:10pm
44
The only thing that I can see is there are USDT-USDC and USDT-USD markets, so you can technically convert USD to USDC by going USD to USDT to USDC, although that brings in an extra fee.
If you each of the trades from USDT-USD to USDT-USDC as a maker and your fees will be 0%.
Thatās how I do it anytime I need to convert between USD and USDC programmatically.
3 Likes
New issue. hopefully I could still get your help.
Title:
Getting 400 Bad Request error when trying to execute buy and sell orders using Coinbase API
Description:
I am trying to develop a trading bot using the Coinbase API. My script is generating buy and sell orders, but I keep getting a 400 Bad Request error when trying to execute these orders. I have included the relevant parts of the code below, which involve the send_request function and the code for creating buy and sell orders.
Response Status: 400
Response Reason: Bad Request
Error: ā¦