diff --git a/README.md b/README.md
index 07e6137..0a8d4b1 100644
--- a/README.md
+++ b/README.md
@@ -27,6 +27,7 @@ This is the Java wrapper for the Bitvavo API. This project can be used to build
* Cancel Orders [REST](https://github.com/bitvavo/java-bitvavo-api#cancel-orders) [Websocket](https://github.com/bitvavo/java-bitvavo-api#cancel-orders-1)
* Orders Open [REST](https://github.com/bitvavo/java-bitvavo-api#get-orders-open) [Websocket](https://github.com/bitvavo/java-bitvavo-api#get-orders-open-1)
* Trades [REST](https://github.com/bitvavo/java-bitvavo-api#get-trades) [Websocket](https://github.com/bitvavo/java-bitvavo-api#get-trades-1)
+ * Account [REST](https://github.com/bitvavo/java-bitvavo-api#get-account) [Websocket](https://github.com/bitvavo/java-bitvavo-api#get-account-1)
* Balance [REST](https://github.com/bitvavo/java-bitvavo-api#get-balance) [Websocket](https://github.com/bitvavo/java-bitvavo-api#get-balance-1)
* Deposit Assets [REST](https://github.com/bitvavo/java-bitvavo-api#deposit-assets) [Websocket](https://github.com/bitvavo/java-bitvavo-api#deposit-assets-1)
* Withdraw Assets [REST](https://github.com/bitvavo/java-bitvavo-api#withdraw-assets) [Websocket](https://github.com/bitvavo/java-bitvavo-api#withdraw-assets-1)
@@ -616,7 +617,9 @@ for(int i = 0; i < response.length(); i ++) {
When placing an order, make sure that the correct optional parameters are set. For a limit order it is required to set both the amount and price. A market order is valid if either the amount or the amountQuote has been set.
```java
// optional parameters: limit:(amount, price, postOnly), market:(amount, amountQuote, disableMarketProtection),
-// both: timeInForce, selfTradePrevention, responseRequired
+// stopLoss/takeProfit:(amount, amountQuote, disableMarketProtection, triggerType, triggerReference, triggerAmount)
+// stopLossLimit/takeProfitLimit:(amount, price, postOnly, triggerType, triggerReference, triggerAmount)
+// all orderTypes: timeInForce, selfTradePrevention, responseRequired
System.out.println(bitvavo.placeOrder("BTC-EUR", "sell", "limit",
new JSONObject("{ amount: 0.1, price: 4000 }")).toString(2));
```
@@ -654,7 +657,8 @@ System.out.println(bitvavo.placeOrder("BTC-EUR", "sell", "limit",
When updating an order make sure that at least one of the optional parameters has been set. Otherwise nothing can be updated.
```java
// Optional parameters: limit:(amount, amountRemaining, price, timeInForce, selfTradePrevention, postOnly)
-// (set at least 1) (responseRequired can be set as well, but does not update anything)
+// untriggered stopLoss/takeProfit:(amount, amountQuote, disableMarketProtection, triggerType, triggerReference, triggerAmount)
+// stopLossLimit/takeProfitLimit: (amount, price, postOnly, triggerType, triggerReference, triggerAmount)
System.out.println(bitvavo.updateOrder("BTC-EUR", "81080b09-2415-44e3-b61c-50ffca4a0221",
new JSONObject("{ amount: 0.2 }")));
```
@@ -974,6 +978,24 @@ for(int i = 0; i < response.length(); i ++) {
```
+#### Get account
+```java
+System.out.println(bitvavo.account().toString(2));
+```
+
+ View Response
+
+```java
+{
+ "fees": {
+ "taker": "0.0025",
+ "maker": "0.0015",
+ "volume": "100"
+ }
+}
+```
+
+
#### Get balance
Returns the balance for this account.
```java
@@ -1780,7 +1802,9 @@ ws.ticker24h(new JSONObject(), new WebsocketClientEndpoint.MessageHandler() {
When placing an order, make sure that the correct optional parameters are set. For a limit order it is required to set both the amount and price. A market order is valid if either the amount or the amountQuote has been set.
```java
// optional parameters: limit:(amount, price, postOnly), market:(amount, amountQuote, disableMarketProtection),
-// both: timeInForce, selfTradePrevention, responseRequired
+// stopLoss/takeProfit:(amount, amountQuote, disableMarketProtection, triggerType, triggerReference, triggerAmount)
+// stopLossLimit/takeProfitLimit:(amount, price, postOnly, triggerType, triggerReference, triggerAmount)
+// all orderTypes: timeInForce, selfTradePrevention, responseRequired
ws.placeOrder("BTC-EUR", "sell", "limit", new JSONObject("{ amount: 0.1, price: 4000 }"),
new WebsocketClientEndpoint.MessageHandler() {
public void handleMessage(JSONObject responseObject) {
@@ -1822,7 +1846,8 @@ ws.placeOrder("BTC-EUR", "sell", "limit", new JSONObject("{ amount: 0.1, price:
When updating an order make sure that at least one of the optional parameters has been set. Otherwise nothing can be updated.
```java
// Optional parameters: limit:(amount, amountRemaining, price, timeInForce, selfTradePrevention, postOnly)
-// (set at least 1) (responseRequired can be set as well, but does not update anything)
+// untriggered stopLoss/takeProfit:(amount, amountQuote, disableMarketProtection, triggerType, triggerReference, triggerAmount)
+// stopLossLimit/takeProfitLimit: (amount, price, postOnly, triggerType, triggerReference, triggerAmount)
ws.updateOrder("BTC-EUR", "81080b09-2415-44e3-b61c-50ffca4a0221", new JSONObject("{ amount: 0.2 }"),
new WebsocketClientEndpoint.MessageHandler() {
public void handleMessage(JSONObject responseObject) {
@@ -2170,6 +2195,29 @@ ws.trades("BTC-EUR", new JSONObject(), new WebsocketClientEndpoint.MessageHandle
```
+#### Get account
+```java
+ws.account(new WebsocketClientEndpoint.MessageHandler() {
+ public void handleMessage(JSONObject responseObject) {
+ JSONObject response = responseObject.getJSONObject("response");
+ System.out.println(response.toString(2));
+ }
+});
+```
+
+ View Response
+
+```java
+{
+ "fees": {
+ "taker": "0.0025",
+ "maker": "0.0015",
+ "volume": "100"
+ }
+}
+```
+
+
#### Get balance
Returns the balance for this account.
```java
diff --git a/src/main/java/com/bitvavo/api/Bitvavo.java b/src/main/java/com/bitvavo/api/Bitvavo.java
index 9028de5..86d748f 100644
--- a/src/main/java/com/bitvavo/api/Bitvavo.java
+++ b/src/main/java/com/bitvavo/api/Bitvavo.java
@@ -553,7 +553,10 @@ public JSONArray ticker24h(JSONObject options) {
* @param market The market for which the order should be created
* @param side is this a buy or sell order
* @param orderType is this a limit or market order
- * @param body optional body parameters: limit:(amount, price, postOnly), market:(amount, amountQuote, disableMarketProtection), both: timeInForce, selfTradePrevention, responseRequired
+ * @param body optional body parameters: limit:(amount, price, postOnly), market:(amount, amountQuote, disableMarketProtection)
+ * stopLoss/takeProfit:(amount, amountQuote, disableMarketProtection, triggerType, triggerReference, triggerAmount)
+ * stopLossLimit/takeProfitLimit:(amount, price, postOnly, triggerType, triggerReference, triggerAmount)
+ * all orderTypes: timeInForce, selfTradePrevention, responseRequired
* @return JSONObject response, get status of the order through response.getString("status")
*/
public JSONObject placeOrder(String market, String side, String orderType, JSONObject body) {
@@ -582,7 +585,8 @@ public JSONObject getOrder(String market, String orderId) {
* @param market the market the order resides on
* @param orderId the id of the order which should be updated
* @param body optional body parameters: limit:(amount, amountRemaining, price, timeInForce, selfTradePrevention, postOnly)
- * (set at least 1) (responseRequired can be set as well, but does not update anything)
+ * untriggered stopLoss/takeProfit:(amount, amountQuote, disableMarketProtection, triggerType, triggerReference, triggerAmount)
+ * stopLossLimit/takeProfitLimit: (amount, price, postOnly, triggerType, triggerReference, triggerAmount)
* @return JSONObject response, get status of the order through response.getString("status")
*/
public JSONObject updateOrder(String market, String orderId, JSONObject body) {
@@ -649,6 +653,14 @@ public JSONArray trades(String market, JSONObject options) {
return privateRequestArray("/trades", postfix, "GET", new JSONObject());
}
+ /**
+ * Return the fee tier for an account
+ * @return JSONObject response, get taker fee through: response.getJSONObject("fees").getString("taker")
+ */
+ public JSONObject account() {
+ return privateRequest("/account", "", "GET", new JSONObject());
+ }
+
/**
* Returns the balance for an account
* @param options optional parameters: symbol
@@ -908,7 +920,10 @@ public void tickerBook(JSONObject options, WebsocketClientEndpoint.MessageHandle
* @param market market on which the order should be created
* @param side is this a sell or buy order
* @param orderType is this a limit or market order
- * @param body optional body parameters: limit:(amount, price, postOnly), market:(amount, amountQuote, disableMarketProtection), both: timeInForce, selfTradePrevention, responseRequired
+ * @param body optional body parameters: limit:(amount, price, postOnly), market:(amount, amountQuote, disableMarketProtection)
+ * stopLoss/takeProfit:(amount, amountQuote, disableMarketProtection, triggerType, triggerReference, triggerAmount)
+ * stopLossLimit/takeProfitLimit:(amount, price, postOnly, triggerType, triggerReference, triggerAmount)
+ * all orderTypes: timeInForce, selfTradePrevention, responseRequired
* @param msgHandler callback
* @return JSONObject response, get order object through response.getJSONObject("response")
*/
@@ -944,7 +959,8 @@ public void getOrder(String market, String orderId, WebsocketClientEndpoint.Mess
* @param market market on which the order should be updated
* @param orderId the order which should be updated
* @param body optional body parameters: limit:(amount, amountRemaining, price, timeInForce, selfTradePrevention, postOnly)
- * (set at least 1) (responseRequired can be set as well, but does not update anything)
+ * untriggered stopLoss/takeProfit:(amount, amountQuote, disableMarketProtection, triggerType, triggerReference, triggerAmount)
+ * stopLossLimit/takeProfitLimit: (amount, price, postOnly, triggerType, triggerReference, triggerAmount)
* @param msgHandler callback
* @return JSONObject response, get order object through response.getJSONObject("response")
*/
@@ -1029,6 +1045,18 @@ public void trades(String market, JSONObject options, WebsocketClientEndpoint.Me
doSendPrivate(options);
}
+ /**
+ * Returns the fee tier for an account
+ *
+ * @param msgHandler callback
+ * @return JSONObject response, get taker fee through response.getJSONObject("response").getJSONObject("fees").getString("taker")
+ */
+ public void account(WebsocketClientEndpoint.MessageHandler msgHandler) {
+ ws.addAccountHandler(msgHandler);
+ JSONObject options = new JSONObject("{ action: privateGetAccount }");
+ doSendPrivate(options);
+ }
+
/**
* Returns the balance for an account
*
diff --git a/src/main/java/com/bitvavo/api/WebsocketClientEndpoint.java b/src/main/java/com/bitvavo/api/WebsocketClientEndpoint.java
index 5ea4f56..c78b0ad 100644
--- a/src/main/java/com/bitvavo/api/WebsocketClientEndpoint.java
+++ b/src/main/java/com/bitvavo/api/WebsocketClientEndpoint.java
@@ -42,6 +42,7 @@ public class WebsocketClientEndpoint {
private MessageHandler getOrdersHandler;
private MessageHandler getOrdersOpenHandler;
private MessageHandler getTradesHandler;
+ private MessageHandler getAccountHandler;
private MessageHandler balanceHandler;
private MessageHandler depositAssetsHandler;
private MessageHandler withdrawAssetsHandler;
@@ -550,6 +551,11 @@ else if(response.getString("action").equals("privateGetTrades")) {
this.getTradesHandler.handleMessage(response);
}
}
+ else if(response.getString("action").equals("privateGetAccount")) {
+ if (this.getAccountHandler != null) {
+ this.getAccountHandler.handleMessage(response);
+ }
+ }
else if(response.getString("action").equals("privateGetBalance")) {
if(this.balanceHandler != null) {
this.balanceHandler.handleMessage(response);
@@ -657,6 +663,10 @@ public void addGetTradesHandler(MessageHandler msgHandler) {
this.getTradesHandler = msgHandler;
}
+ public void addAccountHandler(MessageHandler msgHandler) {
+ this.getAccountHandler = msgHandler;
+ }
+
public void addBalanceHandler(MessageHandler msgHandler) {
this.balanceHandler = msgHandler;
}
diff --git a/src/main/java/com/bitvavo/api/example/example.java b/src/main/java/com/bitvavo/api/example/example.java
index 27f5984..b8e32a3 100644
--- a/src/main/java/com/bitvavo/api/example/example.java
+++ b/src/main/java/com/bitvavo/api/example/example.java
@@ -31,10 +31,7 @@ public static void testREST(Bitvavo bitvavo) {
JSONArray response;
int remaining = bitvavo.getRemainingLimit();
- if (remaining > 0) {
- System.out.println("remaining limit is " + remaining);
- System.out.println(bitvavo.time().toString(2));
- }
+ System.out.println("remaining limit is " + remaining);
// response = bitvavo.markets(new JSONObject());
// for(int i = 0; i < response.length(); i ++) {
@@ -74,6 +71,8 @@ public static void testREST(Bitvavo bitvavo) {
// }
// System.out.println(bitvavo.placeOrder("BTC-EUR", "sell", "limit", new JSONObject("{ amount: 0.1, price: 4000 }")).toString(2));
+
+ // System.out.println(bitvavo.placeOrder("BTC-EUR", "sell", "stopLoss", new JSONObject("{ amount: 0.1, triggerType: price, triggerReference: lastTrade, triggerAmount: 5000 }")).toString(2));
// System.out.println(bitvavo.getOrder("BTC-EUR", "afa9da1c-edb9-4245-9271-3549147845a1").toString(2));
@@ -101,6 +100,8 @@ public static void testREST(Bitvavo bitvavo) {
// System.out.println(response.getJSONObject(i).toString(2));
// }
+ // System.out.println(bitvavo.account().toString(2));
+
// response = bitvavo.balance(new JSONObject());
// for(int i = 0; i < response.length(); i ++) {
// System.out.println(response.getJSONObject(i).toString(2));
@@ -265,6 +266,13 @@ public void handleMessage(JSONObject responseObject) {
// }
// });
+ // ws.account(new WebsocketClientEndpoint.MessageHandler() {
+ // public void handleMessage(JSONObject responseObject) {
+ // JSONObject response = responseObject.getJSONObject("response");
+ // System.out.println(response.toString(2));
+ // }
+ // });
+
// ws.balance(new JSONObject(), new WebsocketClientEndpoint.MessageHandler() {
// public void handleMessage(JSONObject responseObject) {
// JSONArray response = responseObject.getJSONArray("response");