Skip to content
forked from irufus/gdax-java

Java based wrapper for the GDAX API (Formerly known as Coinbase Exchange API)

License

Notifications You must be signed in to change notification settings

rollis/gdax-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gdax-java

Join the chat at https://gitter.im/irufus/gdax-java

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.

#Examples

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 Accounts
  • AccountService.getAccountHistory(String accountId) - returns the history for a given account
  • AccountService.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 account
  • DepositService.coinbaseDeposit(BigDecimal amount, String currency, String coinbaseAccountId) - makes a deposit from a coinbase account into your GDAX account
  • MarketDataService.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 orders
  • OrderService.cancelOrder(String orderId) - cancels a given order
  • OrderService.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 user
  • PaymentService.getPaymentTypes() - gets the payment types available for the logged in user
  • ProductService.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

#WebsocketFeed API

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.

#Updates

  • 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 and application-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)

About

Java based wrapper for the GDAX API (Formerly known as Coinbase Exchange API)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%