Steemfeed-JS - A NodeJS price feed for witneses

in #witness-category8 years ago (edited)

This article is targeted at developers. Primarily witnesses. If you don't understand what a witness is, or why a price feed is needed, read my article explaining witnesses

Due to recent changes in @xeroc's Piston, @jesta's witness price feed isn't working correctly.

While I'm not a big fan of Javascript, @svk's SteemJS-lib is pretty good. I used it to build Steemfeed-JS, which is a witness price feed in Javascript. It does NOT require cli_wallet, it should work across Windows, OSX, and Linux, with all dependencies in JS (just like @jesta/@clayop's).

The price data is retrieved from my service, Steem Value, since it offers direct steem_usd prices via the JSON API. If people want to add more exchanges, they can submit a Pull Request.

How to install?

The source code is up on Github: https://github.com/Someguy123/steemfeed-js/

It requires Node v6. However I've also packaged it up with Docker for quick setup on most platforms.

First, download the git repository, then edit config.json as needed. The interval is in minutes.

git clone https://github.com/Someguy123/steemfeed-js.git
cd steemfeed-js
cp config.example.json config.json
nano config.json

Now, you can run it either with Node v6, or through Docker (recommended).

Using docker:

docker build -t steemfeed-js .
docker run -it --rm --name feed steemfeed-js

# Check the status with docker logs
docker logs feed

Using NodeJS:

# I recommend using NVM to manage NodeJS versioning
nvm use v6

npm install
npm start

Small side note:

If you see a warning like this:

WARNING! ws connection wss://node.steem.ws closed
WebSocket: will try to reconnect in 1 sec, attempt #1
connecting to wss://node.steem.ws

This is not an error. This is simply STEEM.WS disconnecting after 60 seconds of being idle. The script will still function with no problems at all.


Do you like what I'm doing for STEEM/Steemit?

Vote for me to be a witness - every vote counts.

Don't forget to follow me for more like this.

Sort:  

I love the effort, but I think something got lost in the principals of how this should work, and the approach used here is fundamentally flawed.

If you look at all of the other example scripts out there, they all attach to multiple external data sources and make their own judgement of price. When once fails, it's fine because there are still multiple data sources.

This script is reliant on the value.steem.network API for pricing information exclusively, which to be honest, shouldn't be trusted as the sole source of this information. Each witnesses price updates shouldn't be derived exactly from the same source. This creates a single point of failure for failure or abuse.

I'm sorry, I don't mean to rain on your parade, but no one should use this.

Thanks for the information Jesta.

It uses value.steem.network, just because I wanted an MVP out to temporarily replace the python feed as fast as possible. Steem Value uses Poloniex+BTC-e to determine the price, and has an API I could plug into very quickly.

One of the reasons I'm able to personally trust this, is because the network doesn't exactly use a single witness as a source. One witness reporting $5 instead of $0.50 shouldn't shake the internal market.

This isn't to say it's perfectly fine for this to be a permanent solution, I will add more exchanges later on. But the network itself is capable of filtering out bad price feeds, because some witnesses update their feeds by hand, some witnesses use their own scripts, and others use a variety of the third party scripts available, like yours, @steempty's or @clayop's original.

Every witness should have a control for its price feed, so the calculation should be transparent and easily modified by witnesses for their preferences. Relying on a single server lacks this aspect. It's fundamentally no difference with parsing price data from the coinmarketcap IMHO.

I have fixed the feed publishing, and tested against the latest development version of piston.

Will be releasing it in a new module in steemtools next week. For anyone interested, the updated method looks a bit something like this:

    def witness_publish_feed(self, steem_usd_price, witness_name, wif, sim_mode=True):
        op = Feed_publish(
            **{"publisher": witness_name,
               "exchange_rate": {
                   "base": "%s SBD" % steem_usd_price,
                   "quote": "1.000 STEEM"
               }}
        )
        tx = self.steem.constructTx(op, wif)
        if sim_mode:
            return tx
        return self.steem.broadcast(tx)

I have some other witness related goodies in works as well...

Just an observation. The following command runs the process in the foreground:
docker run -it --rm --name feed steemfeed-js
It should be like this, if you want to run it detached in the background:
docker run -itd --rm --name feed steemfeed-js

ahhh thanks for this! Just what I needed :-)

hi someguy123 just a question when you edit the config.json file do you use your personal wif or the wif of your witness node ??

It is the active private key from the permissions page

Coin Marketplace

STEEM 0.17
TRX 0.16
JST 0.029
BTC 76073.33
ETH 2917.65
USDT 1.00
SBD 2.64