HTX will support new MBP (Market By Price) feed in existing Websocket API (phase 1)

Dear API user,

Since the effective day of this notification, HTX will start to support a new MBP (Market By Price) feed in existing Websocket API, through the channel – market.$symbol.mbp.$levels.

 

The new Websocket channel above disseminates incremental update of the MBP book in streaming mode, upon subscription. Refresh message (full image of certain levels MBP book) is also acquirable from the same channel, based on “req” request.

Req “market.$symbol.mbp.$levels”

Request Parameters

Field Name Mandatory Description
symbol True Trading symbol (wildcard inacceptable)
levels False Number of price levels (5,10,20,150)

Response

Field Name Data Type Description
seqNum integer Sequence number of the message
bids string [] Bid side (in descending order of “price”)
    ["price","size"]
asks string [] Ask side (in ascending order of “price”)
    ["price","size"]

 

Sub “market.$symbol.mbp.$levels”

Request Parameters

Field Name Mandatory Description
symbol True Trading symbol (wildcard inacceptable)
levels False Number of price levels (5,10,20,150)

 

Response

Field Name Data Type Description
seqNum integer Sequence number of the message
prevSeqNum integer Sequence number of previous message
bids string [] Bid side (in descending order of “price”)
    ["price","size"]
asks string [] Ask side (in ascending order of “price”)
    ["price","size"]

 

Sample A – refresh message upon “req”

{'id': 'id21', 'rep': 'market.btcusdt.mbp.150', 'status': 'ok', 'data': {'seqNum': 100020142010, 'bids': [[618.37, 71.594], [423.33, 77.726], [223.18, 47.997], [219.34, 24.82], [210.34, 94.463], [204.53, 22.008], [198.05, 82.049], [167.13, 97.114], [117.17, 19.352], [99.11, 38.48245239754659], [84.66, 5.925], [83.83, 57.00126344490675], [80.35, 18.433], [72.7, 71.34128402595132], [72.29, 18.846], [72.07, 95.668], [69.8, 64.874], [69.65, 2.347], [69.19, 51.479], [67.62, 40.526], [63.34, 0.8771003950771937], [63.2, 63.852], [62.15, 82.58], [62.12, 97.377], [61.8, 45.9539205169449], [61.78, 11.231], [61.74, 69.249], [61.72, 36.58], [61.69, 52.627], [61.68, 50.974], [61.55, 50.965], [61.52, 88.064], [61.48, 22.228], [61.42, 28.467], [61.34, 30.285], [61.32, 19.389], [61.28, 15.00109220651907], [61.26, 207.516], [61.24, 35.307], [61.23, 30.977], [61.22, 162.604], [61.21, 99.545], [61.2, 97.177], [61.19, 26.572], [61.17, 59.195], [61.16, 96.64], [61.15, 85.264], [61.14, 90.242], [61.13, 30.394], [61.12, 65.782], [61.11, 174.185], [61.1, 43.89], [61.09, 36.893], [61.08, 37.825], [61.06, 160.019], [61.04, 167.899], [61.03, 70.506], [61.02, 18.654], [61.01, 59.536], [60.99, 180.02], [60.98, 89.532], [60.97, 169.404], [60.95, 126.995], [60.94, 12.498], [60.92, 88.781], [60.91, 14.727], [60.9, 67.195], [60.89, 67.127], [60.87, 235.546], [60.85, 68.383], [60.84, 71.25], [60.83, 7.756], [60.79, 35.908], [60.78, 22.914], [60.77, 70.389], [60.76, 49.77], [60.75, 163.658], [60.74, 13.597], [60.73, 124.56], [60.71, 103.467], [60.7, 21.721], [60.68, 38.754], [60.67, 64.175], [60.66, 38.445], [60.65, 40.985], [60.64, 121.238], [60.63, 9.673], [60.62, 207.061], [60.6, 39.138], [60.59, 72.011], [60.57, 121.376], [60.56, 84.822], [60.55, 137.459], [60.54, 53.793], [60.53, 157.01], [60.52, 66.257], [60.51, 89.356], [60.5, 1.635], [60.49, 125.283], [60.48, 199.118], [60.47, 69.516], [60.46, 152.252], [60.45, 67.069], [60.44, 63.928], [60.43, 9.647], [60.42, 49.781], [60.41, 46.134], [60.4, 91.861], [60.39, 52.487], [60.38, 111.636], [60.37, 122.307], [60.35, 184.275], [60.34, 78.059], [60.33, 54.427], [60.31, 27.704], [60.28, 30.414], [60.27, 58.388], [60.26, 56.321], [60.24, 52.976], [60.22, 0.828], [60.21, 99.166], [60.19, 34.45], [60.17, 92.639], [60.15, 93.4], [60.14, 73.585], [60.13, 165.401], [60.06, 68.354], [60.05, 75.296], [60.04, 152.974], [60.03, 83.667], [60.01, 160.114], [60.0, 157.741], [59.99, 131.641], [59.98, 9.974], [59.97, 37.564], [59.96, 98.764], [59.95, 64.301], [59.94, 56.357], [59.91, 109.974], [59.9, 80.386], [59.88, 208.818], [59.87, 108.063], [59.86, 10.053], [59.84, 34.24], [59.83, 145.421], [59.81, 108.084], [59.8, 4.936], [59.79, 88.264], [59.78, 97.956], [59.77, 32.079]], 'asks': [[650.59, 14.909733438479636], [650.63, 97.996], [650.77, 97.465], [651.23, 83.973], [651.42, 34.465], [651.61, 7.822], [652.12, 57.819], [654.26, 63.142], [655.5, 54.362], [655.93, 38.034], [656.25, 17.21], [656.33, 44.605], [657.72, 5.176], [657.91, 10.644849251676206], [658.1, 80.697], [658.44, 52.804], [658.49, 92.026], [658.63, 21.733], [658.66, 28.872], [658.69, 77.436], [658.88, 28.086], [659.26, 82.323], [660.85, 79.252], [660.96, 52.131], [661.03, 24.8], [661.05, 96.311], [661.08, 8.028], [661.2, 65.354], [661.54, 39.616], [661.62, 17.165], [661.95, 18.299], [662.1, 0.22], [662.35, 6.172], [662.44, 52.443], [662.86, 7.579], [663.37, 59.775], [663.65, 44.612], [663.89, 46.324], [663.99, 85.936], [664.39, 28.659], [664.67, 52.079], [664.83, 41.999], [665.25, 74.079], [665.87, 58.769], [666.44, 7.028], [666.49, 43.58], [666.51, 68.819], [666.68, 93.158], [666.86, 49.504], [666.96, 32.644], [668.45, 63.03], [668.73, 21.391], [668.74, 48.152], [668.9, 56.945], [668.91, 46.599], [668.94, 2.436], [669.12, 22.838826503966004], [669.18, 6.378], [669.37, 99.502], [669.39, 57.98], [669.44, 78.716], [669.48, 91.519], [669.55, 55.022], [669.62, 14.649], [669.68, 6.161], [669.75, 28.483], [669.77, 55.106], [669.85, 6.636], [669.88, 64.139], [669.89, 53.648], [669.97, 97.053], [670.12, 83.221], [670.15, 13.681], [670.19, 37.937], [670.2, 48.251], [670.36, 45.997], [670.48, 3.183], [670.52, 41.815], [670.55, 95.075], [670.67, 63.573], [670.72, 4.565], [670.78, 33.859], [670.79, 51.768], [670.85, 51.966], [670.88, 91.448], [670.92, 63.408], [670.96, 83.33], [670.97, 4.667118475698068], [670.99, 81.623], [671.0, 37.573], [671.01, 1.424], [671.07, 24.685], [671.08, 86.418], [671.1, 33.885], [671.12, 36.824], [671.13, 94.727], [671.17, 64.128], [671.21, 152.034], [671.23, 16.243], [671.25, 26.242], [671.26, 113.513], [671.36, 81.574], [671.41, 159.786], [671.43, 17.54], [671.45, 22.587], [671.46, 156.968], [671.47, 60.138], [671.48, 69.138], [671.59, 54.687], [671.65, 148.23], [671.68, 20.94], [671.69, 65.143], [671.77, 22.55], [671.81, 174.855], [671.83, 80.369], [671.87, 65.099], [671.89, 18.528], [671.94, 31.721], [671.97, 26.026], [671.98, 22.742], [672.02, 34.675], [672.06, 27.126], [672.07, 85.067], [672.11, 98.982], [672.13, 29.915], [672.14, 7.987], [672.17, 128.325], [672.31, 19.35], [672.34, 75.68], [672.39, 27.623], [672.41, 4.339], [672.46, 169.221], [672.53, 6.807], [672.55, 33.975], [672.62, 8.037], [672.68, 20.603], [672.69, 92.931], [672.72, 12.204], [672.77, 55.775], [672.85, 27.12], [672.87, 33.727], [672.89, 16.66432115270567], [672.9, 75.852], [672.92, 98.468], [672.94, 45.896], [672.96, 21.276], [672.98, 90.336], [672.99, 107.692], [673.0, 71.496], [673.01, 103.526]]}}

 

Sample B – incremental message upon “sub”

{"ch":"market.btcusdt.mbp.150","ts":1573199608679,"tick":{"seqNum":100020146795,"prevSeqNum":100020146794,"bids":[],"asks":[[645.140000000000000000,26.755973959140651643]]}}

 

Suggested downstream data processing

  • Subscribe incremental updates and start to cache them;
  • Request refresh message (with same number of levels), and base on its “seqNum” to align it with the cached incremental message which having a same “prevSeqNum”;
  • Start to continuously process incremental messages to build up MBP book;
  • The “prevSeqNum” of current incremental message must be same with “seqNum” of previous message, otherwise it implicates message loss which should require another round refresh message retrieval and alignment;
  • Once receiving a new price level from incremental message, that price level should be inserted into appropriate position of existing MBP book;
  • Once receiving an updated “size” at existing price level from incremental message, the level size should be replaced directly by the new value;
  • Once receiving a “size=0” at existing price level from incremental message, that price level should be removed from MBP book;
  • If one incremental message includes update at multiple price levels, all of those levels should be updated simultaneously in MBP book.

 

Phase 1 provision and limitations

  • Only support the number of price levels at 150. Neither of 5, 10, 20 is acquirable at this point of time.
  • Only support the incremental update at 100ms interval. Shorter interval even full tick MBP data is not acquirable at this point of time.
  • Only support 19 currency pairs – btcusdt,ethusdt,eosusdt,bchusdt,ltcusdt,xrpusdt,htusdt,bsvusdt,etcusdt,zecusdt,ethbtc,eosbtc,bchbtc,ltcbtc,xrpbtc,htbtc,bsvbtc,etcbtc,zecbtc. Other cryptocurrency pairs are not acquirable from the MBP feed at this moment.

 

Effective Date: December 23, 2019 (GMT+8)

All the changes will be updated on https://huobiapi.github.io/docs/spot/v1/en/

HTX
December 18, 2019