Skip to content

Commit

Permalink
"BitBay" exchange rebranded to "Zonda" (#195 #194)
Browse files Browse the repository at this point in the history
  • Loading branch information
aneonex authored Feb 15, 2022
1 parent 019af52 commit ec6a6cf
Showing 1 changed file with 23 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,44 @@ package com.aneonex.bitcoinchecker.datamodule.model.market

import com.aneonex.bitcoinchecker.datamodule.model.CheckerInfo
import com.aneonex.bitcoinchecker.datamodule.model.CurrencyPairInfo
import com.aneonex.bitcoinchecker.datamodule.model.Market
import com.aneonex.bitcoinchecker.datamodule.model.Ticker
import com.aneonex.bitcoinchecker.datamodule.model.market.generic.SimpleMarket
import org.json.JSONObject

class BitBay : Market(NAME, TTS_NAME, null) {
companion object {
private const val NAME = "BitBay.net"
private const val TTS_NAME = "Bit Bay"
private const val URL = "https://bitbay.net/API/Public/%1\$s%2\$s/ticker.json"
private const val URL_CURRENCY_PAIRS = "https://api.bitbay.net/rest/trading/ticker"
}
class BitBay : SimpleMarket(
"Zonda (BitBay)",
"https://api.zonda.exchange/rest/trading/ticker",
"https://api.zonda.exchange/rest/trading/ticker/%1\$s",
"Zonda"
) {

override fun getCurrencyPairsUrl(requestId: Int): String {
return URL_CURRENCY_PAIRS
override fun getPairId(checkerInfo: CheckerInfo): String {
return super.getPairId(checkerInfo) ?: with(checkerInfo) { "${currencyBase}-${currencyCounter}" }
}

override fun parseCurrencyPairsFromJsonObject(requestId: Int, jsonObject: JSONObject, pairs: MutableList<CurrencyPairInfo>) {
val itemsJson = jsonObject.getJSONObject("items")
itemsJson.keys().forEach {
val coins = it.split('-')
itemsJson.keys().forEach { pairId ->
val coins = pairId.split('-')
if(coins.size == 2){
pairs.add( CurrencyPairInfo(
coins[0], // base
coins[1], // quote
null
coins[0], // base
coins[1], // quote
pairId
))
}
}
}

override fun getUrl(requestId: Int, checkerInfo: CheckerInfo): String {
return String.format(URL, checkerInfo.currencyBase, checkerInfo.currencyCounter)
}

@Throws(Exception::class)
override fun parseTickerFromJsonObject(requestId: Int, jsonObject: JSONObject, ticker: Ticker, checkerInfo: CheckerInfo) {
ticker.bid = jsonObject.getDouble("bid")
ticker.ask = jsonObject.getDouble("ask")
ticker.vol = jsonObject.getDouble("volume")
if(jsonObject.has("max"))
ticker.high = jsonObject.getDouble("max")
if(jsonObject.has("min"))
ticker.low = jsonObject.getDouble("min")
ticker.last = jsonObject.getDouble("last")
jsonObject
.getJSONObject("ticker")
.let {
ticker.timestamp = it.getLong("time")
ticker.last = it.getDouble("rate")

ticker.bid = it.getDouble("highestBid")
ticker.ask = it.getDouble("lowestAsk")
}
}
}

0 comments on commit ec6a6cf

Please sign in to comment.