Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
Removed assertTrues that were testing for >= 0. Just need to test for nulls
Fixed issue with canGetPagedHolds test in AccountsTest
  • Loading branch information
irufus committed Feb 7, 2018
1 parent 06f2cef commit ba31958
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 86 deletions.
72 changes: 6 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,9 @@

Java based wrapper for the [GDAX API](https://docs.gdax.com/#introduction) that follows the development style similar to [coinbase-java](https://github.com/coinbase/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.
# Functions supported:
- [x] Authentication (GET, POST, DELETE supported)
- [x] Get Account
- [x] Get Accounts
- [x] Get Account History
- [x] Get Holds
- [x] Place a new Order (limit order)
- [x] Get an Order
- [x] Cancel an Order
- [x] List all open Orders
- [x] Get Market Data
- [x] List fills
- [x] List Products
- [x] HTTP Error code support
- [x] List of Currencies - from Accounts
- [x] Withdrawals - from coinbase accounts / payment methods / crypto account address
- [x] Deposits - from coinbase accounts / payment methods
- [x] Transfers - from coinbase accounts
- [x] Payment methods - coinbase / payment methods
- [x] Reports
- [x] Pagination support for all calls that support it.
- [x] Pagination support for all calls that support it.
- [x] Sandbox support - *sandbox support was dropped by gdax so this is now redundant*

# In Development

Desktop client GUI. Check the issues on the repo for open items to work on. Please join the gitter channel if you have any questions. Support always welcome.
Documenting usages, documenting examples, writing guidelines on how to contribute, and writing unit tests.

# Usage
--------
Expand All @@ -44,7 +15,7 @@ To build and run the application you can use the gradle script - this requires n

1. supply your api keys in `gdax-java/src/main/resources/application.yml`
1. open a command line terminal
1. navigate to the root directory of this project (where `build.gradle` sits)
1. navigate to the root directory of this project (where `build.gradle` sits)
1. execute `./gradlew bootRun` (Mac/unix). For equivalent Windows commands just remove the `./` from the commands, there's a gradlew.bat included as well.

This won't actually do much on its own but I did implement a slightly experimental (buggy) GUI which you can switch on and try by changing the setting gui.enabled in the application.yml above to `true`. You should then see a streamed list of updates displayed in a rather rubbish GUI I was attempting to build out. This is a work in progress so please don't assume its a finished product - its just for demoing that this works.
Expand All @@ -55,26 +26,18 @@ For a lib:

1. If you'd rather work purely in java then you can build an executable jar file `./gradlew jar` and you should be able to find the jar in the build directory.

# 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

#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
# 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.
e.g.
`public OrderService orderService(){
new OrderService();
}`
Expand Down Expand Up @@ -104,32 +67,9 @@ The Api for this application/library is as follows:
- `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
# 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)
- GDAX is updating its API without updating documentation - I've fixed an issue with market data because of this.
- WebsocketFeed added
- OrderBook GUI component added - enable in the `application.yml` by setting enabled to `true`

# TODO
-------
- add pagination versions of all endpoints, or offer a way to append to the endpoint urls.
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.
29 changes: 9 additions & 20 deletions src/test/java/com/coinbase/exchange/api/accounts/AccountsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class AccountsTest extends BaseTest {
@Test
public void canGetAccounts() {
List<Account> accounts = accountService.getAccounts();
assertTrue(accounts.size() >= 0);
assertTrue(accounts != null);
}

@Test
Expand All @@ -36,45 +36,37 @@ public void getAccount() {
public void canGetAccountHistory() {
List<Account> accounts = accountService.getAccounts();
List<AccountHistory> history = accountService.getAccountHistory(accounts.get(0).getId());
assertTrue(history.size() >=0); // anything but null/error.
assertTrue(history != null); // anything but null/error.
}

@Test
public void canGetAccountHolds() {
List<Account> accounts = accountService.getAccounts();
List<Hold> holds = accountService.getHolds(accounts.get(0).getId());
assertTrue(holds.size() >= 0);
assertTrue(holds != null);
// only check the holds if they exist
if (holds.size()>0) {
assertTrue(holds.get(0).getAmount().floatValue() >= 0.0f);
}
}

/**
* note that for paged requests the before param takes precedence
* only if before is null and after is not-null will the after param be inserted.
*/
@Test
public void canGetPagedAccountHistory() {
List<Account> accounts = accountService.getAccounts();
assertTrue(accounts.size() > 0);
/**
* note that for paged requests the before param takes precedence
* only if before is null and after is not-null will the after param be inserted.
*/
String beforeOrAfter = "before";
int pageNumber = 1;
int limit = 5;
List<AccountHistory> firstPageAccountHistory = accountService.getPagedAccountHistory(accounts.get(0).getId(),
beforeOrAfter, pageNumber, limit);
assertTrue(firstPageAccountHistory != null);
assertTrue(firstPageAccountHistory.size() >= 0);
assertTrue(firstPageAccountHistory.size() <= limit);
}

/**
* Test is ignored as it's failing. Seems the request here is
* a bad one. Not sure if this is because there are no holds or
* if this is due to the request (which is the same as for account history)
* is actually fine but there's no data available.
*/
@Ignore
@Test
public void canGetPagedHolds() {
List<Account> accounts = accountService.getAccounts();
Expand All @@ -91,10 +83,7 @@ public void canGetPagedHolds() {
pageNumber,
limit);

if (firstPageOfHolds != null ) {
assertTrue(firstPageOfHolds != null);
assertTrue(firstPageOfHolds.size() >= 0);
assertTrue(firstPageOfHolds.size() <= limit);
}
assertTrue(firstPageOfHolds != null);
assertTrue(firstPageOfHolds.size() <= limit);
}
}

0 comments on commit ba31958

Please sign in to comment.