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 πŸ™‚