mirror of
https://github.com/cryptoadvance/specter-desktop.git
synced 2026-08-13 12:33:29 +02:00
Update spotbit api url and path (#2372)
* Update spotbit api url and path * Update src/cryptoadvance/specter/util/price_providers.py Co-authored-by: Benjamin B <7598058+BBlackwo@users.noreply.github.com> * removed non-existent price-provider and added gemini * fixed history API --------- Co-authored-by: k9ert <k9ert@gmx.de> Co-authored-by: Kim Neunert <kim@swanbitcoin.com>
This commit is contained in:
parent
8a06e9b716
commit
6a51d31bbe
2 changed files with 35 additions and 74 deletions
|
|
@ -79,57 +79,29 @@
|
|||
<select class="floating-input peer" name="price_provider" id="price_provider" onchange="providerChanged()">
|
||||
<option data-currency-type="usd" value="bitstamp_usd" {% if specter.price_provider == 'bitstamp' %}selected{% endif %}>Bitstamp USD</option>
|
||||
<option data-currency-type="usd" value="coindesk_usd" {% if specter.price_provider == 'coindesk' %}selected{% endif %}>Coindesk USD</option>
|
||||
<option data-currency-type="usd" value="spotbit_coinbase" {% if specter.price_provider == 'spotbit_coinbase' %}selected{% endif %}>Spotbit Coinbase (Tor) USD</option>
|
||||
<option data-currency-type="usd" value="spotbit_kraken" {% if specter.price_provider == 'spotbit_kraken' %}selected{% endif %}>Spotbit Kraken (Tor) USD</option>
|
||||
<option data-currency-type="usd" value="spotbit_bitfinex" {% if specter.price_provider == 'spotbit_bitfinex' %}selected{% endif %}>Spotbit Bitfinex (Tor) USD</option>
|
||||
<option data-currency-type="usd" value="spotbit_okcoin" {% if specter.price_provider == 'spotbit_okcoin' %}selected{% endif %}>Spotbit OKCoin (Tor) USD</option>
|
||||
<option data-currency-type="usd" value="spotbit_bitstamp" {% if specter.price_provider == 'spotbit_bitstamp' %}selected{% endif %}>Spotbit Bitstamp (Tor) USD</option>
|
||||
<option data-currency-type="usd" value="spotbit_bitstamp_usd" {% if specter.price_provider == 'spotbit_bitstamp_usd' %}selected{% endif %}>Spotbit Bitstamp (Tor) USD</option>
|
||||
<option data-currency-type="usd" value="spotbit_gemini_usd" {% if specter.price_provider == 'spotbit_gemini_usd' %}selected{% endif %}>Spotbit Gemini (Tor) USD</option>
|
||||
<option data-currency-type="eur" value="bitstamp_eur" {% if specter.price_provider == 'bitstamp_eur' %}selected{% endif %}>Bitstamp EUR</option>
|
||||
<option data-currency-type="eur" value="coindesk_eur" {% if specter.price_provider == 'coindesk_eur' %}selected{% endif %}>Coindesk EUR</option>
|
||||
<option data-currency-type="eur" value="spotbit_coinbase_eur" {% if specter.price_provider == 'spotbit_coinbase_eur' %}selected{% endif %}>Spotbit Coinbase (Tor) EUR</option>
|
||||
<option data-currency-type="eur" value="spotbit_kraken_eur" {% if specter.price_provider == 'spotbit_kraken_eur' %}selected{% endif %}>Spotbit Kraken (Tor) EUR</option>
|
||||
<option data-currency-type="eur" value="spotbit_bitfinex_eur" {% if specter.price_provider == 'spotbit_bitfinex_eur' %}selected{% endif %}>Spotbit Bitfinex (Tor) EUR</option>
|
||||
<option data-currency-type="eur" value="spotbit_okcoin_eur" {% if specter.price_provider == 'spotbit_okcoin_eur' %}selected{% endif %}>Spotbit OKCoin (Tor) EUR</option>
|
||||
<option data-currency-type="eur" value="spotbit_bitstamp_eur" {% if specter.price_provider == 'spotbit_bitstamp_eur' %}selected{% endif %}>Spotbit Bitstamp (Tor) EUR</option>
|
||||
<option data-currency-type="eur" value="spotbit_gemini_eur" {% if specter.price_provider == 'spotbit_gemini_eur' %}selected{% endif %}>Spotbit Gemini (Tor) EUR</option>
|
||||
<option data-currency-type="gbp" value="bitstamp_gbp" {% if specter.price_provider == 'bitstamp_gbp' %}selected{% endif %}>Bitstamp GBP</option>
|
||||
<option data-currency-type="gbp" value="coindesk_gbp" {% if specter.price_provider == 'coindesk_gbp' %}selected{% endif %}>Coindesk GBP</option>
|
||||
<option data-currency-type="gbp" value="spotbit_coinbase_gbp" {% if specter.price_provider == 'spotbit_coinbase_gbp' %}selected{% endif %}>Spotbit Coinbase (Tor) GBP</option>
|
||||
<option data-currency-type="gbp" value="spotbit_kraken_gbp" {% if specter.price_provider == 'spotbit_kraken_gbp' %}selected{% endif %}>Spotbit Kraken (Tor) GBP</option>
|
||||
<option data-currency-type="gbp" value="spotbit_bitfinex_gbp" {% if specter.price_provider == 'spotbit_bitfinex_gbp' %}selected{% endif %}>Spotbit Bitfinex (Tor) GBP</option>
|
||||
<option data-currency-type="gbp" value="spotbit_bitstamp_gbp" {% if specter.price_provider == 'spotbit_bitstamp_gbp' %}selected{% endif %}>Spotbit Bitstamp (Tor) GBP</option>
|
||||
<option data-currency-type="gbp" value="spotbit_gemini_gbp" {% if specter.price_provider == 'spotbit_gemini_gbp' %}selected{% endif %}>Spotbit Gemini (Tor) GBP</option>
|
||||
<option data-currency-type="chf" value="coindesk_chf" {% if specter.price_provider == 'coindesk_chf' %}selected{% endif %}>Coindesk CHF</option>
|
||||
<option data-currency-type="chf" value="spotbit_coinbase_chf" {% if specter.price_provider == 'spotbit_coinbase_chf' %}selected{% endif %}>Spotbit Coinbase (Tor) CHF</option>
|
||||
<option data-currency-type="chf" value="spotbit_kraken_chf" {% if specter.price_provider == 'spotbit_kraken_chf' %}selected{% endif %}>Spotbit Kraken (Tor) CHF</option>
|
||||
<option data-currency-type="jpy" value="coindesk_jpy" {% if specter.price_provider == 'coindesk_jpy' %}selected{% endif %}>Coindesk JPY</option>
|
||||
<option data-currency-type="jpy" value="spotbit_coinbase_jpy" {% if specter.price_provider == 'spotbit_coinbase_jpy' %}selected{% endif %}>Spotbit Coinbase (Tor) JPY</option>
|
||||
<option data-currency-type="jpy" value="spotbit_kraken_jpy" {% if specter.price_provider == 'spotbit_kraken_jpy' %}selected{% endif %}>Spotbit Kraken (Tor) JPY</option>
|
||||
<option data-currency-type="jpy" value="spotbit_bitfinex_jpy" {% if specter.price_provider == 'spotbit_bitfinex_jpy' %}selected{% endif %}>Spotbit Bitfinex (Tor) JPY</option>
|
||||
<option data-currency-type="aud" value="coindesk_aud" {% if specter.price_provider == 'coindesk_aud' %}selected{% endif %}>Coindesk AUD</option>
|
||||
<option data-currency-type="aud" value="spotbit_coinbase_aud" {% if specter.price_provider == 'spotbit_coinbase_aud' %}selected{% endif %}>Spotbit Coinbase (Tor) AUD</option>
|
||||
<option data-currency-type="aud" value="spotbit_kraken_aud" {% if specter.price_provider == 'spotbit_kraken_aud' %}selected{% endif %}>Spotbit Kraken (Tor) AUD</option>
|
||||
<option data-currency-type="cad" value="coindesk_cad" {% if specter.price_provider == 'coindesk_cad' %}selected{% endif %}>Coindesk CAD</option>
|
||||
<option data-currency-type="cad" value="spotbit_coinbase_cad" {% if specter.price_provider == 'spotbit_coinbase_cad' %}selected{% endif %}>Spotbit Coinbase (Tor) CAD</option>
|
||||
<option data-currency-type="cad" value="spotbit_kraken_cad" {% if specter.price_provider == 'spotbit_kraken_cad' %}selected{% endif %}>Spotbit Kraken (Tor) CAD</option>
|
||||
<option data-currency-type="nzd" value="coindesk_nzd" {% if specter.price_provider == 'coindesk_nzd' %}selected{% endif %}>Coindesk NZD</option>
|
||||
<option data-currency-type="nzd" value="spotbit_coinbase_nzd" {% if specter.price_provider == 'spotbit_coinbase_nzd' %}selected{% endif %}>Spotbit Coinbase (Tor) NZD</option>
|
||||
<option data-currency-type="hkd" value="coindesk_hkd" {% if specter.price_provider == 'coindesk_hkd' %}selected{% endif %}>Coindesk HKD</option>
|
||||
<option data-currency-type="hkd" value="spotbit_coinbase_hkd" {% if specter.price_provider == 'spotbit_coinbase_hkd' %}selected{% endif %}>Spotbit Coinbase (Tor) HKD</option>
|
||||
<option data-currency-type="rub" value="coindesk_rub" {% if specter.price_provider == 'coindesk_rub' %}selected{% endif %}>Coindesk RUB</option>
|
||||
<option data-currency-type="rub" value="spotbit_coinbase_rub" {% if specter.price_provider == 'spotbit_coinbase_rub' %}selected{% endif %}>Spotbit Coinbase (Tor) RUB</option>
|
||||
<option data-currency-type="ils" value="coindesk_ils" {% if specter.price_provider == 'coindesk_ils' %}selected{% endif %}>Coindesk NIS</option>
|
||||
<option data-currency-type="ils" value="spotbit_coinbase_ils" {% if specter.price_provider == 'spotbit_coinbase_ils' %}selected{% endif %}>Spotbit Coinbase (Tor) NIS</option>
|
||||
<option data-currency-type="jod" value="coindesk_jod" {% if specter.price_provider == 'coindesk_jod' %}selected{% endif %}>Coindesk JOD</option>
|
||||
<option data-currency-type="jod" value="spotbit_coinbase_jod" {% if specter.price_provider == 'spotbit_coinbase_jod' %}selected{% endif %}>Spotbit Coinbase (Tor) JOD</option>
|
||||
<option data-currency-type="twd" value="coindesk_twd" {% if specter.price_provider == 'coindesk_twd' %}selected{% endif %}>Coindesk TWD</option>
|
||||
<option data-currency-type="twd" value="spotbit_coinbase_twd" {% if specter.price_provider == 'spotbit_coinbase_twd' %}selected{% endif %}>Spotbit Coinbase (Tor) TWD</option>
|
||||
<option data-currency-type="brl" value="coindesk_brl" {% if specter.price_provider == 'coindesk_brl' %}selected{% endif %}>Coindesk BRL</option>
|
||||
<option data-currency-type="brl" value="spotbit_coinbase_brl" {% if specter.price_provider == 'spotbit_coinbase_brl' %}selected{% endif %}>Spotbit Coinbase (Tor) BRL</option>
|
||||
<option data-currency-type="xau" value="coindesk_xau" {% if specter.price_provider == 'coindesk_xau' %}selected{% endif %}>Coindesk Gold</option>
|
||||
<option data-currency-type="xau" value="spotbit_coinbase_xau" {% if specter.price_provider == 'spotbit_coinbase_xau' %}selected{% endif %}>Spotbit Coinbase (Tor) Gold</option>
|
||||
<option data-currency-type="xag" value="coindesk_xag" {% if specter.price_provider == 'coindesk_xag' %}selected{% endif %}>Coindesk Silver</option>
|
||||
<option data-currency-type="xag" value="spotbit_coinbase_xag" {% if specter.price_provider == 'spotbit_coinbase_xag' %}selected{% endif %}>Spotbit Coinbase (Tor) Silver</option>
|
||||
<option data-currency-type="xpt" value="spotbit_coinbase_xpt" {% if specter.price_provider == 'spotbit_coinbase_xpt' %}selected{% endif %}>Spotbit Coinbase (Tor) Platinum</option>
|
||||
<option data-currency-type="xpd" value="spotbit_coinbase_xpd" {% if specter.price_provider == 'spotbit_coinbase_xpd' %}selected{% endif %}>Spotbit Coinbase (Tor) Palladium</option>
|
||||
</select>
|
||||
<label class="floating-label">Provider</label>
|
||||
</fieldset>
|
||||
|
|
|
|||
|
|
@ -15,85 +15,64 @@ OZ_TO_G = 28.3495231
|
|||
currency_mapping = {
|
||||
"usd": {
|
||||
"symbol": "$",
|
||||
"support": [
|
||||
"bitstamp",
|
||||
"coindesk",
|
||||
"spotbit_coinbase",
|
||||
"spotbit_kraken",
|
||||
"spotbit_bitfinex",
|
||||
"spotbit_okcoin",
|
||||
"spotbit_bitstamp",
|
||||
],
|
||||
"support": ["bitstamp", "coindesk", "spotbit_bitstamp", "spotbit_gemini"],
|
||||
},
|
||||
"eur": {
|
||||
"symbol": "€",
|
||||
"support": [
|
||||
"bitstamp",
|
||||
"coindesk",
|
||||
"spotbit_coinbase",
|
||||
"spotbit_kraken",
|
||||
"spotbit_bitfinex",
|
||||
"spotbit_okcoin_eur",
|
||||
"spotbit_bitstamp",
|
||||
"spotbit_gemini",
|
||||
],
|
||||
},
|
||||
"gbp": {
|
||||
"symbol": "£",
|
||||
"support": [
|
||||
"bitstamp",
|
||||
"coindesk",
|
||||
"spotbit_coinbase",
|
||||
"spotbit_kraken",
|
||||
"spotbit_bitfinex",
|
||||
"spotbit_bitstamp",
|
||||
],
|
||||
"support": ["bitstamp", "coindesk", "spotbit_bitstamp", "spotbit_gemini"],
|
||||
},
|
||||
"chf": {
|
||||
"symbol": " Fr.",
|
||||
"support": ["coindesk", "spotbit_coinbase", "spotbit_kraken"],
|
||||
"support": ["coindesk"],
|
||||
},
|
||||
"aud": {
|
||||
"symbol": "$",
|
||||
"support": ["coindesk", "spotbit_coinbase", "spotbit_kraken"],
|
||||
"support": ["coindesk"],
|
||||
},
|
||||
"cad": {
|
||||
"symbol": "$",
|
||||
"support": ["coindesk", "spotbit_coinbase", "spotbit_kraken"],
|
||||
"support": ["coindesk"],
|
||||
},
|
||||
"nzd": {"symbol": "$", "support": ["coindesk", "spotbit_coinbase"]},
|
||||
"hkd": {"symbol": "$", "support": ["coindesk", "spotbit_coinbase"]},
|
||||
"nzd": {"symbol": "$", "support": ["coindesk"]},
|
||||
"hkd": {"symbol": "$", "support": ["coindesk"]},
|
||||
"jpy": {
|
||||
"symbol": "¥",
|
||||
"support": [
|
||||
"coindesk",
|
||||
"spotbit_coinbase",
|
||||
"spotbit_kraken",
|
||||
"spotbit_bitfinex",
|
||||
],
|
||||
},
|
||||
"rub": {"symbol": "₽", "support": ["coindesk", "spotbit_coinbase"]},
|
||||
"ils": {"symbol": "₪", "support": ["coindesk", "spotbit_coinbase"]},
|
||||
"jod": {"symbol": "د.ا", "support": ["coindesk", "spotbit_coinbase"]},
|
||||
"twd": {"symbol": "$", "support": ["coindesk", "spotbit_coinbase"]},
|
||||
"brl": {"symbol": " BRL", "support": ["coindesk", "spotbit_coinbase"]},
|
||||
"rub": {"symbol": "₽", "support": ["coindesk"]},
|
||||
"ils": {"symbol": "₪", "support": ["coindesk"]},
|
||||
"jod": {"symbol": "د.ا", "support": ["coindesk"]},
|
||||
"twd": {"symbol": "$", "support": ["coindesk"]},
|
||||
"brl": {"symbol": " BRL", "support": ["coindesk"]},
|
||||
"xau": {
|
||||
"symbol": " oz. ",
|
||||
"support": ["coindesk", "spotbit_coinbase"],
|
||||
"support": ["coindesk"],
|
||||
"weight_unit_convertible": True,
|
||||
},
|
||||
"xag": {
|
||||
"symbol": " oz. ",
|
||||
"support": ["coindesk", "spotbit_coinbase"],
|
||||
"support": ["coindesk"],
|
||||
"weight_unit_convertible": True,
|
||||
},
|
||||
"xpt": {
|
||||
"symbol": " oz. ",
|
||||
"support": ["spotbit_coinbase"],
|
||||
"support": [],
|
||||
"weight_unit_convertible": True,
|
||||
},
|
||||
"xpd": {
|
||||
"symbol": " oz. ",
|
||||
"support": ["spotbit_coinbase"],
|
||||
"support": [],
|
||||
"weight_unit_convertible": True,
|
||||
},
|
||||
}
|
||||
|
|
@ -106,6 +85,7 @@ def update_price(specter, current_user):
|
|||
specter.update_alt_symbol(symbol, current_user)
|
||||
return True
|
||||
except SpecterError as e:
|
||||
handle_exception(e)
|
||||
logger.error(f"{e} while updating price")
|
||||
except Exception as e:
|
||||
handle_exception(e)
|
||||
|
|
@ -125,6 +105,7 @@ def get_price_at(specter, timestamp="now"):
|
|||
"""returns a price and a currency-symbol at the timestamp"""
|
||||
try:
|
||||
if specter.price_check:
|
||||
|
||||
requests_session = specter.requests_session(
|
||||
force_tor=("spotbit" in specter.price_provider)
|
||||
)
|
||||
|
|
@ -137,7 +118,7 @@ def get_price_at(specter, timestamp="now"):
|
|||
)
|
||||
except AttributeError:
|
||||
raise SpecterError(f"Currency not supported: {currency}")
|
||||
|
||||
print("MUH" + specter.price_provider)
|
||||
if exchange not in currency_mapping[currency]["support"]:
|
||||
raise SpecterError(
|
||||
f"The currency {currency} is not supported on exchange {exchange}"
|
||||
|
|
@ -165,17 +146,21 @@ def get_price_at(specter, timestamp="now"):
|
|||
raise SpecterError("coindesk does not support historic prices")
|
||||
elif specter.price_provider.startswith("spotbit"):
|
||||
exchange = specter.price_provider.split("spotbit_")[1].split("_")[0]
|
||||
|
||||
if timestamp == "now":
|
||||
|
||||
price = failsafe_request_get(
|
||||
requests_session,
|
||||
"http://h6zwwkcivy2hjys6xpinlnz2f74dsmvltzsd4xb42vinhlcaoe7fdeqd.onion/now/{}/{}".format(
|
||||
currency, exchange
|
||||
"http://r5sru63gzyrnaayaua2ydo32f4hf6vd33bq6qmtktx3wjoib2cwi2gqd.onion/api/now/{}/{}".format(
|
||||
currency.upper(), exchange
|
||||
),
|
||||
)["close"]
|
||||
else:
|
||||
price = failsafe_request_get(
|
||||
requests_session,
|
||||
"http://h6zwwkcivy2hjys6xpinlnz2f74dsmvltzsd4xb42vinhlcaoe7fdeqd.onion/hist/{}/{}/{}/{}".format(
|
||||
# TODO: Fix to use `start` and `end` query date time parameters instead of path parameters
|
||||
# Hope that works like this:
|
||||
"http://r5sru63gzyrnaayaua2ydo32f4hf6vd33bq6qmtktx3wjoib2cwi2gqd.onion/api/history/{}/{}?start={}&end={}".format(
|
||||
currency,
|
||||
exchange,
|
||||
timestamp * 1000,
|
||||
|
|
@ -201,6 +186,10 @@ def _parse_exchange_currency(exchange_currency):
|
|||
# e.g. "spotbit_bitstamp_eur" or "bitstamp_eur"
|
||||
arr = exchange_currency.split("_")
|
||||
if len(arr) == 2:
|
||||
if not arr[1] in currency_mapping.keys():
|
||||
raise SpecterError(
|
||||
f"{arr[1]} is not a valid currency. Received: {exchange_currency}"
|
||||
)
|
||||
return arr[0], arr[1]
|
||||
elif len(arr) == 3:
|
||||
return f"{arr[0]}_{arr[1]}", arr[2]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue