Almost complete replacement for WavesDataFeed.
Waves Market Data (wmd) is a service that offers the HTTP API similar to WavesDataFeed's API, but lacks the WebSocket API.
The state of wmd could be build using initial import of a standard Waves blockchain file
or synchronizing with the mother-node's API (could take a long time).
wmd starts the HTTP API and runs the synchronization with the Waves node. From that node it gets the information about new
block, extracts transactions and builds historical market data in raw or candlestick formats.
- ➖ No WebSocket API
- ➖ No processing of UTX transactions
- ➕ Import of binary blockchain file
- 🍴 Better forks resolution
- 🌈 Support of mother-node's rollbacks
- 💰 Correct issuer's balances calculation
usage: wmd [flags]
-log-level Logging level. Supported levels: DEBUG, INFO, WARN, ERROR, FATAL. Default logging level INFO.
-import-file Path to binary blockchain file to import before starting synchronization.
-node Address of the node's gRPC API endpoint. Default value: 127.0.0.1:6870.
-sync-interval Synchronization interval, seconds. Default interval is 10 seconds.
-lag Synchronization lag behind the node, blocks. Default value 1 block.
-address Local network address to bind the HTTP API of the service on. Default value is :6990.
-db Path to data base folder. No default value.
-matcher Matcher's public key in form of Base58 string. Defaults to 7kPFrHDiGw1rCm7LPszuECwWYL3dMf6iMifLRDJQZMzy.
-scheme Blockchain scheme symbol. Defaults to 'W'.
-symbols Path to file of symbol substitutions. No default value.
-rollback The height to rollback to before importing a blockchain file or starting the synchronization. Default value is 0 (no rollback).
In simple case, then wmd runs on the same machine where the Waves node runs, it's should be provided with
parameters without default values only.
wmd -db /var/lib/wmd/db/ -symbols /var/lib/wmd/symbols.txtNote that you have to create all the folders and give correct permissions on them.
The example of symbols.txt file could be found at Github.
To quickly build the initial state of wmd, please, download the actual blockchain file
and execute the following command.
wmd -db /var/lib/wmd/db/ -symbols /var/lib/wmd/symbols.txt -import-file /home/user/Downloads/mainnet-1385453.dmsTo turn wmd executable into a systemd service we have to create a unit service file at /lib/systemd/system/wmd.service. The content of the file is shown below.
[Unit]
Description=WMD
ConditionPathExists=/usr/share/wmd
After=network.target
[Service]
Type=simple
User=wmd
Group=wmd
LimitNOFILE=1024
Restart=on-failure
RestartSec=10
startLimitIntervalSec=60
WorkingDirectory=/usr/share/wmd
ExecStart=/usr/share/wmd/wmd -db /var/lib/wmd/ -address 0.0.0.0:6990 -node grpc.wavesnodes.com:6870 -symbols /usr/share/wmd/symbols.txt -sync-interval 10
# make sure log directory exists and owned by syslog
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/log/wmd
ExecStartPre=/bin/chown syslog:adm /var/log/wmd
ExecStartPre=/bin/chmod 755 /var/log/wmd
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=wmd
[Install]
WantedBy=multi-user.target
Execute the following commands to create the user, and service file.
sudo useradd wmd -s /sbin/nologin -M
sudo mv wmd.service /lib/systemd/system/
sudo chmod 755 /lib/systemd/system/wmd.service
sudo mkdir /usr/share/wmd/
sudo chown wmd:wmd /usr/share/wmd
sudo mkdir /var/lib/wmd
sudo chown wmd:wmd /var/lib/wmd
sudo cp wmd /usr/share/wmd/
sudo cp symbols.txt /usr/share/wmd/To enable, start and stop the service use commands:
sudo systemctl enable wmd.service
sudo systemctl start wmd.service
sudo systemctl stop wmd.serviceTo check the logs use journalctl utility.
sudo journalctl -u wmd -fTo build WMD execute the command:
make release-wmdReturns the current status of the WMD. Status contains current height of WMD's state and the ID of the last block.
curl -X GET "http://localhost:6990/api/status" \
-H "Accept-Encoding: gzip, deflate"Returns the list of asset symbols.
curl -X GET "http://localhost:6990/api/symbols" \
-H "Accept-Encoding: gzip, deflate"Get the list of all markets with 24h stats.
curl -X GET "http://localhost:6990/api/markets" \
-H "Accept-Encoding: gzip, deflate"Get tickers for all markets.
curl -X GET "http://localhost:6990/api/tickers" \
-H "Accept-Encoding: gzip, deflate"Get ticker for a specified asset pair.
curl -X GET "http://localhost:6990/api/ticker/WAVES/BTC"Get last LIMIT confirmed trades for a specified asset pair.
curl -X GET "http://localhost:6990/api/trades/WAVES/BTC/10"Get trades within FROM_TIMESTAMP - TO_TIMESTAMP time range.
curl -X GET "http://localhost:6990/api/trades/WAVES/BTC/1495296000000/1495296280000"Get trades for a specified asset pair and address.
curl -X GET "http://localhost:6990/api/trades/WAVES/BTC/3PCfUovRHpCoGL54UakGBTSDEXTbmYMU3ib/10"Get last LIMIT candlesticks for the specified asset pair.
curl -X GET "http://localhost:6990/api/candles/WAVES/BTC/5/10"Get candlesticks within FROM_TIMESTAMP - TO_TIMESTAMP time range for the specified asset pair.
curl -X GET "http://localhost:6990/api/candles/WAVES/BTC/5/1495296000000/1495296280000"