XChange icon indicating copy to clipboard operation
XChange copied to clipboard

Kucoin migration to v2 api needed (at least for aggregated order books)

Open cymp opened this issue 6 years ago • 11 comments

Hello,

I read on kucoin website that the v1 api will be deprecated in the following months

GET /api/v1/market/orderbook/level2?symbol= (Will be deprecated on December 31, 2019) GET /api/v2/market/orderbook/level2?symbol= (Recommend)

I read on https://github.com/knowm/XChange/issues/2914 that some work has been done, but I am confused about what is left to be done. @badgerwithagun maybe you can give me a hint?

cymp avatar Mar 19 '19 14:03 cymp

@cymp

XChange switched entirely from the v1 to v2 APIs with #2946 and subsequently #2996.

badgerwithagun avatar Mar 19 '19 14:03 badgerwithagun

In this case, why are every calls in https://github.com/knowm/XChange/tree/develop/xchange-kucoin/src/main/java/org/knowm/xchange/kucoin/service prefixed with "v1"?

cymp avatar Mar 19 '19 14:03 cymp

Hm, I think Kucoin might just be mixing terminology.

#2946 moved XChange to use the "Platform 2.0" API, which completely replaced the original "Platform 1" API when they performed a large systems upgrade a couple of months ago. That original API was completely turned off at Kucoin; I don't believe there was ever a transition period (certainly all my existing integrations broke immediately and never worked again).

This sounds like they may be slowly phasing in a "v2" of the platform 2.0 API, but I've not seen any communications from Kucoin about this and can't find anything on the website or in the API documentation. Do you have a link?

badgerwithagun avatar Mar 19 '19 14:03 badgerwithagun

What I read:

  • https://docs.kucoin.com/#order-book:

This document has been deprecated, KuCoin has been upgraded to V2, please check the new document: https://docs.kucoin.com

  • https://docs.kucoin.com/#order-book:

HTTP REQUEST GET /api/v1/market/orderbook/level2?symbol= (Will be deprecated on December 31, 2019)

GET /api/v2/market/orderbook/level2?symbol= (Recommend)

Maybe there is some information somewhere else though...

cymp avatar Mar 19 '19 15:03 cymp

Ah, OK, yes, it's just a slight change in the behaviour of the full aggregated order book API to change the order in which the orders are returned. This is indeed not the same thing as the platform upgrade to 2.0.

They're doing The Right Thing and introducing a new version of the API rather than just changing the behaviour of the existing one.

All we have to do is to change the @Path on that one specific endpoint. I didn't make any assumptions about ordering when translating that to the generic API, so nothing else needs to change.

badgerwithagun avatar Mar 19 '19 15:03 badgerwithagun

Would you mind updating the title of this issue to reflect that we need to switch to the v2 version of the full aggregated orderbook API?

badgerwithagun avatar Mar 19 '19 15:03 badgerwithagun

FYI there's a sorting constructor for OrderBook.

cymp avatar Mar 19 '19 18:03 cymp

Handily though, v2 explicitly states that it is in exactly the order we need already, so we can remove all the sorting and bypass the sorting constructor.

badgerwithagun avatar Mar 19 '19 18:03 badgerwithagun

I can read in the documentation that:

Data Sort Asks: Sort price from low to high (v2) Asks: Sort price from high to low (v1)

So maybe there is an ordering to be done.

cymp avatar Mar 19 '19 18:03 cymp

Yeah, I think v1 was wrong. v2 looks like what we need. I suspect that I put in ordering because the API docs at the time didn't make a strong guarantee either way before they added v2.

I could be wrong though; without testing it's hard to be certain.

badgerwithagun avatar Mar 19 '19 18:03 badgerwithagun

I'm taking a whack at adding all the resilience code for Kucoin. I was running the market data service unit test and it fails on the testOrderBookFull test. Looking at the current (as of 7/20/2021) Kucoin api docs, the v2 full order book agg endpoint looks 'deprecated'.

When I run the test, there's a 404 error. I didn't see what the explicit definition of deprecated means in their api, but it looks like it means it has been removed. v3 requires a general api permission, which means it no longer works as an unauthenticated api call.

@earce I can switch the api over as part of my refactor but my issue is: This is a breaking change and I'm not sure what policy XChange has in dealing with this (I'll review the contribution doc). As of now, this seems to be broken in the wild so there's probably not much to do other than plow forward with v3 and include the breaking change(s) in the next release notes?

Once I have a PR ready I will reference this issue and another issue I commented on earlier.

nibarulabs avatar Jul 21 '21 01:07 nibarulabs