danpaquin / coinbasepro-python

The unofficial Python client for the Coinbase Pro API
MIT License
1.82k stars 740 forks source link

How to "sell all" for a particular product? #440

Open jsho5150 opened 3 years ago

jsho5150 commented 3 years ago

Not an issue, but I was wondering if someone could provide an example of the simplest way to sell all of the units of a particular coin through when using this tool. (Just Market order sell is fine.)

Basically I created script that uses this library to buy an unknown number of units at a specified price and then I attempt to sell them later on, but I don't know how many that I currently own. (I was hoping to avoid making calls that deal with pagination as I don't yet understand how to deal with the returned data in those cases.)

I tried just setting a high value for the "funds" argument in my order sell call, but that only works part of the time. (Other times I get an "insufficient funds" response.

Sorry if I should be posting questions via some other method, but I don't use github very often.

Thanks

sachin-aag commented 3 years ago

I guess the easiest way would be to use get__accounts to find the amount of currency you have. Then you can place a sell market order with the size argument instead of the funds argument.