Author Topic: 5 Node Verified Price Feed - Python  (Read 951 times)

0 Members and 1 Guest are viewing this topic.

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4592
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
I think OP means latest order book state. "Price feed" has other meaning in BitShares.
BitShares committee member: abit
BitShares witness: in.abit

Offline R

  • Hero Member
  • *****
  • Posts: 841
    • View Profile
> working under the assumption that any node can provide rogue price feeds at any given time,

You can select witnesses, committee or 25 private price feed publishers, so just don't provide permission to untrustworthy entities?

Offline litepresence

developing here:

https://github.com/litepresence/extinction-event/tree/master/EV


working under the assumption that any node can provide rogue price feeds at any given time,
I sort all nodes by latency every two minutes
then check last price on 5 low latency nodes to verify authenticity of the data every 30 seconds


5 NODE VERIFIED LAST PRICE

nodes.py and last.py should be run in seperate terminals

nodes.py creates file nodes.txt
last.py creates file last.txt and appends to file blacklist.txt

nodes.txt is the top 10 latency sorted nodes of about 50 known nodes; updated approx every 2 minutes

last.py uses nodes.txt to get price from 5 nodes, then makes a list "prices", updated approx ever 30 seconds

then process that list of prices from 5 different nodes pseudocode:


if the spread of the prices is too wide:

    append to file blacklist.txt the list of prices and the list of nodes used to gather them


if all prices are same:
   
    last = latest price

elif latest price less than 2% different than mean(prices):
   
    last = latest price
 
else:
    try: last = mode(prices)
    except: last = median(prices)

write last to last.txt



the good news:

I ran this all day on BTS/BTC and no set of 5 prices were more than 2% different... meaning I never encountered a rogue node.

the better news:

this price feed can be used with confidence to feed bots with latest price data without risk of node going stale or going rogue

the best news:

I work on bid/ask tomorrow

:D
« Last Edit: March 18, 2018, 01:43:04 am by litepresence »