Gemini API FAQs: Troubleshooting The Best Bitcoin DCA Strategy

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

​🎥 Original Video Tutorial: https://www.youtube.com/watch?v=h6r1h3am6kA


📉 Does it Work With ETH, LINK, LTC etc? 📉

Yes! Check out the symbols and minimums section of the Gemini API.

You’ll see below that not only do you need to update the symbol from btcusd to ethusd (for Ethereum) but you also need to update the tick size. The tick size for BTC is 8 the tick size for ETH is 6 etc. Updating this tick size allows us to get more accurate rounding in the price variable.

🇪🇺 Does it Work With Euros and Pounds? 🇪🇺

Yes! Similarly to the last answer, just check the symbols and minimums section of the Gemini API. You’ll see below that there are codes for USD 🇺🇸 EUR 🇪🇺 GBP 🇬🇧 and SGD 🇸🇬

Just replace btcusd in the code with your desired currency pair.

💰 How Do I Fix Insufficient Funds Error 💰

You’ll get this error if you don’t have enough currency in your account to make the trade. If the symbol you are trading is btcusd, you’ll need USD to execute the trade. Similarly, if you’re trading ethbtc you’ll be writing in the script how much BTC of ETH you want to buy (a little confusing). You can check to see how much of each currency you have in the Account balances and history tab of your Gemini account (Account in the top right -> Balances)

Account Balances and History

It should look something like that ^^ and should show you any holds that are being placed on your account by active trades or other situations that would lower your “Available to trade” balance.

🔑 How Do I Fix Invalid Signature Error 🔑

Invalid Signature Error

A few people have run into this error and it has been solved every time by generating new API Keys and readding them to your Lambda Function in AWS.

❓What is in Layer.zip?❓

Layer.zip contains the gemini-python and google sheets Python packages that I leveraged to write the scripts. We need this code to be hosted in AWS to run the code correctly.

I generated Layer.zip using my local python environment and Docker. If you’d like to generate your own layer.zip I was able to follow this great tutorial and (with 0 prior Docker experience) generate a working Layer.zip.

💻 Can You Implement This Locally Without AWS? 💻

Yes you can! Here’s a video of me implementing the script on iOS using Pyto and Siri Shortcuts:

The first recorded video of a human buying Bitcoin with a HomePod

Of course you can implement for free with your own Python environment on your Mac/PC. You’ll just need to pip install gemini-python and pip install gspread (if you want the spreadsheet functionality) to get the necessary code packages (you don’t need to do this in the AWS version because all those dependencies are packaged in Layer.zip)

🏷 Can I Set the Limit Price to $X 🏷

Yes! The script in the Siri Shortcuts video works by letting you set your own limit price. If you want to manipulate the code from Notion, you’ll just need to update the price variable from:

price = str(round(float(trader.get_ticker(“BTCUSD”)[‘ask’])*.999,2))

to

price = “30000”

In this example, we’re making a limit order where the limit price is $30,000. This has the benefit that your order will fill only when the price falls to $30,000 giving you a better execution price. But comes with the downside that if the price never falls to $30,000 your order will never fill.

The current line: price = str(round(float(trader.get_ticker(“BTCUSD”)[‘ask’])*.999,2))

Is taking the current spot price of Bitcoin (“BTCUSD”)[‘ask’] and setting the price of your order to .999 * current spot price (ie. if Bitcoin is trading at $35,000 your limit order will be made for $34,965). You can change that .999 factor to any other number you’d like if you want to try to get Bitcoin at a lower price.

Comment thread on what happens if you set the factor too low

Above is a comment thread answering the popular question: can I set the factor to be 0.9 / 0.85 / something lower than 0.999

In short, the answer is yes and usually you’ll be fine. When BTC (or whatever currency you’re trading) rips up and doesn’t come back down though you’ll end up with lots of orders on the book over a long period of time.

🤖 How Do I Automatically Deposit Funds to Gemini? 🤖

Unfortunately, I haven’t found a way to do this yet. Ally Bank, Schwab, and Capital One all refused to do recurring deposits to my Gemini account and there is no functionality in the current Gemini API to automate deposits.

If you find a bank that allows creating recurring deposits to Gemini please send me an email at rhett@rhett.blog and I’ll give you credit (and love you forever).

I’ll update this thread (and probably make a video) if/when I figure that out.

As of now, this is the missing piece that would make the strategy fully automated.

My current strategy is to make one large deposit each month to cover all my monthly DCA.

🙈 How Do I See My Order? 🙈

Go to Account -> Settings -> Account and select ActiveTrader as your Trading Interface.

Account -> Settings -> Account

Your open orders should show at the bottom left of your trading interface

Total shown is exclusive of fees

💸 How Do I Confirm The Fees I Paid? 💸

You should be getting an email to the email associated with your Gemini account every time an order fills that looks like this:

Email showing fees

If not, go into Gemini -> Account -> Settings -> Notifications and make sure “Your limit order is complete” is selected.

Notifications

If you still aren’t getting the emails, check your spam filter.

🏦 Why Aren’t My Withdrawals Processing? 🏦

If your withdrawals aren’t processing, first confirm that you’ve whitelisted the address that you’re trying to send to.

You can check this by going to Gemini -> Account -> Settings -> Approved Addresses

You’ll see your withdrawal addresses where that giant black box is

Additionally, when you try to make a withdrawal you’ll want to confirm that the funds you’re expecting to withdraw have settled.

Available for withdrawal under the bell icon in the top right of the trading UI

By default the script will try to withdrawal the full amount of BTC/ETH that is “available for withdrawal”

If you deposited via ACH your funds will take ~7 days to settle within Gemini. Only after the funds have settled will they be considered to be available for withdrawal.

📧 Why Won’t Gemini Support Won’t Email Me Back? 📧

Contrary to what some people might think, I actually don’t work in Gemini support. I have heard though from quite a few people that Gemini’s email support is horrible. This mostly seems to be around account verification.

To avoid this problem I would suggest fully verifying your account before trading on the platform (I agree that this is not a great solution).

If you are already stuck in Gemini email support hell, I received feedback from one commenter who successfully escaped Gemini email support hell that sending a kind email explaining your situation and what you need to get unstuck helped a lot. Sometimes we have to check our egos to get what we want 😃

If this doesn’t work, I don’t really know what to tell you sorry! 😔

🧠 Final Thoughts 🧠

Feel free to DM me on Twitter if you have any questions not covered here. This has been a really fun project and a ton of people have sent me screenshots of them getting this to work and saving a ton of $$$ on fees, so if you get stuck don’t despair! This is definitely doable, even with limited / no technical expertise.

If you can manage to avoid the dreaded Gemini email support system, this is still the lowest fee way to buy Bitcoin.

Onward and upward!

Rhett

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 🙂

Book Review | Principles by Ray Dalio

“Life is short and hard like a bodybuilding elf” – my high school Physics teacher

I read 52 books in 2018, mostly because I fetishized CEOs, hustle culture, and reading as a heuristic for achievement.

I’m older now (27 as of last Friday – happy belated birthday to me), and in my wise old age my philosophy has changed from read as many books as possible to don’t waste time reading things that you find useless.

Principles by Ray Dalio is the first book that I’m putting down early. Not because it’s horrible – it’s not great, but because I don’t plan on starting or operating a global hedge fund anytime soon (and it’s VERY boring and repetitive).

The book (like many other self-help / business books) can be boiled down to: choose long term over short term and systems are better than goals.

If you’re looking for a book to explain to you why you should choose long term over short term and why systems are better than goals – there are lots of more accessible, less specific to running a hedge fund, and generally more interesting options (see Atomic Habits, How to Fail at Almost Everything and Still win Big, 12 Rules for Life, Leadership Strategy and Tactics, the list goes on and on).

If you are looking to start / run a hedge fund this might be a great book for you and you might find those other books not specific enough to your problem.

For the rest of us: we can probably get by with something more fun, stop taking book recommendations from Bill Gates, and start putting down books we don’t care for before we get to the last page.

Memento mori

Buy Principles on Amazon

Get Principles for Free with Trial of Audible Premium Plus

Book Review | The Bitcoin Standard by Saifedean Ammous

Get The Bitcoin Standard Free with Audible Premium Plus

The Bitcoin Standard is Saifedean Ammous’s Bitcoin thesis. What makes the book great is that it doesn’t start from Bitcoin and draw conclusions about sound money but, rather, Saifedean reasons from first principles and comes to Bitcoin as the conclusion.

There are a few great takeaways from this book:

1) Low Time Preference

Keeping low time preference is what allows society to exist. Understanding that I (an individual) don’t have to constantly be farming and hunting my food allows me to specialize on other tasks. Which allows the individual to provide disproportionate value to society.

If Steve Jobs spent his whole life hunting food we’d all be a lot worse off.

2) Austrian vs Keynesian Economics

Saifedean dedicates part of this book to his hatred for Keynesian economics. I don’t feel as strongly and don’t know enough but he makes interesting points about how inflationary currency drives high time preference behavior which cheapens culture, art, and society.

This positions Bitcoin as the exit ramp from Keynesian economics. If you have ever wanted to play pure Austrian economics – Bitcoin forces its adopters to play by these rules. It is interesting to view Bitcoin this way – an environment to see how a programatic version of Austrian economics would play out where no central government or authority can change the rules.

I think reading this in tandem with The Deficit Myth by Stephanie Kelton will give you a cursory understanding of the differences between Austrian and Keynesian economics.

3) Bitcoin as Digital Gold

Bitcoin is shown to have all the same properties (durability, portability, divisibility, recognizability, scarcity) that make gold sound money – but with Bitcoin those properties are on steroids. Bitcoin can’t be destroyed, it is much more portable than gold, it is infinitely divisible, it costs much less to verify that what you have is in fact Bitcoin, and as of 2024 Bitcoin will have a higher stock to flow ratio than Gold.

These properties of hard money are important because it stops foreigners (with harder money) from cheaply producing our money and then coming in and buying our country (as happened in Africa when they were using beads as money, and in India and China who were on the silver standard in a world with other nations on the gold standard).

The countries with easy to produce money were easily taken advantage of economically by countries with hard to produce money (this advantage didn’t stop governments with hard to produce money from getting addicted to stimulus – which will forever be politically convenient). In Rome they would lower the % of gold in a coin and today, JPow adds some extra 0’s at the end of a government database.

All of this ties together to present Bitcoin as the digital version of gold that promises to either:

reform the financial system that has been interfered with by governments and Keynesians (however you feel about them aside)

OR

create an entirely separate monetary system where we can see, in real time, whether the tenants of Austrian economics or Keynesian economics are more valuable (based on real market cap figures).

Looking at the USD/BTC chart, it doesn’t look great for the dollar.

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

Buy Bitcoin Everyday with Coinbase Pro and AWS Lambda Functions

Table of Contents*

*Not financial advice

Background

I got into Bitcoin in 2017 and had a consistent monthly dollar cost averaging schedule set up.

When the price tanked in 2018 so did my interest.

I played all sorts of little psychological games with myself convincing myself why it wasn’t urgent that I make my Bitcoin purchase this month.

There was no hype, and there was very little media attention.

My interest was renewed in 2019 (fueled by the hype of reading Ben Mezrich’s book Bitcoin Billionaires) and I decided that automating my purchases was my best defense against myself and the FUD (fear uncertainty and doubt) circulating around Bitcoin.

I chronicled my first attempt at automation on the blog here: https://rhett.blog/2020/10/21/bitcoin-everyday/

And on YouTube (in a long complicated video) here: https://www.youtube.com/watch?v=UIP6_5G3v5I

This original design was difficult to test and update (involved pushing up to git, logging into AWS Lightsail, pulling from git, and hoping nothing broke) and there was a ~$2 a month fee for the Lightsail instance – yuck!

My smarter than me girlfriend was taking an AWS course, stumbled upon lambda functions and Cloudwatch automation (which are free).

This infrastructure also allows for a more modular design that is a lot easier to maintain (and is less coding to get started).

Hold on to your hats, you’re going to be blown away by how elegant this is.

Coinbase Pro API

This is the same as last time. You’ll still need an API passphrase / secret / key to automate trades.

To sign up for Coinbase Pro you’ll need proof of ID, name, email address, phone number and some other info depending on your region.

Full instructions to sign up for Coinbase Pro are here

Once you’ve signed up for Coinbase Pro, you can activate your API.

Click API under your User Name in the top right
Click +New API Key and record your Passphrase

Under Permissions I’ve Selected View Transfer and Trade because:

If you want your Python script to automatically dump the trade details into your Google Sheet you’ll need to check the View box

If you want your Python script to automate withdraws + deposits you’ll need to check the Transfer box

If you want your Python script to automate purchases you’ll need to check the Trade box

Record your API Passphrase (ray0ddnl6j in the screenshot) in a text file, we’ll need that for our Python Script to access your Coinbase information.

*** It is important not to share your API passphrase / secret / key with anyone you don’t trust and consider setting up 2 Factor Authentication to further protect your Coinbase Pro account.***

***The API credentials in these screenshots are just demonstrations of what yours might look like.***

Record your API Secret
HIghlighted Under Default Portfolio above nickname will be your API Key

Google Sheets API

This Google Sheets functionality is a nice to have, it will allow you to pull your transaction data into Google Sheets to understand how much money you’ve made.

I created this template (The Definitive Bitcoin Spreadsheet) based off of the spreadsheet I use that is compatible with the code I’ll be sharing later.

This is also the same as last time. This video does a great job of explaining.

You’ll end up with a .json file with credentials and you’ll need to include in your Lambda Function later on.

AWS Lambda Functions

Here’s where the magic happens: within your AWS console you’ll want to navigate to Lambda

And then before anything else you’ll want to navigate to layers and hit create layer in the top right

Now head over to this Notion link I’ve set up to host the code you’ll need for these Lambda Functions

https://www.notion.so/rhettre/Buy-Bitcoin-Everyday-Lambda-Functions-Cloudwatch-abe92c33a13b4be19d232d5c91edfccf

The first thing we’ll need from Notion is the layer.zip download

Back in AWS on the create layer screen upload the layers.zip and name it whatever you want and leave the runtime and license fields empty.

This is going to allow our AWS hosted Lambda function to use the cbpro and gsheets Python packages.

Once you’ve set up the layer you can head over to the functions tab on the side of the AWS Lambda screen and click create function in the top right.

In Author from Scratch, name the function whatever you want, select Python 3.8 in runtime and hit create function in the bottom right.

First, within the function we’re going to add our layer. Click on layer underneath your function name and then add a layer in the bottom right.

Choose Custom Layers and add the layer you created earlier, this will allow our script to use those included Python libraries.

If you want to include other Python libraries here is the tutorial I used to generate layers.zip: https://towardsdatascience.com/how-to-install-python-packages-for-aws-lambda-layer-74e193c76a91

Back in your Lambda Function base you’re going to want to copy and paste the code over from my Notion page into your Lambda Function

Once you’ve copied over the code you’ll want to fill in your key secret and password from the Coinbase Pro API step above

Additionally, in the Sheets updater code you’ll need to include your sheets_creds.json in the package at the same level as the lambda_function.py. You can do this by right clicking and adding new file at the folder level.

Deploy the code to save the changes and then hit test and enter any name in “event name” you can leave your test event code at the hello-world template. Once you hit create you’ll be able to run the script using the test button

***BE CAREFUL USING THE TEST BUTTON, THIS WILL CREATE A MARKET BUY ORDER IN THE EXAMPLE ABOVE***

AWS Cloudwatch

Clicking Test will now run your script once, but you want it to run once a day/week/month etc.

Cloudwatch makes this really easy.

Get into CloudWatch from the AWS Management Console and then go to Rules on the left nav

Click the blue (purple? I’m colorblind) Create Rule button

In this section select schedule and you can set either a fixed rate or for more detail you can give it a Cron expression

If you need help configuring your Cron this site is really helpful: https://crontab.guru/ (note that Cron expressions from this site are missing the ? parameter that AWS uses before the last * so you’ll need to re-add that ? expression to your Cron if you generate it from this site)

Select your lambda function from the dropdown and click configure details

Name your rule and give it a description and you’re all done!!!!

Closing

Let me know in comments here or on YouTube or email me at Rhett@rhett.blog if you have any questions or get stuck.

The beauty of this is that you can set different scripts to different automated cron schedules very easily through the AWS UI.

Additionally there is basically no programming involved in this whole process, you don’t even need a local environment since all the code is being handled in AWS.

Now you can stop worrying about the Bitcoin price, sit back, relax, and stack sats.

Book Review | 1984 by George Orwell

I read this book during the COVID-1984 pandemic and it instantly confirmed all my biases.

That’s the problem with this book – you will use it to confirm your political feelings for the rest of your life. Any political action you see that you disagree with will be easily relatable to one of the dystopian concepts presented in 1984 (ex. my reaction to the COVID-1984 lockdowns).

Everywhere you look you’ll start to see opposing media rewriting history or your political opposites (parents / friends / enemies on Twitter) engaging in doublethink or accusing you of thought crimes.

I think it is important to be aware of these concepts and be wary of their encroachment on our everyday lives and values, while simultaneously giving context to our lived experience by comparing it to people facing much worse, happening right now, real atrocities all across the world (Yeonmi Park’s escape from North Korea comes to mind)

With that being said, the fact that this book was published in 1949 and is still incredibly relevant today is a testament to how well it was written.

A must read.

How I Automate My Bitcoin Purchases and Track Profits

Table of Contents

Background

I (like many others) started buying Bitcoin in 2017.

I was buying monthly – in 2017 almost every month included a huge price movement culminating in a $19,000 high in December.

The media noise Bitcoin made every month made it really easy to remember to make my monthly purchase.

As 2018 came around, the speculative bubble popped and the price crashed down to $3,000.

From then on it became incredibly difficult for me to remember to buy monthly because no one was talking about Bitcoin.

That led to me making few investments into Bitcoin in 2018 and missing out on a major opportunity for profit.

Around August 2019 (fueled by the hype of reading Ben Mezrich’s book Bitcoin Billionaires) I finally got serious and automated my Bitcoin purchases with a Python script and Coinbase Pro’s API.

I connected this to my Google Sheet (The Definitive Bitcoin Spreadsheet) that tracks the value of my Bitcoin purchases over time.

I’ve found this spreadsheet to be addictive to look at, but keeping the data in a spreadsheet gives me greater control than any of these silly stock ticker / wallet apps and gives me an ad-free experience.

I hope this article will be user friendly enough that you’ll be able set up the same system quickly and easily.

How to Install Python

Below is a guide to installing Python on Windows/Mac/Linux:

https://docs.python-guide.org/starting/installation/

Alternatively: If you have a Mac you can install Python3 using Homebrew detailed instructions here

Now that we’ve installed Python it’s time to get a Coinbase account.

Coinbase Pro API

To sign up for Coinbase Pro you’ll need proof of ID, name, email address, phone number and some other info depending on your region.

Full instructions to sign up for Coinbase Pro are here

Once you’ve signed up for Coinbase Pro, you can activate your API.

Click API under your User Name in the top right
Click +New API Key and record your Passphrase

Under Permissions I’ve Selected View Transfer and Trade because:

If you want your Python script to automatically dump the trade details into your Google Sheet you’ll need to check the View box

If you want your Python script to automate withdraws + deposits you’ll need to check the Transfer box

If you want your Python script to automate purchases you’ll need to check the Trade box

Record your API Passphrase (ray0ddnl6j in the screenshot) in a text file, we’ll need that for our Python Script to access your Coinbase information.

*** It is important not to share your API passphrase / secret / key with anyone you don’t trust and consider setting up 2 Factor Authentication to further protect your Coinbase Pro account.***

***The API credentials in these screenshots are just demonstrations of what yours might look like.***

Record your API Secret
HIghlighted Under Default Portfolio above nickname will be your API Key

That’s all we need from Coinbase so let’s move on to creating the Python script!

Python Scripting

Before we get started you’ll need to install the gspread and cbpro Python libraries. You can do this from the terminal on Mac with ‘pip install gspread’ and ‘pip install cbpro’

Below is the code you’ll use to automate your bank transfers, purchase Bitcoin, and dump the information into your Google Sheet.

import gspread
from oauth2client.service_account import ServiceAccountCredentials
from datetime import date
import calendar
import cbpro

my_key = 'YOUR API KEY'
my_secret = 'YOUR API SECRET'
my_password = 'YOUR API PASSWORD'
bank_id = 'YOUR BANK ID'

#Populate Transaction Data to Add as New Row in GSheet
def _addTransaction(transaction):
transaction_date = str(transaction['created_at'][0:10])
transaction_id = transaction['trade_id']
provider = "Coinbase Pro"
quantity = float(transaction['size'])
btc_price = float(transaction['price'])
fee = float(transaction['fee'])
usd_amount = float(transaction['usd_volume']) + float(fee)
return [transaction_date, transaction_id, provider, quantity, btc_price, usd_amount, fee]

#Access your GSheet
def _authenticateSpreadsheet():
#Set up access to the spreadsheet
scope = ["https://spreadsheets.google.com/feeds",
'https://www.googleapis.com/auth/spreadsheets',
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("Sheets_creds.json", scope)
client = gspread.authorize(creds)
return client.open("The Definitive Bitcoin Sheet").worksheet("BTC Buy Audit File")

def buyAndPopulateBTC(cb_key, cb_secret, cb_password, bank_id):
buy_size = 0
days_in_month = calendar.monthrange(date.today().year,date.today().month)[1]
auth_client = cbpro.AuthenticatedClient(cb_key, cb_secret, cb_password)

#Buy
auth_client.place_market_order('BTC-USD','buy',funds=buy_size)

#Deposit if Necessary
if date.today().day == 15: deposit = auth_client.deposit(buy_size*days_in_month, 'USD', bank_id)

#Open the correct spreadsheet + worksheet
audit_file = _authenticateSpreadsheet() btc_fills = list(auth_client.get_fills(product_id="BTC-USD"))

#Get last transaction ID added to worksheet and get a range of days to pull in
last_transaction = audit_file.get_all_records()[-1]['Transaction ID']

#Reverse btc_fills to get dates into Sheets in descending order
for transaction in btc_fills[::-1]:
if transaction['trade_id'] > last_transaction:
cbpro_row = _addTransaction(transaction)
audit_file.append_row(cbpro_row, value_input_option="USER_ENTERED")

buyAndPopulateBTC(my_key, my_secret, my_password, bank_id)

As it is written, the code above will buy 0 dollars of bitcoin, deposit 0*number of days in the month (October has 31) dollars into your Coinbase account on the 15th of every month, and record the transaction to your Google Sheet Named “The Definitive Bitcoin Sheet” in worksheet “BTC Buy Audit File”.

However, it won’t work as written. You’ll need to fill out your relevant information (API keys + amounts you want to buy + bank info).

You’ll also need to authorize gspread with Google and get a json keyfile (mine is called Sheets_creds.json in the code above)

It will look something like this:

{
"type":"dafdsfa",
"project_id":"dfjaklsdjf;s",
"private_key_id":"12836580173894dfkalsjdflkdjaslkf",
"client_email":"dflkjkl.jdasklfj.djaslkfjkl.com",
"client_id":"3217493278195",
"auth_uri":"www.ldsajfkldsjflkasjdlf",
"token_uri":"ww.wjlfkdjaflsjdlf",
"auth_provider_x_cert_url":"fjdalkjfklsdalfj"
"client_x_cert_url":"3fsdafdsaf324sa"
}

*** Don’t share your credentials with anyone ***

Keep that credentials file in the same directory as your Python script and reference it correctly in the _authenticateSpreadsheet() method.

If you’re stuck, here’s the tutorial I used to get the Google Sheets part working:

Here is a link to the public version of the spreadsheet I built to track transaction data. If you come up with a different format you’ll want to update the _addTransaction method in the Python script so the data comes over cleanly.

Automation: AWS

At this point in the process I was a little out of my depth.

For a while I just woke up everyday and ran the script from my computer.

That got old fast.

I wanted something that would run the script even if I didn’t have access to my computer (if I’m on vacation I still want to be buying Bitcoin)

Luckily I found this great article by Eric Landstein detailing how to automate Python scripts from a Lightsail Ubuntu instance on AWS.

Link to that article here

You can get your code from your machine to the AWS Ubuntu machine using GitHub or any other version control software.

Alternatively, there are probably other ways to automate this Python script. If you Bing “Automate Python Script” you’ll find plenty of resources.

Resources and Considerations

Be careful running the script – once you set it up correctly if you have a few too many 0’s in the buy size you’ll run out of money.

The buy_size in the script above is set to $0 so you can test. If you’re extra paranoid you can comment that line out or test with an API (key/secret/password) that doesn’t allow trading.

Below are some developer resources that were helpful to me when getting this up and running.

If there are any questions feel free to leave them below, email me at rhett@rhett.blog, or tweet at me @rhettre

See you on the moon,

Rhett

Python CBPro Documentation (Helpful for finding out your Bank ID and other misc data if you want to do something different with your script)

Python GSpread Documentation (Helpful if you have a different spreadsheet layout you want to use)

Cron Timing Calculator (Helpful for getting the Ubuntu cron timing right on AWS)

Book Review | Superforecasting by Philip Tetlock

This book is about prediction and “Superforecasters” – people who are better at forecasting than better than above average forecasters.

Turns out the biggest thing preventing you from becoming a Superforecaster is not your inability to do high school math, but rather your inability to let go of closely held beliefs.

People who are emotionally attached to their beliefs see things through a skewed lens (as we all do) but are then unable to course correct their predictions in light of new evidence.

And it turns out this frequent incremental updating is one of the key skills Superforecasters look to cultivate.

Superforecasting by Philip E. Tetlock

A Case Study – Me (not a Superforecaster):

This book confirmed three of my deeply held beliefs.

The first is that the national media is corrupt and evil. I’ve cultivated this belief by reading countless books on the subject, good luck changing my mind now.

Especially after this book revealed new information to me: the media actively avoids putting % chance predictions on vague assertions they make.

They use language like “a fair chance of…” or “more than likely” or “almost certainly” to justify whatever they’ve said afterwards no matter what happens – this allows them to get away with repeatedly overstating/understating the importance of issues to the public.

Showing a correct prediction % next to national news pundits while they’re speaking would be great (but they’ll never agree that because they’re pure evil).

The second is that decentralized command is an important leadership principle (Thanks Jocko)

The third is that all scientific knowledge is tentative.

Please recognize the massive risk I am taking for saying this in public.

There is a very long line of angry people (who didn’t do very well in high school science, consume a lot of IYI media in adulthood, and all of a sudden became scientists in the last 7 months) queuing up to give my advertisers a piece of their mind.

The worst part of this book is that Tetlock questions the infinite wisdom of Nassim Taleb.

It is difficult for me to contend with the idea that the Black Swan theory is overly complex (aren’t all events somewhat predictable beforehand?) while also deeply wanting to pay $3000 to attend his RWRI conference (with hopes that attending a week long lecture taught by people so smart I can’t understand them will undo the years of binge drinking and return me to the intellectual apex of society making me as smart and self righteous as I was in high school where I intellectually badgered the C student coronavirus experts who seek to cancel me).

If anyone wants to start a low stakes gambling ring on Predictit hmu

Book was good. Little too long (aren’t they all)

Quora Question | If Jeff Bezos is so rich, why does Amazon have such a low pay and poor conditions?

Because Jeff Bezos is uniquely evil and this is how capitalism inevitably ends up!

Or at least that’s what some of these other answers would have you believe.

The bottom line is, Amazon’s “low pay” and “poor conditions” are exaggerated.

Some jobs have lower salaries than other jobs because more people are capable of doing them.

Some Amazon jobs pay only $15 an hour, but the benefits packages are generous relative to other $15 an hour jobs.

Additionally, something like 90% of Jeff Bezos’s net worth is tied up in Amazon stock (that he likely doesn’t want to sell as it would tank the stock price and could put his position as majority shareholder in jeopardy).

That’s not to say that he’s broke, but when we see all these headlines that he has 200 billion dollars – it doesn’t mean he has 200 billion dollars of cash.

Reading Shoe Dog by Phil Knight (founder of Nike) gave me an interesting perspective. Phil Knight wanted to pay shoe manufacturers in other countries (let’s use Thailand as the example) an American living wage.

If Phil Knight paid the factory workers in Thailand $20 an hour, it would be more money than doctors received in Thailand. Phil Knight deciding to raise wages would have turned the whole economy of Thailand upside down.

Why go to medical school if you could make twice as much assembling shoes?

These are the kind of unexamined consequences that can come from arbitrarily raising wages.

If Jeff Bezos raises Amazon’s minimum wage to $50 an hour, those jobs are going to get competitive pretty fast because most people would forego further education to make $100,000 a year doing a low skill factory job.

Ultimately, supply and demand of labor drives a lot of these wage decisions.

Original Post: https://www.quora.com/If-Jeff-Bezos-is-so-rich-why-does-Amazon-have-such-a-low-pay-and-poor-conditions/answer/Rhett-Reisman