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

0 Members and 1 Guest are viewing this topic.

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4653
    • 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: 901
    • 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:

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 and should be run in seperate terminals creates file nodes.txt 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 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
    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

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