Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Subscription of OrderBooks - Asks/Bids issue. #19

@JoshMilli

Description

@JoshMilli

Currently you can call Asks & Bids for individual pairs. Out of experience and testing, multiple pairs seem to overload the subscription call and take the entire subscription service offline.

My suggestion is by limiting the delay in which the Asks & Bids data is received, as well as having a method for the sole purpose of getting Bids and Asks for all the pairs on the current chain.

This will help by limiting the amount of code needed as well as having the ability to control the subscription calls more slowly.

The reason i think the server gets overloaded is because it takes each pair, gets the asks, bids and moves to the next pair. This creates a lot of requests per pair.

//My code as an example:

        orionUnit.orionAggregator.ws.subscribe("aobus", {
        //loop through DATA containing pairs and get the pair
        payload: keys[i], // Some trading pair
        callback: (asks, bids, pairName) => {
  
          let Asks = zodUtil.util.objectValues(asks);
          let Bids = zodUtil.util.objectValues(bids)
          
          for (let i = 0; i < asks.length; i++) {
          let existingPairInData = DATA.find((pair) => pair.Pair === keys[i]);
          
            if (existingPairInData) {
              console.log("existingPairInData", existingPairInData)
              existingPairInData.Spread = Asks[0].price - Bids[0].price / DATA[i].LastPrice;
            }
          }
        }
      });

Suggested method:

orionUnit.orionAggregator.ws.subscribe("aobus", {
payload: "AllPairs",         //All trading pairs on the selected chain
DataDelay: 3000ms
callback: (asks, bids, pairName) => {
console.log(`${pairName} orderbook asks`, asks);
console.log(`${pairName} orderbook bids`, bids);
},
});`

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