Skip to content

Commit

Permalink
Merge pull request #2 from timmolter/develop
Browse files Browse the repository at this point in the history
Merging
  • Loading branch information
makarid authored Jan 25, 2018
2 parents c0ca244 + 0ab945f commit 0dd83e5
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 54 deletions.
12 changes: 6 additions & 6 deletions xchange-bitfinex/src/main/resources/bitfinex.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@
"currencies": {
"BTC": {
"scale": 8,
"withdrawal_fee": 0.0005
"withdrawal_fee": 0.0008
},
"BCH": {
"scale": 8,
"withdrawal_fee": 0.0005
"withdrawal_fee": 0.0001
},
"ETH": {
"scale": 8,
"withdrawal_fee": 0.01
"withdrawal_fee": 0.00405
},
"ETC": {
"scale": 8,
Expand All @@ -128,7 +128,7 @@
},
"USD": {
"scale": 2,
"withdrawal_fee": 0
"withdrawal_fee": 20.0
},
"XMR": {
"scale": 8,
Expand All @@ -144,15 +144,15 @@
},
"EOS": {
"scale": 8,
"withdrawal_fee": 0.1
"withdrawal_fee": 0.31641
},
"IOT": {
"scale": 8,
"withdrawal_fee": 0.5
},
"USDT": {
"scale": 8,
"withdrawal_fee": 5.0
"withdrawal_fee": 20.0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ public static OpenOrders adaptOpenOrders(List<CexIOOrder> cexIOOrderList) {
for (CexIOOrder cexIOOrder : cexIOOrderList) {
OrderType orderType = cexIOOrder.getType() == CexIOOrder.Type.buy ? OrderType.BID : OrderType.ASK;
String id = Long.toString(cexIOOrder.getId());
limitOrders.add(new LimitOrder(orderType, cexIOOrder.getAmount(), cexIOOrder.getPending(),
new CurrencyPair(cexIOOrder.getTradableIdentifier(), cexIOOrder.getTransactionCurrency()), id,
DateUtils.fromMillisUtc(cexIOOrder.getTime()), cexIOOrder.getPrice()));
limitOrders.add(new LimitOrder(orderType, cexIOOrder.getAmount(),
cexIOOrder.getAmount().subtract(cexIOOrder.getPending()), new CurrencyPair(cexIOOrder.getTradableIdentifier(),
cexIOOrder.getTransactionCurrency()), id, DateUtils.fromMillisUtc(cexIOOrder.getTime()), cexIOOrder.getPrice()
));
}

return new OpenOrders(limitOrders);
Expand Down
37 changes: 23 additions & 14 deletions xchange-dsx/src/main/java/org/knowm/xchange/dsx/DSXAdapters.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
package org.knowm.xchange.dsx;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;

import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dsx.dto.account.DSXAccountInfo;
Expand Down Expand Up @@ -40,6 +30,16 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;

/**
* @author Mikhail Wall
*/
Expand Down Expand Up @@ -133,16 +133,25 @@ public static OpenOrders adaptOrders(Map<Long, DSXOrder> dsxOrderMap) {
OrderType orderType = dsxOrder.getType() == DSXOrder.Type.buy ? OrderType.BID : OrderType.ASK;
BigDecimal price = dsxOrder.getRate();
CurrencyPair currencyPair = adaptCurrencyPair(dsxOrder.getPair());

limitOrders.add(new LimitOrder(orderType, dsxOrder.getAmount(), currencyPair, Long.toString(id), null, price));
Date timestamp = DateUtils.fromUnixTime(Long.valueOf(dsxOrder.getTimestampCreated()));

limitOrders.add(new LimitOrder(
orderType,
dsxOrder.getAmount(),
dsxOrder.getAmount().subtract(dsxOrder.getRemainingVolume()),
currencyPair,
Long.toString(id),
timestamp,
price
));
}
return new OpenOrders(limitOrders);
}

public static UserTrades adaptTradeHistory(Map<Long, DSXTradeHistoryResult> tradeHistory) {

List<UserTrade> trades = new ArrayList<>(tradeHistory.size());
for (Map.Entry<Long, DSXTradeHistoryResult> entry : tradeHistory.entrySet()) {
for (Entry<Long, DSXTradeHistoryResult> entry : tradeHistory.entrySet()) {
DSXTradeHistoryResult result = entry.getValue();
OrderType type = result.getType() == DSXTradeHistoryResult.Type.buy ? OrderType.BID : OrderType.ASK;
BigDecimal price = result.getRate();
Expand Down Expand Up @@ -193,7 +202,7 @@ public static ExchangeMetaData toMetaData(DSXExchangeInfo dsxExchangeInfo, DSXMe
Map<Currency, CurrencyMetaData> currencies = new HashMap<>();

if (dsxExchangeInfo != null) {
for (Map.Entry<String, DSXPairInfo> e : dsxExchangeInfo.getPairs().entrySet()) {
for (Entry<String, DSXPairInfo> e : dsxExchangeInfo.getPairs().entrySet()) {
CurrencyPair pair = adaptCurrencyPair(e.getKey());
CurrencyPairMetaData marketMetaData = toMarketMetaData(e.getValue());
currencyPairs.put(pair, marketMetaData);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.knowm.xchange.dsx.dto.trade;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.math.BigDecimal;
import java.text.MessageFormat;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* @author Mikhail Wall
*/
Expand All @@ -14,20 +14,36 @@ public class DSXOrder {
private final String pair;
private final Type type;
private final BigDecimal volume;
private final BigDecimal remainingVolume;
private final BigDecimal rate;
private final int status;
private final OrderType orderType;
private final String timestampCreated;

public DSXOrder(@JsonProperty("pair") String pair, @JsonProperty("type") Type type, @JsonProperty("volume") BigDecimal volume,
@JsonProperty("rate") BigDecimal rate, @JsonProperty("status") int status,
@JsonProperty("orderType") OrderType orderType) {
public DSXOrder(@JsonProperty("pair") String pair, @JsonProperty("type") Type type, @JsonProperty("volume") BigDecimal volume, @JsonProperty("remainingVolume") BigDecimal remainingVolume,
@JsonProperty("rate") BigDecimal rate, @JsonProperty("status") int status,
@JsonProperty("orderType") OrderType orderType, @JsonProperty("timestampCreated") String timestampCreated) {

this.pair = pair;
this.type = type;
this.volume = volume;
this.remainingVolume = remainingVolume;
this.rate = rate;
this.status = status;
this.orderType = orderType;
this.timestampCreated = timestampCreated;
}

public BigDecimal getVolume() {
return volume;
}

public BigDecimal getRemainingVolume() {
return remainingVolume;
}

public String getTimestampCreated() {
return timestampCreated;
}

public String getPair() {
Expand All @@ -54,10 +70,18 @@ public OrderType getOrderType() {
return orderType;
}

@Override
public String toString() {

return MessageFormat.format("DSXOrder[pair=''{0}'', type={1}, volume={2}, rate={3}, status={4}, orderType={5}",
pair, type, volume, rate, status, orderType);
return "DSXOrder{" +
"pair='" + pair + '\'' +
", type=" + type +
", volume=" + volume +
", remainingVolume=" + remainingVolume +
", rate=" + rate +
", status=" + status +
", orderType=" + orderType +
", timestampCreated='" + timestampCreated + '\'' +
'}';
}

public enum Type {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.knowm.xchange.dsx.service;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
Expand Down Expand Up @@ -82,8 +83,8 @@ public String placeLimitOrder(LimitOrder limitOrder) throws IOException {

String pair = DSXAdapters.getPair(limitOrder.getCurrencyPair());

DSXOrder dsxOrder = new DSXOrder(pair, type, limitOrder.getOriginalAmount(), limitOrder.getLimitPrice(),
3, DSXOrder.OrderType.limit);
DSXOrder dsxOrder = new DSXOrder(pair, type, limitOrder.getOriginalAmount(), limitOrder.getOriginalAmount(), limitOrder.getLimitPrice(),
3, DSXOrder.OrderType.limit, null);

DSXTradeResult result = tradeDSX(dsxOrder);
return Long.toString(result.getOrderId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static void rawCancelAllOrders(Exchange exchange) throws IOException {

DSXOrder.Type type = DSXOrder.Type.buy;
String pair = "btcusd";
DSXOrder dsxOrder = new DSXOrder(pair, type, new BigDecimal("0.01"), new BigDecimal("900"), 0, DSXOrder.OrderType.limit);
DSXOrder dsxOrder = new DSXOrder(pair, type, new BigDecimal("0.01"), new BigDecimal("900"), new BigDecimal("900"), 0, DSXOrder.OrderType.limit, null);

DSXTradeResult result = null;
DSXTradeResult result1 = null;
Expand Down Expand Up @@ -100,7 +100,8 @@ private static void raw(Exchange exchange) throws IOException {
// place buy order
DSXOrder.Type type = DSXOrder.Type.buy;
String pair = "btcusd";
DSXOrder dsxOrder = new DSXOrder(pair, type, new BigDecimal("0.1"), new BigDecimal("900"), 0, DSXOrder.OrderType.limit);
DSXOrder dsxOrder = new DSXOrder(pair, type, new BigDecimal("0.1"), new BigDecimal("900"), new BigDecimal("900"), 0, DSXOrder.OrderType
.limit, null);

DSXTradeResult result = null;
try {
Expand Down
50 changes: 48 additions & 2 deletions xchange-gateio/src/main/resources/gateio.json
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,56 @@
},
"currencies": {
"BTC": {
"scale": 8
"scale": 8,
"withdrawal_fee": 0.002
},
"ETH": {
"scale": 8
"scale": 8,
"withdrawal_fee": 0.003
},
"USDT": {
"scale": 8,
"withdrawal_fee": 25.0
},
"LTC": {
"scale": 8,
"withdrawal_fee": 0.002
},
"BCH": {
"scale": 8,
"withdrawal_fee": 0.0006
},
"BTG": {
"scale": 8,
"withdrawal_fee": 0.002
},
"ZEC": {
"scale": 8,
"withdrawal_fee": 0.001
},
"ETC": {
"scale": 8,
"withdrawal_fee": 0.010
},
"DASH": {
"scale": 8,
"withdrawal_fee": 0.002
},
"QTUM": {
"scale": 8,
"withdrawal_fee": 0.010
},
"DOGE": {
"scale": 8,
"withdrawal_fee": 10.0
},
"REP": {
"scale": 8,
"withdrawal_fee": 0.010
},
"BAT": {
"scale": 8,
"withdrawal_fee": 10.0
}
},
"public_rate_limits": null,
Expand Down
21 changes: 14 additions & 7 deletions xchange-gdax/src/main/resources/gdax.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,32 @@
},
"currencies": {
"EUR": {
"scale": 2
"scale": 2,
"withdrawal_fee": 0.0
},
"LTC": {
"scale": 8
"scale": 8,
"withdrawal_fee": 0.0
},
"USD": {
"scale": 2
"scale": 2,
"withdrawal_fee": 0.0
},
"BTC": {
"scale": 8
"scale": 8,
"withdrawal_fee": 0.0
},
"BCH": {
"scale": 8
"scale": 8,
"withdrawal_fee": 0.0
},
"ETH": {
"scale": 8
"scale": 8,
"withdrawal_fee": 0.0
},
"GBP": {
"scale": 2
"scale": 2,
"withdrawal_fee": 0.0
}
},
"public_rate_limits": [
Expand Down
Loading

0 comments on commit 0dd83e5

Please sign in to comment.