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

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 git@github.com: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

H2
H3
H4
3 columns
2 columns
1 column
18 Comments
Ecency