Skip to content

Commit

Permalink
fix deversifi volume (coingecko#2120)
Browse files Browse the repository at this point in the history
  • Loading branch information
wenjieyek authored Jun 9, 2020
1 parent 8324368 commit dd6e0f9
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 12 deletions.
18 changes: 15 additions & 3 deletions lib/cryptoexchange/exchanges/deversifi/services/market.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ def supports_individual_ticker_query?
end

def fetch(market_pair)
volume_output = super(volume_url)
volume = get_volume(volume_output, market_pair)
output = super(ticker_url(market_pair))
adapt(output[0], market_pair)
adapt(output[0], market_pair, volume)
end

def ticker_url(market_pair)
Expand All @@ -19,7 +21,7 @@ def ticker_url(market_pair)
"#{Cryptoexchange::Exchanges::Deversifi::Market::API_URL}/bfx/v2/tickers?symbols=t#{base}#{target}"
end

def adapt(output, market_pair)
def adapt(output, market_pair, volume)
# [
# 0 SYMBOL,
# 1 BID,
Expand All @@ -43,11 +45,21 @@ def adapt(output, market_pair)
ticker.ask = NumericHelper.to_d(output[3])
ticker.high = NumericHelper.to_d(output[9])
ticker.low = NumericHelper.to_d(output[10])
ticker.volume = NumericHelper.to_d(output[8])
ticker.volume = NumericHelper.to_d(volume)
ticker.timestamp = nil
ticker.payload = output
ticker
end

def volume_url
"#{Cryptoexchange::Exchanges::Deversifi::Market::API_URL}/v1/trading/r/last24HoursVolume"
end

def get_volume(output, market_pair)
target = market_pair.target
target = "USDT" if market_pair.target == "USD"
output["symbols"]["#{market_pair.base}:#{target}"]["tokenAmount"]
end
end
end
end
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dd6e0f9

Please sign in to comment.