Java based wrapper for the GDAX API that follows the development style similar to coinbase-java
#Notes:
GDAX primary data sources and servers run in the Amazon US East data center. To minimize latency for API access, we recommend making requests from servers located near the US East data center.
Some of the methods do not yet have tests and so may not work as expected until a later date. Please raise an issue in github if you want something in particular as a priority. I'll be looking to fully flesh this out if possible over the coming months.
To make use of this library you only need a reference to the service that you want.
At present the classes match the interface specified in the coinbase/gdax api here: https://docs.gdax.com/#api
e.g.
public OrderService orderService(){ new OrderService(); }
This works better if you declare the above method as a google guice/spring bean and then wire it in using dependency injection.
Then in your method you can carry out any of the public api operations such as orderService().createOrder(NewSingleOrder order);
- this creates a limit order. Currently this is only the basic order.
#API
The Api for this application/library is as follows: (Note: this section is likely to change but is provided on the basis it will work well for example usage)
AccountService.getAccounts()
- returns an array of all AccountsAccountService.getAccountHistory(String accountId)
- returns the history for a given accountAccountService.getHolds(String accountId)
- returns an array of all held funds for a given account.DepositService.depositViaPaymentMethod(BigDecimal amount, String currency, String paymentMethodId)
- makes a deposit from a stored payment method into your GDAX accountDepositService.coinbaseDeposit(BigDecimal amount, String currency, String coinbaseAccountId)
- makes a deposit from a coinbase account into your GDAX accountMarketDataService.getMarketDataOrderBook(String productId, String level)
- a call to ProductService.getProducts() will return the order book for a given product. You can then use the WebsocketFeed api to keep your orderbook up to date. This is implemented in this codebase. Level can be 1 (top bid/ask only), 2 (top 50 bids/asks only), 3 (entire order book - takes a while to pull the data.)OrderService.getOpenOrders(String accountId)
- returns an array of Orders for any outstanding ordersOrderService.cancelOrder(String orderId)
- cancels a given orderOrderService.createOrder(NewOrderSingle aSingleOrder)
- construct an order and send it to this method to place an order for a given product on the exchange.PaymentService.getCoinbaseAccounts()
- gets the coinbase accounts for the logged in userPaymentService.getPaymentTypes()
- gets the payment types available for the logged in userProductService.getProducts()
- returns an array of Products available from the exchange - BTC-USD, BTC-EUR, BTC-GBP, etc.ReportService.createReport(String product, String startDate, String endDate)
- not certain about this one as I've not tried it but presumably generates a report of a given product's trade history for the dates supplied
At present the WebsocketFeed is implemented and does work (as in it will receive the messages from the exchange and route them according to the message type) but it requires you to pass a new Subscribe(productIds)
message to it and to implement an OrderBook class as I've partly done under the gui
package (as I was attempting to build a desktop gui since the web one has consistently had problems).
Presently this is not an interface as this is a work in progress, however feel free to fork this repo, make the change and send me a pull request back and I'll gladly merge in the change.
- converted to using Gradle
- converted to using SpringBoot for DI and request building
- updated all libraries used - removed some unnecessary libraries
- refactored the code to remove error handling from every method (rightly/wrongly) - its easier to maintain and extend now as a result
- more modular code that matches the service api - favour composition over inheritance
- removed a lot of boilerplate code
- logging added - Logging will output an equivalent curl command now for each get/post/delete request so that when debugging you can copy the curl request and execute it on the command line.
- service tests added for sanity - no unit tests against the data objects
- better configuration options using
application.yml
for your live environment andapplication-test.yml
for your sandbox environment. - banner displayed (specific to each environment) :)
- generally more structure.
- added pagination to all the relevant calls (some not supported since it seems pointless due to the limited offering from gdax - e.g. products)