Skip to content

Instantly share code, notes, and snippets.

@rhettre
Created July 28, 2022 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhettre/b2efd1405a7c3ecd33ba524cd34cdea3 to your computer and use it in GitHub Desktop.
Save rhettre/b2efd1405a7c3ecd33ba524cd34cdea3 to your computer and use it in GitHub Desktop.
Convert GUSD to USD (For Automating Deposits)
import json
import gemini
public_key = ''
private_key = ''
#This function converts all your GUSD to USD
def _convertGUSDtoUSD(pub_key, priv_key):
gusd_balance = 0
trader = gemini.PrivateClient(pub_key, priv_key)
if(list((type['available'] for type in trader.get_balance() if type['currency'] == 'GUSD'))):
gusd_balance = str(list((type['available'] for type in trader.get_balance() if type['currency'] == 'GUSD'))[0])
#use "buy" to convert USD to GUSD
#use "sell" to convert GUSD into USD
#replace gusd_balance below to transfer a static amount, use gusd_balance to transfer all your GUSD to USD
results = trader.wrap_order(gusd_balance, "sell")
print(results)
def lambda_handler(event, context):
_convertGUSDtoUSD(public_key, private_key)
return {
'statusCode': 200,
'body': json.dumps('End of script')
}
@rhettre
Copy link
Author

rhettre commented Jul 28, 2022

You can achieve recurring deposits from your bank account in Gemini by making a recurring purchase of GUSD. GUSD only trades in BTC/GUSD and ETH/GUSD and those markets aren't as liquid as BTC/USD or ETH/USD so it's best to convert your GUSD to USD - which is what the above script does.

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