Author Topic: Setting Up a Price Feed [BTS Tools]  (Read 2076 times)

0 Members and 1 Guest are viewing this topic.

Offline DarkStar1O9

Thanks for the info, I had just created a smartcoin so needed this guide.

Offline sahkan

  • Sr. Member
  • ****
  • Posts: 247
    • View Profile
    • BitShares DEX
Setup your Ubuntu server:
https://bitsharestalk.org/index.php/topic,24005.0.html

Setup your bitShares node:
https://bitsharestalk.org/index.php/topic,23925.0.html

I did some testing, reading and browsing through different price feed scripts and ended up picking wackou's BTS Tools.
Here are some of the options:
Latest by xeroc: https://github.com/xeroc/bitshares-pricefeed
This one by Alt: https://pypi.python.org/pypi/btsprice
And wackou's BTS Tools:  https://pypi.python.org/pypi/bts_tools/0.4.10

You will need to create an api access file for BTS Tools to interact with your node so let's start with that:

SSH to your server
You will need to get a hash for your witness' password:
Code: [Select]
$ python bitshares-core/programs/witness_node/saltpass.py
enter your password (for example: supersecret) and you will get your hash & salt, like so:
 {
            "password_hash_b64" : "9e9GF7ooXVb9k4BoSfNIPTelXeGOZ5DrgOYMj94elaY=",
            "password_salt_b64" : "INDdM6iCi/8="
  }


Now move back to the directory where you want your api access file to be at, for example your home directory:
Code: [Select]
$cd
Create your api access file:
Code: [Select]
$nano api_access.jsonEnter:
{
   "permission_map" :
   [
      [
         "YOUR_WITNESS_NAME",
         {
            "password_hash_b64" : "9e9GF7ooXVb9k4BoSfNIPTelXeGOZ5DrgOYMj94elaY=",
            "password_salt_b64" : "INDdM6iCi/8=",
            "allowed_apis" : ["database_api", "network_broadcast_api", "history_api", "network_node_api"]
         }
      ]
   ]
}


Save & Exit.

Edit the node config file and add the location for your api access file:
Code: [Select]
$nano bitshares-core/witness_node_data_dir/config.ini
find:
api-access =
and modify:
api-access = /home/muLinuxUser/api_access.json

Save & exit

Installing BTS Tools:
Install dependencies:
Code: [Select]
$sudo apt-get install build-essential libyaml-dev python3-dev python3-pip
Install tools:
Code: [Select]
$ pip3 install bts_tools
Verify installed version: (it should also create a default config.yaml file for you):
Code: [Select]
$bts - version
Edit your config.yaml file:
Code: [Select]
$nano .bts_tools/config.yaml# For a more detailed description of the format of this file, visit:
# https://bts-tools.readthedocs.io/en/latest/config_format.html
#

# (OPTIONAL) will show this hostname as the source of notification messages
hostname: <your-host-name>

# the logging levels for the different submodules
# can be any of DEBUG, INFO, WARNING, ERROR
logging:
    bts_tools.feeds: INFO

# flags to be passed to make; shared among all build environments
make_args: ['-j4']

#
# list of clients (witness accounts / seed nodes) that are being monitored
#
clients:
    bts:
        type: bts
        data_dir: ~/.BitShares2
        witness_host: localhost
        witness_port: 8090
        # api_access.json should be created according to:
        # https://github.com/BitShares/bitshares-2#accessing-restricted-apis
        witness_user: YOUR_WITNESS      # as in api_access.json
        witness_password: supersecret  # as in api_access.json
        wallet_host: localhost
        wallet_port: 8093
        wallet_password: changeme!  # only needed for feed publishing
        notification: email
        roles:
        -
            role: witness
            name: xxxxxxxxx
            witness_id: 1.6.xxxx
            signing_key: 5xxxxxxxx
        -
            role: feed_publisher
            name: xxxxxxxx
 
#
# configuration of the monitoring plugins
# global default when not overriden by a role's specific params
#
monitoring:
    seed:
        desired_number_of_connections: 200
        maximum_number_of_connections: 400

    feeds:
        enabled_assets: [RUBLE, BTWTY, ALTCAP]
        disabled_assets: [RUB, SEK, GRIDCOIN, TCNY, CASH.BTC]  # black swan
        check_time_interval: 300
        median_time_span: 1800
        #publish_time_interval: 2400         # use this to publish feeds at fixed time intervals (in seconds)
        #publish_time_slot: 0                # use this to publish every hour at a fixed number of minutes (in minutes)
        feed_providers: [Poloniex, Btc38, Yunbi,    # BTS valuation
                         Yahoo, Google, Bloomberg]  # market indices

#
# configuration of the notification channels
#
notification:
    email:
        smtp_server: smtp.example.com
        smtp_user: user
        smtp_password: secret-password
        identity: "BTS Monitor <bts_monitor@example.com>"
        recipient: me@example.com

    boxcar:
        tokens: []

    telegram:
        token: 'xxxxxxxxxxxxxxxx'
        chat_id: 12341234


Save & exit
For production deployments, it is recommended to put it behind a WSGI server, in which case the entry point is bts_tools.wsgi:application
You can set it up according to wackou's docs:
https://bts-tools.readthedocs.io/en/latest/monitor.html

Start your witness node,
Start CLI, unlock it and import feed key for BTS Tools:
Code: [Select]
import_key "announce" 5KJJNfiSyzsbHoVb81WkHHjaX2vZVQ1Fqq5wE5ro8HWXe6qNFyQ
verify your signing key and witness info:
Code: [Select]
get_witness YOUR_WITNESS_NAME
run the BTS Tools monitor:
Code: [Select]
$bts monitor
and you are all set!

To update your BTS Tools to a new version:
Stop the monitor (CTRL-C) and upgrade:
Code: [Select]
$pip3 install --upgrade bts_tools
Edit config.yaml and adjust as required

Restart the monitor:
Code: [Select]
$bts monitor