The Best Way to Buy Cryptocurrency in 2021 (How To Buy Automatically and With Lowest Fees using Gemini + AWS )

Table of Contents*

*Nothing I post is financial advice

โ™Š๏ธ Sign Up for Gemini and get $10 of BTC when you Trade $100: https://gemini.com/share/ZVG91T

โ€‹๐ŸŽฅ Full Video Tutorial (if you don’t like reading): https://www.youtube.com/watch?v=h6r1h3am6kA

๐Ÿ““ Notion Code Link: https://www.notion.so/rhettre/Buy-Bitcoin-Everyday-Lambda-Functions-Cloudwatch-for-Gemini-Coinbase-Pro-abe92c33a13b4be19d232d5c91edfccf

๐Ÿ’ธ Fee Structure ๐Ÿ’ธ

The reason that Gemini is the best exchange to use is that WHEN USED CORRECTLY they have the best fee structure

However, there are lots of way to mess this up. Example 1 (that most people will use) is the mobile fee structure.

You can see here when you do a regular mobile order (which is very convenient and likely how most people will by default use Gemini) the fees can be anywhere from 1.49% to 10% (!!) – this is WAYYYYY too high

Where Gemini excels is their API Fee schedule + their Transfer Fee schedule (don’t snooze on me here just because I brought up APIs – I’ve already coded everything for you)

You can see here at the lowest volume tier they offer .35% taker fees, but we can do better than that. We’ll be shooting for that .1% maker fee (100X better than the worst case 10% fee on the mobile schedule).

Some other exchanges (Kraken / Binance) also have .1% fees and in some cases (like Binance) allow you to get even lower when you pay the fees using their token.

The reason Gemini is better than both of these exchanges from a fee perspective is that Gemini doesn’t charge you on chain withdrawal fees on your first 10 withdrawals each month. This is huge for tokens like Ether and other ERC-20 tokens with massive gas fees, but it will save you money on Bitcoin too.

โ™Š๏ธŽ Set Up Gemini API โ™Š๏ธŽ

To take advantage of these low fees we need to set up access to your Gemini API. So after you’ve set up a Gemini Account here you’ll head into settings -> API (Programmatic access)

And you should see a screen that looks something like this

Click that big CREATE A NEW API KEY button

Select Primary

And copy your API key / API Secret into a safe place (and make sure never to show them to anyone or they will be able to trade/transfer on your behalf) the API Keys above are for demo purposes only and are not active

Select fund management and trading settings like we have in the screenshot above

Confirm that you’ve copied and pasted your API Key (Public Key) and API Secret (Private Key) into a safe place we’ll be accessing them in the next section (if you ever lose them or the script stops working for some reason you’ll need to come back here and regenerate new ones – no big deal)

Hit confirm and you’re done! – Pretty easy

๐Ÿค‘ Buying With AWS Lambda Functions ๐Ÿค‘

First you’ll need to make an AWS account (you might need to provide them credit card info but all the services we’re using are completely free as of this writing – you can check the current cost of Lambda Functions and Cloudwatch here)

If you’re like “But Rhett I don’t wanna make an AWS account”

Tough Toenails!

It’s 2021! The world is teeming with FREE opportunity!

AWS is one of those opportunities.

Learn it, level up your brain, and prosper!

Now that you’ve set up AWS, all the code you’ll need is hosted for you here in Notion

The first thing you’ll want to do is download this gemini-layer.zip file from the Notion link. This zip file contains all the Python dependencies for the code hosted on the Notion page (namely gemini-python and gsheets [Google Sheets])

If you are suspicious of the code in the layer.zip feel free to generate your own. Instructions here to generate the layer zip using Docker + your own local Python environment.

Once you’re in AWS you’ll head over to the Management console and you’ll go over to Lambda under Compute

Inside Lambda head over to Layers on the left nav and hit Create Layer (top right)

Inside Create Layer, name your layer and upload the gemini-layer.zip file from Notion and choose Python 3.8 as the runtime

Hit create and then head over the functions in the left nav of Lambda and hit create function

Choose Author from Scratch, name your function, and choose Python 3.8 runtime

Delete the code in lambda_function.py and paste in the code from the Notion link above

Fill in the public_key and private_key strings with your public key (API Key) and private key (API Secret) from the Gemini API step above.

It should look something like this (yours will obviously be different but format should be the same):

public_key = “account-SDcdX7y3E5XsYRy6pkt8”

private_key = “AytmxmozZbeNokpfnRFcZfYkrq”

Next go down to add a layer (bottom right of screenshot)

Choose custom layer and pick the layer you imported earlier in this step from gemini-layer.zip

After you hit add, come back to the code tab hit the deploy button to save your changes.

Note that by default on line 21 of the buy-bitcoin the script will try to buy $20 of Bitcoin. You can change this number to whatever number you want.

When you hit test, you can fill out an event name and hit create (leave the code alone).

And then your script will try to buy $20 of Bitcoin from your Gemini account (note: you obviously have to have more than $20 in your account for this to work).

If you are getting timeout issues go to “Configuration” next to the code tab and hit edit on general configuration and change the timeout from 3 seconds to 30 seconds.

You should now have a script that allows you to buy $X from Gemini, so next let’s automate it so you can buy once a day/week/month/year etc.

๐Ÿค– Automation With AWS Cloudwatch ๐Ÿค–

Go back to the AWS Management Console and click on CloudWatch

Inside CloudWatch navigate to the Rules tab under Events in the left nav

Click Create Rule here

Now click into Schedule instead of Event Pattern under Event Source

You can either change the fixed rate of days to the number of days you want or you can get fancy with Cron expressions

Cron expressions will allow you to set your own custom timing for how often these buy / transfer / sheet updating script runs.

For more info on Cron timings check out Amazon’s Documentation here

Some popular Cron timings:

15th + 30th of each Month: 0 12 15,30 * ? *

Every Friday: 0 12 ? * FRI *

Last day of each Month: 0 12 L * ? *

Once you’ve set your timing add your lambda function as the target on the right side under Targets

Configure details, give it a name, AND YOU’RE DONE!!!

๐Ÿง  Final Thoughts ๐Ÿง 

There are some other little things you’ll need to do for the transfer / google sheets updating scripts

In the transfer script you’ll need to whitelist the address within Gemini in Settings and provide your BTC address(es) in the script – same way we included the public and private keys here earlier

The Google Sheets script is a little more complicated you need to set up your Sheets API – but it is really worthwhile because it will give you ultimate control in knowing how much money you’re actually making with this BTC dollar cost averaging strategy.

Video Walkthrough of the Google Sheets Script setup here

Again none of this is financial advice. This strategy has worked out really well for me, and the automation has been really powerful in allowing me to stop worrying about day to day price fluctuations so I wanted to share this with others.

If you do get this set up, let me know. If you have questions or get stuck feel free to leave them below or on the YouTube video above and I’ll do my best to get back to you A$AP Rocky

Happy Stacking ๐Ÿ™‚

My Favorite Purchases of 2020

I wanted to share this on the blog in the new year in case anyone was looking for gift ideas for the tech nerd / athlete / creative person in their lives – and to shamelessly plug my Amazon store that will close if no one buys anything.

I’ve organized the items by price with the cheapest items at the top and the most expensive at the bottom so you should be able to find something here no matter what your budget is.

I made a companion YouTube video for this post here if you’re interested in seeing any other details about the products.

Blender Bottle 22oz Pro Stak

This blender bottle is one of my favorite products ever. I used the first one everyday for three years and dropped it over 200 times before my girlfriend made me get a new one (it was starting to fall apart). With that being said this is one of the most durable cheap water bottles ever made – it is also very fun to flip and toss around. It is not insulated so it won’t hold hot/cold beverages well, but it is great for water or other room temperature beverages. However, most insulated water bottles are more expensive and less durable (I’ve never met someone who owns a Hydroflask that hasn’t dented a Hydroflask). The 22 oz size is perfect for reminding me to get more water throughout the day at work and help remind me to change my posture so I don’t sit in one position for too long. It is not too big that you never get to finish it, and it is not too small that you are constantly filling it up. Additionally this blender bottle comes with little prostak containers that are perfect for pre-workout or other mix-in powder, or even daily vitamins. I used the little stacks frequently when I would travel for work and I don’t go anywhere without this blender bottle.

Buy Blender Bottle 22oz Pro Stak

Slow Dolphin Lightning Kit

When I started making YouTube videos I was completely unaware of how lighting can completely change the quality of the videos. My early videos were plagued by bad window lighting that was constantly being altered by passing clouds. This gave me nightmares in editing trying to balance the exposure of shots that were messed up by the sun. Also, it was basically impossible to film at night. When I watched other YouTubers give lighting recommendations a lot of them recommended huge $1000+ lighting rigs that I had a hard time justifying as I’m just starting off on YouTube. These ~$50 lights from Slow Dolphin Photography are relatively cheap, very easy to set up, and because they are mounted on tripods are very versatile. And you get 2 which is perfect for lighting yourself from both sides and avoiding weird angled shadows.

Buy Slow Dolphin Lighting Kit

MX Master 3

This is the best mouse I’ve ever used. The buttons are very tactile, the side scroll is perfect for Final Cut Pro, the gesture button allows me to dock my Mac and still get all the functionality of the touchpad, and being able to map copy+paste to the thumb buttons is a game changer in spreadsheets, etc, etc, etc I could go on and on. Buy this mouse – it’s excellent

Buy MX Master 3

Liforme Yoga Mat

My old yoga mat would never lay flat and was deformed by the heat on our drive to Houston. I liked the idea of a yoga mat with a center line and positional guides that could help me perfect my form on different poses as I continued my practice so I bought the Liforme mat. The difference between it and my first mat is night and day. The Liforme mat always lays flat, it is well built but not too chunky (you may need a towel if you practice on concrete – it’s not that thick), and the alignment system gives you the confidence that you’re doing the poses correctly even if you are practicing alone.

Buy Liforme Mat

Honorable Mention: Down Dog App

I’ve been practicing yoga remotely with Down Dog’s mobile app for about 18 months now. When I signed up Down Dog had a lifetime membership which I think is a ridiculous deal. Having practiced yoga over 130 times with Down Dog as of this recording my cost per class is only $1.53 and that cost per class is falling with each new session I do. In person Yoga classes usually run about $10 a session in my experience or if they come with a gym membership can run $30+ a month.

Buy Down Dog Yoga App

Dell U4919DW Ultra Sharp 49″ Monitor

I have found this monitor very helpful for programming, video editing, writing, and note taking. If you combine it with the MX Master 3 mouse you can have 12 full sized windows on only 4 desktops which gives you a ton of flexibility with how you want to organize your workflow. The biggest downfall of this setup is it is difficult to share your full screen in Zoom (like you might have seen in the video – the screen grabs are difficult to share because most monitors are not optimized to deal with the ultra-wide aspect ratio). Other than that, this monitor is excellent and doubles as a great backdrop for YouTube videos. It is expensive but if you find a refurbished model you could get it for $1000 or less.

Buy Dell 49″ Monitor