bisq-network / bisq-pricenode

GNU General Public License v3.0
5 stars 12 forks source link

Large price diferences between price nodes #28

Open ghost opened 12 months ago

ghost commented 12 months ago

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 commented 12 months ago

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 commented 11 months ago

Screenshot 2023-09-15 212528

ghost commented 11 months ago

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 commented 10 months ago

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 https://github.com/bisq-network/bisq-pricenode/issues/33 (solved by restarting), and resultant pending improvements: #35, #36, #37.