Skip to content

Instantly share code, notes, and snippets.

@rhettre
Last active September 2, 2022 15:39
Show Gist options
  • Save rhettre/3d6fcf428fca4bb5badafa7454b28761 to your computer and use it in GitHub Desktop.
Save rhettre/3d6fcf428fca4bb5badafa7454b28761 to your computer and use it in GitHub Desktop.
Withdraw From Gemini to One Address
import json
import gemini
import random
import math
public_key = ""
private_key = ""
coin_to_withdrawal="BTC"
trader = gemini.PrivateClient(public_key, private_key)
#withdraws full available balance of specified coin to given address
def _withdrawFullCoinBalance(coin, address):
amount = "0"
for currency in trader.get_balance():
if(currency['currency'] == coin):
amount_before_fee = float(currency['availableForWithdrawal'])
print(f'Amount Available for Withdrawal: {amount_before_fee}')
#set your fee variable to whatever the corresponding coin is https://www.gemini.com/fees/transfer-fee-schedule#section-dynamic-fees
fee = float(.0001)
amount_to_withdrawal = str(math.floor((amount_before_fee-fee)*(10**8))/10**8)
withdraw = trader.withdraw_to_address(coin, address, amount_to_withdrawal)
print(withdraw)
return amount_to_withdrawal
def lambda_handler(event, context):
#Edit these addresses to whatever you want
btc_BlockFi = ''
btc_multisig = ''
btc_multisig2 = ''
#Add the addresses to this list
btc_addresses = [btc_BlockFi,btc_multisig, btc_multisig2, btc_multisig3]
eth_BlockFi = ''
eth_addresses = [eth_BlockFi]
btc_withdraw = _withdrawFullCoinBalance(coin_to_withdrawal, random.choice(btc_addresses))
return {
'statusCode': 200,
'body': json.dumps(f'End of Script')
}
@rhettre
Copy link
Author

rhettre commented Jul 28, 2022

withdraw-bitcoin lambda_function.py withdraws all your available to withdraw BTC and ETH from Gemini. It takes a public and private API KEY + public key BTC and ETH wallet addresses as strings in the btc_addresses + eth_addresses variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment