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 #2801 from SaschaZ/add_missing_order_parameters
[Bitmex] Add missing order parameters
- Loading branch information
Showing
18 changed files
with
1,788 additions
and
876 deletions.
There are no files selected for viewing
1,072 changes: 641 additions & 431 deletions
1,072
xchange-bitmex/src/main/java/org/knowm/xchange/bitmex/Bitmex.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
xchange-bitmex/src/main/java/org/knowm/xchange/bitmex/dto/trade/BitmexContingencyType.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,19 @@ | ||
package org.knowm.xchange.bitmex.dto.trade; | ||
|
||
@SuppressWarnings("unused") | ||
public enum BitmexContingencyType { | ||
OCO("OneCancelsTheOther"), | ||
OTO("OneTriggersTheOther"), | ||
OUOA("OneUpdatesTheOtherAbsolute"), | ||
OUOP("OneUpdatesTheOtherProportional"); | ||
|
||
private String apiParameter; | ||
|
||
BitmexContingencyType(String apiParameter) { | ||
this.apiParameter = apiParameter; | ||
} | ||
|
||
public String toApiParameter() { | ||
return apiParameter; | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
...e-bitmex/src/main/java/org/knowm/xchange/bitmex/dto/trade/BitmexExecutionInstruction.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,108 @@ | ||
package org.knowm.xchange.bitmex.dto.trade; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@SuppressWarnings("unused") | ||
public enum BitmexExecutionInstruction { | ||
PARTICIPATE_DO_NOT_INITIATE("ParticipateDoNotInitiate"), | ||
ALL_OR_NONE("AllOrNone"), | ||
MARK_PRICE("MarkPrice"), | ||
INDEX_PRICE("IndexPrice"), | ||
LAST_PRICE("LastPrice"), | ||
CLOSE("Close"), | ||
REDUCE_ONLY("ReduceOnly"), | ||
FIXED("Fixed"); | ||
|
||
private String apiParameter; | ||
|
||
BitmexExecutionInstruction(String apiParameter) { | ||
this.apiParameter = apiParameter; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return apiParameter; | ||
} | ||
|
||
public static class Builder { | ||
|
||
private boolean postOnly; | ||
private boolean allOrNone; | ||
private boolean markPrice; | ||
private boolean indexPrice; | ||
private boolean lastPrice; | ||
private boolean close; | ||
private boolean reduceOnly; | ||
private boolean fixed; | ||
|
||
public List<BitmexExecutionInstruction> build() { | ||
final ArrayList<BitmexExecutionInstruction> instructions = new ArrayList<>(); | ||
if (postOnly) { | ||
instructions.add(PARTICIPATE_DO_NOT_INITIATE); | ||
} | ||
if (allOrNone) { | ||
instructions.add(ALL_OR_NONE); | ||
} | ||
if (markPrice) { | ||
instructions.add(MARK_PRICE); | ||
} | ||
if (indexPrice) { | ||
instructions.add(INDEX_PRICE); | ||
} | ||
if (lastPrice) { | ||
instructions.add(LAST_PRICE); | ||
} | ||
if (close) { | ||
instructions.add(CLOSE); | ||
} | ||
if (reduceOnly) { | ||
instructions.add(REDUCE_ONLY); | ||
} | ||
if (fixed) { | ||
instructions.add(FIXED); | ||
} | ||
return instructions; | ||
} | ||
|
||
public Builder setPostOnly(boolean postOnly) { | ||
this.postOnly = postOnly; | ||
return this; | ||
} | ||
|
||
public Builder setAllOrNone(boolean allOrNone) { | ||
this.allOrNone = allOrNone; | ||
return this; | ||
} | ||
|
||
public Builder setMarkPrice(boolean markPrice) { | ||
this.markPrice = markPrice; | ||
return this; | ||
} | ||
|
||
public Builder setIndexPrice(boolean indexPrice) { | ||
this.indexPrice = indexPrice; | ||
return this; | ||
} | ||
|
||
public Builder setLastPrice(boolean lastPrice) { | ||
this.lastPrice = lastPrice; | ||
return this; | ||
} | ||
|
||
public Builder setClose(boolean close) { | ||
this.close = close; | ||
return this; | ||
} | ||
|
||
public Builder setReduceOnly(boolean reduceOnly) { | ||
this.reduceOnly = reduceOnly; | ||
return this; | ||
} | ||
|
||
public Builder setFixed(boolean fixed) { | ||
this.fixed = fixed; | ||
return this; | ||
} | ||
} | ||
} |
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
76 changes: 16 additions & 60 deletions
76
xchange-bitmex/src/main/java/org/knowm/xchange/bitmex/dto/trade/BitmexOrderType.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 |
---|---|---|
@@ -1,67 +1,23 @@ | ||
package org.knowm.xchange.bitmex.dto.trade; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.core.ObjectCodec; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.knowm.xchange.bitmex.dto.trade.BitmexOrderType.BitmexOrderTypeDeserializer; | ||
|
||
@JsonDeserialize(using = BitmexOrderTypeDeserializer.class) | ||
@SuppressWarnings("unused") | ||
public enum BitmexOrderType { | ||
MARKET, | ||
LIMIT, | ||
STOP_LOSS, | ||
TAKE_PROFIT, | ||
STOP_LOSS_PROFIT, | ||
STOP_LOSS_PROFIT_LIMIT, | ||
STOP_LOSS_LIMIT, | ||
TAKE_PROFIT_LIMIT, | ||
TRAILING_STOP, | ||
TRAILING_STOP_LIMIT, | ||
STOP_LOSS_AND_LIMIT, | ||
SETTLE_POSITION; | ||
|
||
private static final Map<String, BitmexOrderType> fromString = new HashMap<>(); | ||
|
||
static { | ||
for (BitmexOrderType orderType : values()) fromString.put(orderType.toString(), orderType); | ||
|
||
fromString.put("l", LIMIT); | ||
fromString.put("m", MARKET); | ||
LIMIT("Limit"), | ||
STOP("Stop"), | ||
MARKET("Market"), | ||
STOP_LIMIT("StopLimit"), | ||
PEGGED("Pegged"), | ||
MARKET_IF_TOUCHED("MarketIfTouched"), | ||
LIMIT_IF_TOUCHED("MarketIfTouched"), | ||
MARKET_WITH_LEFT_OVER_AS_LIMIT("MarketWithLeftOverAsLimit"); | ||
|
||
private String apiParameter; | ||
|
||
BitmexOrderType(String apiParameter) { | ||
this.apiParameter = apiParameter; | ||
} | ||
|
||
public static BitmexOrderType fromString(String orderTypeString) { | ||
|
||
return fromString.get(orderTypeString.replace('-', '_').toLowerCase()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
|
||
return super.toString().toLowerCase(); | ||
} | ||
|
||
public String toApiFormat() { | ||
|
||
return name().toLowerCase().replace('_', '-'); | ||
} | ||
|
||
static class BitmexOrderTypeDeserializer extends JsonDeserializer<BitmexOrderType> { | ||
|
||
@Override | ||
public BitmexOrderType deserialize(JsonParser jsonParser, DeserializationContext ctxt) | ||
throws IOException, JsonProcessingException { | ||
|
||
ObjectCodec oc = jsonParser.getCodec(); | ||
JsonNode node = oc.readTree(jsonParser); | ||
String orderTypeString = node.textValue(); | ||
return fromString(orderTypeString); | ||
} | ||
public String toApiParameter() { | ||
return apiParameter; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
...e-bitmex/src/main/java/org/knowm/xchange/bitmex/dto/trade/BitmexOrderTypeDescription.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,69 @@ | ||
package org.knowm.xchange.bitmex.dto.trade; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.core.ObjectCodec; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.knowm.xchange.bitmex.dto.trade.BitmexOrderTypeDescription.BitmexOrderTypeDeserializer; | ||
|
||
@JsonDeserialize(using = BitmexOrderTypeDeserializer.class) | ||
public enum BitmexOrderTypeDescription { | ||
MARKET, | ||
LIMIT, | ||
STOP_LOSS, | ||
TAKE_PROFIT, | ||
STOP_LOSS_PROFIT, | ||
STOP_LOSS_PROFIT_LIMIT, | ||
STOP_LOSS_LIMIT, | ||
TAKE_PROFIT_LIMIT, | ||
TRAILING_STOP, | ||
TRAILING_STOP_LIMIT, | ||
STOP_LOSS_AND_LIMIT, | ||
SETTLE_POSITION; | ||
|
||
private static final Map<String, BitmexOrderTypeDescription> fromString = new HashMap<>(); | ||
|
||
static { | ||
for (BitmexOrderTypeDescription orderType : values()) | ||
fromString.put(orderType.toString(), orderType); | ||
|
||
fromString.put("l", LIMIT); | ||
fromString.put("m", MARKET); | ||
} | ||
|
||
public static BitmexOrderTypeDescription fromString(String orderTypeString) { | ||
|
||
return fromString.get(orderTypeString.replace('-', '_').toLowerCase()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
|
||
return super.toString().toLowerCase(); | ||
} | ||
|
||
public String toApiFormat() { | ||
|
||
return name().toLowerCase().replace('_', '-'); | ||
} | ||
|
||
static class BitmexOrderTypeDeserializer extends JsonDeserializer<BitmexOrderTypeDescription> { | ||
|
||
@Override | ||
public BitmexOrderTypeDescription deserialize( | ||
JsonParser jsonParser, DeserializationContext ctxt) | ||
throws IOException, JsonProcessingException { | ||
|
||
ObjectCodec oc = jsonParser.getCodec(); | ||
JsonNode node = oc.readTree(jsonParser); | ||
String orderTypeString = node.textValue(); | ||
return fromString(orderTypeString); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
xchange-bitmex/src/main/java/org/knowm/xchange/bitmex/dto/trade/BitmexPegPriceType.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,20 @@ | ||
package org.knowm.xchange.bitmex.dto.trade; | ||
|
||
@SuppressWarnings("unused") | ||
public enum BitmexPegPriceType { | ||
LAST_PEG("LastPeg"), | ||
MID_PRICE_PEG("MidPricePeg"), | ||
MARGET_PEG("MarketPeg"), | ||
PRIMARY_PEG("PrimaryPeg"), | ||
TRAILING_STOP_PEG("TrailingStopPeg"); | ||
|
||
private String apiParameter; | ||
|
||
BitmexPegPriceType(String apiParameter) { | ||
this.apiParameter = apiParameter; | ||
} | ||
|
||
public String toApiParameter() { | ||
return apiParameter; | ||
} | ||
} |
Oops, something went wrong.