irufus / gdax-java Goto Github PK
View Code? Open in Web Editor NEWJava based wrapper for Coinbase Pro (Formerly known as GDAX API and Coinbase Exchange API)
License: MIT License
Java based wrapper for Coinbase Pro (Formerly known as GDAX API and Coinbase Exchange API)
License: MIT License
For coinbase the URI should be
/withdrawals/coinbase-account
On both of these a different RequestType is needed
I have a fix on my fork
duanemay@02e41b4
Coinbase has fully embraced calling the new platform Coinbase Pro. The update is just to align with those changes
src\test\java\com\coinbase\exchange\api\orders\OrderTests.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.
Hi, I´m not new to Spring but i am new to Spring Boot.
I think your library is quite good (or will be when i get to use it) but the curve to start it off is really hard, even for those who know Spring, there is no guide to how to setup the most basic scenario. I recommend you to make a very basic controller/main/example inside the
After various intents on implementing a basic bot with this wrapper I wanted to ask. Could you post a simple process for creating and executing one? Every time i try to get any service its null, even if i autowire it in a way i think is correct and i´m not sure where/how i should put my source code.
For example, to obtain "the ticker" for a certain market:
Thanks
Miguel.
every time when I tried to payment via Gdax account it gives me forbidden error:
however I was purchased the licensed too.
after licensed purchase, I try to use java as well python script, but for both GDAX API generate forbidden error 403 error at my side.
please find the below screen short :
https://content.screencast.com/users/Rajesh771986/folders/Jing/media/96165bca-8b6f-4a1c-bd47-4243b5fa04a0/2018-03-06_2016.png
Gdax support team number is also not connecting:
+1 (855) 577-1727
kindly request suggest what should I do?
Im using the implementation from this code and i on GET requests i get good responses from the API however, when trying to se POST i get that answer
I used the timestamp generation on your code but got and invalid signature response from the API, that's because you are using the getSeconds and they want milis
im unable to figure where exactly the problem here is the relevant code
System.out.println(jsonOrder);
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpPost request = new HttpPost(BASE_URL + "/orders");
org.joda.time.DateTime now = new org.joda.time.DateTime(); // Default time zone.
DateTime nowUtc = DateTime.now ( DateTimeZone.UTC );
String timestamp = now.getMillis() + "";
request.addHeader("accept", "application/json");
request.addHeader("content-type", "application/json");
request.addHeader("User-Agent", "gdax-java-client");
request.addHeader(CB_ACCESS_KEY, API_KEY);
request.addHeader(CB_ACCESS_SIGN, generateSignedHeader("/orders", "POST", jsonOrder, timestamp));
request.addHeader(CB_ACCESS_TIMESTAMP, timestamp);
request.addHeader(CB_ACCESS_PASSPHRASE, PASSPHRASE);
HttpResponse response = client.execute(request);
String jsonResponse = EntityUtils.toString(response.getEntity(), "UTF-8");
client.close();
return jsonResponse;`
The generateSignedHeader is your implementation and it is working for GET requests
Hi,
I'd recommend using Lombok for DTO's such as Account, Order etc, which will take away the boilerplate code for getters/setters,
And more importantly, introduce toString() methods for all, so that it's easy to log out a list of Orders / Accounts etc. (If using Lombok, @DaTa annotation will automatically add toString). If not using Lombok, this should be added to DTOs manually for ease of client use.
build.gradle
compileOnly('org.springframework.boot:spring-boot-configuration-processor')
compileOnly('org.projectlombok:lombok')
Account.java
@DaTa annotation.
Thanks.
I see coinbase has a Pricing API to retrieve all these details, but didn't find anything in the GDAX documentation? Should I use coinbase API for pricing instead?
this.objectMapper = objectMapper(new JavaTimeModule());
should probably be:
this.objectMapper = objectMapper.registerModule(new JavaTimeModule());
Otherwise, I get the following error when executing build tasks:
.../gdax-java/src/main/java/com/coinbase/exchange/api/websocketfeed/WebsocketFeed.java:58: error: cannot find symbol
this.objectMapper = objectMapper(new JavaTimeModule());
^
symbol: method objectMapper(JavaTimeModule)
location: class WebsocketFeed
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
FAILURE: Build failed with an exception.
I've been reading through the gdax official documentation and they mention that we need to subscribe to channels in order to get updates. I couldn't find any channel subscriptions in the code. Is the WebsocketFeed stream subscribe to a "full channel" ?
.gradlew build errors with
Execution failed for task ':model:compileJava'. > Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'
Where can the target be changed?
Hi!
Without authentication, I can subscribe to GDAX Websocket feed (any channel combination).
Instead, if I set my key, passphrase and secret code, then I get the answer:
{"type":"error","message":"Sorry, you could not be authenticated: Bad Request","reason":"invalid signature"}
According to the GDAX api, when specifying channels you must authenticate using the path: "/users/self/verify"
(just "/users/self"
if you don't specify channels).
However in signObject()
on WebsocketFeed.java
, the path is "" as you might find on line 198:
jsonObj.setSignature(signature.generate("", "GET", jsonString, timestamp));
I tried to correct the issue (i.e. setting the correct path), with no success.
Provide sample gdax-java examples in Readme.md
"As part of the rebranding of Coinbase Exchange to GDAX, API endpoints have changed. The old *.exchange.coinbase.com endpoints will continue working until Aug 24th, 2016. For the new endpoints see the documentation
Call to GET /payment-methods fails due to:
See https://docs.gdax.com/#payment-methods
This was fixed by #20 commit 500657d
Call to GET /coinbase-accounts fails due to:
There are three separate projects within this repo.
Hello everyone.
I don't know if i am doing something wrong here but for some reason i cant correctly generate the jar to use in my project. Already spent some time trying. If anyone could please provide the jar or explain how they generated if i would appreciate it.
Thank you all.
Hey,
While using your library I noticed a null pointer exception when trying to execute a "AccountService.getAccounts()" method. I've put my secret, API key and passphrase into the application.yml. It seems like the "exchange" variable is null.
By the way: I compiled your library into a .jar file and included it into my personal project. (I checked and can confirm that API key etc. are inside the .jar file)
Any idea on whats going wrong?
Thanks for the library!
I just have username and password on gdax ... where should I enter that in application.yml ?
or there is another "key" that I am not aware ?
by the way is there any simple example, in one .java file just to do login and get the orderbook ? (using the jar file )
Unable to reach the sandbox API I noted that the exception was stating Cloudflare was blocking me due to unknown user-agent. The solution to this is to add a User-Agent string to the header.
headers.add("User-Agent", "MyAgent");
Most of the unit tests are working again with this change.
I cloned the project for the first time and I get this build error.
There is one package in src/main/java named:
com.coinbase.exchange.api.marketdata
and there is another package in src/test/java named:
com.coinbase.exchange.api.MarketData
I notice that if I change the name MarketData to marketdata then this error goes away.
error message:
ERROR - GET request Failed for '/fills': {"message":"query must contained either product_id or order_id"}
information on the change
https://docs.pro.coinbase.com/#fills
Error with this mapping. Am planning to change the field type hopefully that solves the issue.
org.springframework.web.client.RestClientException: Error while extracting response for type [class [Lcom.coinbase.exchange.model.Product;] and content type [application/json;charset=utf-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type java.lang.Integer
from String "2.0": not a valid Integer value; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type java.lang.Integer
from String "2.0": not a valid Integer value
at [Source: (PushbackInputStream); line: 1, column: 2523] (through reference chain: java.lang.Object[][6]->com.coinbase.exchange.model.Product["max_market_funds"])
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:117)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:994)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:977)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:737)
I believe adding information how to write tests for the gdax-java library would be useful. This information should be added to the Readme and should help improve any newcomer's understanding of what the repo does and how they can contribute.
After looking around I can tell this is one of the better Coinbase Pro Java projects out there: well tested, regularly maintained, follows good Git practices. But the jar not being available on Maven Central makes it much more difficult to use this work in other projects. Are there any plans to do that? It would be very nice if I could just put the dependency in my build file, and it would be much appreciated!
I believe paged requests could be better implemented by overloading the GdaxExchange.get(...)
method and providing an interceptor that updates the request headers. This would clean up a lot of the boilerplate and make transitioning between either method more seamless.
I just want the jar. ./gradlew jar does not work. i dont want to run this in spring boot. just standalone java application.
Hi,
I downloaded the project and tried building the jar. The build fails because it cannot resolve modules because it cannot resolve any maven. I tried it on different computers and had the same error.
This document's purpose will serve as a guideline how to contribute to the repo.
WebSocket is not working with the sandbox environment.
Error:
javax.websocket.DeploymentException: The HTTP request to initiate the WebSocket connection failed
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServerRecursive(WsWebSocketContainer.java:485)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:194)
at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:150)
at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:147)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: javax.net.ssl.SSLException: Received fatal alert: handshake_failure
at org.apache.tomcat.websocket.AsyncChannelWrapperSecure$WrapperFuture.get(AsyncChannelWrapperSecure.java:512)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServerRecursive(WsWebSocketContainer.java:343)
... 5 common frames omitted
Caused by: javax.net.ssl.SSLException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1666)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1634)
at sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1800)
at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1083)
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
at org.apache.tomcat.websocket.AsyncChannelWrapperSecure$WebSocketSslHandshakeThread.run(AsyncChannelWrapperSecure.java:392)
`
//current injection (i.e. Withdrawals Service)
@Autowired
GdaxExchange gdaxExchange;
//Constructor injection method
GdaxExchange gdaxExchange;
@Inject
public WithdrawalService (GdaxExchange gdaxExchange){ ... }
`
will you add more algo on the order book to reproduce the ask5,...ask1,bid1,...bid5?
This is a great project and helps me a lot, thank you very much for all your work. Still I would like to make a small proposal: after checking out it is a bit difficult to separate the actuall API packages from your own application. Maybe you can create an com.irufus.gdax.app package and move all the code that is not the actuall api over there? That would be awesome.
Kind regards
Johannes
When a rate limit is exceeded, a status of 429 Too Many Requests will be returned.
Hi,
Is there a example of how to use the "WebsocketFeed" for caching a snapshot of the orderbook provided?
I look forward for your help!
Regards
Marko
When I run the GUI, the websocket invariably stops receiving messages with no indication of a failure. I'm not directly using the GUI, I'm just logging matched orders from the swing worker. I added a println and at least some of the time the socket returns this close reason "code [1006], reason [Unexpected end of stream]".
If anyone can point me in the right direction to figure out why this happens that would be great; I'm trying to achieve an always-on, super stable feed. This repo is awesome, thanks to all contributors!
I'm not used to spring, so it would be very helpful to have an example, or a small sort of quick-start explanation how to get started using the your API. I managed to build it using the Eclipse IDE, and also to run the unit tests, but struggling now how to start. It would be helpful to have a description of - for example - just read my account-data.
thx in advance!
Hi ,
I was looking at your api and i came up with a question.
Let say we want to get /products/{productId}/candles.
It requires the startTime and endTime and that is ok, my question is should i provide this values in which timezone?
The new system has deprecated the old method so we must make sure we don't use the deprecated calls
For accounts orders, fills, deposits, withdrawals and more.
Hi,
I downloaded the code, and was running the junit tests locally and encountered an issue with the cancelAllOrders test method. Even though the method failed with the below exception, it still canceled all my existing orders.
At this moment, I only have a View Only API Key. I don't have any API Keys with Trade permissions.
I didnt try running the createOrder test methods for fear of it creating market orders, even with the VIEW only API key. Do please look into this urgently.
Thanks.
Error below:
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Can not construct instance of com.coinbase.exchange.api.orders.Order: no String-argument constructor/factory method to deserialize from String value ('e7046f48-9c93-4250-9981-be9fd1701c58'); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.coinbase.exchange.api.orders.Order: no String-argument constructor/factory method to deserialize from String value ('e7046f48-9c93-4250-9981-be9fd1701c58')
at [Source: java.io.PushbackInputStream@6fd5717c; line: 1, column: 2] (through reference chain: java.lang.Object[][0])
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:244)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:229)
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:96)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:917)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:901)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:655)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:559)
at com.coinbase.exchange.api.exchange.GdaxExchangeImpl.delete(GdaxExchangeImpl.java:98)
at com.coinbase.exchange.api.orders.OrderService.cancelAllOpenOrders(OrderService.java:53)
at com.coinbase.exchange.api.orders.OrderTests.cancelAllOrders(OrderTests.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.coinbase.exchange.api.orders.Order: no String-argument constructor/factory method to deserialize from String value ('e7046f48-9c93-4250-9981-be9fd1701c58')
at [Source: java.io.PushbackInputStream@6fd5717c; line: 1, column: 2] (through reference chain: java.lang.Object[][0])
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270)
at com.fasterxml.jackson.databind.DeserializationContext.instantiationException(DeserializationContext.java:1456)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1012)
at com.fasterxml.jackson.databind.deser.ValueInstantiator._createFromStringFallbacks(ValueInstantiator.java:370)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:315)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromString(BeanDeserializerBase.java:1282)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:159)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:150)
at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:196)
at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:20)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2922)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:241)
... 38 more
Ensure the API will work with the new Market order feature for new orders.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.