Git Product home page Git Product logo

bitshares-pricefeed's Introduction

Profile Views

Lines of code

๐Ÿฑ My Github Data

๐Ÿ† 3590 Contributions this year

๐Ÿ“ฆ 72.6 kB Used in Github's Storage

๐Ÿ’ผ Opted to Hire

๐Ÿ“œ 41 Public Repositories

๐Ÿ”‘ 64 Private Repositories

I'm an Early ๐Ÿค

๐ŸŒž Morning    564 commits    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   35.7% 
๐ŸŒ† Daytime    952 commits    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   60.25% 
๐ŸŒƒ Evening    64 commits     โ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   4.05% 
๐ŸŒ™ Night      0 commits      โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   0.0%

๐Ÿ“… I'm Most Productive on Tuesday

Monday       364 commits    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   23.04% 
Tuesday      415 commits    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   26.27% 
Wednesday    321 commits    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   20.32% 
Thursday     252 commits    โ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   15.95% 
Friday       201 commits    โ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   12.72% 
Saturday     13 commits     โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   0.82% 
Sunday       14 commits     โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   0.89%

I Mostly Code in Python

Python                   13 repos            โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   41.94% 
HTML                     4 repos             โ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   12.9% 
C++                      4 repos             โ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   12.9% 
TeX                      2 repos             โ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   6.45% 
CSS                      2 repos             โ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   6.45%

bitshares-pricefeed's People

Contributors

grctest avatar ryanrfox avatar wmbutler avatar xeroc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bitshares-pricefeed's Issues

KeyError: 'witness' - HERO feed

I have setup uptick and tested a transaction:

:~$uptick transfer ihashfury 1 BTS
{'expiration': '2017-09-10T15:54:31',
 'extensions': [],
 'operations': [[0,
                 {'amount': {'amount': 100000, 'asset_id': '1.3.0'},
                  'extensions': [],
                  'fee': {'amount': 21851, 'asset_id': '1.3.0'},
                  'from': '1.2.23043',
                  'to': '1.2.12687'}]],
 'ref_block_num': 5828,
 'ref_block_prefix': 3709539019}

:~$uptick info

+-----------------------------------+------------------------------------------+
| Key                               | Value                                    |
+-----------------------------------+------------------------------------------+
| accounts_registered_this_interval | 49                                       |
| current_aslot                     | 20055683                                 |
| current_witness                   | 1.6.76                                   |
| dynamic_flags                     | 0                                        |
| head_block_id                     | 013016ea44a4e9a8e6f5f52e6b2b0aa61759ef2a |
| head_block_number                 | 19928810                                 |
| id                                | 2.1.0                                    |
| last_budget_time                  | 2017-09-10T15:00:00                      |
| last_irreversible_block_num       | 19928788                                 |
| next_maintenance_time             | 2017-09-10T16:00:00                      |
| recent_slots_filled               | 340282366920938463463374607431768211455  |
| recently_missed_count             | 0                                        |
| time                              | 2017-09-10T15:55:54                      |
| witness_budget                    | 8500000                                  |
+-----------------------------------+------------------------------------------+

uptick working.

I have also installed bitshares-pricefeed and have a hero.yaml feed file:

# The RPC API node
node: wss://node.bitshares.eu

# If true, a new price feed needs manual confirmation
confirm: False

# The producer name(s)
producer: delegate.ihashfury


assets:
    HERO:
        # max age of a feed
        maxage: 43200

        # minimum percentage that forces a publish
        min_change: 0.5

        # warn if price change goes above this percentage
        warn_change: 1.5

        # skip publishing a feed if price goes above this percentage
        skip_change: 3

        # Basic Price setup
        ###################

        # We want to feed according to a formula
        type: formula

        # We want to refer to an internal asset
        reference: intern 

        # ... namely "USD" a.k.a. "bitUSD"
        ref_asset: USD

        # The formula:
        #####################################
        # * 5% gain since creation of Federal Reserve System on 23th of December 1913.
        # * (date.today() - date(1913, 12, 23)).days is the number of days since then
        # * 365.2425 is the average number of days per year (https://en.wikipedia.org/wiki/Year)
        # * rounded to 2 decimals
        # * relative to the USD price feed in BitShares
        #####################################
        formula: 1.05 ** ((date.today() - date(1913, 12, 23)).days / 365.2425) / {quoteSettlement_price}

        # Maximum short squeeze ratio
        maximum_short_squeeze_ratio: 110.0

        # maintenance collateral ratio (percentage)
        maintenance_collateral_ratio: 200.0

        # Core exchange factor for paying transaction fees in
        # non-BTS assets. Premium of 5%
        core_exchange_factor: 1.05

:~$ bitshares-pricefeed --configfile=/home/ihashfury/bts/pricefeeds/hero.yaml update HERO
after entering my passphrase I get tis error:

Traceback (most recent call last):
  File "/home/ihashfury/.local/bin/bitshares-pricefeed", line 11, in <module>
    sys.exit(main())
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/bitshares_pricefeed/ui.py", line 80, in new_func
    return ctx.invoke(f, *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/bitshares_pricefeed/ui.py", line 57, in new_func
    return ctx.invoke(f, *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/bitshares_pricefeed/ui.py", line 72, in new_func
    return ctx.invoke(f, *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/bitshares_pricefeed/cli.py", line 80, in update
    feed.derive(assets)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/bitshares_pricefeed/pricefeed.py", line 387, in derive
    self.obtain_price_change(symbol)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/bitshares_pricefeed/pricefeed.py", line 67, in obtain_price_change
    current_feed = self.get_my_current_feed(asset)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/bitshares_pricefeed/pricefeed.py", line 55, in get_my_current_feed
    if feed["witness"].witness == self.producer["id"]:
KeyError: 'witness'

BTS/CNY feed is off relative to BTS/USD

After some pretty basic calculations, it appears that your CNY calculation is heavily flawed. I went through the code but can't follow the logic.

+--------+------------+--------------+--------------+---------------------+---------------------+----------------------+--------------+----------------------+--------+--------+----------------------+---------------------+
| symbol | collateral |  new price   |     cer      |         mean        |        median       |      wgt. avg.       | wgt. std (#) |      blockchain      |  mssr  |  mcr   |    my last price     |     last update     |
+--------+------------+--------------+--------------+---------------------+---------------------+----------------------+--------------+----------------------+--------+--------+----------------------+---------------------+
|  GBP   |    BTS     | 0.0625304430 | 0.0656569651 | 0.0595669234 (4.98) | 0.0625304430 (0.00) | 0.0576336306 (8.50)  |  0.79 (60)   | 0.0628170735 (-0.46) | 110.0% | 175.0% | 0.0670462633 (-6.74) | 14:14:35.204235 ago |
|  USD   |    BTS     | 0.0816662452 | 0.0857495575 | 0.0816662452 (0.00) | 0.0816662452 (0.00) | 0.0816662452 (0.00)  |  0.00 ( 1)   | 0.0824159991 (-0.91) | 110.0% | 175.0% | 0.0845249894 (-3.38) | 14:14:29.303468 ago |
|  TRY   |    BTS     | 0.3177479207 | 0.3336353167 | 0.3026485896 (4.99) | 0.3177479207 (0.00) | 0.2928259577 (8.51)  |  4.01 (60)   | 0.3222144045 (-1.39) | 110.0% | 175.0% | 0.3411752928 (-6.87) | 14:14:26.402634 ago |
|  CAD   |    BTS     | 0.1043448373 | 0.1095620792 | 0.0993849601 (4.99) | 0.1043448373 (0.00) | 0.0961593951 (8.51)  |  1.32 (60)   | 0.1052701491 (-0.88) | 110.0% | 175.0% | 0.1117687230 (-6.64) | 14:14:38.501839 ago |
|  MXN   |    BTS     | 1.5688823519 | 1.6473264695 | 1.4939024084 (5.02) | 1.5688823519 (0.00) | 1.4454167902 (8.54)  |  19.80 (60)  | 1.5818809981 (-0.82) | 110.0% | 175.0% | 1.6840551181 (-6.84) | 14:14:44.601015 ago |
|  JPY   |    BTS     | 9.3175830510 | 9.7834622035 | 8.8749072189 (4.99) | 9.3175830510 (0.00) | 8.5868714863 (8.51)  | 117.62 (90)  | 9.3505787956 (-0.35) | 110.0% | 175.0% | 9.9729729730 (-6.57) | 14:14:47.700147 ago |
| RUBLE  |    BTS     | 4.8864713175 | 5.1307948834 | 4.6554199689 (4.96) | 4.8864713175 (0.00) | 4.5043802523 (8.48)  |  61.72 (60)  | 5.0575516842 (-3.38) | 110.0% | 175.0% | 5.2258296176 (-6.49) | 14:14:53.799999 ago |
|  CHF   |    BTS     | 0.0815972341 | 0.0856770958 | 0.0776985801 (5.02) | 0.0815972341 (0.00) | 0.0751771527 (8.54)  |  1.03 (60)   | 0.0817862464 (-0.23) | 110.0% | 175.0% | 0.0875474083 (-6.80) | 14:14:32.899237 ago |
|  AUD   |    BTS     | 0.1074076217 | 0.1127780027 | 0.1022953996 (5.00) | 0.1074076217 (0.00) | 0.0989748166 (8.52)  |  1.36 (60)   | 0.1081220077 (-0.66) | 110.0% | 175.0% | 0.1150904920 (-6.68) | 14:14:59.998345 ago |
|  BTC   |    BTS     | 0.0000129530 | 0.0000136006 | 0.0000126621 (2.30) | 0.0000129530 (0.00) | 0.0000116013 (11.65) |  0.00 (19)   | 0.0000124032 (4.43)  | 110.0% | 175.0% | 0.0000122074 (6.11)  | 14:14:57.097502 ago |
|  CNY   |    BTS     | 0.5066087100 | 0.5319391455 | 0.5066087100 (0.00) | 0.5066087100 (0.00) | 0.5103365741 (-0.73) |  0.57 ( 2)   | 0.5419346622 (-6.52) | 110.0% | 175.0% | 0.5211226429 (-2.79) | 14:14:42.196564 ago |
|  EUR   |    BTS     | 0.0701477364 | 0.0736551232 | 0.0670469616 (4.62) | 0.0701477364 (0.00) | 0.0646981626 (8.42)  |  0.88 (134)  | 0.0699471854 (0.29)  | 110.0% | 175.0% | 0.0699471854 (0.29)  | 14:14:51.196722 ago |
+--------+------------+--------------+--------------+---------------------+---------------------+----------------------+--------------+----------------------+--------+--------+----------------------+---------------------+

screen shot 2017-11-14 at 11 14 33 am

.081666 / .15 = .05444

But your feed for bts/cny is showing as: .5066

CER for external assets are not calculating properly

A recent update of the CER calculations for internal markets was also applied to the external markets using the get_cer(self, symbol, price) method. However, self.config["assets"][symbol] is not iterable for external assets when called, so the if statement(s) within the method will not evaluate.

Wrong prices displayed on summary for formula assets

If I run HERTZ.yaml (after fixing #37), I have inconsistent information displayed on the console:

$ python3 cli.py --configfile bitshares_pricefeed/examples/hertz.yaml update

+--------+------------+--------------+--------------+------------------------+------------------------+------------------------+--------------+------------------------+--------+--------+-------------------------+-------------+
| symbol | collateral |  new price   |     cer      |          mean          |         median         |       wgt. avg.        | wgt. std (#) |       blockchain       |  mssr  |  mcr   |      my last price      | last update |
+--------+------------+--------------+--------------+------------------------+------------------------+------------------------+--------------+------------------------+--------+--------+-------------------------+-------------+
| HERTZ  |    BTS     | 4.7511676181 | 0.2525694937 | 0.2104745781 (2157.36) | 0.2104745781 (2157.36) | 0.2104745781 (2157.36) |  0.00 ( 1)   | 0.2262904320 (1999.59) | 110.0% | 200.0% | -1.0000000000 (-575.12) | unknown ago |
+--------+------------+--------------+--------------+------------------------+------------------------+------------------------+--------------+------------------------+--------+--------+-------------------------+-------------+

As you can see new price = 4.7511676181 and cer = 0.2525694937, it seems inverted.

Default.yaml contains outdated settings

Openexchangerates & Currencylayer both have "base:" rather than "bases" set
Bitrix is set to True, but they are not currently providing a market for BTS/BTC
btcavg is listed twice within sources

Feed Errors

BitcoinAverage We encountered an error loading live data. Trying to recover from cache! (
Error fetching results from BitcoinAverage! (HTTPSConnectionPool(host='api.bitcoinaverage.com', port=443): Max retries exceeded with url: /ticker/USD (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd98dc263c8>: Failed to establish a new connection: [Errno -2] Name or service not known',))))

Google We encountered an error loading live data. Trying to recover from cache! (
Error fetching results from Google! (division by zero))

Exiting due to exchange importance on Google!

Coinmarketcap We encountered an error loading live data. Trying to recover from cache! (list index out of range)

BtcChina We encountered an error loading live data. Trying to recover from cache! (
Error fetching results from BtcChina! (float() argument must be a string or a number, not 'NoneType'))

Fetched data from ChBTC is empty!

Yunbi We encountered an error loading live data. Trying to recover from cache! (
Error fetching results from Yunbi! (Expecting value: line 1 column 1 (char 0)))

Btc38 We encountered an error loading live data. Trying to recover from cache! (
Error fetching results from Btc38! (Expecting value: line 1 column 1 (char 0)))

Huobi We encountered an error loading live data. Trying to recover from cache! (
Error fetching results from Huobi! (Expecting value: line 1 column 1 (char 0)))

Update error: Assert Exception: o.feed.core_exchange_rate.quote.asset_id == asset_id_type()

Hi,

I have created a new user-issued SmartCoin, called MYASSET below. I am trying to publish a price feed. My asset is using USD as the short backing store and I want to calculate my own price values so I am using a formula update with a constant number (2 as noted below). My account is not a witness or a lifetime member, but it is the issuer of the asset.

I am seeing an error for which I cannot find any documentation. I see a confirmation prompt and then get the error below. I have included the output of running bitshare-pricefeed update. I have also tried to configure this publish call using pybitshares and see the same error.

Can you please help?

Price change for MYASSET (inf) has been above 'skip_change'. Please confirm to still publish, else feed will be skipped! [y/N]: y

Traceback (most recent call last):
  File "/home/abagher/.local/lib/python3.5/site-packages/bitsharesapi/bitsharesnoderpc.py", line 42, in rpcexec
    return super(BitSharesNodeRPC, self).rpcexec(payload)
  File "/home/abagher/.local/lib/python3.5/site-packages/graphenelib-0.5.5-py3.5.egg/grapheneapi/graphenewsrpc.py", line 160, in rpcexec
grapheneapi.graphenewsrpc.RPCError: Assert Exception: o.feed.core_exchange_rate.quote.asset_id == asset_id_type(): 

During handling of the above exception, another exception occurred:
File "/home/abagher/.local/bin/bitshares-pricefeed", line 11, in <module>
    sys.exit(main())
  File "/home/abagher/.local/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/abagher/.local/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)

<long stack trace ommitted >

  File "/home/abagher/.local/lib/python3.5/site-packages/graphenelib-0.5.5-py3.5.egg/grapheneapi/graphenewsrpc.py", line 195, in method
  File "/home/abagher/.local/lib/python3.5/site-packages/bitsharesapi/bitsharesnoderpc.py", line 50, in rpcexec
    raise exceptions.UnhandledRPCError(msg)
bitsharesapi.exceptions.UnhandledRPCError: Assert Exception: o.feed.core_exchange_rate.quote.asset_id == asset_id_type():
Assert Exception: o.feed.core_exchange_rate.quote.asset_id == asset_id_type():

My configuration file is here.

config.yml

# This is an example configuration file that might need modifications
# to properly run in your environment
#
# API KEYS
##########
# Some services require you to obtain an API key and provide it here in
# the configuration:
#
#     * OpenExchangeRates (has a free subscription)
#     * Currencylayer (has a a free subscription)
#     * Quandl (has a a free subscription)
#     * BitcoinAverage (has a a free subscription)
#     
# The corresponding variables can be defined in the `exchanges` key.


# If true, a new price feed needs manual confirmation
confirm: True

# The producer name(s)
producer: MYACCOUNT

# Exchange settings (Here, you may need to add API keys)
exchanges:

        
# default settings
default:

    # Type: extern, formula, alias
    type: extern

    # reference is only required if type==formula
    # if extern: formula may contain 
    #    *  {USD[weighted]}
    #    *  {USD[median]}
    #    *  {USD[mean]}   or other assets than USD
    #    with values derived from external exchanges
    #
    # reference: extern

    # if formula: settlement price can be taken from chain
    #    accessible values are:
    #    * {core_exchange_rate}
    #    * {quoteSettlement_price}
    #    * {latest}
    #    while the asset needs to be defined with ref_asset
    #
    # ref_asset: USD
    # formula: 100 * {quoteSettlement_price}
    #
    # if alias: Alias allows to change the name of the asset wrt to
    #    external sources. E.g.:
    #       SMART.USD:
    #           type: alias
    #           alias: USD
    #
    # alias: USD

    # max age of a feed
    maxage: 43200

    # minimum percentage that forces a publish
    min_change: 0.5

    # warn if price change goes above this percentage
    warn_change: 1.5

    # skip publishing a feed if price goes above this percentage
    skip_change: 3

    # how to derive a single price from several sources
    # Choose from: "median", "mean", or "weighted" (by volume)
    metric: weighted

    # Core exchange factor for paying transaction fees in
    # non-BTS assets. Premium of 5%
    core_exchange_factor: 1.05

    # maintenance collateral ratio (percentage)
    maintenance_collateral_ratio: 175.0

    # Maximum short squeeze ratio
    maximum_short_squeeze_ratio: 110.0

    # If set to True, prices are also derived via 3
    # markets instead of just two:
    # E.g.: GOLD:USD -> USD:BTC -> BTC:BTS = GOLD:BTS
    derive_across_3markets: False


# Enabled assets that are derived if no asset is provided via command
# line
assets:
    MYASSET:
        # We want to feed according to a formula
        type: formula

        # We want to refer to an internal asset
        reference: intern 

        # ... namely "USD" a.k.a. "bitUSD"
        ref_asset: MYASSET
        formula: "2"
    # ARS:

# Intermediate assets are useful for 2 and 3 market price derivation
# E.g.: USD:BTC -> BTC:BTS = USD:BTS
#       GOLD:USD -> USD:BTC -> BTC:BTS = GOLD:BTS
intermediate_assets:
    - CNY
    - USD
    - BTC

Hero

I am still confused by this price script.

Results from:
formula: 1.05 ** ((date.today() - date(1913, 12, 23)).days / 365.2425) / {quoteSettlement_price}

+--------+------------+---------------+---------------+----------------------+----------------------+----------------------+--------------+---------------------------+--------+--------+---------------------------+-----------------------------+
| symbol | collateral |   new price   |      cer      |         mean         |        median        |      wgt. avg.       | wgt. std (#) |         blockchain        |  mssr  |  mcr   |       my last price       |         last update         |
+--------+------------+---------------+---------------+----------------------+----------------------+----------------------+--------------+---------------------------+--------+--------+---------------------------+-----------------------------+
|  HERO  |    BTS     | 13.5762835227 | 14.2550976988 | 13.5762835227 (0.00) | 13.5762835227 (0.00) | 13.5762835227 (0.00) |  0.00 ( 1)   | 0.0005311489 (2555921.97) | 110.0% | 200.0% | 0.0006979593 (1945039.62) | 64 days, 3:35:17.123215 ago |
+--------+------------+---------------+---------------+----------------------+----------------------+----------------------+--------------+---------------------------+--------+--------+---------------------------+-----------------------------+
[Alert] Price change for HERO (-99.994859) has been above 'skip_change'. Please confirm to still publish, else feed will be skipped! [y/N]: ^CAborted!

Results from:
formula: 1.05 ** ((date.today() - date(1913, 12, 23)).days / 365.2425) * {quoteSettlement_price}

+--------+------------+-----------------+-----------------+------------------------+------------------------+------------------------+--------------+-----------------------------+--------+--------+-----------------------------+-----------------------------+
| symbol | collateral |    new price    |       cer       |          mean          |         median         |       wgt. avg.        | wgt. std (#) |          blockchain         |  mssr  |  mcr   |        my last price        |         last update         |
+--------+------------+-----------------+-----------------+------------------------+------------------------+------------------------+--------------+-----------------------------+--------+--------+-----------------------------+-----------------------------+
|  HERO  |    BTS     | 1855.9413933188 | 1948.7384629847 | 1855.9413933188 (0.00) | 1855.9413933188 (0.00) | 1855.9413933188 (0.00) |  0.00 ( 1)   | 0.0005369790 (345626310.85) | 110.0% | 200.0% | 0.0006979593 (265909574.57) | 64 days, 3:38:58.113590 ago |
+--------+------------+-----------------+-----------------+------------------------+------------------------+------------------------+--------------+-----------------------------+--------+--------+-----------------------------+-----------------------------+
[Alert] Price change for HERO (-99.999962) has been above 'skip_change'. Please confirm to still publish, else feed will be skipped! [y/N]: ^CAborted!

Resolve Google error/warning

Google We encountered an error loading live data. Trying to recover from cache! (
Error fetching results from Google! (could not convert string to float: 'c){var d=Ya;return Object.prototype.hasOwnProperty.call(d'))

HERTZ Algorithm Based Asset price feed script request

Hey,

I've created a new algorithm based asset (FBA/MPA) called HERTZ which oscillates the price feed using a sin wave: https://bitsharestalk.org/index.php/topic,24161.msg306505.html

I'd appreciate support in your price feeds, so that more witnesses will be able to provide feeds.

https://openledger.io/asset/HERTZ/
http://cryptofresh.com/a/HERTZ


Replicated post from above thread:

Existing haskell price feed script: https://github.com/grctest/HERTZ-Price-feed-script/

Reference hero file: https://github.com/xeroc/bitshares-pricefeed/blob/master/bitshares_pricefeed/examples/hero.yaml

hero formula (line 41):
formula: 1.05 ** ((date.today() - date(1913, 12, 23)).days / 365.2425) / {quoteSettlement_price}

The haskell script could be replicated in python, or we could use the haskell script to precompute a large CSV of blocknumbers to modify the latest price feed value with.
formula: quoteSettlement_price + read_CSV_For_Wave_Value(BlockNumber)

The python price feed script uses time/dates instead of block numbers, so perhaps there will be a difference in computed values between haskell and python.

python implementation? (I don't know python)

import math
import date

quoteSettlement_price = XDR
Time_In_Period = one month duration
amplitude = 0.5

x_value = remainder of (((date.today() - date(Asset_Genesis_Date_Timestamp))/Time_In_Period)/1.00))  // to return 0.xx

feed_price = quoteSettlement_price + (((quoteSettlement_price * amplitude)*(sin((x_value * Time_In_Period)) * ((2*math.pi)/Time_In_Period) ))))

[Hero & Hertz] 'bitshares-pricefeed' referencing bitUSD | BTS_Tools referencing BTC:USD (bitUSD|BTC:USD)

Summarized snippets of Wackou's price feed script:

btc_price = feeds_bts_btc.price()

feeds_btc_usd = get_multi_feeds('get', [('BTC', 'USD')],
                                active_providers_bts({providers.BitcoinAverage,
                                                      providers.CoinMarketCap,
                                                      providers.Bitfinex,
                                                      providers.Bitstamp}))
btc_usd = feeds_btc_usd.price()
usd_price = btc_price * btc_usd
feeds['HERO'] = usd_price / (1.05 ** ((pendulum.today() - pendulum.Pendulum(1913, 12, 23)).in_days() / 365.2425))

Current Hero&Hertz Yaml USD reference:

# ... namely "USD" a.k.a. "bitUSD"
ref_asset: USD

There's a difference in price BTS:USD reference between the two Bitshares price feed libraries. @xeroc's scripts reference bitUSD (decentralized, reliant on bitUSD functioning properly, less volatile?) meanwhile @wackou's price feed scripts reference external BTC:USD price feeds (Reliant on centralized exchanges, potentially vulnerable to manipulation, potentially avoid following bitUSD into a blackswan).

What's the appropriate USD reference for Hero (and consequentially Hertz) bitUSD:BTS and/or BTC:USD?

Cheers

Remove closed exchanges.

Following end of 2017 China ban of crypto exchanges, many exchange have closed.

At least those sources are impacted:

  • BTC38 (API/website down),
  • BTCChina (API/website down),
  • Yunbi (API/Website down)
  • BTer (API/Website down)
  • ChBTC? (API still respond, but data seems old)

Volume bug

For many asset pairs, the volume is not correct, in fact, it appears that the price is being substituted for volume.

--------+-------+----------------+--------+------------------------+-------------------------------+
| base   | quote | price          | diff   | volume                 | source                        |
+--------+-------+----------------+--------+------------------------+-------------------------------+
| SEK    | BTS   | 1.9123072829   | -1.82  | 1.9123072828519956     | ['bitshares', 'fixer']        |
| SEK    | BTS   | 1.9830552930   | +1.82  | 1.983055293            | ['coinmarketcap', 'fixer']    |
| CAD    | BTS   | 0.2975642363   | -1.82  | 0.29756423631963025    | ['bitshares', 'fixer']        |
| CAD    | BTS   | 0.3085813179   | +1.82  | 0.3085813179           | ['coinmarketcap', 'fixer']    |
| EUR    | BTS   | 0.1922905356   | -3.53  | 0.19229053564952653    | ['bitshares', 'fixer']        |
| EUR    | BTS   | 0.1922869229   | -3.53  | 0.19228692289494279    | ['bitshares', 'fixer']        |
| EUR    | BTS   | 0.1994060132   | +0.04  | 0.1994060131997067     | ['coinmarketcap', 'fixer']    |
| EUR    | BTS   | 0.1994068188   | +0.04  | 0.1994068188           | ['coinmarketcap', 'fixer']    |
| EUR    | BTS   | 0.1997789661   | +0.23  | 0.1997789661           | ['poloniex', 'btcavg']        |
| EUR    | BTS   | 0.1993741455   | +0.03  | 0.19937414550000002    | ['zb', 'btcavg']              |
| EUR    | BTS   | 0.1984970342   | -0.41  | 0.1984970342           | ['coinmarketcap', 'btcavg']   |
| EUR    | BTS   | 0.2044344030   | +2.56  | 0.20443440300000001    | ['aex', 'btcavg']             |
| EUR    | BTS   | 0.1990367950   | -0.14  | 0.199036795            | ['lbank', 'btcavg']           |
| EUR    | BTS   | 0.1998523989   | +0.27  | 0.19985239889999998    | ['poloniex', 'bitstamp']      |
| EUR    | BTS   | 0.1994474295   | +0.06  | 0.1994474295           | ['zb', 'bitstamp']            |
| EUR    | BTS   | 0.1985699958   | -0.38  | 0.19856999579999998    | ['coinmarketcap', 'bitstamp'] |
| EUR    | BTS   | 0.2045095470   | +2.60  | 0.204509547            | ['aex', 'bitstamp']           |
| EUR    | BTS   | 0.1991099550   | -0.11  | 0.19910995499999998    | ['lbank', 'bitstamp']         |
| EUR    | BTS   | 0.1997789661   | +0.23  | 0.1997789661           | ['poloniex', 'btcavg']        |
| EUR    | BTS   | 0.1993741455   | +0.03  | 0.19937414550000002    | ['zb', 'btcavg']              |
| EUR    | BTS   | 0.1984970342   | -0.41  | 0.1984970342           | ['coinmarketcap', 'btcavg']   |
| EUR    | BTS   | 0.2044344030   | +2.56  | 0.20443440300000001    | ['aex', 'btcavg']             |
| EUR    | BTS   | 0.1990367950   | -0.14  | 0.199036795            | ['lbank', 'btcavg']           |
| CNY    | BTS   | 1.4875980419   | -3.30  | 20040519.356079545     | ['bitshares']                 |
| CNY    | BTS   | 1.5426815431   | +0.28  | 1.5426815431164902     | ['coinmarketcap', 'fixer']    |
| CNY    | BTS   | 1.5426373854   | +0.28  | 1.5426373854           | ['coinmarketcap', 'fixer']    |
| CNY    | BTS   | 1.5391186209   | +0.05  | 1.5391186209           | ['poloniex', 'btcavg']        |
| CNY    | BTS   | 1.5359998395   | -0.15  | 1.5359998395           | ['zb', 'btcavg']              |
| CNY    | BTS   | 1.5292424798   | -0.59  | 1.5292424798           | ['coinmarketcap', 'btcavg']   |
| CNY    | BTS   | 1.5749846070   | +2.38  | 1.5749846070000002     | ['aex', 'btcavg']             |
| CNY    | BTS   | 1.5334008550   | -0.32  | 1.533400855            | ['lbank', 'btcavg']           |
| CNY    | BTS   | 1.5391186209   | +0.05  | 1.5391186209           | ['poloniex', 'btcavg']        |
| CNY    | BTS   | 1.5359998395   | -0.15  | 1.5359998395           | ['zb', 'btcavg']              |
| CNY    | BTS   | 1.5292424798   | -0.59  | 1.5292424798           | ['coinmarketcap', 'btcavg']   |
| CNY    | BTS   | 1.5749846070   | +2.38  | 1.5749846070000002     | ['aex', 'btcavg']             |
| CNY    | BTS   | 1.5334008550   | -0.32  | 1.533400855            | ['lbank', 'btcavg']           |
| TRY    | BTS   | 0.9031951511   | -1.82  | 0.9031951511346472     | ['bitshares', 'fixer']        |
| TRY    | BTS   | 0.9366100101   | +1.82  | 0.9366100101000001     | ['coinmarketcap', 'fixer']    |
| SGD    | BTS   | 0.3138385589   | -1.82  | 0.31383855889792717    | ['bitshares', 'fixer']        |
| SGD    | BTS   | 0.3254432838   | +1.82  | 0.32544328380000004    | ['coinmarketcap', 'fixer']    |
| GOLD   | BTS   | 0.0001859587   | +0.00  | 0.00018595874016944647 | ['coinmarketcap', 'quandl']   |
| CHF    | BTS   | 0.2211314489   | -1.82  | 0.22113144892722608    | ['bitshares', 'fixer']        |
| CHF    | BTS   | 0.2293178416   | +1.82  | 0.22931784162000002    | ['coinmarketcap', 'fixer']    |
| AUD    | BTS   | 0.3022947981   | -1.82  | 0.3022947980928464     | ['bitshares', 'fixer']        |
| AUD    | BTS   | 0.3134759379   | +1.82  | 0.3134759379           | ['coinmarketcap', 'fixer']    |
| GBP    | BTS   | 0.1706423714   | -1.82  | 0.1706423713854161     | ['bitshares', 'fixer']        |
| GBP    | BTS   | 0.1769527495   | +1.82  | 0.17695274954999998    | ['coinmarketcap', 'fixer']    |
| MXN    | BTS   | 4.4406289149   | -1.82  | 4.4406289148514135     | ['bitshares', 'fixer']        |
| MXN    | BTS   | 4.6048584960   | +1.82  | 4.604858495999999      | ['coinmarketcap', 'fixer']    |
| NZD    | BTS   | 0.3259773589   | -1.81  | 0.3259773589197649     | ['bitshares', 'fixer']        |
| NZD    | BTS   | 0.3380224572   | +1.81  | 0.3380224572           | ['coinmarketcap', 'fixer']    |
| JPY    | BTS   | 25.6878429874  | -1.82  | 25.687842987388766     | ['bitshares', 'fixer']        |
| JPY    | BTS   | 25.6881029510  | -1.82  | 25.688102950990626     | ['bitshares', 'fixer']        |
| JPY    | BTS   | 26.6389693500  | +1.82  | 26.638969349999996     | ['coinmarketcap', 'fixer']    |
| JPY    | BTS   | 26.6385475286  | +1.82  | 26.638547528599887     | ['coinmarketcap', 'fixer']    |
| RUBLE  | BTS   | 13.7498687012  | -1.82  | 13.74986870120653      | ['bitshares', 'fixer']        |
| RUBLE  | BTS   | 14.2587622530  | +1.82  | 14.258762252999999     | ['coinmarketcap', 'fixer']    |
| BTC    | BTS   | 0.0000296100   | +1.30  | 6662576.1617381        | ['poloniex']                  |
| BTC    | BTS   | 0.0000295500   | +1.09  | 1326355.0              | ['zb']                        |
| BTC    | BTS   | 0.0000294200   | +0.65  | 703089734874.2352      | ['coinmarketcap']             |
| BTC    | BTS   | 0.0000303000   | +3.66  | 2117488.980771         | ['aex']                       |
| BTC    | BTS   | 0.0000295000   | +0.92  | 48564.0094             | ['lbank']                     |
| BTC    | BTS   | 0.0000286188   | -2.09  | 2.8618832507309437e-05 | ['bitshares', 'btcavg']       |
| BTC    | BTS   | 0.0000286188   | -2.09  | 2.8618832507309437e-05 | ['bitshares', 'btcavg']       |
| BTC    | BTS   | 0.0000296196   | +1.33  | 2.9619593172501686e-05 | ['coinmarketcap', 'btcavg']   |
| BTC    | BTS   | 0.0000296644   | +1.48  | 2.9664363636363635e-05 | ['coinmarketcap', 'bitstamp'] |
| BTC    | BTS   | 0.0000296196   | +1.33  | 2.9619593172501686e-05 | ['coinmarketcap', 'btcavg']   |
| BTC    | BTS   | 0.0000270215   | -7.56  | 2.702152725714898e-05  | ['coinmarketcap', 'okcoin']   |
| KRW    | BTS   | 256.9379337956 | -1.82  | 256.9379337955633      | ['bitshares', 'fixer']        |
| KRW    | BTS   | 266.4386397000 | +1.82  | 266.4386397            | ['coinmarketcap', 'fixer']    |
| SILVER | BTS   | 0.0149636808   | +0.00  | 0.014963680831549985   | ['coinmarketcap', 'quandl']   |
| HKD    | BTS   | 1.8457009379   | -1.82  | 1.8457009378543727     | ['bitshares', 'fixer']        |
| HKD    | BTS   | 1.8456628906   | -1.82  | 1.8456628905752397     | ['bitshares', 'fixer']        |
| HKD    | BTS   | 1.9140544345   | +1.82  | 1.9140544345377757     | ['coinmarketcap', 'fixer']    |
| HKD    | BTS   | 1.9139922048   | +1.82  | 1.9139922048           | ['coinmarketcap', 'fixer']    |
| USD    | BTS   | 0.2447310000   | -1.88  | 20684900.0             | ['coinmarketcap']             |
| USD    | BTS   | 0.2359925534   | -5.38  | 0.23599255336572583    | ['bitshares', 'fixer']        |
| USD    | BTS   | 0.2359993086   | -5.38  | 0.23599930860993548    | ['bitshares', 'fixer']        |
| USD    | BTS   | 0.2446517367   | -1.91  | 0.24465173669999998    | ['poloniex', 'btcavg']        |
| USD    | BTS   | 0.2441559885   | -2.11  | 0.24415598849999998    | ['zb', 'btcavg']              |
| USD    | BTS   | 0.2430818674   | -2.54  | 0.24308186739999998    | ['coinmarketcap', 'btcavg']   |
| USD    | BTS   | 0.2503528410   | +0.37  | 0.250352841            | ['aex', 'btcavg']             |
| USD    | BTS   | 0.2437428650   | -2.28  | 0.24374286499999998    | ['lbank', 'btcavg']           |
| USD    | BTS   | 0.2442825000   | -2.06  | 0.24428249999999999    | ['poloniex', 'bitstamp']      |
| USD    | BTS   | 0.2437875000   | -2.26  | 0.2437875              | ['zb', 'bitstamp']            |
| USD    | BTS   | 0.2427150000   | -2.69  | 0.242715               | ['coinmarketcap', 'bitstamp'] |
| USD    | BTS   | 0.2499750000   | +0.22  | 0.249975               | ['aex', 'bitstamp']           |
| USD    | BTS   | 0.2433750000   | -2.42  | 0.24337499999999998    | ['lbank', 'bitstamp']         |
| USD    | BTS   | 0.2446517367   | -1.91  | 0.24465173669999998    | ['poloniex', 'btcavg']        |
| USD    | BTS   | 0.2441559885   | -2.11  | 0.24415598849999998    | ['zb', 'btcavg']              |
| USD    | BTS   | 0.2430818674   | -2.54  | 0.24308186739999998    | ['coinmarketcap', 'btcavg']   |
| USD    | BTS   | 0.2503528410   | +0.37  | 0.250352841            | ['aex', 'btcavg']             |
| USD    | BTS   | 0.2437428650   | -2.28  | 0.24374286499999998    | ['lbank', 'btcavg']           |
| USD    | BTS   | 0.2681745129   | +7.52  | 0.2681745129           | ['poloniex', 'okcoin']        |
| USD    | BTS   | 0.2676310995   | +7.30  | 0.26763109949999997    | ['zb', 'okcoin']              |
| USD    | BTS   | 0.2664537038   | +6.83  | 0.2664537038           | ['coinmarketcap', 'okcoin']   |
| USD    | BTS   | 0.2744237670   | +10.02 | 0.274423767            | ['aex', 'okcoin']             |
| USD    | BTS   | 0.2671782550   | +7.12  | 0.267178255            | ['lbank', 'okcoin']     

Console messages for troubleshooting

Bill Butler, [04.11.17 12:05]
I would like to know why there is a 3-4 minute delay on the script.

  • Some messages would be nice to help troubleshoot, like:
Checking Google...success|fail (30ms)
Checking Yahoo...success|fail (300ms)

Bill Butler, [04.11.17 12:06]
Even calling all those API's the script shouldn't take more than 15-20 seconds to complete.

JS Port/Maintenance/Feed Sources

Seeing as this is not heavily maintained and my python skills are limited, I am porting the entire thing over to node/JS (about 80% done).

I am using this issue to notify users that it will be published on github soon and also to gather feedback & feature requests to be implemented on my port as well as new Feed sources.

I would also appreciate if people could notify me of sources that no longer work (e.g. I believe AEX api no longer works)

ValueError: Price for ARS has not yet been derived

BitcoinAverage We encountered an error loading live data. Trying to recover from cache! (
Error fetching results from BitcoinAverage! (key: expected bytes or bytearray, but got 'NoneType'))

Google We encountered an error loading live data. Trying to recover from cache! (
Error fetching results from Google! (could not convert string to float: 'c){var d=Ya;return Object.prototype.hasOwnProperty.call(d'))
'backing_symbol' not in self.price[alias]
Traceback (most recent call last):
File "/home/ubuntu/.local/bin/bitshares-pricefeed", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/bitshares_pricefeed/ui.py", line 18, in new_func
return ctx.invoke(f, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/uptick/decorators.py", line 50, in new_func
return ctx.invoke(f, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/uptick/decorators.py", line 77, in new_func
return ctx.invoke(f, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/uptick/decorators.py", line 98, in new_func
return ctx.invoke(f, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/bitshares_pricefeed/cli.py", line 88, in update
feed.derive(assets)
File "/home/ubuntu/.local/lib/python3.5/site-packages/bitshares_pricefeed/pricefeed.py", line 400, in derive
self.obtain_price_change(symbol)
File "/home/ubuntu/.local/lib/python3.5/site-packages/bitshares_pricefeed/pricefeed.py", line 66, in obtain_price_change
raise ValueError("Price for %s has not yet been derived" % symbol)
ValueError: Price for ARS has not yet been derived

Launch Error

OS: Ubuntu xenial
Python:

ubuntu@ip-172-31-51-77:~$ python3 --version
Python 3.5.2
ubuntu@ip-172-31-51-77:~$ bitshares-pricefeed create
Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/bitshares-pricefeed", line 7, in <module>
    from bitshares_pricefeed.cli import main
  File "/home/ubuntu/.local/lib/python3.5/site-packages/bitshares_pricefeed/cli.py", line 7, in <module>
    from bitshares.price import Price
  File "/home/ubuntu/.local/lib/python3.5/site-packages/bitshares/__init__.py", line 1, in <module>
    from .bitshares import BitShares
  File "/home/ubuntu/.local/lib/python3.5/site-packages/bitshares/bitshares.py", line 9, in <module>
    from bitsharesbase import transactions, operations
  File "/home/ubuntu/.local/lib/python3.5/site-packages/bitsharesbase/transactions.py", line 3, in <module>
    from .signedtransactions import Signed_Transaction
  File "/home/ubuntu/.local/lib/python3.5/site-packages/bitsharesbase/signedtransactions.py", line 2, in <module>
    from .operations import Operation
  File "/home/ubuntu/.local/lib/python3.5/site-packages/bitsharesbase/operations.py", line 10, in <module>
    from .objects import GrapheneObject, isArgsThisClass
  File "/home/ubuntu/.local/lib/python3.5/site-packages/bitsharesbase/objects.py", line 15, in <module>
    from graphenebase.objects import Operation as GPHOperation
ImportError: cannot import name 'Operation'

Unable to automate the unlocking of wallet password

According to the docs for HERO (feedproducer page), the process of using BitShares-PriceFeed can be automated by setting an environment variable UNLOCK with the password for the Uptick wallet. For example,

export UNLOCK=<PasswordHere>
bitshares-pricefeed --configfile=hero.yaml update HERO

However, a manual prompt for the password is still requested.

Is Google source safe to use?

From my understanding of the code, currenlty the Google source does (with the default configuration) an average of the last 4d quotes with an 1h scale.

This behaviour does not match all the other sources which compute a 'last' price (~ real time).

Should we remove Google source to avoid missuse?

Hertz.yaml & Hero.yaml - assert "price" not in args[0], "You cannot provide a 'price' this way"

The error below occurred when using hertz.yaml & hero.yaml:

Traceback (most recent call last):
File "/home/ubuntu/.local/bin/bitshares-pricefeed", line 11, in
sys.exit(main())
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/bitshares_pricefeed/ui.py", line 20, in new_func
return ctx.invoke(f, *args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/uptick/decorators.py", line 45, in new_func
return ctx.invoke(f, *args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/uptick/decorators.py", line 102, in new_func
return ctx.invoke(f, *args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/uptick/decorators.py", line 127, in new_func
return ctx.invoke(f, *args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/bitshares_pricefeed/cli.py", line 199, in update
quote=price["short_backing_symbol"])
File "/home/ubuntu/.local/lib/python3.5/site-packages/bitshares/price.py", line 89, in init
assert "price" not in args[0], "You cannot provide a 'price' this way"
AssertionError: You cannot provide a 'price' this way

Hertz comments inaccuracies - requesting change.

Lines 34
and 38 in the hertz.yaml file incorrectly reference an old amplitude value of 50%, it's now 14%.

Line 34 should read:

# * Sin wave modulation of bitUSD (Ranges from $0.86 to $1.14 throughout the month).

And line 38 should read:

# * The amplitude of the sin wave is 0.14.

Doesn't affect the formula, just the comments, however it's possible a feed producer could get confused.

Thanks ๐Ÿ‘

Quandl: Quote inconsistency between Quandl and QuandlPlain.

With the same configuration, if I change the implementation klass from Quandl to QuandlPlain I don't have the same results:

Computed the 14/05/2018
   {'USD': {'SILVER': {'volume': 1.0, 'price': 16.76}, 'GOLD': {'volume': 1.0, 'price': 1324.8}}}
   {'USD': {'SILVER': {'volume': 1.0, 'price': 16.44}, 'GOLD': {'volume': 1.0, 'price': 1306.85}}}

Accepting feeds automatically when run in background

Once the process is automated, how should I auto-accept these? Will the script hang without user input?

[Warning] Price change for CNY (-2.096886) has been above 'warn_change'.  Please confirm! [y/N]: y
[Warning] Price change for MXN (-1.607775) has been above 'warn_change'.  Please confirm! [y/N]: y
[Warning] Price change for CAD (-1.699552) has been above 'warn_change'.  Please confirm! [y/N]: y

Add unit tests

It will be much easier to maintain the tool if there is some unit test.

Examples of usefull tests:

  • a test for each source that check that the code can compute the price. This will detect big errors like API changes and allow to quickly see which sources work.
  • a test for each "Algorithm Based Asset" (HERO, HERTZ, ...)

Fix source Bitcoin Venezuela.

Bitcoin Venezuela feed source does not work anymore:

  • HTTP endpoint is not working anymore (use HTTPS)
  • JSON format has changed.
  • only the last computed quote for each base is returned by the current code

Change CER for CNY to 1.2

Consensus of witnesses is to change the CER for CNY to 1.2 (from a default of 1.05 used for all other assets).

ALTCAP.XDR

I think I'm missing something simple.

Config:

# This is an example configuration file that might need modifications
# to properly run in your environment
#
# API KEYS
##########
# Some services require you to obtain an API key and provide it here in
# the configuration:
#
#     * OpenExchangeRates (has a free subscription)
#     * Currencylayer (has a a free subscription)
#     * Quandl (has a a free subscription)
#     * BitcoinAverage (has a a free subscription)
#     
# The corresponding variables can be defined in the `exchanges` key.


# If true, a new price feed needs manual confirmation
confirm: True

# The producer name(s)
producer: delegate.ihashfury

# Exchange settings (Here, you may need to add API keys)
exchanges:

    ####################################
    # Fiat Exchange Rates
    ####################################
    google:
        klass: Google
        enable: True
        quotes:
            - CNY
            - GBP
            - JPY
            - EUR
            - USD
        bases:
            - USD
            - EUR
            - CNY
    openexchangerates:
        klass: OpenExchangeRates
        enable: True
        api_key: api_key
        free_subscription: True
        quotes:
            - XDR
        base:
            # Only USD with free subscription
            - USD
        quoteNames:
            XDR: ALTCAP.XDR
    currencylayer:
        klass: CurrencyLayer
        enable: True
        api_key: api_key
        free_subscription: True
        quotes:
            - XDR
        base:
            # Only USD with free subscription
            - USD
        quoteNames:
            XDR: ALTCAP.XDR

    ####################################
    # Bitcoin Exchange Rates
    ####################################
    bitstamp:
        klass: Bitstamp
        enable: True
        quotes:
            - BTC
        bases:
            - USD
            - EUR
    btcavg:
        klass: BitcoinAverage
        secret_key: api_key
        public_key: api_key
        enable: True
        quotes:
            - BTC
        bases:
            - USD
            - EUR
            - CNY
    okcoin:
        klass: Okcoin
        enable: True
        quotes:
            - BTC
        bases:
            - CNY
            - USD
    ####################################
    # Bitshares Exchange Rates
    ####################################
    poloniex:
        klass: Poloniex
        enable: True
        quotes:
            - BTS
        bases:
            - BTC
    bittrex:
        klass: Bittrex
        enable: True
        quotes:
            - BTS
        bases:
            - BTC
    zb:
        klass: Zb
        enable: True
        quotes:
            - BTS
        bases:
            - BTC
    bitshares:
        klass: Graphene
        enable: True
        url: wss://bitshares.openledger.info/ws
        quotes:
            - USD
            - CNY
        bases:
            - BTS
    coinmarketcap:
        klass: Coinmarketcap
        enable: True
        quotes:
            - BTC
            - BTS
        bases:
            - USD
    aex:
        klass: Aex
        enable: True
        quotes:
            - BTS
        bases:
            - BTC

        
# default settings
default:

    # Type: extern, formula, alias
    type: extern

    # reference is only required if type==formula
    # if extern: formula may contain 
    #    *  {USD[weighted]}
    #    *  {USD[median]}
    #    *  {USD[mean]}   or other assets than USD
    #    with values derived from external exchanges
    #
    # reference: extern

    # if formula: settlement price can be taken from chain
    #    accessible values are:
    #    * {core_exchange_rate}
    #    * {quoteSettlement_price}
    #    * {latest}
    #    while the asset needs to be defined with ref_asset
    #
    # ref_asset: USD
    # formula: 100 * {quoteSettlement_price}
    #
    # if alias: Alias allows to change the name of the asset wrt to
    #    external sources. E.g.:
    #       SMART.USD:
    #           type: alias
    #           alias: USD
    #
    # alias: USD

    # max age of a feed
    maxage: 10800

    # minimum percentage that forces a publish
    min_change: 0.5

    # warn if price change goes above this percentage
    warn_change: 11

    # skip publishing a feed if price goes above this percentage
    skip_change: 26

    # how to derive a single price from several sources
    # Choose from: "median", "mean", or "weighted" (by volume)
    metric: weighted

    # Select sources for this particular asset. Each source
    # has its own fetch() method and collects several markets
    # any market of an exchanges is considered but only the
    # current asset's price is derived
    #
    # Choose from: - "*": all,
    #              - loaded exchanges (see below)
    sources:
        - google
        - openexchangerates
        - currencylayer
        - btcavg
        - bitstamp
        - okcoin
        - poloniex
        - bittrex
        - zb
        - coinmarketcap
        - aex
        - bitshares

    # Core exchange factor for paying transaction fees in
    # non-BTS assets. Premium of 5%
    core_exchange_factor: 1.05

    # maintenance collateral ratio (percentage)
    maintenance_collateral_ratio: 175.0

    # Maximum short squeeze ratio
    maximum_short_squeeze_ratio: 110.0

    # If set to True, prices are also derived via 3
    # markets instead of just two:
    # E.g.: GOLD:USD -> USD:BTC -> BTC:BTS = GOLD:BTS
    # derive_across_3markets: False
 

# Enabled assets that are derived if no asset is provided via command
# line
assets:
    ALTCAP.XDR:

# Intermediate assets are useful for 2 and 3 market price derivation
# E.g.: USD:BTC -> BTC:BTS = USD:BTS
#       GOLD:USD -> USD:BTC -> BTC:BTS = GOLD:BTS
# intermediate_assets:
    # - CNY
    # - USD
    # - BTC

Error:

'backing_symbol' not in self.price[alias]
Traceback (most recent call last):
  File "/home/ihashfury/.local/bin/bitshares-pricefeed", line 11, in <module>
    sys.exit(main())
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/bitshares_pricefeed/ui.py", line 18, in new_func
    return ctx.invoke(f, *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/uptick/decorators.py", line 50, in new_func
    return ctx.invoke(f, *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/uptick/decorators.py", line 77, in new_func
    return ctx.invoke(f, *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/uptick/decorators.py", line 98, in new_func
    return ctx.invoke(f, *args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/bitshares_pricefeed/cli.py", line 88, in update
    feed.derive(assets)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/bitshares_pricefeed/pricefeed.py", line 400, in derive
    self.obtain_price_change(symbol)
  File "/home/ihashfury/.local/lib/python3.5/site-packages/bitshares_pricefeed/pricefeed.py", line 66, in obtain_price_change
    raise ValueError("Price for %s has not yet been derived" % symbol)
ValueError: Price for ALTCAP.XDR has not yet been derived

TypeError: can't subtract offset-naive and offset-aware datetimes

Script fails with the below error whatever configuration is used:

Traceback (most recent call last):
  File "cli.py", line 5, in <module>
    cli.main()
  File "/home/zapata/.local/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/zapata/.local/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/zapata/.local/lib/python3.5/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/zapata/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/mnt/d/Projects/bitshares/bitshares-pricefeed/bitshares_pricefeed/ui.py", line 20, in new_func
    return ctx.invoke(f, *args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/uptick/decorators.py", line 50, in new_func
    return ctx.invoke(f, *args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/uptick/decorators.py", line 77, in new_func
    return ctx.invoke(f, *args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/uptick/decorators.py", line 98, in new_func
    return ctx.invoke(f, *args, **kwargs)
  File "/home/zapata/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/mnt/d/Projects/bitshares/bitshares-pricefeed/bitshares_pricefeed/cli.py", line 162, in update
    feed.derive(assets)
  File "/mnt/d/Projects/bitshares/bitshares-pricefeed/bitshares_pricefeed/pricefeed.py", line 496, in derive
    self.obtain_flags(symbol)
  File "/mnt/d/Projects/bitshares/bitshares-pricefeed/bitshares_pricefeed/pricefeed.py", line 101, in obtain_flags
    if (datetime.utcnow() - feed_age).total_seconds() > self.assetconf(symbol, "maxage"):
TypeError: can't subtract offset-naive and offset-aware datetimes

This seems to be caused by an update in python-bitshares: bitshares/python-bitshares@85eca5f

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.