Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription of OrderBooks - Asks/Bids issue. #19

Open
JoshMilli opened this issue Jun 15, 2022 · 0 comments
Open

Subscription of OrderBooks - Asks/Bids issue. #19

JoshMilli opened this issue Jun 15, 2022 · 0 comments

Comments

@JoshMilli
Copy link

JoshMilli commented Jun 15, 2022

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);
},
});`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@JoshMilli and others