Coinbase Pro Withdrawal Crypto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cbpro | |
import json | |
from math import floor | |
my_key = "" | |
my_secret = "" | |
my_passphrase = "" | |
my_currency = "BTC" | |
withdraw_address = "" | |
withdraw_precision = 8 | |
def _withdrawCrypto(cb_key, cb_secret, cb_passphrase): | |
auth_client = cbpro.AuthenticatedClient(cb_key, cb_secret, cb_passphrase) | |
for account in auth_client.get_accounts(): | |
if account['currency'] == my_currency: | |
withdraw_size = (floor(float(account['available'])*(10**(withdraw_precision))))/(10**(withdraw_precision)) | |
print(account) | |
print(f"Withdraw size = {withdraw_size}") | |
withdrawal = auth_client.crypto_withdraw(withdraw_size, my_currency, withdraw_address) | |
print(withdrawal) | |
return withdraw_size | |
def lambda_handler(event, context): | |
withdrawal = _withdrawCrypto(my_key,my_secret,my_passphrase) | |
return { | |
'statusCode': 200, | |
'body': json.dumps(f"You withdrew {my_currency}!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment