This repository has been archived by the owner on Jun 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 217
Gdax adding user channel #160
Merged
dozd
merged 7 commits into
bitrich-info:develop
from
bryantharris:gdax_adding_user_channel
Oct 8, 2018
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
74f5c40
[gdax] Enabling of 'user' channel to receive fill messages.
bryantharris 78808fb
Merge remote-tracking branch 'upstream/develop' into develop
bryantharris 50a77e6
[gdax] Enabling of 'user' channel to receive fill messages. (reverted…
bryantharris beb0a9d
[gdax] Enabling of 'user' channel to receive fill messages. (reverted…
bryantharris a280d61
[gdax] Refactored obtaining of Websocket Auth Data to occur in the co…
bryantharris 54638bb
Merge branch 'develop' into gdax_adding_user_channel
bryantharris d361c85
Merge branch 'develop' into gdax_adding_user_channel
dozd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
package info.bitrich.xchangestream.gdax; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.knowm.xchange.gdax.dto.account.GDAXWebsocketAuthData; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import info.bitrich.xchangestream.core.ProductSubscription; | ||
import info.bitrich.xchangestream.gdax.dto.GDAXWebSocketSubscriptionMessage; | ||
import info.bitrich.xchangestream.gdax.netty.WebSocketClientCompressionAllowClientNoContextHandler; | ||
|
@@ -11,12 +20,6 @@ | |
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; | ||
import io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtensionHandler; | ||
import io.reactivex.Observable; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class GDAXStreamingService extends JsonNettyStreamingService { | ||
private static final Logger LOG = LoggerFactory.getLogger(GDAXStreamingService.class); | ||
|
@@ -25,11 +28,13 @@ public class GDAXStreamingService extends JsonNettyStreamingService { | |
private static final String SHARE_CHANNEL_NAME = "ALL"; | ||
private final Map<String, Observable<JsonNode>> subscriptions = new HashMap<>(); | ||
private ProductSubscription product = null; | ||
private GDAXWebsocketAuthData authData = null; | ||
|
||
private WebSocketClientHandler.WebSocketMessageHandler channelInactiveHandler = null; | ||
|
||
public GDAXStreamingService(String apiUrl) { | ||
public GDAXStreamingService(String apiUrl,GDAXWebsocketAuthData authData) { | ||
super(apiUrl, Integer.MAX_VALUE); | ||
this.authData = authData; | ||
} | ||
|
||
public ProductSubscription getProduct() { | ||
|
@@ -66,15 +71,15 @@ protected String getChannelNameFromMessage(JsonNode message) { | |
|
||
@Override | ||
public String getSubscribeMessage(String channelName, Object... args) throws IOException { | ||
GDAXWebSocketSubscriptionMessage subscribeMessage = new GDAXWebSocketSubscriptionMessage(SUBSCRIBE, product); | ||
GDAXWebSocketSubscriptionMessage subscribeMessage = new GDAXWebSocketSubscriptionMessage(SUBSCRIBE, product, authData); | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
return objectMapper.writeValueAsString(subscribeMessage); | ||
} | ||
|
||
@Override | ||
public String getUnsubscribeMessage(String channelName) throws IOException { | ||
GDAXWebSocketSubscriptionMessage subscribeMessage = | ||
new GDAXWebSocketSubscriptionMessage(UNSUBSCRIBE, new String[]{"level2", "matches", "ticker"}); | ||
new GDAXWebSocketSubscriptionMessage(UNSUBSCRIBE, new String[]{"level2", "matches", "ticker"}, authData); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this unsubscribe message also include "user" if |
||
ObjectMapper objectMapper = new ObjectMapper(); | ||
return objectMapper.writeValueAsString(subscribeMessage); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on something similar for Binance right now, and this bit gave me pause. Are you getting duplicated trades appearing where you get both the
Trade
from thematches
channel and theUserTrade
from theuser
channel?I certainly do with Binance and it itched. The only way I could think of to resolve the issue looks something like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the code replaces the Trade object with a UserTrade object so there wouldn't be a duplicate.
Honestly in my usage (external to this project) I'm just looking for the fills coming in (UserTrade) so it never hurt my bot if there was or wasn't a Trade reported via the regular trade feed.
I suppose if the record came in via the trade feed with no user information there would be a duplicate.