-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1301 from ww3456/develop
[Poloniex] order entry, amend and cancel improvements
- Loading branch information
Showing
15 changed files
with
372 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
xchange-poloniex/src/main/java/org/knowm/xchange/poloniex/dto/trade/PoloniexLimitOrder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.knowm.xchange.poloniex.dto.trade; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.Date; | ||
|
||
import org.knowm.xchange.currency.CurrencyPair; | ||
import org.knowm.xchange.dto.trade.LimitOrder; | ||
|
||
/** | ||
* Poloniex order response contains details of any trades that have just executed in the order entry return value. If a LimitOrder of this type is | ||
* supplied to the trade service orderEntry method it will be populated with this information. | ||
*/ | ||
public class PoloniexLimitOrder extends LimitOrder { | ||
|
||
private PoloniexTradeResponse response = null; | ||
|
||
public PoloniexLimitOrder(OrderType type, BigDecimal tradableAmount, CurrencyPair currencyPair, String id, Date timestamp, BigDecimal limitPrice) { | ||
super(type, tradableAmount, currencyPair, id, timestamp, limitPrice); | ||
} | ||
|
||
public void setResponse(PoloniexTradeResponse value) { | ||
response = value; | ||
} | ||
|
||
public PoloniexTradeResponse getResponse() { | ||
return response; | ||
} | ||
|
||
public static class Builder extends LimitOrder.Builder { | ||
|
||
public Builder(OrderType orderType, CurrencyPair currencyPair) { | ||
super(orderType, currencyPair); | ||
} | ||
|
||
public PoloniexLimitOrder build() { | ||
final PoloniexLimitOrder order = new PoloniexLimitOrder(orderType, tradableAmount, currencyPair, id, timestamp, limitPrice); | ||
order.setOrderFlags(flags); | ||
return order; | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...nge-poloniex/src/main/java/org/knowm/xchange/poloniex/dto/trade/PoloniexMoveResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.knowm.xchange.poloniex.dto.trade; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import si.mazi.rescu.ExceptionalReturnContentException; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.knowm.xchange.poloniex.dto.marketdata.PoloniexPublicTrade; | ||
|
||
public class PoloniexMoveResponse { | ||
|
||
private boolean success; | ||
|
||
private Long orderNumber; | ||
|
||
private Map<String, List<PoloniexPublicTrade>> resultingTrades; | ||
|
||
@JsonCreator | ||
public PoloniexMoveResponse(@JsonProperty("success") Boolean success, @JsonProperty("orderNumber") Long orderNumber, | ||
@JsonProperty("resultingTrades") Map<String, List<PoloniexPublicTrade>> resultingTrades) { | ||
|
||
if (orderNumber == null) { | ||
throw new ExceptionalReturnContentException("No trade data in response"); | ||
} | ||
this.success = success; | ||
this.orderNumber = orderNumber; | ||
this.resultingTrades = resultingTrades; | ||
} | ||
|
||
public boolean success() { | ||
|
||
return success; | ||
} | ||
|
||
public Long getOrderNumber() { | ||
|
||
return orderNumber; | ||
} | ||
|
||
public Map<String, List<PoloniexPublicTrade>> getPoloniexPublicTrades() { | ||
|
||
return resultingTrades; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
xchange-poloniex/src/main/java/org/knowm/xchange/poloniex/dto/trade/PoloniexOrderFlags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.knowm.xchange.poloniex.dto.trade; | ||
|
||
import org.knowm.xchange.dto.Order.IOrderFlags; | ||
|
||
public enum PoloniexOrderFlags implements IOrderFlags { | ||
|
||
/** | ||
* A fill-or-kill order will either fill in its entirety or be completely aborted. | ||
*/ | ||
FILL_OR_KILL, | ||
|
||
/** | ||
* An immediate-or-cancel order can be partially or completely filled, but any portion of the order that cannot be filled immediately will be | ||
* cancelled rather than left on the order book. | ||
*/ | ||
IMMEDIATE_OR_CANCEL, | ||
|
||
/** | ||
* A post-only order will only be placed if no portion of it fills immediately; this guarantees you will never pay the taker fee on any part of the | ||
* order that fills. | ||
*/ | ||
POST_ONLY; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.