From 0cb911c299d27e12c23404c8cb01a5495241f9f3 Mon Sep 17 00:00:00 2001 From: valzav Date: Wed, 28 Oct 2015 17:39:18 -0400 Subject: [PATCH 1/8] look for email address in the memo --- scripts/monitor-refcode/monitor.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/monitor-refcode/monitor.py b/scripts/monitor-refcode/monitor.py index 9261bc6a..d0448d53 100644 --- a/scripts/monitor-refcode/monitor.py +++ b/scripts/monitor-refcode/monitor.py @@ -74,15 +74,21 @@ def process_operations(self, operations) : memomsg)) # Parse the memo - pattern = re.compile('[a-zA-Z0-9]{8}') + pattern = re.compile('[A-Z0-9]{3}-[A-Z0-9-]{8}') searchResults = pattern.search(memomsg) if not searchResults: continue ref_code = searchResults.group(0) + email = "" + pattern = re.compile('[a-z0-9][-a-z0-9_\+\.]*[a-z0-9]\@.+\.[a-z]+') + searchResults = pattern.search(memomsg.lower()) + if searchResults: + email = searchResults.group(0) + # Request to Faucet headers = {'content-type': 'text/plain'} - query = "refcode[code]=%s&refcode[account]=%s&refcode[asset_symbol]=%s&refcode[asset_amount]=%s" % (ref_code, from_account["name"], amount_asset["symbol"], op["amount"]["amount"]) + query = "refcode[code]=%s&refcode[account]=%s&refcode[asset_symbol]=%s&refcode[asset_amount]=%s&refcode[send_to]=%s" % (ref_code, from_account["name"], amount_asset["symbol"], op["amount"]["amount"], email) print("--- query: %s" % query) response = requests.post(config.faucet_url, params=query, From bd3b095e56553f50226bf9b255646ab25ef2a9b3 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Thu, 29 Oct 2015 10:32:37 +0100 Subject: [PATCH 2/8] [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 :) ) --- scripts/pricefeeds/config-example.py | 1 + scripts/pricefeeds/pricefeeds.py | 39 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/scripts/pricefeeds/config-example.py b/scripts/pricefeeds/config-example.py index 465ad338..ce42f055 100644 --- a/scripts/pricefeeds/config-example.py +++ b/scripts/pricefeeds/config-example.py @@ -24,6 +24,7 @@ maximum_short_squeeze_ratio = 1100 # Stop calling when collateral only pays off 110% of the debt minValidAssetPriceInBTC = 0.00001# minimum valid price for BTS in BTC +price_metric = "weighted" # "median", "mean", or "weighted" (by volume) change_min = 0.5 # Percentage of price change to force an update change_max = 5.0 # Percentage of price change to cause a warning diff --git a/scripts/pricefeeds/pricefeeds.py b/scripts/pricefeeds/pricefeeds.py index 0d1cb5be..a09f42e6 100755 --- a/scripts/pricefeeds/pricefeeds.py +++ b/scripts/pricefeeds/pricefeeds.py @@ -108,7 +108,7 @@ def fetch_from_btcIndonesia(): result = response.json()["ticker"] if float(result["last"]) > config.minValidAssetPriceInBTC: price["BTC"][ coin ].append(float(result["last"])) - volume["BTC"][ coin ].append(float(result["vol_bts"])*config.btcid_trust_level) + volume["BTC"][ coin ].append(float(result["vol_"+coin.lower()])*config.btcid_trust_level) except Exception as e: print("\nError fetching results from btcIndonesia! ({0})\n".format(str(e))) if config.btcid_trust_level > 0.8: @@ -233,7 +233,7 @@ def fetch_from_poloniex(): for coin in availableAssets : if float(result["BTC_"+coin]["last"]) > config.minValidAssetPriceInBTC: price["BTC"][ coin ].append(float(result["BTC_"+coin]["last"])) - volume["BTC"][ coin ].append(float(result["BTC_"+coin]["baseVolume"])*config.poloniex_trust_level) + volume["BTC"][ coin ].append(float(result["BTC_"+coin]["quoteVolume"])*config.poloniex_trust_level) def fetch_from_bittrex(): availableAssets = [ "BTSX" ] @@ -392,7 +392,7 @@ def derive_prices(): if base == quote : continue for idx in range(0, len(price[base][quote])) : price[quote][base].append( (float(1/price[base][quote][idx] ))) - #volume[quote][base].append((float(1/volume[base][quote][idx]))) + volume[quote][base].append((float(1/volume[base][quote][idx]))) # derive BTS prices for all _base assets for base in _bases : @@ -401,34 +401,35 @@ def derive_prices(): for ratio in price[base][quote] : for idx in range(0, len(price[base]["BTS"])) : price[quote]["BTS"].append( (float(price[base]["BTS"][idx] /ratio))) - #volume[quote]["BTS"].append((float(volume[base]["BTS"][idx]/ratio))) + volume[quote]["BTS"].append((float(volume[base]["BTS"][idx]/ratio))) for base in _bases : for quote in asset_list_publish : for ratio in price[ base ][ quote ] : for idx in range(0, len(price[base]["BTS"])) : price["BTS"][quote].append( (float(price[base]["BTS"][idx] /ratio))) - #volume["BTS"][quote].append((float(volume[base]["BTS"][idx]/ratio))) + volume["BTS"][quote].append((float(volume[base]["BTS"][idx]/ratio))) + # Derive Final Price according to price metric for asset in asset_list_publish : - ### Median - try : + if config.price_metric == "median" : price_in_bts_weighted[asset] = statistics.median(price[core_symbol][asset]) - except Exception as e: - print("Error in asset %s: %s" %(asset, str(e))) - ### Mean - #price_in_bts_weighted[asset] = statistics.mean(price[core_symbol][asset]) + elif config.price_metric == "mean" : + price_in_bts_weighted[asset] = statistics.mean(price[core_symbol][asset]) - ### Weighted Mean - #assetvolume= [v for v in volume[core_symbol][asset] ] - #assetprice = [p for p in price[core_symbol][asset] ] - #if len(assetvolume) > 1 : - # price_in_bts_weighted[asset] = num.average(assetprice, weights=assetvolume) - #else : - # price_in_bts_weighted[asset] = assetprice[0] + elif config.price_metric == "weighted" : + assetvolume= [v for v in volume[core_symbol][asset] ] + assetprice = [p for p in price[core_symbol][asset] ] + if len(assetvolume) > 1 : + price_in_bts_weighted[asset] = num.average(assetprice, weights=assetvolume) + else : + price_in_bts_weighted[asset] = assetprice[0] + + else : + raise Exception("Configuration error, 'price_metric' has to be out of [ 'median', 'mean', 'weighted]") - ### Discount + # Discount for shorts if any price_in_bts_weighted[asset] = price_in_bts_weighted[asset] * config.discount ## ---------------------------------------------------------------------------- From 615ee933e6c371c2a2f0a1d345a4679a96c6dca1 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Thu, 29 Oct 2015 17:46:04 +0100 Subject: [PATCH 3/8] [Price Feed] New recommended parameters / addded more CCEDK pairs * added CNY/EUR/USD : BTS pairs of CCEDK * new recommended parameters * weighted metric * reduced ccedk trust until they fix their total vs. 24h volume issue --- scripts/pricefeeds/config-example.py | 17 +++++++------- scripts/pricefeeds/pricefeeds.py | 33 +++++++++++++++++----------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/scripts/pricefeeds/config-example.py b/scripts/pricefeeds/config-example.py index ce42f055..c2abe3ef 100644 --- a/scripts/pricefeeds/config-example.py +++ b/scripts/pricefeeds/config-example.py @@ -30,8 +30,8 @@ ## Enable exchanges enable_yunbi = False # currently halted -enable_btc38 = False # not yet trading bts2 -enable_bter = False +enable_bter = False # No BTS2 +enable_btc38 = True enable_poloniex = True enable_bittrex = True enable_btcavg = True @@ -40,10 +40,11 @@ ## trust level for exchanges (if an exception happens and level is 0.8 script ## will quit with a failure) -btc38_trust_level = 0.9 -bter_trust_level = 0.5 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 +bittrex_trust_level = 0.1 +ccedk_trust_level = 0.1 +btcid_trust_level = 0.5 +btc38_trust_level = 0.5 +# disabled! +yunbi_trust_level = 0.0 +bter_trust_level = 0.0 diff --git a/scripts/pricefeeds/pricefeeds.py b/scripts/pricefeeds/pricefeeds.py index a09f42e6..a1419b5f 100755 --- a/scripts/pricefeeds/pricefeeds.py +++ b/scripts/pricefeeds/pricefeeds.py @@ -117,20 +117,27 @@ def fetch_from_btcIndonesia(): def fetch_from_ccedk(): global price, volume - try: - url="https://www.ccedk.com/api/v1/stats/marketdepth?pair_id=50" - response = requests.get(url=url, headers=_request_headers, timeout=3 ) - result = response.json()["response"]["entity"] - availableAssets = [ core_symbol ] - except Exception as e: - print("\nError fetching results from ccedk! ({0})\n".format(str(e))) - if config.ccedk_trust_level > 0.8: - sys.exit("\nExiting due to exchange importance!\n") - return - for coin in availableAssets : + bts_markets = { + "CNY":123, + "USD":55, + "BTC":50, + "EUR":54, + } + for market in bts_markets : + pair_id = bts_markets[market] + try : + url="https://www.ccedk.com/api/v1/stats/marketdepth?pair_id=%d" % pair_id + response = requests.get(url=url, headers=_request_headers, timeout=3 ) + result = response.json()["response"]["entity"] + availableAssets = [ core_symbol ] + except Exception as e: + print("\nError fetching results from ccedk! ({0})\n".format(str(e))) + if config.ccedk_trust_level > 0.8: + sys.exit("\nExiting due to exchange importance!\n") + return if float(result["avg"]) > config.minValidAssetPriceInBTC: - price["BTC"][ coin ].append(float(result["avg"])) - volume["BTC"][ coin ].append(float(result["vol"])*config.ccedk_trust_level) + price[market][ core_symbol ].append(float(result["avg"])) + volume[market][ core_symbol ].append(float(result["vol"])*config.ccedk_trust_level) def fetch_from_yunbi(): global price, volume From 5e67e557fbcb48335fb506af290dc6eacbdcb506 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Fri, 30 Oct 2015 09:50:06 +0100 Subject: [PATCH 4/8] [Price feed] fixed CCEDK volume --- scripts/pricefeeds/pricefeeds.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pricefeeds/pricefeeds.py b/scripts/pricefeeds/pricefeeds.py index a1419b5f..fde98d36 100755 --- a/scripts/pricefeeds/pricefeeds.py +++ b/scripts/pricefeeds/pricefeeds.py @@ -126,7 +126,7 @@ def fetch_from_ccedk(): for market in bts_markets : pair_id = bts_markets[market] try : - url="https://www.ccedk.com/api/v1/stats/marketdepth?pair_id=%d" % pair_id + url="https://www.ccedk.com/api/v1/stats/marketdepthfull?pair_id=%d" % pair_id response = requests.get(url=url, headers=_request_headers, timeout=3 ) result = response.json()["response"]["entity"] availableAssets = [ core_symbol ] @@ -136,7 +136,7 @@ def fetch_from_ccedk(): sys.exit("\nExiting due to exchange importance!\n") return if float(result["avg"]) > config.minValidAssetPriceInBTC: - price[market][ core_symbol ].append(float(result["avg"])) + price[market][ core_symbol ].append(float(result["last_price"])) volume[market][ core_symbol ].append(float(result["vol"])*config.ccedk_trust_level) def fetch_from_yunbi(): From 9e6bd3eeb397051b598c1e2c786c20cb1a6000b3 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Fri, 30 Oct 2015 09:50:37 +0100 Subject: [PATCH 5/8] [Price feed] default parameter tweak --- scripts/pricefeeds/config-example.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/pricefeeds/config-example.py b/scripts/pricefeeds/config-example.py index c2abe3ef..fa53d388 100644 --- a/scripts/pricefeeds/config-example.py +++ b/scripts/pricefeeds/config-example.py @@ -29,22 +29,22 @@ change_max = 5.0 # Percentage of price change to cause a warning ## Enable exchanges -enable_yunbi = False # currently halted +enable_btcavg = True # used to get BTC/* prices enable_bter = False # No BTS2 -enable_btc38 = True +enable_btc38 = False # No official statement for BTS2 yet +enable_btcid = False # No official statement for BTS2 yet +enable_yunbi = True enable_poloniex = True enable_bittrex = True -enable_btcavg = True enable_ccedk = True -enable_btcid = True ## trust level for exchanges (if an exception happens and level is 0.8 script ## will quit with a failure) -poloniex_trust_level = 1.0 -bittrex_trust_level = 0.1 -ccedk_trust_level = 0.1 -btcid_trust_level = 0.5 -btc38_trust_level = 0.5 -# disabled! -yunbi_trust_level = 0.0 -bter_trust_level = 0.0 +poloniex_trust_level = 1.0 # trades BTS2 +ccedk_trust_level = 1.0 # trades BTS2 +bittrex_trust_level = 0.5 # is currently migrating +yunbi_trust_level = 0.5 # is currently migrating + +btc38_trust_level = 0.0 # disabled! +btcid_trust_level = 0.0 # disabled! +bter_trust_level = 0.0 # disabled! From 18badda762d5403b6b98a097e72c189ea2c23d07 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Fri, 30 Oct 2015 09:51:36 +0100 Subject: [PATCH 6/8] [Price Feed] added BTC/CNY market at bitcoin average --- scripts/pricefeeds/pricefeeds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pricefeeds/pricefeeds.py b/scripts/pricefeeds/pricefeeds.py index fde98d36..c22c8332 100755 --- a/scripts/pricefeeds/pricefeeds.py +++ b/scripts/pricefeeds/pricefeeds.py @@ -297,7 +297,7 @@ def fetch_from_yahoo(): def fetch_bitcoinaverage(): global price, volume url="https://api.bitcoinaverage.com/ticker/" - availableAssets = [ "USD", "EUR" ] + availableAssets = [ "USD", "EUR", "CNY" ] for coin in availableAssets : response = requests.get(url=url+coin, headers=_request_headers, timeout=3) result = response.json() From 5af256359aae1365a53ecaf35203eb1c2f27d607 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Wed, 4 Nov 2015 09:54:07 +0100 Subject: [PATCH 7/8] [Price feed] recommended min_price boundary to be 100 satoshi instead of 1000 --- scripts/pricefeeds/config-example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pricefeeds/config-example.py b/scripts/pricefeeds/config-example.py index fa53d388..5cbe101c 100644 --- a/scripts/pricefeeds/config-example.py +++ b/scripts/pricefeeds/config-example.py @@ -22,7 +22,7 @@ core_exchange_factor = 0.95 # 5% discount if paying fees in bitassets maintenance_collateral_ratio = 1750 # Call when collateral only pays off 175% the debt maximum_short_squeeze_ratio = 1100 # Stop calling when collateral only pays off 110% of the debt -minValidAssetPriceInBTC = 0.00001# minimum valid price for BTS in BTC +minValidAssetPriceInBTC = 100 * 1e-8# minimum valid price for BTS in BTC price_metric = "weighted" # "median", "mean", or "weighted" (by volume) change_min = 0.5 # Percentage of price change to force an update From 7b8a67d6960356b1fd4a637bbbb00e425b49c629 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Wed, 4 Nov 2015 17:27:59 +0100 Subject: [PATCH 8/8] [libs] Add capability to produce MUSE addresses/pubkeys --- graphenebase/base58.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/graphenebase/base58.py b/graphenebase/base58.py index fa94f809..dbbe338d 100644 --- a/graphenebase/base58.py +++ b/graphenebase/base58.py @@ -37,7 +37,9 @@ def __format__(self, _format) : elif _format.lower() == "btc": return base58CheckEncode(0x00, self._hex) elif _format.lower() == "bts" : - return _format + str(self) + return _format.upper() + str(self) + elif _format.lower() == "muse" : + return _format.upper() + str(self) else : raise Exception("Format %s unkown." %_format) """