How to "sell all" of an asset

Is there a way to sell all of an asset, instead of a specified base_size? The coinbase gui has a “sell all” button. I want that, as opposed to determining how much of an asset I have in my account and then calculating base_increment * int(value / base_increment) to try to zero out the account.

more specifically I’m running into the issue that if I have less of an asset than the base_min_size I am unable to sell it via market order api v3 calls.

e.g.
my account value: 0.00000000027825063 BTC (~$1 at the time of writing this)
BTC base_increment = 0.00000001
BTC base_min_size = 0.00016

For my example python code snippet (below) I get:
sell response: {“success”:False, … “preview_failure_reason”:“PREVIEW_INSUFFICIENT_FUND”}

        data = json.dumps({
            "client_order_id": "my_order_id",
            "product_id": "BTC-USD",
            "side": "SELL",
            "order_configuration": {"market_market_ioc": {"base_size":"0.000001"}}
        })
        response = self.session.request(
            method='POST',
            url="https://api.coinbase.com/api/v3/brokerage/orders",
            timeout=10,
            auth=self.auth,  # my python requests AuthBase object, 
            data=data
        ).json()
        return response

Hello @jvb2358! Welcome to the Coinbase Developer Forum! Thank you for your enthusiasm in using the Advanced Trade API. First, we appreciate you for providing your code snippet that is having an issue when using the Create Order Endpoint. However, we would like to inform you that unfortunately, as much as we want to help you in debugging your code, we are actually only able to provide assistance and troubleshooting for issues with the raw Coinbase APIs and cannot provide detailed guidance with writing your code in specific programming languages and frameworks.

We understand that you want to know if there are ways to sell all Assets via the Advanced Trade API. Unfortunately, this is something that is currently not offered by Coinbase.

Rest assured that we’ve logged your insight about an Advanced Trade API feature that can sell all of the assets of an account as a feature request with our internal teams so we can continue improving our user experience. Most new features and improvements to our products come directly from feedback like yours, so it’s very valuable to us. While we can’t offer any specific timeline for adding features, we are constantly working to build products our customers will love.

If you want to stay up to date on the latest from Coinbase Cloud, you can also bookmark the following webpage and subscribe to email updates at the bottom of the page: https://www.coinbase.com/cloud/discover

Thank you for your patience and understanding. Have a great day!

2 Likes

You’re out of luck. base_min_size is the rule for the minimum you can place an order to buy or sell. You can buy more to then try to sell the entire position to a 0.00 value but this is the only feasible workaround I have found.

In Coinbase Pro API minimum you can sell/buy is base_increment (for market order):

Same change is planned for Advanced Trade API. Soon…