Skip to content

Instantly share code, notes, and snippets.

View rhettre's full-sized avatar

Rhett Reisman rhettre

View GitHub Profile
@rhettre
rhettre / coinbase_advanced_trade_sheet.py
Last active April 4, 2024 11:41
Automates the import of Coinbase transactions into a Google Sheet for cost basis tracking.
import json
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from datetime import datetime, timezone
from coinbase_advanced_trader import coinbase_client
from coinbase_advanced_trader.config import set_api_credentials
# Link to Base Spreadsheet - https://docs.google.com/spreadsheets/d/1VYuy5cSnZiQqF4yp6_sVFpLXXXszCGEiMh-Z37mKims/edit?usp=sharing
COINBASE_PUBLIC_KEY = ''
COINBASE_PRIVATE_KEY = ''
@rhettre
rhettre / coinbase_config.json
Created April 1, 2023 22:21
Sample config.json for Coinbase Withdrawals and Deposits
{
"API_KEY": "",
"API_SECRET": "",
"DEPOSIT_ID": "",
"PAYMENT_METHOD": "",
"DEPOSIT_AMOUNT": 10,
"DEPOSIT_CURRENCY": "USD",
"BTC_ADDRESS": "",
"WITHDRAW_CURRENCY": "BTC",
"WITHDRAWAL_ID": "",
@rhettre
rhettre / coinbase_withdrawals.py
Last active December 1, 2023 05:43
This Python script contains an AWS Lambda function designed to automate withdrawals from Coinbase accounts. It was created in response to the retirement of the Coinbase Pro API, which previously facilitated withdrawal automation. The script leverages the Coinbase Wallet API to list payment methods and initiate crypto withdrawals. Users can custo…
import json
import hmac
import hashlib
import time
import requests
from requests.auth import AuthBase
import os
with open(os.path.join(os.path.dirname(__file__), 'config.json')) as config_file:
config = json.load(config_file)
@rhettre
rhettre / coinbase_deposits.py
Last active April 1, 2023 22:19
This Python script contains an AWS Lambda function designed to automate deposits into Coinbase accounts. It was created in response to the retirement of the Coinbase Pro API, which previously facilitated deposit automation. The script leverages the Coinbase Wallet API to list payment methods and initiate deposits in USD. Users can customize the …
import json
import hmac
import hashlib
import time
import requests
from requests.auth import AuthBase
import os
with open(os.path.join(os.path.dirname(__file__), 'config.json')) as config_file:
config = json.load(config_file)
@rhettre
rhettre / random_example_1.py
Created January 23, 2023 14:29
Generate 5 random numbers. If you pass an integer seed into line 6 random.seed(), you will see that your results will always correspond to that seed number.
import random
print("---RANDOM NUMBERS---")
for i in range(5):
# Any number can be used in place of '0'.
random.seed(5)
# Generated random number will be between 1 to 1000.
print(random.randint(1, 1000))
print("---END---")
@rhettre
rhettre / CBAT_limit_orders.py
Last active March 3, 2024 15:32
Place limit orders on Coinbase Advanced Trader for just below/above the spot price for your buys/sells. Executable and automatable in AWS
import http.client
import hmac
import hashlib
import json
import time
import base64
import uuid
from enum import Enum
import math
@rhettre
rhettre / kraken_withdrawal.py
Last active January 10, 2023 15:15
Automate Cryptocurrency Withdrawals From Kraken
import time
import requests
import urllib.parse
import hashlib
import hmac
import base64
import json
# Read Kraken API key and secret stored in environment variables
api_url = "https://api.kraken.com"
@rhettre
rhettre / crypto-gsheet-populator.py
Last active May 31, 2024 02:49
I built this script to populate trades made in any trading pair available on Coinbase Pro or Gemini into a Google Sheet so it would be easier to track trades, profitability, and cost basis. This could be extended to other exchanges. See https://www.youtube.com/watch?v=hutDJ-FVatw for full explanation.
import json
import gspread
import time
import sys
import base64
import hashlib
import hmac
import urllib.request
import requests
from datetime import datetime, timezone
@rhettre
rhettre / kraken-limit-orders.py
Last active November 12, 2022 15:00
Kraken Limit Orders
import time
import sys
import json
import base64
import hashlib
import hmac
import urllib.request
import requests
import datetime
@rhettre
rhettre / ftx-withdrawal.py
Created July 28, 2022 13:41
FTX Withdrawals
import ftx
import json
import random
YOUR_API_KEY = ""
YOUR_API_SECRET = ""
#Fill in your FTX API Keys above
coin = 'BTC'
#change COIN to 'ETH' for Ethereum, 'ADA' for Cardano (etc)