hashgraph / hedera-exchange-rate-tool

Hedera Exchange Rate Tool to send median of HBAR/USD exchange rate from various Exchanges to Hedera Network
Apache License 2.0
2 stars 4 forks source link

Use a chain of coin pairs to derive USD/HBAR rate #91

Open noshmody opened 4 years ago

noshmody commented 4 years ago

if an exchange does not directly offer an hbar/usd pair, we can chain other pairs to derive an hbar/usd pair. For example, if the exchange offered a usd/btc pair and a hbar/btc, then dividing the second by the first would generate an equivalent usd/hbar pair.

Requirements for the chaining are here

https://hederatest.sharepoint.com/:w:/s/HederaHome/EfiCGVQQdX9PsRCdYupHIggBujOZqkyeX2L35k4vzRiJSg?e=DdCU2L

And during debugging, the answer from each chain can be compared to the numbers on this web page:

https://coinmarketcap.com/currencies/hedera-hashgraph/markets/

paulmadsenhed commented 4 years ago

The current situation is that there are only 3 exchanges that have a USD-HBAR pair - Bittrex, Liquid and OKCoin - all of which the ERT alredy uses

lbaird commented 4 years ago

Interesting. I assume each of the 18 exchanges has USD-BTC and BTC-HBAR. Maybe we take the ratio?

paulmadsenhed commented 4 years ago

That would allow us to add Binance, OKex, and UpBit as they all support HBAR/BTC and USD/BTC

lbaird commented 4 years ago

Cool. And if they can tell us hbar volume, then we could do a weighted median.

paulmadsenhed commented 4 years ago

Ok, will work on requirements.

paulmadsenhed commented 4 years ago

Actually, turns out that Upbit doesnt have an HBAR-BTC pair, and OKEX has only a BTC-USDT pair.

So it would only be Binance that we could add to ERT using this ratio mechanism.

lbaird commented 4 years ago

Do Upbit and OKEX have a pair of HBAR with anything? Does that anything pair with USD?

paulmadsenhed commented 4 years ago

UpBit - has only HBAR-KRW Okex - has HBAR-BTC but no pair with USD (fiat restrictions?)

according to CMC, we have the following pairs to work with

https://coinmarketcap.com/currencies/hedera-hashgraph/markets/

unless we contemplated HBAR -> BTC --> USDT --> USD ??

lbaird commented 4 years ago

We could do HBAR -> BTC --> USDT --> USD. It’s an interesting question whether we get better answers doing that, or just excluding them entirely. Maybe excluding them is safer.

But if we ever do use a long chain like that, then the “volume” of the chain should be the minimum volume of all the pairs in the chain.

We also need to figure out which rate and volume to use with each exchange. I think Liquid has something like both “rate” and “rate_24”, and the latter was more accurate than the former in recent days. But I don’t know what they mean.

paulmadsenhed commented 4 years ago

for review https://hederatest.sharepoint.com/:w:/s/HederaHome/EfiCGVQQdX9PsRCdYupHIggByhI9FyaT4NJiCc8bu_nIzA?e=s3CX3R

paulmadsenhed commented 4 years ago

Note that Coinbase lists a HBAR/USD price for all exchanges, even those that dont directly offer that pair. So they must be doing the same sort of 'pair chaining'.

https://coinmarketcap.com/currencies/hedera-hashgraph/markets/

lbaird commented 4 years ago

For debugging and for testing, we should use that web page to check whether we’re getting close to the same answer they are for each exchange. It’s a nice check.

lbaird commented 4 years ago

I've now summarized this whole thread in the top comment.

paulmadsenhed commented 4 years ago

ack

paulmadsenhed commented 3 years ago

@lbaird if we relax the requirement that both pairs come from the same exchange, our options increase.

For instance, pull HBAR/BTC from Binance, and BTC/USD from Coinbase (https://api.coinbase.com/v2/prices/BTC-USD/buy) we can calculate HBAR/USD .

Once we have that BTC/USD price, we can use it for multiple other exchanges in the same manner and significantly expand our coverage

lbaird commented 3 years ago

That’s true. Or maybe USDT or other stable coins.


From: paulmadsenhed notifications@github.com Sent: Saturday, January 9, 2021 5:39:17 AM To: hashgraph/hedera-exchange-rate-tool hedera-exchange-rate-tool@noreply.github.com Cc: Leemon Baird lbairdgit@gmail.com; Mention mention@noreply.github.com Subject: Re: [hashgraph/hedera-exchange-rate-tool] Use a chain of coin pairs to derive USD/HBAR rate (#91)

@lbairdhttps://github.com/lbaird if we relax the requirement that both pairs come from the same exchange, our options increase.

For instance, pull HBAR/BTC from Binance, and BTC/USD from Coinbase we can calculate HBAR/USD .

Once we have that BTC/USD price, we can use it for multiple other exchanges in the same manner and significantly expand our coverage

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/hashgraph/hedera-exchange-rate-tool/issues/91#issuecomment-757136799, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABDBYWY6VBARRUEYCFK5Y23SZA56LANCNFSM4KDNP4IA.