[Python] Price Feed Script for BitShares 2.0

Started by xeroc, October 09, 2015, 02:24:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

checkrasier


roadscape

Thanks xeroc, the update works flawlessly +5%
http://cryptofresh.com  |  witness: roadscape

xeroc

Another update!

[Price Feed] New configuration variable "price_metric" allows to set for median, mean, or weighted (by volume) price.

The default value for price_metric should be weighted. Note that this will move
the price since now Poloniex's price will have more weight as before (as it
should be). I recommend to not update all witnesses at once (which shouldn't be
a problem considering the decentralization of timezones :) )


https://github.com/xeroc/python-graphenelib/commit/bd3b095e56553f50226bf9b255646ab25ef2a9b3

xeroc

Pushed a new update. It now supports
* Bitcoin Indonesia
* CCEDK

I also recommend to DISABLE yunbi since they do not allow trades any longer.

lines added to the configuration are prefixed with "+":

## Enable exchanges
+enable_yunbi             = False # currently halted
enable_btc38             = True
enable_bter              = False
enable_poloniex          = True
enable_bittrex           = True
enable_btcavg            = True
+enable_ccedk             = True
+enable_btcid             = True

poloniex_trust_level     = 1.0
bittrex_trust_level      = 0.5
yunbi_trust_level        = 0.8
+ccedk_trust_level        = 1.0
+btcid_trust_level        = 1.0



xeroc


cube

ID: bitcube
bitcube is a dedicated witness and committe member. Please vote for bitcube.

xeroc

Quote
!bitasset.has_settlement(): No further feeds may be published after a settlement event
oha .. did we have a black swan on those two assets? How are we supposed to reinitiate the markets? @bytemaster?

BunkerChainLabs-DataSecurityNode

Confirmed.. removing those assets got feeds working again..  and I was getting the same error reported.
+-+-+-+-+-+-+-+-+-+-+
[url="//www.peerplays.com"]www.Peerplays.com[/url] | Decentralized Gaming Built with Graphene - Now with BookiePro and Sweeps!
+-+-+-+-+-+-+-+-+-+-+

checkrasier

Thanks spartako, removing RUB and SEK worked for me

spartako

#83
Many witnesses have problem publishing feeds because they got these errors for RUB and SEK assets :

grapheneapi.grapheneapi.RPCError: 0 exception: unspecified
10 assert_exception: Assert Exception
!bitasset.has_settlement(): No further feeds may be published after a settlement event
    {}
    th_a  asset_evaluator.cpp:475 do_evaluate

    {"o":{"fee":{"amount":10000,"asset_id":"1.3.0"},"publisher":"1.2.333","asset_id":"1.3.111","feed":{"settlement_price":{"base":{"amount":206,"asset_id":"1.3.111"},"quote":{"amount":65121,"asset_id":"1.3.0"}},"maintenance_collateral_ratio":1750,"maximum_short_squeeze_ratio":1100,"core_exchange_rate":{"base":{"amount":206,"asset_id":"1.3.111"},"quote":{"amount":68377,"asset_id":"1.3.0"}}},"extensions":[]}}
    th_a  asset_evaluator.cpp:494 do_evaluate

    {}
    th_a  evaluator.cpp:45 start_evaluate

    {}
    th_a  db_block.cpp:631 apply_operation



I'm able to publish again removing RUB and SEK from bts_assets:


- _all_bts_assets = ["BTC", "SILVER", "GOLD", "TRY", "SGD", "HKD", "RUB", "SEK", "NZD",
+ _all_bts_assets = ["BTC", "SILVER", "GOLD", "TRY", "SGD", "HKD",  "NZD",
                    "CNY", "MXN", "CAD", "CHF", "AUD", "GBP", "JPY", "EUR", "USD",
                    "KRW" ] # , "SHENZHEN", "HANGSENG", "NASDAQC", "NIKKEI"
  _bases =["CNY", "USD", "BTC", "EUR", "HKD", "JPY"]
  _yahoo_base  = ["USD","EUR","CNY","JPY","HKD"]
- _yahoo_quote = ["XAG", "XAU", "TRY", "SGD", "HKD", "RUB", "SEK", "NZD", "CNY",
+ _yahoo_quote = ["XAG", "XAU", "TRY", "SGD", "HKD",  "NZD", "CNY",
                  "MXN", "CAD", "CHF", "AUD", "GBP", "JPY", "EUR", "USD", "KRW"]
wallet_account_set_approval spartako

cube

I do not have a problem with Bitcoinaverage.  twitter, perhaps it is blocking your ip address due to 'too much' polling?
ID: bitcube
bitcube is a dedicated witness and committe member. Please vote for bitcube.

xeroc

Bitcoinaverage timed out .. i should add more souces for the btc/* price pairs soonish ..

Who could find the api docs of some exchanges that have BTC/FIAT pairs?

twitter

#80
any idea why i got following error form running the latest price feed script .




Fetching data from wallet...
[Starting Threads]: (yunbi)(btcavg)(yahoo)(poloniex)(btc38).Exception in thread Thread-5:
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 135, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/util/connection.py", line 90, in create_connection
    raise err
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/util/connection.py", line 80, in create_connection
    sock.connect(sa)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 559, in urlopen
    body=body, headers=headers)
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 782, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 215, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 140, in _new_conn
    (self.host, self.timeout))
requests.packages.urllib3.exceptions.ConnectTimeoutError: (<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f01ee367fd0>, 'Connection to api.bitcoinaverage.com timed out. (connect timeout=3)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/requests/adapters.py", line 369, in send
    timeout=timeout
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 609, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/util/retry.py", line 271, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.bitcoinaverage.com', port=443): Max retries exceeded with url: /ticker/EUR (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f01ee367fd0>, 'Connection to api.bitcoinaverage.com timed out. (connect timeout=3)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "pricefeeds.py", line 249, in fetch_bitcoinaverage
    response = requests.get(url=url+coin, headers=_request_headers, timeout=3)
  File "/usr/local/lib/python3.4/dist-packages/requests/api.py", line 69, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 471, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 579, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/adapters.py", line 415, in send
    raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='api.bitcoinaverage.com', port=443): Max retries exceeded with url: /ticker/EUR (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f01ee367fd0>, 'Connection to api.bitcoinaverage.com timed out. (connect timeout=3)'))

....Error in asset EUR: no median for empty data

+-------+----------------+----------------+------------------+-------------------+---------------+-----------------------+--------------------+
| asset |       BTS/base |        my mean | median exchanges | blockchain median | % change (my) | % change (blockchain) |        last update |
+-------+----------------+----------------+------------------+-------------------+---------------+-----------------------+--------------------+
|   BTC | 69498.06949807 | 64811.95713623 |   69150.57915058 |    68535.15625000 |      -0.00191 |              -1.38553 | 0:05:23.343019 ago |
|   CNY |    38.87355179 |    36.05850485 |      38.67918403 |       38.24285714 |       0.20771 |              -1.62243 | 0:05:23.346144 ago |
|   USD |   249.51735719 |   231.62213537 |     248.26977040 |      246.37083333 |      -0.86347 |              -1.26104 | 0:05:20.349681 ago |
+-------+----------------+----------------+------------------+-------------------+---------------+-----------------------+--------------------+
Traceback (most recent call last):
  File "pricefeeds.py", line 572, in <module>
    if publish_rule() :
  File "pricefeeds.py", line 68, in publish_rule
    realPrice = statistics.median( price["BTS"][asset] )
  File "/usr/lib/python3.4/statistics.py", line 313, in median
    raise StatisticsError("no median for empty data")
statistics.StatisticsError: no median for empty data
witness:

pc

Quote from: xeroc on October 22, 2015, 02:39:46 PM

Here we go .. an update to reduce the number of transactions to publish feeds
since you still need to pay the fee per operation .. updating to this version will not bring more profit

Excellent!
Bitcoin - Perspektive oder Risiko? ISBN 978-3-8442-6568-2 [url="http://bitcoin.quisquis.de"]http://bitcoin.quisquis.de[/url]

xeroc

xeroc/python-graphenelib
[python-graphenelib:master] 4 new commits by Fabian Schuh:
ebe489a: [PriceFeed] config: More comments and cleaning up - Fabian Schuh
0fa6fac: Readded missing value - Fabian Schuh
7dbf5a6: [Price Feed] Merge all price feed updates into a single transaction. - Fabian Schuh
f7676bb: [Price Feed] Remove debug messages - Fabian Schuh


Here we go .. an update to reduce the number of transactions to publish feeds
since you still need to pay the fee per operation .. updating to this version will not bring more profit