ccxt / ccxt

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
https://docs.ccxt.com
MIT License
32.44k stars 7.46k forks source link

Can I use fetchOrderBook for new Coinbase exchange? #16598

Closed zydjohnHotmail closed 1 year ago

zydjohnHotmail commented 1 year ago

Operating System

Windows 10

Programming Languages

JS

CCXT Version

2.6.36

Description

Hello: As I can see in the latest version of CCXT (2.6.36), the Coinbase has been upgraded, which is good. However, I found that at least one import function is missing: fetchOrderBook. Is it possible to add this function in CCXT library for the new version? By the way, I can see from web page that CCXT seems already has version of 2.6.58, but using npm install, I can install version of 2.6.36 as the latest version. Is there any bug when publishing a new version? Please advise! Thanks,

Code

  
carlosmiei commented 1 year ago

Hello, @zydjohnHotmail we're upgrading it gradually, but we will try to add fetchOrderBook as soon as possible.

Regarding the npm package, we're facing an issue with the metadata and waiting for a response from npm, hopefully will be resolved soon.

zydjohnHotmail commented 1 year ago

Hi, Thanks for your quick reply, please let me know when done, you can close this issue if the job is done, so I will know it. Thanks for your wounderful work!

Dan-krm commented 1 year ago

There currently isn't an endpoint available to implement fetchOrderBook we can add it in the future if they update the api, all of the available methods are pending review and once they're merged I'll update this issue: #16281 and create some examples

zydjohnHotmail commented 1 year ago

Hi: I read the new advanced trade API document, I can't find fetchOrderBook API end point. So I created an account with Coinbase cloud, and publish a post to ask adding the necessary API end point. Here is my question URL: https://forums.coinbasecloud.dev/t/consider-add-order-book-in-new-advanced-trade-api/2578 I think if you and some other people will publish the similar posts, then Coinbase may consider to add such API end point. Just as I request a new exchange for Coinbase Advanced Trade API, since there are other people are interested, so CCXT add it rather quickly. Please consider my suggestions.

zydjohnHotmail commented 1 year ago

Hello: As I register with Coinbase Cloud and post a request for order book in new Advanced Trade API. And I got the following answer: We appreciate your continuous support to our Coinbase products. As of the moment, the WebSocket level2 channel of Advanced Trade is the equivalent of the Get product book of Exchange/Pro. The level2 channel guarantees delivery of all updates and is the easiest way to keep a snapshot of the order book. To subscribe to the level2 channel, you may follow the instructions provided here. Also, you may check here for reference on what are the equivalent endpoints in Coinbase Pro to Advanced Trade and Sign in with Coinbase. We hope this helps. Please do not hesitate to reply back to this thread if you have any other concerns. Thank you! Coinbase Advanced Trade API has WebSocket level2 channel, the document is at this URL: https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-overview#subscribe A reference for API mapping can be found at this URL: https://docs.cloud.coinbase.com/advanced-trade-api/docs/rest-api-pro-mapping Since Coinbase Advanced Trade API has WebSocket level2 channel, I want to know if it is possible to take a snapshot for all trading pairs and send it back as order book? Please look at the documents first, Thanks,

Dan-krm commented 1 year ago

Hey @zydjohnHotmail thanks for looking into this, we likely wouldn't use a websocket endpoint to populate our REST API implementations but I can look into adding support for this websocket endpoint to CCXT pro and working out an example of a snapshot to simulate fetchOrderBook.

ethanopp commented 1 year ago

Hey @zydjohnHotmail thanks for looking into this, we likely wouldn't use a websocket endpoint to populate our REST API implementations but I can look into adding support for this websocket endpoint to CCXT pro and working out an example of a snapshot to simulate fetchOrderBook.

Following - @Dan-krm app I’m using requires web socket integration, any ETA on when coinbase advanced trade will be set up in ccxt for WS?

zydjohnHotmail commented 1 year ago

Hi, I think you can keep working on your plan. Since I suggested adding Rest API Endpoint to get Order Book Data at Coinbase cloud forum, and I got feedback that they will consider this suggestion, but not making any decisions. I hope they can make such decision. But keep on your own working now. Thanks

ebugday81 commented 1 year ago

Is there an alternative option to fetch the current price for a trading pair for Coinbase? Before it was pretty easy to take the avg of current highest bid and lowest ask. But as the orderbook is not fetchable anymore I'm at a loss regarding fetching the price. Thanks in advance!

Dan-krm commented 1 year ago

@ebugday81 you can use fetchTicker, or fetchTickers, the last key is the current price in the quote currency, also in the info portion of the response of fetchTickers there is a mid_market_price, it wasn't populated when the advanced trade support was first added but it might be now or soon

ebugday81 commented 1 year ago

@Dan-krm I analyzed the real-time updated price with the price of last key, but ofc it is different. The reason for that is that the trading history is not updated immediately but seems like cached or something like that. Another reason could be that the price is determined by asks and bids and not by successful trades. Thanks anyways!

zydjohnHotmail commented 1 year ago

Hello: It has been quite some time now, are there any progress in adding fetchOrderBook to Coinbase API for the new/upadted exchange? If you have some implements already done, please show me some code example on how to use them? Thanks,

Dan-krm commented 1 year ago

Hey @zydjohnHotmail watchOrderBook is being worked on here #16871 Advanced Trade doesn't have fetchOrderBook but there is watchOrderBook being implemented in the mentioned PR, you should be able to use fetchOrderBook on coinbasepro until it is phased out