Author [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] Topic: Yet Another Price Feed Mod  (Read 2891 times)

Offline emski

  • Hero Member
  • *****
  • Posts: 1283
    • View Profile
    • http://lnkd.in/nPbhxG
Yet Another Price Feed Mod
« on: October 04, 2014, 11:42:19 PM »

I've done some modifications to xeroc's (which was derived from alt's version) version of the price feed script.
You can see it here: https://github.com/emilvelichkov/pytshares

Basically I've added weighting of each exchange so a delegate could select which exchange matters more.

Also I've changed the conditions when the feed is published:
Nothing except time restrictions and price difference is taken into account. If price differs more than [-max_negative_diff , max_positive_diff]*MyLastFeed feed is published. By default: [-0.2%, 0.5%].
Feeds cannot be published more frequently than minFeedAgeInSeconds.

Also I've changed the logic of price fetching to include additional validation and to ignore error from exchanges with low trust_level. This way failure to fetch price data from low trusted exchange will not prevent the calculation and publishing of feeds.

It is still experimental so some issues might arise. Some proof-read is welcome.

Here is the full changelog:
+ added minFeedAgeInSeconds (minimum time between feed publish)
+ added minValidAssetPrice (any feed for asset with lower price will be ignored)
+ added max_positive_diff/max_negative_diff (asset price should increase more than max_positive_diff in order to be published)
+ added exchange trust level (it multiplies the volume of the exchange.)
* changed publish_rule in the following way:
price is published if maxFeedAgeInSeconds have passed
price is published if price of any asset changes more than [-max_negative_diff, max_positive_diff]
* Errors fetching prices from any exchange are ignored unless exchange_trust_level > 0.8 (this is to prevent single small exchange from stopping all feeds)
« Last Edit: October 05, 2014, 05:49:55 AM by emski »

Offline tonyk

  • Hero Member
  • *****
  • Posts: 3307
    • View Profile
Re: Yet Another Price Feed Mod
« Reply #1 on: October 05, 2014, 12:48:39 AM »

I as a user/owner have always advocated for weighing the price feed from different exchanges, so I am happy to see that and hope more delegates will start using this script.

The other features seem beneficial to the delegates themselves, so I hope for a fast adoption.

0.02 BTSX
Lack of arbitrage is the problem, isn't it. And this 'should' solves it.

Offline liondani

Re: Yet Another Price Feed Mod
« Reply #2 on: October 05, 2014, 07:57:06 AM »

I as a user/owner have always advocated for weighing the price feed from different exchanges, so I am happy to see that and hope more delegates will start using this script.

The other features seem beneficial to the delegates themselves, so I hope for a fast adoption.

0.02 BTSX

until now I published the feeds manually...  With this approach I consider seriously to start using the script.
Thanks to alt, xeroc and emski for their efforts   ;)
  https://bitshares.OPENLEDGER.info/?r=GREECE  | You are in Control | BUY | SELL | SHORT | SWAP | LOAN | TRADE |  

Offline emski

  • Hero Member
  • *****
  • Posts: 1283
    • View Profile
    • http://lnkd.in/nPbhxG
Re: Yet Another Price Feed Mod
« Reply #3 on: October 05, 2014, 08:16:00 AM »
I think there might be an error in discount implementation in the original script.
It increases the feed price instead of decreasing it.

assume discount = 0.995
Original code:
Code: [Select]
### Discount
  price_in_btsx_weighted[asset] = price_in_btsx_weighted[asset] / config["discount"]

My code:
Code: [Select]
### Discount
  price_in_btsx_weighted[asset] = price_in_btsx_weighted[asset] * config["discount"]

Offline vikram

Re: Yet Another Price Feed Mod
« Reply #4 on: October 10, 2014, 08:09:10 PM »
Seems like it might be good to make a wiki page listing the different price feed scripts and their main differences. Something in the spirit of this: https://en.wikipedia.org/wiki/Tomato_%28firmware%29#Feature_comparison but of course not so complicated.

Offline emski

  • Hero Member
  • *****
  • Posts: 1283
    • View Profile
    • http://lnkd.in/nPbhxG
Re: Yet Another Price Feed Mod
« Reply #5 on: October 16, 2014, 07:28:14 AM »
I've merged the fix for btc38 failure (thanks alt).

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11904
    • View Profile
    • BitShares.Europe
  • BTS: xeroc
  • GitHub: xeroc
Re: Yet Another Price Feed Mod
« Reply #6 on: October 19, 2014, 01:48:51 PM »
I think there might be an error in discount implementation in the original script.
It increases the feed price instead of decreasing it.

assume discount = 0.995
Original code:
Code: [Select]
### Discount
  price_in_btsx_weighted[asset] = price_in_btsx_weighted[asset] / config["discount"]

My code:
Code: [Select]
### Discount
  price_in_btsx_weighted[asset] = price_in_btsx_weighted[asset] * config["discount"]

For sake of completeness :)

I fixed that issue bug in my code :-D
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu

Offline emski

  • Hero Member
  • *****
  • Posts: 1283
    • View Profile
    • http://lnkd.in/nPbhxG
Re: Yet Another Price Feed Mod
« Reply #7 on: November 11, 2014, 08:39:37 PM »
I've updated with changes related to v0.4.24 .
I've merged some bugfixes (thanks to xeroc (python identation is tricky)).

Offline emski

  • Hero Member
  • *****
  • Posts: 1283
    • View Profile
    • http://lnkd.in/nPbhxG
Re: Yet Another Price Feed Mod
« Reply #8 on: November 13, 2014, 09:05:27 PM »
Apparently BTER changed BTSX asset name to BTS.
I've pushed a quick patch to address that.
I'll try to make something more robust soon.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11904
    • View Profile
    • BitShares.Europe
  • BTS: xeroc
  • GitHub: xeroc
Re: Yet Another Price Feed Mod
« Reply #9 on: November 14, 2014, 07:44:12 AM »
Apparently BTER changed BTSX asset name to BTS.
I've pushed a quick patch to address that.
I'll try to make something more robust soon.
dito ... had my inbox filled with errors .. need to put hand on the script some more ..
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu

Offline kokojie

  • Sr. Member
  • ****
  • Posts: 286
    • View Profile
  • Witness: kokojie
  • Payrate: 3%
Re: Yet Another Price Feed Mod
« Reply #10 on: November 15, 2014, 12:51:25 AM »
I still get errors with both emski and xeroc's updated script:

emski:
  File "./btsx_feed.py", line 125
    volume_in_btc[ mapAsset ].append(float(result[coin.lower()+"_btc"]["vol_btc"])*confi$
                                                                                                                                           ^
SyntaxError: invalid syntax


xeroc:
  File "/home/user/feed_xeroc/btsx_feed.py", line 433, in <module>
    if publish_rule() :
  File "/home/user/feed_xeroc/btsx_feed.py", line 47, in publish_rule
    elif fabs(myCurrentFeed[asset]-realPrice[asset])/realPrice[asset] > config["change_min"] and\
KeyError: 'change_min'

Offline emski

  • Hero Member
  • *****
  • Posts: 1283
    • View Profile
    • http://lnkd.in/nPbhxG
Re: Yet Another Price Feed Mod
« Reply #11 on: November 15, 2014, 12:55:44 AM »
I still get errors with both emski and xeroc's updated script:

emski:
  File "./btsx_feed.py", line 125
    volume_in_btc[ mapAsset ].append(float(result[coin.lower()+"_btc"]["vol_btc"])*confi$
                                                                                                                                           ^
SyntaxError: invalid syntax


xeroc:
  File "/home/user/feed_xeroc/btsx_feed.py", line 433, in <module>
    if publish_rule() :
  File "/home/user/feed_xeroc/btsx_feed.py", line 47, in publish_rule
    elif fabs(myCurrentFeed[asset]-realPrice[asset])/realPrice[asset] > config["change_min"] and\
KeyError: 'change_min'

What arguments are you passing to the scripts ?
Example: "./btsx_feed.py GOLD BTC USD CNY EUR"

Are you sure you have the file as in github ?

Offline emski

  • Hero Member
  • *****
  • Posts: 1283
    • View Profile
    • http://lnkd.in/nPbhxG
Re: Yet Another Price Feed Mod
« Reply #12 on: November 15, 2014, 01:00:13 AM »
My bad. I've committed not working version.
Should be OK now.

Offline kokojie

  • Sr. Member
  • ****
  • Posts: 286
    • View Profile
  • Witness: kokojie
  • Payrate: 3%
Re: Yet Another Price Feed Mod
« Reply #13 on: November 15, 2014, 01:14:24 AM »
cool, emski yours is working for me now

Offline emski

  • Hero Member
  • *****
  • Posts: 1283
    • View Profile
    • http://lnkd.in/nPbhxG
Re: Yet Another Price Feed Mod
« Reply #14 on: November 15, 2014, 01:16:53 AM »
cool, emski yours is working for me now

The error in xeroc's script you see might be related to improper config file.
There are different variables in both versions. Make sure you use proper version.

 

Google+