Skip to content

Commit

Permalink
Add ability to calculate volume from quoteVolume, and fix Huobi volume.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdupre committed Sep 6, 2021
1 parent bbf4c84 commit 475f613
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.Objects;
import org.knowm.xchange.currency.CurrencyPair;
Expand Down Expand Up @@ -149,6 +150,9 @@ public BigDecimal getVwap() {
}

public BigDecimal getVolume() {
if (volume == null && quoteVolume != null && last != null && last != BigDecimal.ZERO) {
return quoteVolume.divide(last, RoundingMode.HALF_UP);
}

return volume;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static Ticker adaptTicker(HuobiTicker huobiTicker, CurrencyPair currencyP
builder.last(huobiTicker.getClose());
builder.high(huobiTicker.getHigh());
builder.low(huobiTicker.getLow());
builder.volume(huobiTicker.getVol());
builder.quoteVolume(huobiTicker.getVol());
builder.timestamp(huobiTicker.getTs());
builder.currencyPair(currencyPair);
return builder.build();
Expand All @@ -69,7 +69,7 @@ public static List<Ticker> adaptAllTickers(HuobiAllTicker[] allTickers) {
.last(huobiTicker.getClose())
.high(huobiTicker.getHigh())
.low(huobiTicker.getLow())
.volume(huobiTicker.getVol())
.quoteVolume(huobiTicker.getVol())
.timestamp(huobiTicker.getTs())
.build())
.collect(Collectors.toList());
Expand Down

0 comments on commit 475f613

Please sign in to comment.