Skip to content

Get full orderbook for every product #136

@lucasrothman

Description

@lucasrothman

I'm trying to get the full level 2 orderbook for every market, and then maintain a live version of the orderbook using the websocket.

For coinbase I would make a request:

// Request
{
    "type": "subscribe",
    "channels": ["level2"],
    "product_ids": [
        "ETH-USD",
        "BTC-USD"
    ]
}

and then the first response is the entire current orderbook for each product:

{
  "type": "snapshot",
  "product_id": "BTC-USD",
  "bids": [["10101.10", "0.45054140"]],
  "asks": [["10102.55", "0.57753524"]]
}

and then subsequent events are changes like the following:

{
  "type": "l2update",
  "product_id": "BTC-USD",
  "time": "2019-08-14T20:42:27.265Z",
  "changes": [
    [
      "buy",
      "10101.80000000",
      "0.162567"
    ]
  ]
}

This lets me always maintain the current orderbook for all products.

What's the best way to do this with Bitkub?

I tried first using the REST API to fetch the current orderbook for each market and then starting a separate websocket for each market to update the orderbook. However, when I then hit the REST API endpoint for the orderbook again and compare it against what I have, it seems different. Any help is appreciated, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions