Updated examples with toCurrency.

This commit is contained in:
Erik C. Thauvin 2021-05-25 18:41:24 -07:00
parent 2590fe67b8
commit 2aad45a9bd
2 changed files with 21 additions and 17 deletions

View file

@ -7,20 +7,22 @@ import net.thauvin.erik.crypto.CryptoPrice.Companion.toPrice
fun main(@Suppress("UNUSED_PARAMETER") args: Array<String>) {
// Get current Bitcoin market price.
val price = marketPrice("BTC")
println("The current Bitcoin price is ${price.amount} in ${price.currency}")
println("The current Bitcoin price is ${price.toCurrency()}")
// Get current Bitcoin market price in Euro.
val euroPrice = marketPrice("BTC", "EUR")
println("The current Bitcoin price is ${euroPrice.amount} in Euros")
// Get current Bitcoin buy price using API.
// See: https://developers.coinbase.com/api/v2#get-buy-price
val buyPrice = apiCall(listOf("prices", "BTC-USD", "buy"), emptyMap()).toPrice()
println("The current BTC buy price is ${buyPrice.amount} in ${buyPrice.currency}")
println("The current Bitcoin price is ${euroPrice.toCurrency()}")
println()
// Get current Ethereum market price in Pound sterling.
val gbpPrice = marketPrice("ETH", "GBP")
println("The current Ehtereum price is ${gbpPrice.amount} in Pound sterling")
println("The current Ehtereum price is ${gbpPrice.toCurrency()}")
println()
// Get current Bitcoin buy price using API.
// See: https://developers.coinbase.com/api/v2#get-buy-price
val buyPrice = apiCall(listOf("prices", "BTC-USD", "buy"), emptyMap()).toPrice()
println("The current ${buyPrice.base} buy price is ${buyPrice.amount} in ${buyPrice.currency}")
}