Every Crypto Miner Needs These Trading Bots

Miners have been lonely because developers are not building trading bots that fit their needs. This all changes now!

Miners have been lonely because developers are not building trading bots that fit their needs. This all changes now!

Cryptocurrency mining is a popular way to participate in the cryptocurrency market. By offering up computing resources, miners earn rewards for verifying transactions and securing the network.

The rewards that are received for mining are distributed as tokens that can be used on the network. Often times, mining rewards are earned at sporadic or unpredictable times. Since many mining consensus algorithms like Proof-of-Work (PoW) rely on chance. Once a reward is earned from mining, it will be sent to the wallet owned by the miner.

In many cases, miners may not want the assets they mine. Instead, miners may wish to cash out on their rewards and take cash (or other cryptocurrencies) instead. To convert funds from the mined asset to another, miners typically execute trades on an exchange to make it happen. This is a time-consuming and continuous process that deserves a better alternative.

We propose a new strategy for miners to simplify the procedure for collecting their profits and converting their funds to the desired cryptocurrency or fiat currency.

At its core, these strategies are rooted in automated portfolio management. Rather than constantly monitoring the state of your funds and individually executing trades on an exchange to transfer your mining rewards, automated solutions can connect to your exchange account to manage the process for you.

The Secrets to Managing Your Binance US Portfolio Using Trading Bots

Portfolio Automation

Let’s begin with an example.

Imagine we have a simple DOGE mining operation. Our rigs mine DOGE and we sporadically receive rewards throughout the day. However, since we don’t actually want to own DOGE, our current process is to check our exchange account 3 times a day to transfer the rewards to Bitcoin.

This is a typical situation that many miners are currently experiencing.


To reduce the burden of logging into an exchange account multiple times a day to transfer funds, miners are turning towards portfolio management solutions to automate their portfolio.

Strategies like dollar-cost averaging (DCA) and rebalancing are perfect for situations like the example that was described above.

Each time the DOGE mining rewards are sent to the exchange, the portfolio management application can pick up these changes and execute the necessary trades to move the funds from DOGE to BTC. Without ever logging into an exchange, miners can then focus on their mining operations and spend less time with manual processes.

Dollar-Cost Averaging

Dollar-cost averaging is a strategy to detect when funds are deposited into your account. When these new funds are detected, they will be picked up by the portfolio management application and traded to the assets you want. In the simple example described above, DCA would detect that DOGE has been deposited to your exchange account and trade all of the DOGE to BTC.

DCA can also be used to inject the deposited funds into a diverse portfolio. Instead of simply trading everything into Bitcoin, DCA can distribute funds based on a percentage. The result could be trading the DOGE to 50% BTC, 25% LTC, and 25% XRP. This can easily be configured in your DCA strategy to distribute the funds the way that works best for you.

Dollar-Cost Averaging for Crypto Portfolios

Portfolio Rebalancing

Portfolio rebalancing is similar to DCA in many ways. The major difference is the portfolio will be rebalanced at a set interval or trigger. When a rebalance is triggered, it will sell everything in your exchange account that isn’t in your desired portfolio and buy the assets that you want to own.

In the example above, the rebalance will see that DOGE has been deposited. As a result, the DOGE will be sold to the desired asset(s). In this case, the desired asset was 100% Bitcoin.

At the end of a rebalance, the portfolio will be 100% BTC.

Similar to DCA, rebalancing can be done with an entire portfolio of assets. Everything that is not in the desired portfolio will be sold and all of the assets that are in the desired portfolio will be bought. It’s as simple as selecting what percent of each asset you want to own, like 50% BTC, 25% XMR, and 25% EOS. Then, pick how often you want to rebalance, like every 2 hours, 1 day, or 3 weeks.

Portfolio Rebalancing for Cryptocurrency


Shrimpy automates both of these strategies in an intelligent way to make sure your trades are automatically executed when funds are deposited into your account. When the mining reward shows up in your exchange account, Shrimpy will automatically recognize this deposit and include it during the next rebalance or DCA event.

This can be done in two different ways. If you have large deposits each time, you can use the “DCA” function. DCA will automatically detect when new funds are deposited so it can instantly trade.

Another option is using a high-frequency rebalancing strategy. For example, rebalancing every 1 hour. If you set your portfolio to rebalance every hour, it will collect all of the funds in your account you don’t want and trade them to the assets you do want in your portfolio.

Note: Smaller mining operations should use the second option or at least a combination of both DCA and rebalancing. If the DCA can’t trade due to minimum trade limits on the exchange, then the 1-hour rebalance will pick up the funds during the next scheduled rebalancing event.

Python Scripts

If automation through an application isn’t your speed. You can always leverage exchange APIs to collect information about your asset balances, detect when those balances change, and automate the process of executing trades on the exchange to sell your mined asset.

Shrimpy provides the most robust set of developer APIs. These APIs can simplify the way you automatically check your exchange account and execute trades to buy and sell the assets you want.

The following Python scripts will provide a detailed example of how you can automate this process.

Install Trading Library

Since each crypto exchange is unique in the way they have developed their APIs, integrating with every exchange has become a nightmare situation for many developers.

To simplify the way we interact with exchanges, the following scripts will use the Shrimpy Trading Library. That way we can focus less time on how to manage each of these exchange connections and more time on developing our scripts.

Get started by installing Shrimpy for Python.

pip install shrimpy-python

API Keys

Before we can connect to any exchanges, we will need access to both our Exchange API Keys and our Shrimpy Master API Keys.

Exchange API Keys

Retrieve your exchange API keys by logging into your exchange account and following the necessary steps to create a new set of API keys.

How to Get Exchange API Keys

Since the scripts we are writing will actually trade on your account, make sure you enable the API permissions for both reading data from your account as well as executing trades. Do NOT enable withdrawal permissions.

Securely store the keys you generate. They will be needed in the following scripts. The place where you will include your exchange API keys will look something like the following section in the code.

exchange_name = 'bittrex'
exchange_public_key = 'fbnnn1xzimjustkeyboardmashing8xn1t8'
exchange_secret_key = '09672v4n09xn0morekeyboardmashing947'

Note: Shrimpy supports these exchanges: binance, binanceus, bittrex, bittrexinternational, kucoin, poloniex, bibox, hitbtc, bitstamp, bitfinex, coinbasepro, kraken, gemini, huobiglobal, bitmart, and okex.

Shrimpy Master Keys

Since we will manage all of our exchange connections through Shrimpy, we must now create our Shrimpy Master API Keys. These keys will maintain the connections to all of our exchanges, authorize trading, and collect account data from each exchange.

Start by signing up for the Shrimpy developer APIs.

Once you sign up, select the button to “Create Api Master Key”. During the process of creating your Shrimpy Master API Keys, make sure you have enabled all of the permissions for “User”, “Account”, “Trading”, and “Data”. Without the first 3 permissions, we won’t be able to connect to exchanges and trade. The last permission is used when we collect websocket or historical data from the exchange (It will not be necessary for this tutorial, but you may wish to use it in the future).

Save your keys to a secure location. In the following scripts, you will input your keys into the script at places that look like this in the code.

shrimpy_public_key = '8x7138n1xzimjustkeyboardmashing8xn1t8jv5098'
shrimpy_secret_key = '771dc5n72v4n09xn0morekeyboardmashing9475c0294n50'

Note: The Shrimpy Developer APIs cost $19/mo for the personal plan. This will allow you to connect up to 20 exchange accounts.

Setting up your Shrimpy account

Before we can start gathering data from our exchange accounts and trade, we must first set up our Shrimpy account. This will include some of the steps that we previously discussed in the sections above.

Once you run this script, make sure to store your user_id and account_id for later use.

# import required libraries
import shrimpy

# assign your Shrimpy Master API keys for later use
shrimpy_public_key = '8x7138n1xzimjustkeyboardmashing8xn1t8jv5098'
shrimpy_secret_key = '771dc5n72v4n09xn0morekeyboardmashing9475c0294n50'

# assign your exchange keys for which you wish to access the balance data
exchange_name = "bittrex"
exchange_public_key = 'fbnnn1xzimjustkeyboardmashing8xn1t8'
exchange_secret_key = '09672v4n09xn0morekeyboardmashing947'

# create the Shrimpy client
client = shrimpy.ShrimpyApiClient(shrimpy_public_key, shrimpy_secret_key)

# create a user which will be linked to our exchange
create_user_response = client.create_user('The Shrimp Master')
user_id = create_user_response['id']

# link our first exchange so we can access balance data
link_account_response = client.link_account(
    user_id,
    exchange_name,
    exchange_public_key,
    exchange_secret_key
)

account_id = link_account_response['id']

# copy and save these values
print(user_id)
print(account_id)

Automating your selling strategy

The next script will continuously run, check your account information, and trade when we find that some new assets have been deposited into your account.

Everything in your account will automatically be sold to the asset marked as “consolidation_symbol”.

Notice: In this script, we use the user_id and account_id that should have been stored from the previous step.

Warning! Running this script will literally sell everything you own into the asset selected as the “consolidation_symbol”. If you don’t want this to happen DO NOT RUN THIS SCRIPT. We are not responsible for the use, abuse, or misuse of this script.

# import required libraries
import shrimpy
import time

# input your user and account IDs
user_id = 'dc12349b-1234-12k4-123n12n12nnf'
account_id = 12345

# assign your Shrimpy Master API keys for later use
shrimpy_public_key = '8x7138n1xzimjustkeyboardmashing8xn1t8jv5098'
shrimpy_secret_key = '771dc5n72v4n09xn0morekeyboardmashing9475c0294n50'

# create the Shrimpy client
client = shrimpy.ShrimpyApiClient(shrimpy_public_key, shrimpy_secret_key)

While True:
    # collect asset balances on the exchange
    balance = client.get_balance(user_id, account_id)
    holdings = balance['balances']

    # select the asset for which you would like to consolidate
    consolidation_symbol = 'BTC'

    # sell every asset besides the consolidation asset
    for asset in holdings:
        asset_symbol = asset['symbol']
        asset_amount = asset['nativeValue']
        if asset_symbol != consolidation_symbol:
            print('Selling ' + str(asset_amount) + ' of ' + asset_symbol)
            create_trade_response = client.create_trade(
                user_id,
                account_id,
                asset_symbol,
                consolidation_symbol,
                asset_amount
            )

    # check every 15 minutes
    time.sleep(900)

That’s it! You are now automating your mining operation to automatically sell your rewards. Experiment with the APIs and develop new scripts to help further automate your portfolio.

Additional Reading

A Comparison Of Rebalancing Strategies for Crypto Portfolios

Cryptocurrency Trading Bots - The Complete Guide

How to Make a Crypto Trading Bot Using Python

Script for Bitcoin Price Live Ticker (Using Websockets)

How to Calculate Your Crypto Portfolio Performance

Our Trading Bot

Shrimpy is an account aggregating platform for cryptocurrency. It is designed for both professional and novice traders to come and learn about the growing crypto industry. Trade with ease, track your performance, and analyze the market. Shrimpy is the trusted platform for trading over $13B in digital assets.

Follow us on Twitter for updates!


Thanks for stopping by!

The Shrimpy Team