xchange-stream icon indicating copy to clipboard operation
xchange-stream copied to clipboard

[bitstamp] API v2 not getting trades

Open jurepetrovic opened this issue 5 years ago • 16 comments

Hello Gentlemen,

I tried to replace the old Bitstamp API with v2 today. I only changed the import line:

import info.bitrich.xchangestream.bitstamp.v2.BitstampStreamingExchange;

and everything compiled fine. However, it seems I am not getting any updates from the exchange. The log shows normal connection:

2019-11-06 18:55:19 | INFO | [main] i.b.x.b.v.BitstampStreamingService:125 - Connecting to wss://ws.bitstamp.net 2019-11-06 18:55:21 | INFO | [nioEventLoopGroup-2-1] i.b.x.s.n.WebSocketClientHandler:63 - WebSocket Client connected! 2019-11-06 18:55:21 | WARN | [nioEventLoopGroup-2-1] i.b.x.b.v.BitstampStreamingService:228 - Resubscribing channels 2019-11-06 18:55:21 | INFO | [main] i.b.x.b.v.BitstampStreamingService:312 - Subscribing to channel live_trades_btceur 2019-11-06 18:55:22 | INFO | [main] i.b.x.b.v.BitstampStreamingService:312 - Subscribing to channel live_trades_etheur

There is just not a single trade incoming. Subscription remained exactly the same as in v1, where it worked flawlessly.

Anyone had the same problem?

Thank you and best regards, Jure

jurepetrovic avatar Nov 06 '19 18:11 jurepetrovic

Nobody noted that?

jurepetrovic avatar Nov 11 '19 10:11 jurepetrovic

Just so you know someone's listening... I don't use Bitstamp myself, sorry!

badgerwithagun avatar Nov 11 '19 16:11 badgerwithagun

Ok, I saw @pchertalev commited something in bitstamp v2. I'll wait a bit to see if he knows something. If not, I'l dig in myself....just don't know where properly...maybe with wireshark ;)

jurepetrovic avatar Nov 12 '19 15:11 jurepetrovic

@jurepetrovic I've investigated this issue and found out it that the problem is in https://github.com/bitrich-info/xchange-stream/blob/develop/xchange-bitstamp/src/main/java/info/bitrich/xchangestream/bitstamp/v2/BitstampStreamingService.java line 59. Name of the event in channels live_orders_... and live_trades_... is not data but trades or order_.... See https://www.bitstamp.net/websocket/v2/

chachalaca avatar Nov 18 '19 19:11 chachalaca

@chachalaca Nice! I see they also have javascript examples on the site. I will check, when I find some time...

jurepetrovic avatar Nov 19 '19 07:11 jurepetrovic

Ok, I changed that on my fork to come pass this line. https://github.com/jurepetrovic/xchange-stream

And then it crashed on JSON to object mapping in BitstampStreamingMarketDataService.java, line 67 Need to go deeper here.

Mapper Crash

jurepetrovic avatar Nov 19 '19 10:11 jurepetrovic

Seems like BitstampWebSocketTransaction.java class does not match the specs. Will need to update the mapping class.

jurepetrovic avatar Nov 19 '19 10:11 jurepetrovic

This is weird. I've made almost identical fix as you but it works flawlessly..

chachalaca avatar Nov 19 '19 12:11 chachalaca

java.lang.NoSuchMethodError: org.knowm.xchange.bitstamp.dto.marketdata.BitstampTransaction.(JJLjava/math/BigDecimal;Ljava/math/BigDecimal;I)V

I'm getting this exception when trying to call constructor of the parent class in BitstampWebSocketTransaction.java.

What version of basic xchange are you using?

Thanks, Jure

jurepetrovic avatar Nov 19 '19 14:11 jurepetrovic

Ok, I got this. It works for me now. Did a little cleanup and new class for v2 BitstampTrades. Can somebody of you guys do a quick check? https://github.com/jurepetrovic/xchange-stream/commit/580ce201ab23f24daa62f40afdb53b32faeca3a5

What do you think? Can we do PR?

jurepetrovic avatar Nov 19 '19 14:11 jurepetrovic

Ok, let's see how this pans out. @badgerwithagun who's reviewing this part?

https://github.com/bitrich-info/xchange-stream/pull/451

jurepetrovic avatar Nov 19 '19 15:11 jurepetrovic

Guys, I'm not clear what is the problem I started BitstampManualExample and trades are recieved well:

15:43:29.390 [main] INFO  info.bitrich.xchangestream.bitstamp.v2.BitstampStreamingExchange - Calling Remote Init...
15:43:29.398 [main] DEBUG si.mazi.rescu.HttpTemplate - Executing GET request at https://www.bitstamp.net/api/v2/trading-pairs-info/
15:43:30.286 [main] DEBUG si.mazi.rescu.HttpTemplate - Request http status = 200
15:43:30.386 [main] INFO  info.bitrich.xchangestream.bitstamp.v2.BitstampStreamingService - Connecting to wss://ws.bitstamp.net
15:43:31.685 [nioEventLoopGroup-2-1] INFO  info.bitrich.xchangestream.service.netty.WebSocketClientHandler - WebSocket Client connected!
15:43:31.685 [nioEventLoopGroup-2-1] WARN  info.bitrich.xchangestream.bitstamp.v2.BitstampStreamingService - Resubscribing channels
15:43:31.687 [main] INFO  info.bitrich.xchangestream.bitstamp.v2.BitstampStreamingService - Subscribing to channel live_trades_btcusd
15:43:31.720 [main] DEBUG info.bitrich.xchangestream.bitstamp.v2.BitstampStreamingService - Sending message: {"event":"bts:subscribe","data":{"channel":"live_trades_btcusd"}}
15:43:31.760 [nioEventLoopGroup-2-1] DEBUG info.bitrich.xchangestream.service.netty.JsonNettyStreamingService - Received message: {"event":"bts:subscription_succeeded","channel":"live_trades_btcusd","data":{}}
15:43:32.992 [nioEventLoopGroup-2-1] DEBUG info.bitrich.xchangestream.service.netty.JsonNettyStreamingService - Received message: {"data": {"microtimestamp": "1574858612723759", "amount": 0.01006, "buy_order_id": 4387860425, "sell_order_id": 4387860983, "amount_str": "0.01006000", "price_str": "7268.04", "timestamp": "1574858612", "price": 7268.04, "type": 1, "id": 101101885}, "event": "trade", "channel": "live_trades_btcusd"}
15:43:41.185 [nioEventLoopGroup-2-1] DEBUG info.bitrich.xchangestream.service.netty.JsonNettyStreamingService - Received message: {"data": {"microtimestamp": "1574858621023145", "amount": 0.09047, "buy_order_id": 4387861204, "sell_order_id": 4387861446, "amount_str": "0.09047000", "price_str": "7263.35", "timestamp": "1574858621", "price": 7263.35, "type": 1, "id": 101101889}, "event": "trade", "channel": "live_trades_btcusd"}
15:43:44.136 [nioEventLoopGroup-2-1] DEBUG info.bitrich.xchangestream.service.netty.JsonNettyStreamingService - Received message: {"data": {"microtimestamp": "1574858623986044", "amount": 0.007401, "buy_order_id": 4387861720, "sell_order_id": 4387861684, "amount_str": "0.00740100", "price_str": "7265.58", "timestamp": "1574858623", "price": 7265.58, "type": 0, "id": 101101891}, "event": "trade", "channel": "live_trades_btcusd"}

pchertalev avatar Nov 27 '19 12:11 pchertalev

Ah! I got - subscriber is not recieving trades - there is just JsonNettyStreamingService log.

pchertalev avatar Nov 27 '19 12:11 pchertalev

Guys, sorry I don't like changes from @jurepetrovic. I have opened my PR regarding this issue.

pchertalev avatar Nov 27 '19 14:11 pchertalev

https://github.com/bitrich-info/xchange-stream/pull/456

pchertalev avatar Nov 27 '19 14:11 pchertalev

With #456 I get trades again image

mdvx avatar Nov 29 '19 04:11 mdvx