Invertee / CoinbasePro-Powershell

Powershell module for the CoinbasePro API.
MIT License
11 stars 6 forks source link

Thanks for the great start. #1

Open jasonpearce opened 5 years ago

jasonpearce commented 5 years ago

I love this. I'd like to make some suggestions, ask questions, and submit some tickets. Please know I'm grateful for what you've already created and do not expect anything in return. But if you are interested in working on this more, here are my thoughts in a few issues I'll soon open.

Invertee commented 5 years ago

Hi!

To be honest this is something I haven't thought about for a little while but now logging into Coinbase it looks like a few things have changed. I'd like to keep the module current as there is no point it being available if it's not in a usable state. I've just read through your suggestions and they're great, loads of detail. I've thought of a way to implement a few of them so I'll give it a go in the next few weeks if I find the time.

Thank you!

jasonpearce commented 5 years ago

Invertee,

I hope you are doing well. I'm just letting you know that if you do decide to update your PowerShell module, I'm still interested and would likely use it. I realize I may be in a minority and you might not have many users, it appears a few others might also be interested in having a PowerShell interface to Coinbase (https://stackoverflow.com/questions/28800386/coinbase-exchange-api-with-powershell).

I know PowerShell best. What I'd like to do is write something like this (https://jasonpearce.com/static/coin-by-percent-waterfall.html ; something I wrote in JavaScript) that will actually set Limit Buy or Sell orders for the Coinbase Pro coins that interest me. Right now, I use this table I created to manually dollar-cost-average in/out of positions as prices increase or decrease. But I have to copy and paste all of these calculations and orders into Coinbase Pro.

My hope is that your PowerShell module will provide me enough tools to write a PowerShell script that will perform similar percentage increase/decrease calculations for all of Coinbase Pro's coins, then let me set buy/sell limit orders for various USD trading pairs.

To accomplish this task, I think I would need the following tools beyond all of your Authentication cmdlets:

Get-CoinbaseCurrencies -Market All|USD|USDC|BTC|DAI|ETH I'm trading in USD mostly, so I'd want to get only the Coin/USD pairings.

Get-CoinbaseOrders -Status Open|Filled -Market BTC-USD|ETH-USD|ETC-USD -Properties Size|Filled|Price|Fee|Time I'd use this to retrieve all of my open orders, then use a similar Remove-CoinbaseOrders cmdlet to Cancel all or some of my Open Orders.

Get-CoinbaseWalletBalances -Asset USD|BTC|ETH|Etc -Holdings % -Balance $ -AvailableQty 0.1 -Price $ I'd use Get-CoinbaseWalletBalances -Asset USD mostly. If I wanted to evenly dollar-cost-avg into five coins, each with five Buy Limit orders, I'd divide up my total available USD balance by 25 and pipe that value in a future Trade-Coinbase cmdlet. You might also want to create Get-CoinbaseWalletDeposits and Get-CoinbaseWalletWithdrawls for reporting purposes.

Trade-Coinbase -Market BTC-USD|ETH-USD -Order Buy|Sell -Type Market|Limit|Stop -Amount -LimitPrice -StopPrice This is the big one. Either you create three cmdlets Trade-CoinbaseMarket, Trade-CoinbaseLimit, and Trade-CoinbaseStop; or one big one that is just Trade-Coinbase. Three might be better to simplify. Challenges for this include error reporting (like setting an Amount that is lower than the minimum value Coinbase selects, or insufficient funds) and the number of decimals permitted per currency.

Coinbase vs Coinbase Pro: You might want to write separate cmdlets for Get-Coinbase and Get-CoinbasePro if their APIs work in both environments. Maybe their API is only for Pro. But if not, something you may want to consider.

Thank you I understand you are under no obligation to deliver anything and I do not mean to apply pressure. My intent is to simply show appreciation, motivation, and forethought as to how I might use your work if you decided to further develop your function. Thanks for your time and contributions. Cheers.

Invertee commented 4 years ago

Hello!

It's taken me a little longer than I expected simply to find the time to look at this again but I am here now!

I've just published a few new changes which to the module which may help met your needs and broadly speaking this now covers all of the methods listed in the CoinbasePro API. Firstly on the initial module import it will now reach out the API and download a list of active markets and currencies and saves them in appdata, this should mean that currencies and products are always kept up to date. The only downside to this is that products can no longer be tab completed as it uses a validation script instead of a set array of values.

Secondly I've added some functions for depositing and withdrawing funds into Coinbase Pro from registered payment methods, Coinbase accounts or crypto addresses which could be useful for moving funds off the platform automatically to a cold wallet.

On some of your points unless I'm mistaken these should already be covered:

Get-CoinbaseCurrencies -Market All|USD|USDC|BTC|DAI|ETH

If you're trying to access the individual markets available on CoinbasePro you will want to use the Get-CoinbaseProProducts which lists all marketplaces available. If you want to filter them I'd personally pipe them to 'Where-Object' like so Get-CoinbaseProProducts | Where-Object id -Like *USD.

Open orders and filled orders can be retrieved with the Get-CoinbaseProOrder and Get-CoinbaseProOrders functions, the former retrieves a singular order (filled or not) using it's order id which can be either be queried or can be set when the order is placed. The latter will return any open order for a product. You can also use Get-CoinbaseProFills to see filled orders for a product but due to the way the API is designed you can't retrieve a list of a filled and open orders for one product.

I'd recommend in your script to assign the id (with New-GUID for example) of the order yourself with the OrderID parameter and keeping track of it somehow.

Trading can be carried out with the three functions New-CoinbaseProLimitOrder,New-CoinbaseProMarketOrder and New-CoinbaseProStopOrder, these should allow you to create any order that's possible via the GUI. There is some simple validation on these but in my opinion most of the validation should be left to Coinbase, because there is different limits on different products and these limits seem to change fairly frequently. Any error should return you an exception with a appropriate error message in.

Wallet balances can be queried with the Get-CoinbaseProAccounts which again can be piped into where-object and filtered. It would be possible to add filtering into many of these functions but it would add further parameters and I'd worry that this would make them more complex when it can be piped into functions better designed for filtering.

All of these functions are for Coinbase Pro except for Get-CoinbaseAccounts which returns Coinbase accounts which you can deposit and withdraw money to and from with the appropriate functions. I've renamed all of them to reflect this. As far as I know the Coinbase API is completely separate and it probably would warrant a module in itself.

Please get in touch to let me know how you get on, it'd be cool to know you've built something good with it. Absolutely loving that waterfall table generator, presumably build on NodeJS?

jasonpearce commented 4 years ago

Thank you. I've already started playing with this and figuring out what I can retrieve, change, and do. I'll be happy to share. My WaterFall generator is hand-written JavaScript. This was a project I chose to help me learn some basics. I may then rewrite it using a JavaScript framework. Glad you like it.