Steem-Price-Feed | Script for Witness Price Feed Update using Coin Gecko Web Socket and API

in #utopian-io5 years ago

Repository

https://github.com/coingecko/steemprice-feed

Steem-Price-Feed (spf)

Steem price feed is a tool for witness for pulling price data from CoinGecko.com and publish the price feed. It used CoinGecko WebSocket for real time steem price and also REST API method as a fallback.

We recently launched our witness and we realize that most of the price feed tools are cron job written to check the price; therefore, we decided to write this script with our web socket, which means it will update price accurately instead of a cron job. The script will restart automatically on failure with docker or pm2.

Features
  • Using CoinGecko websocket to update Steem price feed on the fly.
  • In case websocket disconnected use CoinGecko REST API ``/simple/price` endpoint to update price and restart websocket.
  • Using Docker or PM2 approach to respawn the script on error.
  • Testing and CI to make sure that the code can be run on Node v8+.
  • Customizable env file for setting up websocket, price time out, and sensitivity.
  • SENSITIVITY allow price update only when the last update price change.
Technology Stack
  • Node.js
  • TypeScript
  • Docker
  • Jest (for testing)
  • DSteem
RoadMap
  • Fallback to Exchange data source.
  • Handle error properly.

How to use?

Prerequisite
  • Node.js (v8+)
  • Makefile installed (optional)
  • Docker (optional)
General step
  • git clone this repo git clone [email protected]:coingecko/steemprice-feed.git
  • cd steemprice-feed
  • edit .env.sample to .env (cp .env.sample .env then nano .env or vi .env)
ACTIVEKEY= # Steem Active Key (String)
WITNESS= # Steem Witness Username (String)
PEGMULTI=1 # Peg Multiple settings (Number) [default: 1]
WEBSOCKETTIMEOUT=10 # Time out in minutes for checking web socket (Number) [default: 10]
PRICETIMEOUT=5 # Time out in minutes for last price check (Number) [default: 5]
SENSITIVITY=0.001 # Sensitivity for the price update. (Float) [default: 0.001]
Docker
docker-compose build # Build the docker image
docker-compose up -d # Run the docker
docker-compose logs # to see log message
docker-compose logs --tail="all" # To see all logs
docker-compose down # To shut down docker
Without Docker (PM2)
  • Make sure Makefile are installed. Read Makefile for the full command being used.
  • run make init to install pm2 (skip this step if you already install pm2, and run npm install)
  • run make start (start the tool with pm2)

There is other command available as well:

  • To stop the price feed update, run make stop
  • To delete existing process running run make delete
  • To check log message, run make log
  • To check log message (last 1000), run make log-1000
Done!

You can check the log for more details. (either make log or docker-compose logs)

Contributing

This project is license with MIT, anyone can contribute and file bugs report at https://github.com/coingecko/steemprice-feed.

We had intergrated test and CI, therefore contributors need to make sure that the code are able to pass CI.

As @coingecko set out to be a Witness on Steem, we know that one of our offering is to utilize our expertise and infrastructure to make Steem Price Feed publishing easier for witnesses.

We look forward to contributing more to the Steem Community as well as Open Source. If you like what we're doing, we hope you can consider voting CoinGecko.com as Witness.

GitHub Account

https://github.com/coingecko

Sort:  

Looks great @coingecko!

It seems like you're doing frequent updates every time the price is changed. This looks like a little bit overkill since the markets are not that volatile.

Blockchain uses these publish_feed transactions by getting a median in 3.5 days. So, broadcasting a 0.001 change in the price with 2 minute intervals doesn't change much in the practice.

For example, let's check these updates:

Screen Shot 2019-02-05 at 10.54.51 AM.png

You have almost broadcasted the same price four times in seven minutes.

Also, since witnesses use these tools on the servers, it's always a better practice to use signing key to broadcast prices. (It's possible after HF20) Which is more secure in comparison storing an active key.


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

We are currently running older version of the script, the new version added SENSITIVITY

SENSITIVITY=0.000 # Sensitivity for the price update. (Float) [default: 0.000]

which will only update price when it passes a certain threshold

to solve this issue, will update the script once the holiday is over.

it's always a better practice to use signing key to broadcast prices.

true, will take note of that on the next version.

Thank you for your review, @emrebeyler! Keep up the good work!

Dear @coingecko

I was wondering if I could reach out to you via telegram?

I just realized a moment ago that you guys trying to become a witness. Perhaps I could help. Do you telegram? Hope we could get in touch closer and find a way to collaborate.

Yours
Piotr

Hi,

feel free to contact us directly via [email protected]

You can also join our Telegram group or Discord server too!

Your pricefeed is updating way too often, almost spammy. In general, set your pricefeed at least once per 24h. I recommend every 6h.

Hi @coingecko!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Keep up the Good work @coingecko .
We are here for you.
Much love for your efforts.

@coingecko Love your guys effort and teamwork - already voted you as one of my witnesses :)

Happy CNY to you guys and gals!

Yes I like well done you are doing best of luck thanks for updating coingecko

Dear brother @coingecko
I appreciate you and your team's contribution for steem community . I have already voted coingecko as witness.

Hi friends @coingecko I wish you all the best.
I appreciate your job.
I like it.
Thanks for update.👍

Posted using Partiko Android

Thanks for using eSteem!
Your post has been voted as a part of eSteem encouragement program. Keep up the good work! Install Android, iOS Mobile app or Windows, Mac, Linux Surfer app, if you haven't already!
Learn more: https://esteem.app
Join our discord: https://discord.gg/8eHupPq

Coin Marketplace

STEEM 0.37
TRX 0.12
JST 0.040
BTC 70162.45
ETH 3540.43
USDT 1.00
SBD 4.79