Skip to content

Commit

Permalink
Merge pull request 'Change source of price info' (#125) from 20240822…
Browse files Browse the repository at this point in the history
…-fiatprice-updates into main
  • Loading branch information
vicariousdrama committed Aug 22, 2024
2 parents 2875c41 + 3fbddab commit 83c3ff7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 64 deletions.
26 changes: 3 additions & 23 deletions sample-config/fiatprice.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"attributionColor.comment": "The text color for the source attribution line expressed as a Hexadecimal color specifier",
"attributionColor.fka": "colorBisq",
"attributionColor.type": "color",
"attributionColor": "#40FF40",
"attributionColor": "#1bd8f4",
"backgroundColor.comment": "The background color of the image expressed as a Hexadecimal color specifier",
"backgroundColor.fka": "colorBackground",
"backgroundColor.type": "color",
Expand All @@ -18,33 +18,13 @@
"fiatUnit.comment": "The three letter fiat currency unit for value comparisons",
"fiatUnit.type": "string",
"fiatUnit.choices": {
"ARS": "Argentine Peso",
"AUD": "Australian Dollar",
"BRL": "Brazilian Real",
"GBP": "British Pound",
"CAD": "Canadian Dollar",
"CLP": "Chilean Peso",
"CNY": "Chinese Yuan",
"CZK": "Czech Koruna",
"DKK": "Danish Krone",
"EUR": "Euro",
"HKD": "Hong Kong Dollar",
"HUF": "Hungarian Forint",
"INR": "Indian Rupee",
"JPY": "Japanese Yen",
"MXN": "Mexican Peso",
"NZD": "New Zealand Dollar",
"NGN": "Nigerian Naira",
"NOK": "Norwegian Kroner",
"PHP": "Philippine Peso",
"PLN": "Polish Zloty",
"RON": "Romanian Lei",
"RUB": "Russian Ruble",
"SGD": "Singapore Dollar",
"SEK": "Swedish Krona",
"CHF": "Swiss Franc",
"USD": "United States Dollar",
"VUV": "Vanuatu Vatu"
"USD": "United States Dollar"
},
"fiatUnit": "USD",
"headerColor.comment": "The color of the text expressed as a Hexadecial color specifier",
Expand Down Expand Up @@ -73,7 +53,7 @@
"priceUrl.comment": "The url that provides the pricing information from bisq marketplace",
"priceUrl.fka": "priceurl",
"priceUrl.type": "string",
"priceUrl": "https://bisq.markets/bisq/api/markets/ticker",
"priceUrl": "https://mempool.space/api/v1/prices",
"useTor.comment": "Indicates whether remote calls should use tor socks proxy for privacy.",
"useTor.type": "boolean",
"useTor": true,
Expand Down
26 changes: 3 additions & 23 deletions sample-config/satsperfiatunit.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"attributionColor.comment": "The text color for the source attribution line expressed as a Hexadecimal color specifier",
"attributionColor.fka": "colorBisq",
"attributionColor.type": "color",
"attributionColor": "#40FF40",
"attributionColor": "#1bd8f4",
"backgroundColor.comment": "The background color of the image expressed as a Hexadecimal color specifier",
"backgroundColor.fka": "colorBackground",
"backgroundColor.type": "color",
Expand All @@ -18,33 +18,13 @@
"fiatUnit.comment": "The three letter fiat currency unit for value comparisons",
"fiatUnit.type": "string",
"fiatUnit.choices": {
"ARS": "Argentine Peso",
"AUD": "Australian Dollar",
"BRL": "Brazilian Real",
"GBP": "British Pound",
"CAD": "Canadian Dollar",
"CLP": "Chilean Peso",
"CNY": "Chinese Yuan",
"CZK": "Czech Koruna",
"DKK": "Danish Krone",
"EUR": "Euro",
"HKD": "Hong Kong Dollar",
"HUF": "Hungarian Forint",
"INR": "Indian Rupee",
"JPY": "Japanese Yen",
"MXN": "Mexican Peso",
"NZD": "New Zealand Dollar",
"NGN": "Nigerian Naira",
"NOK": "Norwegian Kroner",
"PHP": "Philippine Peso",
"PLN": "Polish Zloty",
"RON": "Romanian Lei",
"RUB": "Russian Ruble",
"SGD": "Singapore Dollar",
"SEK": "Swedish Krona",
"CHF": "Swiss Franc",
"USD": "United States Dollar",
"VUV": "Vanuatu Vatu"
"USD": "United States Dollar"
},
"fiatUnit": "USD",
"headerColor.comment": "The color of the header text expressed as a Hexadecial color specifier",
Expand Down Expand Up @@ -72,7 +52,7 @@
"priceUrl.comment": "The url that provides the pricing information from bisq marketplace",
"priceUrl.fka": "priceurl",
"priceUrl.type": "string",
"priceUrl": "https://bisq.markets/bisq/api/markets/ticker",
"priceUrl": "https://mempool.space/api/v1/prices",
"satShape.comment": "The shape that each individual sat should be drawn.",
"satShape.fka": "satshape",
"satShape.type": "string",
Expand Down
8 changes: 4 additions & 4 deletions scripts/fiatprice.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self):
}

# Define our defaults (all panel specific key names should be listed)
self._defaultattr("attributionColor", "#40ff40")
self._defaultattr("attributionColor", "#1bd8f4")
self._defaultattr("bigTextEnabled", True)
self._defaultattr("bigTextOnTopEnabled", True)
self._defaultattr("fiatUnit", "USD")
Expand All @@ -51,7 +51,7 @@ def __init__(self):
self._defaultattr("priceLow", 0)
self._defaultattr("priceShadowColor", "#ffffff7f")
self._defaultattr("priceUpColor", "#40ff40")
self._defaultattr("priceUrl", "https://bisq.markets/bisq/api/markets/ticker")
self._defaultattr("priceUrl", "https://mempool.space/api/v1/prices")
self._defaultattr("useTor", True)
self._defaultattr("watermarkAnchor", "bottom")

Expand Down Expand Up @@ -89,7 +89,7 @@ def run(self):
else:
vicarioustext.drawcenteredtext(self.draw, f"Price: {priceText}", smallPriceSize, x, y, ImageColor.getrgb(self.priceColor))
# attribution
vicarioustext.drawbottomlefttext(self.draw, "Data from bisq", attributionSize, 0, self.height, ImageColor.getrgb(self.attributionColor))
vicarioustext.drawbottomlefttext(self.draw, "Data from mempool", attributionSize, 0, self.height, ImageColor.getrgb(self.attributionColor))

self.canvas.alpha_composite(alphaLayer)
alphaLayer.close()
Expand Down Expand Up @@ -117,4 +117,4 @@ def run(self):
exit(0)

# Continuous run
p.runContinuous()
p.runContinuous()
12 changes: 6 additions & 6 deletions scripts/satsperfiatunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self):
}

# Define our defaults (all panel specific key names should be listed)
self._defaultattr("attributionColor", "#40ff40")
self._defaultattr("attributionColor", "#1bd8f4")
self._defaultattr("bigTextEnabled", True)
self._defaultattr("bigTextOnTopEnabled", True)
self._defaultattr("fiatUnit", "USD")
Expand All @@ -55,7 +55,7 @@ def __init__(self):
self._defaultattr("priceLow", 0)
self._defaultattr("priceShadowColor", "#ffffff7f")
self._defaultattr("priceUpColor", "#40ff407f")
self._defaultattr("priceUrl", "https://bisq.markets/bisq/api/markets/ticker")
self._defaultattr("priceUrl", "https://mempool.space/api/v1/prices")
self._defaultattr("satShape", "square") # circle, square, symbol-s, triangle
self._defaultattr("satShapeColor", "#ff7f00")
self._defaultattr("useTor", True)
Expand All @@ -74,15 +74,15 @@ def fetchData(self):
self.priceColor = self.priceDownColor
if self.priceChange > 0:
self.priceColor = self.priceUpColor
if fiatkeyname != f"btc_{self.fiatUnit}".lower():
self.fiatUnit = fiatkeyname.split("_")[1].upper()
if fiatkeyname != f"{self.fiatUnit}".upper():
self.fiatUnit = fiatkeyname.upper()

def getSatsPerFiatUnit(self):
return int(round(100000000.0 / self.priceLast))

def renderAttribution(self):
fontsize = int(self.height * 16/320)
vicarioustext.drawbottomlefttext(self.draw, "Data from bisq", fontsize, 0, self.height, ImageColor.getrgb(self.attributionColor))
vicarioustext.drawbottomlefttext(self.draw, "Data from mempool", fontsize, 0, self.height, ImageColor.getrgb(self.attributionColor))

def renderBigTextOver(self):
if not self.bigTextEnabled: return
Expand Down Expand Up @@ -216,4 +216,4 @@ def setupSatSizing(self):
exit(0)

# Continuous run
p.runContinuous()
p.runContinuous()
16 changes: 8 additions & 8 deletions scripts/vicariousnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,19 @@ def getnostrstats(useTor=True, url="https://stats.nostr.band/stats_api?method=st
j = errresponse
return j

def getpriceinfo(useTor=True, url="https://bisq.markets/bisq/api/markets/ticker", price_last=-1, price_high=-1, price_low=-1, fiatUnit="USD"):
newestfile = getfromurlifstale(useTor, url, "../data/bisq", 3600)
def getpriceinfo(useTor=True, url="https://mempool.space/api/v1/prices", price_last=-1, price_high=-1, price_low=-1, fiatUnit="USD"):
newestfile = getfromurlifstale(useTor, url, "../data/mempoolprices", 3600)
if len(newestfile) > 0:
with open(newestfile) as f:
j = json.load(f)
if "error" not in j:
keyname = f"btc_{fiatUnit}".lower()
keyname = f"{fiatUnit}".upper()
if keyname not in j:
print(f"Price service does not have BTC to {fiatUnit} currency pair. Using btc_usd")
keyname = "btc_usd"
price_last = int(math.floor(float(j[keyname]["last"])))
price_high = int(math.floor(float(j[keyname]["high"])))
price_low = int(math.floor(float(j[keyname]["low"])))
print(f"Price service does not have BTC to {fiatUnit} currency pair. Using USD")
keyname = "USD"
price_last = int(math.floor(float(j[keyname])))
price_high = price_last
price_low = price_last
return (price_last,price_high,price_low,keyname)

def getraretoshiuserinfoFallback(useTor=True, raretoshiDataDirectory="../data/raretoshi/", raretoshiUser="rapidstart", userInfo=None, userInfoLast=0, userInfoInterval=3600):
Expand Down

0 comments on commit 83c3ff7

Please sign in to comment.