Skip to content

Commit

Permalink
[gateio-v4] Add Currency deserializer
Browse files Browse the repository at this point in the history
  • Loading branch information
bigscoop committed Oct 26, 2023
1 parent 9400af4 commit 2bc4db1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import lombok.Builder;
import lombok.Data;
import lombok.extern.jackson.Jacksonized;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.Order.OrderType;
import org.knowm.xchange.gateio.config.converter.CurrencyPairToStringConverter;
import org.knowm.xchange.gateio.config.converter.OrderTypeToStringConverter;
import org.knowm.xchange.gateio.config.converter.StringToCurrencyConverter;
import org.knowm.xchange.gateio.config.converter.StringToCurrencyPairConverter;
import org.knowm.xchange.gateio.config.converter.StringToOrderTypeConverter;

Expand Down Expand Up @@ -85,7 +87,8 @@ public class GateioOrder {
BigDecimal fee;

@JsonProperty("fee_currency")
String feeCurrency;
@JsonDeserialize(converter = StringToCurrencyConverter.class)
Currency feeCurrency;

@JsonProperty("point_fee")
BigDecimal pointFee;
Expand All @@ -106,7 +109,8 @@ public class GateioOrder {
BigDecimal rebatedFee;

@JsonProperty("rebated_fee_currency")
String rebatedFeeCurrency;
@JsonDeserialize(converter = StringToCurrencyConverter.class)
Currency rebatedFeeCurrency;

@JsonProperty("stp_id")
Integer stpId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public abstract class GateioExchangeWiremock {

protected static GateioExchange exchange;

// private static final boolean IS_RECORDING = true;
private static final boolean IS_RECORDING = false;

private static WireMockServer wireMockServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.time.Instant;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.Order.OrderStatus;
import org.knowm.xchange.dto.Order.OrderType;
Expand Down Expand Up @@ -36,14 +37,14 @@ class GateioTradeServiceRawTest extends GateioExchangeWiremock {
.avgDealPrice(new BigDecimal("27038.3"))
.fee(new BigDecimal("0.0000014"))
.price(BigDecimal.ZERO)
.feeCurrency("BTC")
.feeCurrency(Currency.BTC)
.pointFee(BigDecimal.ZERO)
.gtFee(BigDecimal.ZERO)
.gtMakerFee(BigDecimal.ZERO)
.gtTakerFee(BigDecimal.ZERO)
.rebatedFee(BigDecimal.ZERO)
.gtDiscount(false)
.rebatedFeeCurrency("USDT")
.rebatedFeeCurrency(Currency.USDT)
.finishAs("filled")
.build();

Expand Down Expand Up @@ -112,14 +113,14 @@ void valid_market_sell_order() throws IOException {
.avgDealPrice(new BigDecimal("27062.6"))
.fee(new BigDecimal("0.03788764"))
.price(BigDecimal.ZERO)
.feeCurrency("USDT")
.feeCurrency(Currency.USDT)
.pointFee(BigDecimal.ZERO)
.gtFee(BigDecimal.ZERO)
.gtMakerFee(BigDecimal.ZERO)
.gtTakerFee(BigDecimal.ZERO)
.rebatedFee(BigDecimal.ZERO)
.gtDiscount(false)
.rebatedFeeCurrency("BTC")
.rebatedFeeCurrency(Currency.BTC)
.finishAs("filled")
.build();

Expand Down

0 comments on commit 2bc4db1

Please sign in to comment.