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

Large price diferences between price nodes #28

Open
ghost opened this issue Sep 11, 2023 · 4 comments
Open

Large price diferences between price nodes #28

ghost opened this issue Sep 11, 2023 · 4 comments

Comments

@ghost
Copy link

ghost commented Sep 11, 2023

Very often there is a large price difference on XMR/BTC between predefined price nodes.
It is not unusual to have a spread higher than 1%. The high spread is not related to quick fluctuation of the price.

On one hand this limits trading between peers, on the other hand one of the peers could be severely penalized by the price offset.

Here is a little script that can be run to compare the prices:

#!/bin/bash

# List of URLs to fetch data from
URLS=("http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/getAllMarketPrices" "http://emzypricpidesmyqg2hc6dkwitqzaxrqnpkdg3ae2wef5znncu2ambqd.onion/getAllMarketPrices" "http://devinpndvdwll4wiqcyq5e7itezmarg7rzicrvf6brzkwxdm374kmmyd.onion/getAllMarketPrices" "http://ro7nv73awqs3ga2qtqeqawrjpbxwarsazznszvr6whv7tes5ehffopid.onion/getAllMarketPrices")

# Specify the currency code you want to compare
CURRENCY_CODE="XMR"

while true; do
  prices=()
  temp_files=()

  # Fetch data from each URL in parallel
  for url in "${URLS[@]}"; do
    temp_file=$(mktemp)
    temp_files+=("$temp_file")
    torsocks curl -s $url > "$temp_file" &
  done

  # Wait for all background jobs to finish
  wait

  echo "Fetching prices for currency: $CURRENCY_CODE"

  # Extract prices from temporary files
  for i in "${!temp_files[@]}"; do
    temp_file="${temp_files[$i]}"
    url="${URLS[$i]}"
    price=$(cat "$temp_file" | jq -r ".data[] | select(.currencyCode == \"$CURRENCY_CODE\") | .price")
    prices+=("$price")
    echo "Server: $url, Price: $price"
    rm "$temp_file"
  done

  # Find minimum and maximum prices
  minPrice=${prices[0]}
  maxPrice=${prices[0]}
  for price in "${prices[@]}"; do
    if (( $(echo "$price < $minPrice" | bc -l) )); then
      minPrice=$price
    fi

    if (( $(echo "$price > $maxPrice" | bc -l) )); then
      maxPrice=$price
    fi
  done

  # Calculate the percentage difference
  difference=$(echo "scale=5; ($maxPrice - $minPrice) / $minPrice * 100" | bc)
  echo "Difference: $difference%"

  # Wait for 15 seconds before the next iteration
  sleep 15
done
@ghost
Copy link

ghost commented Sep 12, 2023

I thought the ops team ran a monitoring script to check if the pricenodes are in sync. @Emzy can you confirm that?

I've occasionally heard of a pricenode not refreshing its rates, stuck with stale prices (requiring a reboot). Does that sound like the problem, or do the pricenodes seem to be operating normally when this discrepancy happens?

@ghost
Copy link
Author

ghost commented Sep 15, 2023

Screenshot 2023-09-15 212528

@ghost
Copy link

ghost commented Sep 15, 2023

Thanks @worminder, I think this is because wiz and ro7nv nodes are running an older version which does not have outlier filtering. There have been many improvements lately, some of which are pending merge. Once ready, hopefully soon, we can upgrade all price nodes together.

@ghost
Copy link

ghost commented Oct 27, 2023

Update to previous comment, ro7nv was upgraded Sep 18th, wiz pricenode was banned from network Oct 8th.

Another user has complained about an XMR price discrepancy, so I'll start running a similar script to keep a closer eye on prices. Have not noticed any recent discrepancy other than #33 (solved by restarting), and resultant pending improvements: #35, #36, #37.

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

0 participants