diff --git a/CHANGELOG.md b/CHANGELOG.md index d78ea61a..f93702e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,171 @@ # Changelog +## 3.2.0 - 2023-12-22 + +### Added +- New VIP Loans Endpoints: + - `GET /sapi/v1/loan/vip/ongoing/orders` + - `POST /sapi/v1/loan/vip/repay` + - `GET /sapi/v1/loan/vip/repay/history` + - `POST /sapi/v1/loan/vip/renew` + - `GET /sapi/v1/loan/vip/collateral/account` + - `POST /sapi/v1/loan/vip/borrow` + - `GET /sapi/v1/loan/vip/loanable/data` + - `GET /sapi/v1/loan/vip/collateral/data` + - `GET /sapi/v1/loan/vip/request/data` + - `GET /sapi/v1/loan/vip/request/interestRate` + +- New Margin endpoints: + - `GET /sapi/v1/margin/available-inventory` + - `GET /sapi/v1/margin/capital-flow` + - `POST /sapi/v1/margin/max-leverage` + - `GET /sapi/v1/margin/dust` + - `POST /sapi/v1/margin/dust` + - `GET /sapi/v1/margin/delist-schedule` + - `GET /sapi/v1/margin/next-hourly-interest-rate` + - `GET /sapi/v1/margin/exchange-small-liability` + - `POST /sapi/v1/margin/exchange-small-liability` + - `GET /sapi/v1/margin/exchange-small-liability-history` + - `GET /sapi/v1/margin/crossMarginCollateralRatio` + - `GET /sapi/v1/margin/leverageBracket` + - `GET /sapi/v1/margin/tradeCoeff` + +- New Wallet endpoints: + - `GET /sapi/v1/capital/contract/convertible-coins` + - `POST /sapi/v1/capital/contract/convertible-coins` + - `POST /sapi/v1/capital/deposit/credit-apply` + - `GET /sapi/v1/asset/wallet/balance` + - `GET /sapi/v1/asset/custody/transfer-history` + - `GET /sapi/v1/capital/deposit/address/list` + +- New Futures endpoint: + - `GET /sapi/v1/futures/histDataLink` + +- New Classic Porfolio Margin endpoints: + - `GET /sapi/v1/portfolio/margin-asset-leverage` + - `POST /sapi/v1/portfolio/asset-collection` + - `POST /sapi/v1/portfolio/repay-futures-switch` + - `GET /sapi/v1/portfolio/repay-futures-switch` + - `POST /sapi/v1/portfolio/repay-futures-negative-balance` + - `POST /sapi/v1/portfolio/auto-collection` + - `POST /sapi/v1/portfolio/bnb-transfer` + - `GET /sapi/v1/portfolio/asset-index-price` + - `GET /sapi/v1/portfolio/interest-history` + +- New Trade endpoints: + - `GET /api/v3/myPreventedMatches` + - `GET /api/v3/myAllocations` + - `GET /api/v3/account/commission` + - `POST /api/v3/sor/order` + - `POST /api/v3/sor/order/test` + +- New Market endpoint: + - `GET /api/v3/ticker/tradingDay` + +- New Gift Code endpoints: + - `POST /sapi/v1/giftcard/buyCode` + - `GET /sapi/v1/giftcard/buyCode/token-limit` + +- New Crypto Loans endpoints: + - `POST /sapi/v1/loan/flexible/borrow` + - `GET /sapi/v1/loan/flexible/ongoing/orders` + - `GET /sapi/v1/loan/flexible/borrow/history` + - `POST /sapi/v1/loan/flexible/repay` + - `POST /sapi/v1/loan/flexible/repay/history` + - `POST /sapi/v1/loan/flexible/adjust/ltv` + - `GET /sapi/v1/loan/flexible/ltv/adjustment/history` + - `GET /sapi/v1/loan/flexible/loanable/data` + - `GET /sapi/v1/loan/flexible/collateral/data` + +- New Simple Earn endpoints: + - `GET /sapi/v1/simple-earn/flexible/list` + - `GET /sapi/v1/simple-earn/locked/list` + - `POST /sapi/v1/simple-earn/flexible/subscribe` + - `POST /sapi/v1/simple-earn/locked/subscribe` + - `POST /sapi/v1/simple-earn/flexible/redeem` + - `POST /sapi/v1/simple-earn/locked/redeem` + - `GET /sapi/v1/simple-earn/flexible/position` + - `GET /sapi/v1/simple-earn/locked/position` + - `GET /sapi/v1/simple-earn/account` + - `GET /sapi/v1/simple-earn/flexible/history/subscriptionRecord` + - `GET /sapi/v1/simple-earn/locked/history/subscriptionRecord` + - `GET /sapi/v1/simple-earn/flexible/history/redemptionRecord` + - `GET /sapi/v1/simple-earn/locked/history/redemptionRecord` + - `GET /sapi/v1/simple-earn/flexible/history/rewardsRecord` + - `GET /sapi/v1/simple-earn/locked/history/rewardsRecord` + - `POST /sapi/v1/simple-earn/flexible/setAutoSubscribe` + - `POST /sapi/v1/simple-earn/locked/setAutoSubscribe` + - `GET /sapi/v1/simple-earn/flexible/personalLeftQuota` + - `GET /sapi/v1/simple-earn/locked/personalLeftQuota` + - `GET /sapi/v1/simple-earn/flexible/subscriptionPreview` + - `GET /sapi/v1/simple-earn/locked/subscriptionPreview` + - `GET /sapi/v1/simple-earn/flexible/history/rateHistory` + - `GET /sapi/v1/simple-earn/flexible/history/collateralRecord` + +- New Auto-Invest endpoints: + - `GET /sapi/v1/lending/auto-invest/target-asset/list` + - `GET /sapi/v1/lending/auto-invest/target-asset/roi/list` + - `GET /sapi/v1/lending/auto-invest/all/asset` + - `GET /sapi/v1/lending/auto-invest/source-asset/list` + - `POST /sapi/v1/lending/auto-invest/plan/edit-status` + - `GET /sapi/v1/lending/auto-invest/plan/list` + - `GET /sapi/v1/lending/auto-invest/plan/id` + - `GET /sapi/v1/lending/auto-invest/history/list` + - `GET /sapi/v1/lending/auto-invest/index/info` + - `GET /sapi/v1/lending/auto-invest/index/user-summary` + - `POST /sapi/v1/lending/auto-invest/one-off` + - `GET /sapi/v1/lending/auto-invest/one-off/status` + - `POST /sapi/v1/lending/auto-invest/redeem` + - `GET /sapi/v1/lending/auto-invest/redeem/history` + - `GET /sapi/v1/lending/auto-invest/rebalance/history` + +- New Spot Algo endpoints: + - `POST /sapi/v1/algo/spot/newOrderTwap` + - `DELETE /sapi/v1/algo/spot/order` + - `GET /sapi/v1/algo/spot/openOrders` + - `GET /sapi/v1/algo/spot/historicalOrders` + - `GET /sapi/v1/algo/spot/subOrders` + +- New Staking endpoints: + - `POST /sapi/v2/eth-staking/eth/stake` + - `POST /sapi/v1/eth-staking/eth/redeem` + - `GET /sapi/v1/eth-staking/eth/history/stakingHistory` + - `GET /sapi/v1/eth-staking/eth/history/redemptionHistory` + - `GET /sapi/v1/eth-staking/eth/history/rewardsHistory` + - `GET /sapi/v1/eth-staking/eth/quota` + - `GET /sapi/v1/eth-staking/eth/history/rateHistory` + - `GET /sapi/v2/eth-staking/account` + - `POST /sapi/v1/eth-staking/wbeth/wrap` + - `GET /sapi/v1/eth-staking/wbeth/history/wrapHistory` + - `GET /sapi/v1/eth-staking/wbeth/history/unwrapHistory` + - `GET /sapi/v1/eth-staking/eth/history/wbethRewardsHistory` + +- WebSocket API - New Trade requests: + - `sor.order.place` + - `sor.order.test` + +- WebSocket API - New Account requests: + - `myAllocations` + - `account.commission` + +- WebSocket API - New Authentication requests: + - `session.logon` + - `session.status` + - `session.logout` + +- WebSocket API - New Market request: + - `ticker.tradingDay` + +### Removed +- Deleted deprecated Savings endpoints, namely: + - `GET /sapi/v1/lending/project/list` + - `POST /sapi/v1/lending/customizedFixed/purchase` + - `GET /sapi/v1/lending/project/position/list` + - `POST /sapi/v1/lending/positionChanged` + +### Changed +- Renamed Sub-Account examples and tests to be similar to their respective method names. + ## 3.1.0 - 2023-10-17 ### Added diff --git a/README.md b/README.md index 435eceb7..bf80e2ed 100644 --- a/README.md +++ b/README.md @@ -3,19 +3,22 @@ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Code Style](https://img.shields.io/badge/code%20style-checkstyle-yellow)](https://checkstyle.org/checks.html) -This is a lightweight library that works as a connector to the [Binance public API](https://github.com/binance/binance-spot-api-docs) +This is a lightweight library that works as a connector to the [Binance public API](https://github.com/binance/binance-spot-api-docs). -- Supported APIs: - - `/api/*` - - `/sapi/*` - - Spot WebSocket Market Stream - - Spot User Data Stream - - Spot WebSocket API +It supports the following APIs: + - `/api/*` endpoints; + - `/sapi/*` endpoints; + - Spot WebSocket Market Stream; + - Spot User Data Stream; + - Spot WebSocket API; -- Test cases and examples +Additionally, it includes test cases and examples. -## Installation -Replace `LATEST_VERSION` with the latest version number and paste the snippet below in `pom.xml` +## Documentation +[https://www.javadoc.io/doc/io.github.binance/binance-connector-java/latest/index.html](https://www.javadoc.io/doc/io.github.binance/binance-connector-java/latest/index.html) + +## Getting Started +Copy and paste the following dependency snippet into your `pom.xml` file, replacing `LATEST_VERSION`` with the most [recent version](https://mvnrepository.com/artifact/io.github.binance/binance-connector-java) available: ``` io.github.binance @@ -23,64 +26,27 @@ Replace `LATEST_VERSION` with the latest version number and paste the snippet be LATEST_VERSION ``` -Run `mvn install` where `pom.xml` is located to install the dependency. +Next, install the dependency by executing `mvn install` in the directory where your `pom.xml` is located. -## Documentation -[https://www.javadoc.io/doc/io.github.binance/binance-connector-java/latest/index.html](https://www.javadoc.io/doc/io.github.binance/binance-connector-java/latest/index.html) +## Examples +The examples are located under **src/test/java/examples**. Before running any of it, `PrivateConfig.java` must be set up correctly with `API_KEY` and` SECRET_KEY` or `PRIVATE_KEY_PATH` (if using RSA Keys). -### Run Example -The examples are located under **src/test/java/examples**. - -Before running any of it, `PrivateConfig.java` must be set up correctly with `API_KEY` and` SECRET_KEY` or `PRIVATE_KEY_PATH` (if using RSA Keys). - -Note that this `PrivateConfig.java` is only used for examples, -you should have your own configuration file when using the library. - -### RESTful APIs - -The endpoints are categorized according to the [Binance](https://binance-docs.github.io/apidocs/spot/en/#change-log) API document. -Each object corresponds to its category which will be used -to call its respective endpoints. - - -| Category | Object | -| --------------- | ---------------- | -| Binance Code | createGiftCard | -| BLVT | createBlvt | -| BSwap | createBswap | -| C2C | createC2C | -| Convert | createConvert | -| CryptoLoans | createCrytoLoans | -| Fiat | createFiat | -| Futures | createFutures | -| Margin | createMargin | -| Market | createMarket | -| Mining | createMining | -| NFT | createNFT | -| Pay | createPay | -| Portfolio Margin| createPortfolioMargin | -| Rebate | createRebate | -| Savings | createSavings | -| Staking | createStaking | -| Sub Account | createsubAccount | -| Trade | createTrade | -| UserData | createUserData | -| Wallet | createWallet | - -
+Note that this `PrivateConfig.java` is only used for examples, you should have your own configuration file when using the library. + +### REST APIs #### Market Endpoint: Exchange Information ```java SpotClient client = new SpotClientImpl(); -String result = client.createMarket().exchangeInfo(); +Map parameters = new LinkedHashMap<>(); +String result = client.createMarket().exchangeInfo(parameters); ``` #### Trade Endpoint: Testing a new order ```java -Map parameters = new LinkedHashMap(); - SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); +Map parameters = new LinkedHashMap(); parameters.put("symbol","BTCUSDT"); parameters.put("side", "SELL"); parameters.put("type", "LIMIT"); @@ -92,7 +58,6 @@ String result = client.createTrade().testNewOrder(parameters); ``` ### WebSocket Stream - ```java WebSocketStreamClient wsStreamClient = new WebSocketStreamClientImpl(); // defaults to live exchange unless stated. @@ -119,17 +84,14 @@ wsStreamClient.closeAllConnections(); Different types of WebSocket callbacks are available. Please refer to the `src/test/java/examples/websocketstream/TradeStreamWithAllCallbacks.java` example file to explore their usage. -More examples are available at `src/test/java/examples/websocketstream` folder. - ### WebSocket API - ```java RsaSignatureGenerator signatureGenerator = new RsaSignatureGenerator("PRIVATE_KEY_PATH"); -WebSocketApiClient wsApiClient = new WebSocketApiClientImpl("API_KEY", signatureGenerator); // defaults to live exchange unless stated. +WebSocketApiClient wsApiClient = new WebSocketApiClientImpl("API_KEY", signatureGenerator); // defaults to live exchange unless stated // Open connection with a callback as parameter wsApiClient.connect(((message) -> { - System.out.println(message); +System.out.println(message); })); JSONObject optionalParams = new JSONObject(); @@ -138,7 +100,7 @@ optionalParams.put("quantity", 1); wsApiClient.trade().testNewOrder("BTCUSDT", "BUY", "MARKET", optionalParams); -Thread.sleep(3000); +Thread.sleep(60000); // Close connection wsApiClient.close(); @@ -148,12 +110,10 @@ If `requestId` is empty (`""`), `null` or not sent, this library will generate a Different types of WebSocket callbacks are available. Please refer to the `src/test/java/examples/websocketapi/WsApiwithAllCallbacks.java` example file to explore their usage. -More examples are available at `src/test/java/examples/websocketapi` folder. - +## Features ### Testnet - -While `/sapi/*` endpoints don't have testnet environment yet, `/api/*` endpoints can be tested in -[Spot Testnet](https://testnet.binance.vision/). You can use it by changing the base URL: +While `/sapi/*` endpoints do not yet have a testnet environment, `/api/*` endpoints can be tested on the [Spot Testnet](https://testnet.binance.vision/). +You can use it by changing the base URL: ```java Map parameters = new LinkedHashMap<>(); @@ -163,8 +123,8 @@ String result = client.createMarket().time(); ``` ### Base URL +If `baseUrl` is not provided, it defaults to `api.binance.com`. -If `baseUrl` is not provided, it defaults to `api.binance.com`.
It's recommended to pass in the `baseUrl` parameter, even in production as Binance provides alternative URLs: - `https://api1.binance.com` - `https://api2.binance.com` @@ -172,8 +132,8 @@ It's recommended to pass in the `baseUrl` parameter, even in production as Binan - `https://api4.binance.com` ### Optional parameters +Parameters can be set in any implementation of `Map` interface, where `String` represents the parameter name and `Object` the parameter value. These parameters should have the same naming as in the API doc." -All parameters are read from a `Map` implemented data structure where `String` is the name of the parameter and `Object` is the value of the parameter. The parameters should follow their exact naming as in the API documentation.
```java Map parameters = new LinkedHashMap(); @@ -186,24 +146,20 @@ parameters.put("price", 9500); ``` ### Response MetaData - -The Binance API server provides weight usages in the headers of each response. This value can be return by -calling `setShowLimitUsage` and setting it to `true`. +The Binance API server provides weight usages in the headers of each response, which can be returned if you set `setShowLimitUsage(true)`. ```java SpotClient client = new SpotClientImpl(); client.setShowLimitUsage(true); String result = client.createMarket().time(); logger.info(result); ``` -output: +Output: ``` INFO: {"data":"{"serverTime":1633434339494}","x-mbx-used-weight":"1","x-mbx-used-weight-1m":"1"} ``` ### Proxy -HTTP Proxy is supported. - -To set it up, call `setProxy()` with `ProxyAuth` and before submitting requests to binance: +To set HTTP Proxy, call `setProxy()` with `ProxyAuth` and before submitting requests: ```java SpotClient client = new SpotClientImpl(); @@ -236,8 +192,7 @@ client.setProxy(proxy); logger.info(client.createMarket().time()); ``` -To undo `Proxy`, use `unsetProxy()` before submitting requests to binance: - +To undo `Proxy`, use `unsetProxy()` before submitting requests: ```java client.unsetProxy(); logger.info(client.createMarket().time()); @@ -284,7 +239,7 @@ When creating `SpotClient`, `WebSocketStreamClient` or `WebSocketApiClient`, you SpotClient client = new SpotClientImpl("ApiKey", signGenerator); ``` -### Error +## Errors There are 3 types of error which may be thrown by this library. @@ -310,11 +265,12 @@ try { } ``` -### Test +## Test Cases `mvn clean test` -## Contributing +## Contribution +Contributions are welcome! + +If you've found a bug within this project, please open an issue to discuss what you would like to change. -Contributions are welcome.
-If you've found a bug within this project, please open an issue to discuss what you would like to change.
-If it's an issue with the API, please open a topic at [Binance Developer Community](https://dev.binance.vision) +If it's an issue with the API itself, you can submit on the [Binance Developer Community](https://dev.binance.vision) diff --git a/pom.xml b/pom.xml index 550321cf..d4ae67cd 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.binance binance-connector-java - 3.1.0 + 3.2.0 jar ${project.groupId}:${project.artifactId} lightweight connector to API diff --git a/src/main/java/com/binance/connector/client/SpotClient.java b/src/main/java/com/binance/connector/client/SpotClient.java index ff08a081..ed7c3425 100644 --- a/src/main/java/com/binance/connector/client/SpotClient.java +++ b/src/main/java/com/binance/connector/client/SpotClient.java @@ -1,5 +1,6 @@ package com.binance.connector.client; +import com.binance.connector.client.impl.spot.AutoInvest; import com.binance.connector.client.impl.spot.BSwap; import com.binance.connector.client.impl.spot.Blvt; import com.binance.connector.client.impl.spot.C2C; @@ -15,11 +16,13 @@ import com.binance.connector.client.impl.spot.Pay; import com.binance.connector.client.impl.spot.PortfolioMargin; import com.binance.connector.client.impl.spot.Rebate; -import com.binance.connector.client.impl.spot.Savings; +import com.binance.connector.client.impl.spot.SimpleEarn; +import com.binance.connector.client.impl.spot.SpotAlgo; import com.binance.connector.client.impl.spot.Staking; import com.binance.connector.client.impl.spot.SubAccount; import com.binance.connector.client.impl.spot.Trade; import com.binance.connector.client.impl.spot.UserData; +import com.binance.connector.client.impl.spot.VIPLoans; import com.binance.connector.client.impl.spot.Wallet; import com.binance.connector.client.utils.ProxyAuth; @@ -28,6 +31,7 @@ public interface SpotClient { void setShowLimitUsage(boolean showLimitUsage); void setProxy(ProxyAuth proxy); void unsetProxy(); + AutoInvest createAutoInvest(); Blvt createBlvt(); BSwap createBswap(); C2C createC2C(); @@ -43,10 +47,12 @@ public interface SpotClient { Pay createPay(); PortfolioMargin createPortfolioMargin(); Rebate createRebate(); - Savings createSavings(); + SimpleEarn createSimpleEarn(); + SpotAlgo createSpotAlgo(); Staking createStaking(); SubAccount createSubAccount(); Trade createTrade(); UserData createUserData(); + VIPLoans createVIPLoans(); Wallet createWallet(); } diff --git a/src/main/java/com/binance/connector/client/WebSocketApiClient.java b/src/main/java/com/binance/connector/client/WebSocketApiClient.java index 1b302986..f223e74a 100644 --- a/src/main/java/com/binance/connector/client/WebSocketApiClient.java +++ b/src/main/java/com/binance/connector/client/WebSocketApiClient.java @@ -1,6 +1,7 @@ package com.binance.connector.client; import com.binance.connector.client.impl.websocketapi.WebSocketApiAccount; +import com.binance.connector.client.impl.websocketapi.WebSocketApiAuth; import com.binance.connector.client.impl.websocketapi.WebSocketApiGeneral; import com.binance.connector.client.impl.websocketapi.WebSocketApiMarket; import com.binance.connector.client.impl.websocketapi.WebSocketApiTrade; @@ -15,9 +16,10 @@ public interface WebSocketApiClient { void connect(WebSocketMessageCallback onMessageCallback); void connect(WebSocketOpenCallback onOpenCallback, WebSocketMessageCallback onMessageCallback, WebSocketClosingCallback onClosingCallback, WebSocketClosedCallback onClosedCallback, WebSocketFailureCallback onFailureCallback); void close(); + WebSocketApiAccount account(); + WebSocketApiAuth auth(); WebSocketApiGeneral general(); WebSocketApiMarket market(); WebSocketApiTrade trade(); - WebSocketApiAccount account(); WebSocketApiUserDataStream userDataStream(); } diff --git a/src/main/java/com/binance/connector/client/enums/Category.java b/src/main/java/com/binance/connector/client/enums/Category.java new file mode 100644 index 00000000..2c9298ca --- /dev/null +++ b/src/main/java/com/binance/connector/client/enums/Category.java @@ -0,0 +1,10 @@ +package com.binance.connector.client.enums; + +public enum Category { + ACCOUNT, + AUTH, + GENERAL, + MARKET, + TRADE, + USER_DATA_STREAM +} diff --git a/src/main/java/com/binance/connector/client/impl/SpotClientImpl.java b/src/main/java/com/binance/connector/client/impl/SpotClientImpl.java index f231808b..682d451b 100644 --- a/src/main/java/com/binance/connector/client/impl/SpotClientImpl.java +++ b/src/main/java/com/binance/connector/client/impl/SpotClientImpl.java @@ -2,6 +2,7 @@ import com.binance.connector.client.SpotClient; import com.binance.connector.client.enums.DefaultUrls; +import com.binance.connector.client.impl.spot.AutoInvest; import com.binance.connector.client.impl.spot.BSwap; import com.binance.connector.client.impl.spot.Blvt; import com.binance.connector.client.impl.spot.C2C; @@ -17,11 +18,13 @@ import com.binance.connector.client.impl.spot.Pay; import com.binance.connector.client.impl.spot.PortfolioMargin; import com.binance.connector.client.impl.spot.Rebate; -import com.binance.connector.client.impl.spot.Savings; +import com.binance.connector.client.impl.spot.SimpleEarn; +import com.binance.connector.client.impl.spot.SpotAlgo; import com.binance.connector.client.impl.spot.Staking; import com.binance.connector.client.impl.spot.SubAccount; import com.binance.connector.client.impl.spot.Trade; import com.binance.connector.client.impl.spot.UserData; +import com.binance.connector.client.impl.spot.VIPLoans; import com.binance.connector.client.impl.spot.Wallet; import com.binance.connector.client.utils.ProxyAuth; import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; @@ -76,6 +79,11 @@ public void unsetProxy() { this.proxy = null; } + @Override + public AutoInvest createAutoInvest() { + return new AutoInvest(baseUrl, apiKey, signatureGenerator, showLimitUsage, proxy); + } + @Override public Blvt createBlvt() { return new Blvt(baseUrl, apiKey, signatureGenerator, showLimitUsage, proxy); @@ -151,8 +159,13 @@ public Rebate createRebate() { } @Override - public Savings createSavings() { - return new Savings(baseUrl, apiKey, signatureGenerator, showLimitUsage, proxy); + public SimpleEarn createSimpleEarn() { + return new SimpleEarn(baseUrl, apiKey, signatureGenerator, showLimitUsage, proxy); + } + + @Override + public SpotAlgo createSpotAlgo() { + return new SpotAlgo(baseUrl, apiKey, signatureGenerator, showLimitUsage, proxy); } @Override @@ -175,6 +188,11 @@ public UserData createUserData() { return new UserData(baseUrl, apiKey, showLimitUsage, proxy); } + @Override + public VIPLoans createVIPLoans() { + return new VIPLoans(baseUrl, apiKey, signatureGenerator, showLimitUsage, proxy); + } + @Override public Wallet createWallet() { return new Wallet(baseUrl, apiKey, signatureGenerator, showLimitUsage, proxy); diff --git a/src/main/java/com/binance/connector/client/impl/WebSocketApiClientImpl.java b/src/main/java/com/binance/connector/client/impl/WebSocketApiClientImpl.java index 0aa03975..659dfc4c 100644 --- a/src/main/java/com/binance/connector/client/impl/WebSocketApiClientImpl.java +++ b/src/main/java/com/binance/connector/client/impl/WebSocketApiClientImpl.java @@ -1,9 +1,11 @@ package com.binance.connector.client.impl; import com.binance.connector.client.WebSocketApiClient; +import com.binance.connector.client.enums.Category; import com.binance.connector.client.enums.DefaultUrls; import com.binance.connector.client.exceptions.BinanceConnectorException; import com.binance.connector.client.impl.websocketapi.WebSocketApiAccount; +import com.binance.connector.client.impl.websocketapi.WebSocketApiAuth; import com.binance.connector.client.impl.websocketapi.WebSocketApiGeneral; import com.binance.connector.client.impl.websocketapi.WebSocketApiMarket; import com.binance.connector.client.impl.websocketapi.WebSocketApiTrade; @@ -33,11 +35,6 @@ public class WebSocketApiClientImpl implements WebSocketApiClient { private final WebSocketFailureCallback noopFailureCallback = (throwable, response) -> { }; private WebSocketConnection connection; private WebSocketApiRequestHandler requestHandler; - private WebSocketApiGeneral wsApiGeneral; - private WebSocketApiMarket wsApiMarket; - private WebSocketApiTrade wsApiTrade; - private WebSocketApiAccount wsApiAccount; - private WebSocketApiUserDataStream wsApiUserDataStream; public WebSocketApiClientImpl() { this("", null); @@ -63,22 +60,6 @@ private void checkRequestHandler() { } } - private void checkCategoryInstance(Object categoryInstance, Class categoryClass) { - if (categoryInstance == null) { - if (categoryClass == WebSocketApiGeneral.class) { - this.wsApiGeneral = new WebSocketApiGeneral(this.requestHandler); - } else if (categoryClass == WebSocketApiMarket.class) { - this.wsApiMarket = new WebSocketApiMarket(this.requestHandler); - } else if (categoryClass == WebSocketApiTrade.class) { - this.wsApiTrade = new WebSocketApiTrade(this.requestHandler); - } else if (categoryClass == WebSocketApiAccount.class) { - this.wsApiAccount = new WebSocketApiAccount(this.requestHandler); - } else if (categoryClass == WebSocketApiUserDataStream.class) { - this.wsApiUserDataStream = new WebSocketApiUserDataStream(this.requestHandler); - } - } - } - @Override public void connect(WebSocketMessageCallback onMessageCallback) { connect(noopOpenCallback, onMessageCallback, noopClosingCallback, noopClosedCallback, noopFailureCallback); @@ -100,38 +81,39 @@ public void close() { } @Override - public WebSocketApiGeneral general() { + public WebSocketApiAccount account() { checkRequestHandler(); - checkCategoryInstance(this.wsApiGeneral, WebSocketApiGeneral.class); - return this.wsApiGeneral; + return (WebSocketApiAccount) WebSocketApiModuleFactory.build(Category.ACCOUNT, this.requestHandler); } @Override - public WebSocketApiMarket market() { + public WebSocketApiAuth auth() { checkRequestHandler(); - checkCategoryInstance(this.wsApiMarket, WebSocketApiMarket.class); - return this.wsApiMarket; + return (WebSocketApiAuth) WebSocketApiModuleFactory.build(Category.AUTH, this.requestHandler); } @Override - public WebSocketApiTrade trade() { + public WebSocketApiGeneral general() { checkRequestHandler(); - checkCategoryInstance(this.wsApiTrade, WebSocketApiTrade.class); - return this.wsApiTrade; + return (WebSocketApiGeneral) WebSocketApiModuleFactory.build(Category.GENERAL, this.requestHandler); } @Override - public WebSocketApiAccount account() { + public WebSocketApiMarket market() { + checkRequestHandler(); + return (WebSocketApiMarket) WebSocketApiModuleFactory.build(Category.MARKET, this.requestHandler); + } + + @Override + public WebSocketApiTrade trade() { checkRequestHandler(); - checkCategoryInstance(this.wsApiAccount, WebSocketApiAccount.class); - return this.wsApiAccount; + return (WebSocketApiTrade) WebSocketApiModuleFactory.build(Category.TRADE, this.requestHandler); } @Override public WebSocketApiUserDataStream userDataStream() { checkRequestHandler(); - checkCategoryInstance(this.wsApiUserDataStream, WebSocketApiUserDataStream.class); - return this.wsApiUserDataStream; + return (WebSocketApiUserDataStream) WebSocketApiModuleFactory.build(Category.USER_DATA_STREAM, this.requestHandler); } } diff --git a/src/main/java/com/binance/connector/client/impl/WebSocketApiModuleFactory.java b/src/main/java/com/binance/connector/client/impl/WebSocketApiModuleFactory.java new file mode 100644 index 00000000..d8dfc2d1 --- /dev/null +++ b/src/main/java/com/binance/connector/client/impl/WebSocketApiModuleFactory.java @@ -0,0 +1,65 @@ +package com.binance.connector.client.impl; + +import com.binance.connector.client.enums.Category; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.websocketapi.WebSocketApiAccount; +import com.binance.connector.client.impl.websocketapi.WebSocketApiAuth; +import com.binance.connector.client.impl.websocketapi.WebSocketApiGeneral; +import com.binance.connector.client.impl.websocketapi.WebSocketApiMarket; +import com.binance.connector.client.impl.websocketapi.WebSocketApiModule; +import com.binance.connector.client.impl.websocketapi.WebSocketApiTrade; +import com.binance.connector.client.impl.websocketapi.WebSocketApiUserDataStream; +import com.binance.connector.client.utils.websocketapi.WebSocketApiRequestHandler; + +public final class WebSocketApiModuleFactory { + + private static WebSocketApiAccount wsApiAccount; + private static WebSocketApiAuth wsApiAuth; + private static WebSocketApiGeneral wsApiGeneral; + private static WebSocketApiMarket wsApiMarket; + private static WebSocketApiTrade wsApiTrade; + private static WebSocketApiUserDataStream wsApiUserDataStream; + + private WebSocketApiModuleFactory() { + // Private constructor to prevent instantiation + } + + private interface ModuleCreator { + WebSocketApiModule create(); + } + + private static WebSocketApiModule obtainModule(WebSocketApiModule module, ModuleCreator creator) { + if (module == null) { + module = creator.create(); + } + return module; + } + + /** + * Build WebSocketApiModule for the given WebSocket API category if it does not exist yet. + * Otherwise, return the existing one. + * + * @param category + * @param requestHandler + * @return WebSocketApiModule + */ + public static WebSocketApiModule build(Category category, WebSocketApiRequestHandler requestHandler) { + switch (category) { + case ACCOUNT: + return obtainModule(wsApiAccount, () -> new WebSocketApiAccount(requestHandler)); + case AUTH: + return obtainModule(wsApiAuth, () -> new WebSocketApiAuth(requestHandler)); + case GENERAL: + return obtainModule(wsApiGeneral, () -> new WebSocketApiGeneral(requestHandler)); + case MARKET: + return obtainModule(wsApiMarket, () -> new WebSocketApiMarket(requestHandler)); + case TRADE: + return obtainModule(wsApiTrade, () -> new WebSocketApiTrade(requestHandler)); + case USER_DATA_STREAM: + return obtainModule(wsApiUserDataStream, () -> new WebSocketApiUserDataStream(requestHandler)); + default: + throw new BinanceConnectorException("Unknown WebSocket API Category: " + category); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/binance/connector/client/impl/spot/AutoInvest.java b/src/main/java/com/binance/connector/client/impl/spot/AutoInvest.java new file mode 100644 index 00000000..078eb915 --- /dev/null +++ b/src/main/java/com/binance/connector/client/impl/spot/AutoInvest.java @@ -0,0 +1,397 @@ +package com.binance.connector.client.impl.spot; + +import java.util.Map; + +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.utils.ParameterChecker; +import com.binance.connector.client.utils.ProxyAuth; +import com.binance.connector.client.utils.RequestHandler; +import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; +import com.binance.connector.client.utils.signaturegenerator.SignatureGenerator; + +/** + *

Auto-Invest Endpoints

+ * All endpoints under the + * Auto-Invest Endpoints + * section of the API documentation will be implemented in this class. + *
+ * Response will be returned in String format. + */ +public class AutoInvest { + private final String baseUrl; + private final RequestHandler requestHandler; + private final boolean showLimitUsage; + + public AutoInvest(String baseUrl, String apiKey, String secretKey, boolean showLimitUsage, ProxyAuth proxy) { + this.baseUrl = baseUrl; + this.requestHandler = new RequestHandler(apiKey, new HmacSignatureGenerator(secretKey), proxy); + this.showLimitUsage = showLimitUsage; + } + + public AutoInvest(String baseUrl, String apiKey, SignatureGenerator signatureGenerator, boolean showLimitUsage, ProxyAuth proxy) { + this.baseUrl = baseUrl; + this.requestHandler = new RequestHandler(apiKey, signatureGenerator, proxy); + this.showLimitUsage = showLimitUsage; + } + + private final String TARGET_ASSET_LIST = "/sapi/v1/lending/auto-invest/target-asset/list"; + /** + * GET /sapi/v1/lending/auto-invest/target-asset/list + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * targetAsset -- optional/string
+ * size -- optional/long -- Default:8 Max:100
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-target-asset-list-user_data + */ + public String targetAssetList(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, TARGET_ASSET_LIST, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String TARGET_ASSET_ROI_LIST = "/sapi/v1/lending/auto-invest/target-asset/roi/list"; + /** + * ROI return list for target asset + * + *

+ * GET /sapi/v1/lending/auto-invest/target-asset/roi/list + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * targetAsset -- mandatory/string
+ * hisRoiType -- mandatory/enum -- FIVE_YEAR,THREE_YEAR,ONE_YEAR,SIX_MONTH,THREE_MONTH,SEVEN_DAY
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-target-asset-roi-data-user_data + */ + public String targetAssetRoiList(Map parameters) { + ParameterChecker.checkParameter(parameters, "targetAsset", String.class); + ParameterChecker.checkParameter(parameters, "hisRoiType", String.class); + return requestHandler.sendSignedRequest(baseUrl, TARGET_ASSET_ROI_LIST, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String ALL_SOURCE_AND_TARGET_ASSETS = "/sapi/v1/lending/auto-invest/all/asset"; + /** + * Query all source assets and target assets + * + *

+ * GET /sapi/v1/lending/auto-invest/all/asset + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-all-source-asset-and-target-asset-user_data + */ + public String allSourceAndTargetAssets(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, ALL_SOURCE_AND_TARGET_ASSETS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String SOURCE_ASSET_LIST = "/sapi/v1/lending/auto-invest/source-asset/list"; + /** + * Query Source Asset to be used for investment + * + *

+ * GET /sapi/v1/lending/auto-invest/source-asset/list + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * targetAsset -- optional/string -- Example: BTC,ETH,BNB
+ * indexId -- optional/long
+ * usageType -- mandatory/string -- "RECURRING", "ONE_TIME"
+ * flexibleAllowedToUse -- optional/boolean
+ * sourceType -- optional/enum -- MAIN_SITE for Binance user,TR for Binance Turkey user
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-source-asset-list-user_data + */ + public String sourceAssetList(Map parameters) { + ParameterChecker.checkParameter(parameters, "usageType", String.class); + return requestHandler.sendSignedRequest(baseUrl, SOURCE_ASSET_LIST, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String CHANGE_PLAN_STATUS = "/sapi/v1/lending/auto-invest/plan/edit-status"; + /** + * Change Plan Status + *

+ * POST /sapi/v1/lending/auto-invest/plan/edit-status + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * planId -- mandatory/long
+ * status -- mandatory/enum -- "ONGOING","PAUSED","REMOVED"
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#change-plan-status-trade + */ + public String changePlanStatus(Map parameters) { + ParameterChecker.checkParameter(parameters, "planId", Long.class); + ParameterChecker.checkParameter(parameters, "status", String.class); + return requestHandler.sendPublicRequest(baseUrl, CHANGE_PLAN_STATUS, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String PLANS = "/sapi/v1/lending/auto-invest/plan/list"; + /** + * Query plan lists + *

+ * GET /sapi/v1/lending/auto-invest/plan/list + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * planType -- mandatory/string
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-list-of-plans-user_data + */ + public String plansList(Map parameters) { + ParameterChecker.checkParameter(parameters, "planType", String.class); + return requestHandler.sendPublicRequest(baseUrl, PLANS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String HOLDING_PLAN = "/sapi/v1/lending/auto-invest/plan/id"; + /** + * Query holding details of the plan + * + *

+ * GET /sapi/v1/lending/auto-invest/plan/id + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * planId -- optional/long
+ * requestId -- optional/string
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-holding-details-of-the-plan-user_data + */ + public String holdingPlan(Map parameters) { + return requestHandler.sendPublicRequest(baseUrl, HOLDING_PLAN, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String PLAN_SUBSCRIPTIONS_HISTORY = "/sapi/v1/lending/auto-invest/history/list"; + /** + * Query the transaction history of plan subscriptions + * + *

+ * GET /sapi/v1/lending/auto-invest/history/list + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * planId -- optional/long
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * targetAsset -- optional/string
+ * planType -- optional/enum
+ * size -- optional/long -- Default:10 Max:100
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-subscription-transaction-history-user_data + */ + public String planSubsHistory(Map parameters) { + return requestHandler.sendPublicRequest(baseUrl, PLAN_SUBSCRIPTIONS_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String INDEX_INFO = "/sapi/v1/lending/auto-invest/index/info"; + /** + * Query index details + * + *

+ * GET /sapi/v1/lending/auto-invest/index/info + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * indexId -- mandatory/long
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-index-details-user_data + */ + public String indexInfo(Map parameters) { + ParameterChecker.checkParameter(parameters, "indexId", Long.class); + return requestHandler.sendSignedRequest(baseUrl, INDEX_INFO, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String INDEX_USER_SUMMARY = "/sapi/v1/lending/auto-invest/index/user-summary"; + /** + * Details on users Index-Linked plan position details + * + *

+ * GET /sapi/v1/lending/auto-invest/index/user-summary + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * indexId -- mandatory/long
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-index-linked-plan-position-details-user_data + */ + public String userIndexPlans(Map parameters) { + ParameterChecker.checkParameter(parameters, "indexId", Long.class); + return requestHandler.sendSignedRequest(baseUrl, INDEX_USER_SUMMARY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String ONE_TIME_TRANSACTION = "/sapi/v1/lending/auto-invest/one-off"; + /** + * One time transaction + * + *

+ * POST /sapi/v1/lending/auto-invest/one-off + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * sourceType -- mandatory/string -- "MAIN_SITE" for Binance,"TR" for Binance Turkey
+ * requestId -- optional/string -- If not null, must follow sourceType + unique string, e.g: TR12354859
+ * subscriptionAmount -- mandatory/decimal
+ * sourceAsset -- mandatory/string
+ * flexibleAllowedToUse -- optional/boolean -- true/false;true: using flexible wallet
+ * planId -- optional/long -- portfolio plan's Id
+ * indexId -- optional/long
+ * details -- optional/arraylist -- The "PortfolioDetail" class contains 2 fields: "targetAsset" and "percentage".
+ * The sum of all the "PortfolioDetail" percentages in the Array should be 100.
+ * "details" example:
+ * details[0].targetAsset=BTC, details[0].percentage=60
+ * details[1].targetAsset=ETH, details[1].percentage=40
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#one-time-transaction-trade + */ + public String submitOneTimeTransaction(Map parameters) { + ParameterChecker.checkParameter(parameters, "sourceType", String.class); + ParameterChecker.checkRequiredParameter(parameters, "subscriptionAmount"); + ParameterChecker.checkParameter(parameters, "sourceAsset", String.class); + return requestHandler.sendSignedRequest(baseUrl, ONE_TIME_TRANSACTION, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String ONE_TIME_TRANSACTION_STATUS = "/sapi/v1/lending/auto-invest/one-off/status"; + /** + * Transaction status for one-time transaction + * + *

+ * GET /sapi/v1/lending/auto-invest/one-off/status + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * transactionId -- mandatory/long -- portfolio plan's Id
+ * requestId -- optional/string -- transactionId and requestId cannot be empty at the same time
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-one-time-transaction-status-user_data + */ + public String oneTimeTransactionStatus(Map parameters) { + ParameterChecker.checkParameter(parameters, "transactionId", Long.class); + return requestHandler.sendSignedRequest(baseUrl, ONE_TIME_TRANSACTION_STATUS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String REDEEM_INDEX_PLAN = "/sapi/v1/lending/auto-invest/redeem"; + /** + * To redeem index-Linked plan holdings + * + *

+ * POST /sapi/v1/lending/auto-invest/redeem + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * indexId -- mandatory/long -- portfolio plan's Id
+ * requestId -- optional/string -- transactionId and requestId cannot be empty at the same time
+ * redemptionPercentage -- mandatory/long -- user redeem percentage,10/20/100.
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#index-linked-plan-redemption-trade + */ + public String redeemIndexPlan(Map parameters) { + ParameterChecker.checkParameter(parameters, "indexId", Long.class); + ParameterChecker.checkParameter(parameters, "redemptionPercentage", Integer.class); + return requestHandler.sendSignedRequest(baseUrl, REDEEM_INDEX_PLAN, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String INDEX_LINKED_PLAN_REDEMPTION_HISTORY = "/sapi/v1/lending/auto-invest/redeem/history"; + /** + * Get the history of Index Linked Plan Redemption transactions + * + * Max 30 day difference between startTime and endTime + * If no startTime and endTime, default to show past 30 day records + * + *

+ * GET /sapi/v1/lending/auto-invest/redeem/history + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * requestId -- mandatory/long
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * asset -- optional/string
+ * size -- optional/long -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#index-linked-plan-redemption-user_data + */ + public String indexPlanRedeemHistory(Map parameters) { + ParameterChecker.checkParameter(parameters, "requestId", Long.class); + return requestHandler.sendSignedRequest(baseUrl, INDEX_LINKED_PLAN_REDEMPTION_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String INDEX_LINKED_PLAN_REBALANCE_DETAILS = "/sapi/v1/lending/auto-invest/rebalance/history"; + /** + * GET /sapi/v1/lending/auto-invest/rebalance/history + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#index-linked-plan-rebalance-details-user_data + */ + public String indexPlanRebalanceInfo(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, INDEX_LINKED_PLAN_REBALANCE_DETAILS, parameters, HttpMethod.GET, showLimitUsage); + } +} diff --git a/src/main/java/com/binance/connector/client/impl/spot/CryptoLoans.java b/src/main/java/com/binance/connector/client/impl/spot/CryptoLoans.java index 29713b6d..14797bb3 100644 --- a/src/main/java/com/binance/connector/client/impl/spot/CryptoLoans.java +++ b/src/main/java/com/binance/connector/client/impl/spot/CryptoLoans.java @@ -96,7 +96,7 @@ public String loanBorrow(Map parameters) { * startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000
- * limit -- optional/long -- Default: 10; max: 100
+ * limit -- optional/long -- Default: 10; max: 100;
* recvWindow -- optional/long
* @return String * @see @@ -118,7 +118,7 @@ public String loanBorrowHistory(Map parameters) { * loanCoin -- optional/string
* collateralCoin -- optional/string
* current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000
- * limit -- optional/long -- Default: 10; max: 100
+ * limit -- optional/long -- Default: 10; max: 100;
* recvWindow -- optional/long
* @return String * @see
@@ -165,7 +165,7 @@ public String loanRepay(Map parameters) { * startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000
- * limit -- optional/long -- Default: 10; max: 100
+ * limit -- optional/long -- Default: 10; max: 100;
* recvWindow -- optional/long
* @return String * @see
@@ -211,7 +211,7 @@ public String loanAdjustLTV(Map parameters) { * startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000
- * limit -- optional/long -- Default: 10; max: 100
+ * limit -- optional/long -- Default: 10; max: 100;
* recvWindow -- optional/long
* @return String * @see
@@ -302,4 +302,209 @@ public String customizeMarginCall(Map parameters) { ParameterChecker.checkRequiredParameter(parameters, "marginCall"); return requestHandler.sendSignedRequest(baseUrl, CUSTOMIZE_MARGIN_CALL, parameters, HttpMethod.POST, showLimitUsage); } + + private final String FLEXIBLE_LOAN_BORROW = "/sapi/v1/loan/flexible/borrow"; + /** + * POST /sapi/v1/loan/flexible/borrow + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * loanCoin -- mandatory/string -- Coin loaned.
+ * loanAmount -- optional/decimal -- Loan amount. Mandatory when collateralAmount is empty.
+ * collateralCoin -- mandatory/string -- Coin used as collateral.
+ * collateralAmount -- optional/decimal -- Mandatory when loanAmount is empty.
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see
+ * https://binance-docs.github.io/apidocs/spot/en/#borrow-flexible-loan-borrow-trade + */ + public String flexibleLoanBorrow(Map parameters) { + ParameterChecker.checkParameter(parameters, "loanCoin", String.class); + ParameterChecker.checkParameter(parameters, "collateralCoin", String.class); + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_BORROW, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String FLEXIBLE_LOAN_ONGOING_ORDERS = "/sapi/v1/loan/flexible/ongoing/orders"; + /** + * GET /sapi/v1/loan/flexible/ongoing/orders + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * loanCoin -- optional/string -- Coin loaned.
+ * collateralCoin -- optional/string -- Coin used as collateral
+ * current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000;
+ * limit -- optional/long -- Default: 10; max: 100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#borrow-get-flexible-loan-ongoing-orders-user_data + */ + public String flexibleLoanOngoingOrders(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_ONGOING_ORDERS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String FLEXIBLE_LOAN_BORROW_HISTORY = "/sapi/v1/loan/flexible/borrow/history"; + /** + * GET /sapi/v1/loan/flexible/borrow/history + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * loanCoin -- optional/string -- Coin loaned
+ * collateralCoin -- optional/string -- Coin used as collateral
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000;
+ * limit -- optional/long -- Default: 10; max: 100;
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#borrow-get-flexible-loan-borrow-history-user_data + */ + public String flexibleLoanBorrowHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_BORROW_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String FLEXIBLE_LOAN_REPAY = "/sapi/v1/loan/flexible/repay"; + /** + * POST /sapi/v1/loan/flexible/repay + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * loanCoin -- mandatory/string -- Coin loaned
+ * collateralCoin -- mandatory/string -- Coin used as collateral
+ * repayAmount -- mandatory/decimal -- repay amount of loanCoin
+ * collateralReturn -- optional/boolean -- Default: TRUE. TRUE: Return extra collateral to earn account; FALSE: Keep extra collateral in the order, and lower LTV.
+ * fullRepayment -- optional/boolean -- Default: FALSE. TRUE: Full repayment; FALSE: Partial repayment, based on loanAmount.
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#repay-flexible-loan-repay-trade + */ + public String flexibleLoanRepay(Map parameters) { + ParameterChecker.checkParameter(parameters, "loanCoin", String.class); + ParameterChecker.checkParameter(parameters, "collateralCoin", String.class); + ParameterChecker.checkRequiredParameter(parameters, "repayAmount"); + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_REPAY, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String FLEXIBLE_LOAN_REPAY_HISTORY = "/sapi/v1/loan/flexible/repay/history"; + /** + * GET /sapi/v1/loan/flexible/repay/history + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * loanCoin -- optional/string -- Coin loaned
+ * collateralCoin -- optional/string -- Coin used as collateral
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000;
+ * limit -- optional/long -- Default: 10; max: 100;
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#repay-get-flexible-loan-repayment-history-user_data + */ + public String flexibleLoanRepayHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_REPAY_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String FLEXIBLE_LOAN_ADJUST_LTV = "/sapi/v1/loan/flexible/adjust/ltv"; + /** + * POST /sapi/v1/loan/flexible/adjust/ltv + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * loanCoin -- mandatory/string -- Coin loaned
+ * collateralCoin -- mandatory/string -- Coin used as collateral
+ * adjustmentAmount -- mandatory/decimal
+ * direction -- mandatory/enum -- "ADDITIONAL", "REDUCED"
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#adjust-ltv-flexible-loan-adjust-ltv-trade + */ + public String flexibleLoanAdjustLtv(Map parameters) { + ParameterChecker.checkParameter(parameters, "loanCoin", String.class); + ParameterChecker.checkParameter(parameters, "collateralCoin", String.class); + ParameterChecker.checkRequiredParameter(parameters, "adjustmentAmount"); + ParameterChecker.checkParameter(parameters, "direction", String.class); + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_ADJUST_LTV, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String FLEXIBLE_LOAN_LTV_ADJUST_HISTORY = "/sapi/v1/loan/flexible/ltv/adjustment/history"; + /** + * GET /sapi/v1/loan/flexible/ltv/adjustment/history + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * loanCoin -- optional/string -- Coin loaned
+ * collateralCoin -- optional/string -- Coin used as collateral
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Current querying page. Start from 1. Default:1 Max:1000
+ * limit -- optional/long -- Default: 10; max: 100;
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#adjust-ltv-get-flexible-loan-ltv-adjustment-history-user_data + */ + public String flexibleLoanLtvAdjustHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_LTV_ADJUST_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String FLEXIBLE_LOAN_ASSETS = "/sapi/v1/loan/flexible/loanable/data"; + /** + * Get interest rate and borrow limit of flexible loanable assets. The borrow limit is shown in USD value. + * + *

+ * GET /sapi/v1/loan/flexible/loanable/data + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * loanCoin -- optional/string -- Coin loaned
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-flexible-loan-assets-data-user_data + */ + public String flexibleLoanAssets(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_ASSETS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String FLEXIBLE_LOAN_COLLATERAL_ASSETS = "/sapi/v1/loan/flexible/collateral/data"; + /** + * Get LTV information and collateral limit of flexible loan's collateral assets. The collateral limit is shown in USD value. + * + *

+ * GET /sapi/v1/loan/flexible/collateral/data + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * collateralCoin -- optional/string -- Coin used as collateral
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-flexible-loan-collateral-assets-data-user_data + */ + public String flexibleLoanCollateralAssets(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_COLLATERAL_ASSETS, parameters, HttpMethod.GET, showLimitUsage); + } } diff --git a/src/main/java/com/binance/connector/client/impl/spot/Futures.java b/src/main/java/com/binance/connector/client/impl/spot/Futures.java index 621aa23d..1c7a3a73 100644 --- a/src/main/java/com/binance/connector/client/impl/spot/Futures.java +++ b/src/main/java/com/binance/connector/client/impl/spot/Futures.java @@ -69,7 +69,7 @@ public String futuresTransfer(Map parameters) { * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

- * asset -- mandatory/string -- The asset being transferred, e.g. USDT
+ * asset -- optional/string -- The asset being transferred, e.g. USDT
* startTime -- mandatory/long
* endTime -- optional/long
* current -- optional/long -- Currently querying page. Start from 1. Default:1
@@ -84,4 +84,33 @@ public String futuresTransferHistory(Map parameters) { ParameterChecker.checkParameter(parameters, "startTime", Long.class); return requestHandler.sendSignedRequest(baseUrl, FUTURES_TRANSFER, parameters, HttpMethod.GET, showLimitUsage); } + + private final String HISTORICAL_DATA = "/sapi/v1/futures/histDataLink"; + /** + * GET /sapi/v1/futures/histDataLink + * + * - The span between startTime and endTime can't be more than 7 days + * - The downloand link will be valid for 1 day + * - Only VIP user can query this endpoint + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * symbol -- mandatory/string -- symbol name, e.g. BTCUSDT or BTCUSD_PERP
+ * dataType -- mandatory/enum -- "T_DEPTH" for ticklevel orderbook data, "S_DEPTH" for orderbook snapshot data
+ * startTime -- mandatory/long
+ * endTime -- mandatory/long
+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-future-ticklevel-orderbook-historical-data-download-link-user_data + */ + public String futuresOrderBookHistory(Map parameters) { + ParameterChecker.checkParameter(parameters, "symbol", String.class); + ParameterChecker.checkParameter(parameters, "dataType", String.class); + ParameterChecker.checkParameter(parameters, "startTime", Long.class); + ParameterChecker.checkParameter(parameters, "endTime", Long.class); + return requestHandler.sendSignedRequest(baseUrl, HISTORICAL_DATA, parameters, HttpMethod.GET, showLimitUsage); + } } diff --git a/src/main/java/com/binance/connector/client/impl/spot/GiftCard.java b/src/main/java/com/binance/connector/client/impl/spot/GiftCard.java index 7806dc45..93a81a46 100644 --- a/src/main/java/com/binance/connector/client/impl/spot/GiftCard.java +++ b/src/main/java/com/binance/connector/client/impl/spot/GiftCard.java @@ -12,7 +12,7 @@ /** *

Gift Card Endpoints

* All endpoints under the - * Gift Card Endpoint + * Gift Card Endpoint * section of the API documentation will be implemented in this class. *
* Response will be returned in String format. @@ -53,8 +53,8 @@ public GiftCard(String baseUrl, String apiKey, SignatureGenerator signatureGener * amount -- mandatory/double -- The amount of the coin
* recvWindow -- optional/long
* @return String - * @see - * https://binance-docs.github.io/apidocs/spot/en/#create-a-binance-code-user_data + * @see + * https://binance-docs.github.io/apidocs/spot/en/#create-a-single-token-gift-card-user_data */ public String createCode(Map parameters) { ParameterChecker.checkParameter(parameters, "token", String.class); @@ -82,8 +82,8 @@ public String createCode(Map parameters) { * To protect user data privacy, you may choose to transfer the user id in any desired format (max. 400 characters).
* recvWindow -- optional/long
* @return String - * @see - * https://binance-docs.github.io/apidocs/spot/en/#redeem-a-binance-code-user_data + * @see + * https://binance-docs.github.io/apidocs/spot/en/#redeem-a-binance-gift-card-user_data */ public String redeemCode(Map parameters) { ParameterChecker.checkParameter(parameters, "code", String.class); @@ -105,8 +105,8 @@ public String redeemCode(Map parameters) { * referenceNo -- mandatory/string -- reference number
* recvWindow -- optional/long
* @return String - * @see - * https://binance-docs.github.io/apidocs/spot/en/#verify-a-binance-code-user_data + * @see + * https://binance-docs.github.io/apidocs/spot/en/#verify-binance-gift-card-by-gift-card-number-user_data */ public String verify(Map parameters) { ParameterChecker.checkParameter(parameters, "referenceNo", String.class); @@ -131,4 +131,61 @@ public String verify(Map parameters) { public String rsaPublicKey(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, RSA_PUB, parameters, HttpMethod.GET, showLimitUsage); } + + private final String CREATE_DUAL_TOKEN_CODE = "/sapi/v1/giftcard/buyCode"; + /** + * This API is for buying a fixed-value Binance Code, which means your Binance Code will be redeemable to a token that is different to the token that you are paying in. If the token you’re paying and the redeemable token are the same, please use the Create Binance Code endpoint. + * You can use supported crypto currency or fiat token as baseToken to buy Binance Code that is redeemable to your chosen faceToken. + * Once successfully purchased, the amount of baseToken would be deducted from your funding wallet. + * + * To get started with, please make sure: + * - You have a Binance account + * - You have passed kyc + * - You have a sufficient balance in your Binance funding wallet + * - You need Enable Withdrawals for the API Key which requests this endpoint. + * + *

+ * POST /sapi/v1/giftcard/buyCode + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * baseToken -- mandatory/string -- The token you want to pay, example BUSD
+ * faceToken -- mandatory/string -- The token you want to buy, example BNB. If faceToken = baseToken, it's the same as createCode endpoint.
+ * baseTokenAmount -- mandatory/double -- The base token asset quantity, example 1.002
+ * discount -- optional/double -- The discount rate, example 0.1
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#create-a-dual-token-gift-card-fixed-value-discount-feature-trade + */ + public String createDualTokensCode(Map parameters) { + ParameterChecker.checkParameter(parameters, "baseToken", String.class); + ParameterChecker.checkParameter(parameters, "faceToken", String.class); + ParameterChecker.checkParameter(parameters, "baseTokenAmount", Double.class); + return requestHandler.sendSignedRequest(baseUrl, CREATE_DUAL_TOKEN_CODE, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String TOKEN_LIMIT = "/sapi/v1/giftcard/buyCode/token-limit"; + /** + * This API is to help you verify which tokens are available for you to purchase fixed-value gift cards. + * + *

+ * GET /sapi/v1/giftcard/buyCode/token-limit + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * baseToken -- mandatory/string -- The token you want to pay, example BUSD
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#fetch-token-limit-user_data + */ + public String tokensLimit(Map parameters) { + ParameterChecker.checkParameter(parameters, "baseToken", String.class); + return requestHandler.sendSignedRequest(baseUrl, TOKEN_LIMIT, parameters, HttpMethod.GET, showLimitUsage); + } } diff --git a/src/main/java/com/binance/connector/client/impl/spot/Margin.java b/src/main/java/com/binance/connector/client/impl/spot/Margin.java index fdc01b0b..ce0305a4 100644 --- a/src/main/java/com/binance/connector/client/impl/spot/Margin.java +++ b/src/main/java/com/binance/connector/client/impl/spot/Margin.java @@ -208,8 +208,10 @@ public String priceIndex(Map parameters) { * newClientOrderId -- optional/string -- A unique id among open orders. Automatically generated if not sent.
* icebergQty -- optional/decimal -- Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order.
* newOrderRespType -- optional/enum -- Set the response JSON. ACK, RESULT, or FULL; MARKET and LIMIT order types default to FULL, all other orders default to ACK.
- * sideEffectType -- optional/enum -- NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default NO_SIDE_EFFECT.
+ * sideEffectType -- optional/enum -- NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY, AUTO_BORROW_REPAY; default NO_SIDE_EFFECT.
* timeInForce -- optional/enum -- GTC,IOC,FOK
+ * selfTradePreventionMode -- optional/enum -- The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE
+ * autoRepayAtCancel -- optional/boolean -- Only for when it's a MARGIN_BUY or AUTO_BORROW_REPAY. Default: true (debt generated by the order needs to be repaid after cancellation.)
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String * @see @@ -494,7 +496,9 @@ public String getAllOrders(Map parameters) { * stopIcebergQty -- optional/enum -- NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default NO_SIDE_EFFECT.
* stopLimitTimeInForce -- optional/enum -- GTC,IOC,FOK
* newOrderRespType -- optional/enum -- Set the response JSON.
- * sideEffectType -- optional/enum -- NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default NO_SIDE_EFFECT.
+ * sideEffectType -- optional/enum -- NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY, AUTO_BORROW_REPAY; default NO_SIDE_EFFECT.
+ * selfTradePreventionMode -- optional/enum -- The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE
+ * autoRepayAtCancel -- optional/boolean -- Only for when it's a MARGIN_BUY or AUTO_BORROW_REPAY. Default: true (debt generated by the order needs to be repaid after cancellation.)
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String * @see
@@ -700,8 +704,7 @@ public String isolatedTransfer(Map parameters) { *

* asset -- optional/string -- asset,such as BTC
* symbol -- mandatory/string
- * transFrom -- optional/string -- "SPOT", "ISOLATED_MARGIN"
- * transTo -- optional/string -- "SPOT", "ISOLATED_MARGIN"
+ * type -- optional/string -- "ROLL_IN", "ROLL_OUT"
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Current page, default 1
@@ -905,6 +908,42 @@ public String crossMarginData(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, CROSS_MARGIN_DATA, parameters, HttpMethod.GET, showLimitUsage); } + private final String CROSS_MARGIN_COLLATERAL_RATIO = "/sapi/v1/margin/crossMarginCollateralRatio"; + /** + * Get cross margin collateral ratio + * + *

+ * GET /sapi/v1/margin/crossMarginCollateralRatio + *
+ * @return String + * @see
+ * https://binance-docs.github.io/apidocs/spot/en/#cross-margin-collateral-ratio-market_data + */ + public String crossMarginCollateralRatio() { + return requestHandler.sendApiRequest(baseUrl, CROSS_MARGIN_COLLATERAL_RATIO, null, HttpMethod.GET, showLimitUsage); + } + + private final String ADJUST_CROSS_MARGIN_MAX_LEVERAGE = "/sapi/v1/margin/max-leverage"; + /** + * Adjust cross margin max leverage + * + *

+ * POST /sapi/v1/margin/max-leverage + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * maxLeverage -- mandatory/integer -- Can only adjust to 3, 5 or 10. Example: maxLeverage=10 for Cross Margin Pro, maxLeverage = 5 or 3 for Cross Margin Classic
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#adjust-cross-margin-max-leverage-user_data + */ + public String adjustCrossMarginMaxLeverage(Map parameters) { + ParameterChecker.checkParameter(parameters, "maxLeverage", Integer.class); + return requestHandler.sendSignedRequest(baseUrl, ADJUST_CROSS_MARGIN_MAX_LEVERAGE, parameters, HttpMethod.POST, showLimitUsage); + } + private final String ISOLATED_MARGIN_DATA = "/sapi/v1/margin/isolatedMarginData"; /** * Get isolated margin fee data collection with any vip level or user's current specific data as https://www.binance.com/en/margin-fee. @@ -989,4 +1028,242 @@ public String orderRateLimit(Map parameters) { public String dribblet(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, DRIBBLET, parameters, HttpMethod.GET, showLimitUsage); } + + private final String AVAILABLE_INVENTORY = "/sapi/v1/margin/available-inventory"; + /** + * Get the available margin inventory + *

+ * GET /sapi/v1/margin/available-inventory + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * type -- mandatory/string -- MARGIN, ISOLATED
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-margin-available-inventory-user_data + */ + public String availableInventory(Map parameters) { + ParameterChecker.checkParameter(parameters, "type", String.class); + return requestHandler.sendSignedRequest(baseUrl, AVAILABLE_INVENTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String CAPITAL_FLOW = "/sapi/v1/margin/capital-flow"; + /** + * Get cross or isolated margin capital flow + * + *

+ * GET /sapi/v1/margin/capital-flow + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * asset -- optional/string
+ * symbol -- optional/string -- Required when querying isolated margin data
+ * type -- optional/string -- MARGIN, ISOLATED
+ * startTime -- optional/long -- Only supports querying the data of the last 90 days
+ * endTime -- optional/long -- UTC timestamp in ms
+ * fromId -- optional/long -- If fromId is set, the data with "id" > "fromId" will be returned. Otherwise the latest data will be returned
+ * limit -- optional/long -- The number of data items returned each time is limited. Default 500; Max 1000.
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-cross-or-isolated-margin-capital-flow-user_data + */ + public String capitalFlow(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, CAPITAL_FLOW, parameters, HttpMethod.GET, showLimitUsage); + } + + + private final String BNB_CONVERTABLE_ASSETS = "/sapi/v1/margin/dust"; + /** + * Get assets that can be converted into BNB. + * + *

+ * GET /sapi/v1/margin/dust + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-assets-that-can-be-converted-into-bnb-user_data-2 + */ + public String bnbConvertibleAssets(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, BNB_CONVERTABLE_ASSETS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String DUST_TRANSFER = "/sapi/v1/margin/dust"; + /** + * Convert dust assets to BNB + * + *

+ * POST /sapi/v1/margin/dust + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * asset -- mandatory/array -- The assets to be converted. For example: asset=BTC,USDT
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#dust-transfer-trade + */ + public String convertToBnB(Map parameters) { + ParameterChecker.checkRequiredParameter(parameters, "asset"); + return requestHandler.sendSignedRequest(baseUrl, DUST_TRANSFER, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String DELIST_SCHEDULE = "/sapi/v1/margin/delist-schedule"; + /** + * Get tokens or symbols delist schedule for cross margin and isolated margin + * + *

+ * GET /sapi/v1/margin/delist-schedule + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-tokens-or-symbols-delist-schedule-for-cross-margin-and-isolated-margin-market_data + */ + public String delistSchedule(Map parameters) { + return requestHandler.sendApiRequest(baseUrl, DELIST_SCHEDULE, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String NEXT_HOURLY_INTEREST_RATE = "/sapi/v1/margin/next-hourly-interest-rate"; + /** + * Get the next hourly interest estimation + * + *

+ * GET /sapi/v1/margin/next-hourly-interest-rate + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * assets -- mandatory/string -- List of assets, separated by commas, up to 20
+ * isIsolated -- mandatory/boolean -- Whether it's for isolated margin or not: "TRUE", "FALSE"
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-a-future-hourly-interest-rate-user_data + */ + public String nextHourlyInterestRate(Map parameters) { + ParameterChecker.checkParameter(parameters, "assets", String.class); + ParameterChecker.checkParameter(parameters, "isIsolated", Boolean.class); + return requestHandler.sendSignedRequest(baseUrl, NEXT_HOURLY_INTEREST_RATE, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String SMALL_LIABILITY_ASSETS = "/sapi/v1/margin/exchange-small-liability"; + /** + * Query the assets suitable for small liability exchanges. + * + *

+ * GET /sapi/v1/margin/exchange-small-liability + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-small-liability-exchange-coin-list-user_data + */ + public String smallLiabilityAssets(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, SMALL_LIABILITY_ASSETS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String EXCHANGE_SMALL_LIABILITY = "/sapi/v1/margin/exchange-small-liability"; + /** + * Convert cross margin assets with low liability value + * + *

+ * POST /sapi/v1/margin/exchange-small-liability + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * assetNames - mandatory/array -- List of asset names. Example: assetNames = BTC,ETH
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#small-liability-exchange-margin + */ + public String exchangeSmallLiability(Map parameters) { + ParameterChecker.checkRequiredParameter(parameters, "assetNames"); + return requestHandler.sendSignedRequest(baseUrl, EXCHANGE_SMALL_LIABILITY, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String SMALL_LIABILITY_EXCHANGE_HISTORY = "/sapi/v1/margin/exchange-small-liability-history"; + /** + * Get the conversion history of low liabilities + * + *

+ * GET /sapi/v1/margin/exchange-small-liability-history + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * current -- mandatory/int -- Current querying page. Start from 1. Default:1
+ * size --mandatory/int -- Default:10 Max:100
+ * startTime -- optional/long -- Default: 30 days from current timestamp
+ * endTime -- optional/long -- Default: present timestamp
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-small-liability-exchange-history-user_data + */ + public String smallLiabilityExchangeHistory(Map parameters) { + ParameterChecker.checkRequiredParameter(parameters, "current"); + ParameterChecker.checkRequiredParameter(parameters, "size"); + return requestHandler.sendSignedRequest(baseUrl, SMALL_LIABILITY_EXCHANGE_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String LEVERAGE_BRACKET = "/sapi/v1/margin/leverageBracket"; + /** + * Get the liability assets leverage bracket in Cross Margin Pro Mode + * + *

+ * GET /sapi/v1/margin/leverageBracket + *
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-liability-coin-leverage-bracket-in-cross-margin-pro-mode-market_data + */ + public String leverageBracket() { + return requestHandler.sendApiRequest(baseUrl, LEVERAGE_BRACKET, null, HttpMethod.GET, showLimitUsage); + } + + + private final String TRADE_COEFF = "/sapi/v1/margin/tradeCoeff"; + /** + * Get personal margin level information + * + *

+ * GET /sapi/v1/margin/tradeCoeff + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-summary-of-margin-account-user_data + */ + public String tradeCoeff(Map parameters) { + return requestHandler.sendApiRequest(baseUrl, TRADE_COEFF, parameters, HttpMethod.GET, showLimitUsage); + } } diff --git a/src/main/java/com/binance/connector/client/impl/spot/Market.java b/src/main/java/com/binance/connector/client/impl/spot/Market.java index ba49dfc9..e92fd43b 100644 --- a/src/main/java/com/binance/connector/client/impl/spot/Market.java +++ b/src/main/java/com/binance/connector/client/impl/spot/Market.java @@ -198,6 +198,7 @@ public String aggTrades(Map parameters) { * interval -- mandatory/string
* startTime -- optional/long
* endTime -- optional/long
+ * timeZone -- optional/string -- Default:0 (UTC)
* limit -- optional/integer -- limit the results Default 500; max 1000
* @return String * @see @@ -224,6 +225,7 @@ public String klines(Map parameters) { * interval -- mandatory/string
* startTime -- optional/long
* endTime -- optional/long
+ * timeZone -- optional/string -- Default:0 (UTC)
* limit -- optional/integer -- limit the results Default 500; max 1000
* @return String * @see
@@ -290,7 +292,6 @@ public String ticker24H(Map parameters) { *

* GET /api/v3/ticker/price *
- * https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics * @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter @@ -319,7 +320,6 @@ public String tickerSymbol(Map parameters) { *

* GET /api/v3/ticker/bookTicker *
- * https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics * @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter @@ -350,17 +350,12 @@ public String bookTicker(Map parameters) { *

* GET /api/v3/ticker *
- * https://binance-docs.github.io/apidocs/spot/en/#rolling-window-price-change-statistics * @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

- * symbol -- mandatory/string -- Either symbol or symbols must be provided - * Examples of accepted format for the symbols parameter: - * ["BTCUSDT","BNBUSDT"] - * or - * %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
- * symbols -- optional/string -- The maximum number of symbols allowed in a request is 100.
+ * symbol -- mandatory/string -- Either symbol or symbols must be provided. + * symbols -- optional/string -- Example: ["BTCUSDT","BNBUSDT"] or %5B%22BTCUSDT%22,%22BNBUSDT%22%5D. The maximum number of symbols allowed in a request is 100.
* windowSize -- optional/enum -- Defaults to 1d if no parameter provided
* type -- optional/enum -- Supported values: FULL or MINI. If none provided, the default is FULL
* @return String @@ -380,4 +375,37 @@ public String ticker(Map parameters) { } return requestHandler.sendPublicRequest(baseUrl, TICKER, parameters, HttpMethod.GET, showLimitUsage); } + + private final String TRADING_DAY = "/api/v3/ticker/tradingDay"; + /** + * Price change statistics for a trading day. + *

+ * GET /api/v3/ticker/tradingDay + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * symbol -- mandatory/string -- Either symbol or symbols must be provided. + * symbols -- optional/string -- Example: ["BTCUSDT","BNBUSDT"] or %5B%22BTCUSDT%22,%22BNBUSDT%22%5D. The maximum number of symbols allowed in a request is 100.
+ * windowSize -- optional/string -- Defaults to 1d if no parameter provided
+ * timeZone -- optional/enum -- Default: 0 (UTC)
+ * type -- optional/enum -- Supported values: FULL or MINI. If none provided, the default is FULL
+ * @return String + * @see
+ * https://binance-docs.github.io/apidocs/spot/en/#trading-day-ticker + */ + public String tradingDayTicker(Map parameters) { + if (parameters.containsKey("symbol") && parameters.containsKey("symbols")) { + throw new BinanceConnectorException("symbol and symbols cannot be sent together."); + } + if (parameters.containsKey("symbols")) { + ParameterChecker.checkParameterType(parameters.get("symbols"), ArrayList.class, "symbols"); + parameters.put("symbols", JSONParser.getJSONArray( + (ArrayList) parameters.get("symbols"), "symbols")); + } else { + ParameterChecker.checkParameter(parameters, "symbol", String.class); + } + return requestHandler.sendPublicRequest(baseUrl, TRADING_DAY, parameters, HttpMethod.GET, showLimitUsage); + } } diff --git a/src/main/java/com/binance/connector/client/impl/spot/PortfolioMargin.java b/src/main/java/com/binance/connector/client/impl/spot/PortfolioMargin.java index 6f0b8e0d..df28c0c7 100644 --- a/src/main/java/com/binance/connector/client/impl/spot/PortfolioMargin.java +++ b/src/main/java/com/binance/connector/client/impl/spot/PortfolioMargin.java @@ -3,20 +3,21 @@ import java.util.Map; import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.utils.ParameterChecker; import com.binance.connector.client.utils.ProxyAuth; import com.binance.connector.client.utils.RequestHandler; import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; import com.binance.connector.client.utils.signaturegenerator.SignatureGenerator; +/** + *

Portfolio Margin Endpoints

+ * All endpoints under the + * Portfolio Margin Endpoints + * section of the API documentation will be implemented in this class. + *
+ * Response will be returned in String format. + */ public class PortfolioMargin { - /** - *

Portfolio Margin Endpoints

- * All endpoints under the - * PortfolioMargin Endpoint - * section of the API documentation will be implemented in this class. - *
- * Response will be returned in String format. - */ private final String baseUrl; private final RequestHandler requestHandler; private final boolean showLimitUsage; @@ -43,8 +44,8 @@ public PortfolioMargin(String baseUrl, String apiKey, SignatureGenerator signatu *

* recvWindow -- optional/long
* @return String - * @see - * https://binance-docs.github.io/apidocs/spot/en/#get-portfolio-margin-account-info-user_data + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-classic-portfolio-margin-account-info-user_data */ public String getAccount(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, ACCOUNT, parameters, HttpMethod.GET, showLimitUsage); @@ -62,8 +63,8 @@ public String getAccount(Map parameters) { *

* recvWindow -- optional/long
* @return String - * @see - * https://binance-docs.github.io/apidocs/spot/en/#portfolio-margin-collateral-rate-market_data + * @see + * https://binance-docs.github.io/apidocs/spot/en/#classic-portfolio-margin-collateral-rate-market_data */ public String collateralRate(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, COLLATERAL_RATE, parameters, HttpMethod.GET, showLimitUsage); @@ -81,8 +82,8 @@ public String collateralRate(Map parameters) { *

* recvWindow -- optional/long
* @return String - * @see - * https://binance-docs.github.io/apidocs/spot/en/#query-portfolio-margin-bankruptcy-loan-record-user_data + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-classic-portfolio-margin-bankruptcy-loan-amount-user_data */ public String bankruptcyLoanRecord(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, PM_LOAN, parameters, HttpMethod.GET, showLimitUsage); @@ -98,12 +99,200 @@ public String bankruptcyLoanRecord(Map parameters) { * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

+ * from -- optional/string -- SPOT or MARGIN,default SPOT
* recvWindow -- optional/long
* @return String - * @see - * https://binance-docs.github.io/apidocs/spot/en/#portfolio-margin-bankruptcy-loan-repay + * @see + * https://binance-docs.github.io/apidocs/spot/en/#classic-portfolio-margin-bankruptcy-loan-repay */ public String repay(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, REPAY, parameters, HttpMethod.POST, showLimitUsage); } + + private final String INTEREST_HISTORY = "/sapi/v1/portfolio/interest-history"; + /** + * Query interest history of negative balance for portfolio margin. + * + *

+ * GET /sapi/v1/portfolio/interest-history + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * asset -- optional/string
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * size -- optional/integer -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-classic-portfolio-margin-negative-balance-interest-history-user_data + */ + public String interestHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, INTEREST_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String ASSET_INDEX_PRICE = "/sapi/v1/portfolio/asset-index-price"; + /** + * Query Portfolio Margin Asset Index Price + * + *

+ * GET /sapi/v1/portfolio/asset-index-price + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * asset -- optional/string
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-portfolio-margin-asset-index-price-market_data + */ + public String assetIndexPrice(Map parameters) { + return requestHandler.sendApiRequest(baseUrl, ASSET_INDEX_PRICE, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String AUTO_COLLECTION = "/sapi/v1/portfolio/auto-collection"; + /** + * Transfers all assets from Futures Account to Margin account + * + * - The BNB would not be collected from UM-PM account to the Portfolio Margin account. + * - You can only use this function 500 times per hour in a rolling manner. + *

+ * POST /sapi/v1/portfolio/auto-collection + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#fund-auto-collection-user_data + */ + public String autoCollection(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, AUTO_COLLECTION, parameters, HttpMethod.POST, showLimitUsage); + } + + + private final String ASSET_COLLECTION = "/sapi/v1/portfolio/asset-collection"; + /** + * Transfers specific asset from Futures Account to Margin account + * + *

+ * POST /sapi/v1/portfolio/asset-collection + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * asset -- mandatory/string
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#fund-collection-by-asset-user_data + */ + public String assetCollection(Map parameters) { + ParameterChecker.checkParameter(parameters, "asset", String.class); + return requestHandler.sendSignedRequest(baseUrl, ASSET_COLLECTION, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String BNB_TRANSFER = "/sapi/v1/portfolio/bnb-transfer"; + /** + * BNB transfer can be between Margin Account and USDM Account + * + *

+ * POST /sapi/v1/portfolio/bnb-transfer + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * transferSide -- mandatory/string -- "TO_UM","FROM_UM"
+ * amount -- mandatory/decimal
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#bnb-transfer-user_data + */ + public String bnbTransfer(Map parameters) { + ParameterChecker.checkParameter(parameters, "transferSide", String.class); + ParameterChecker.checkRequiredParameter(parameters, "amount"); + return requestHandler.sendSignedRequest(baseUrl, BNB_TRANSFER, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String SWITCH_AUTO_REPAY_FUTURES = "/sapi/v1/portfolio/repay-futures-switch"; + /** + * Change Auto-repay-futures Status + * + *

+ * POST /sapi/v1/portfolio/repay-futures-switch + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * autoRepay -- mandatory/boolean
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#change-auto-repay-futures-status-trade + */ + public String switchAutoRepayFutures(Map parameters) { + ParameterChecker.checkRequiredParameter(parameters, "autoRepay"); + return requestHandler.sendSignedRequest(baseUrl, SWITCH_AUTO_REPAY_FUTURES, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String AUTO_REPAY_FUTURES_STATUS = "/sapi/v1/portfolio/repay-futures-switch"; + /** + * Query Auto-repay-futures Status + * + *

+ * GET /sapi/v1/portfolio/repay-futures-switch + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-auto-repay-futures-status-user_data + */ + public String autoRepayFuturesStatus(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, AUTO_REPAY_FUTURES_STATUS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String REPAY_FUTURES = "/sapi/v1/portfolio/repay-futures-negative-balance"; + /** + * Repay futures Negative Balance + * + *

+ * POST /sapi/v1/portfolio/repay-futures-negative-balance + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#repay-futures-negative-balance-user_data + */ + public String repayFutures(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, REPAY_FUTURES, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String ASSET_LEVERAGE = "/sapi/v1/portfolio/margin-asset-leverage"; + /** + * GET /sapi/v1/portfolio/margin-asset-leverage + *
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-portfolio-margin-asset-leverage-user_data + */ + public String assetLeverage() { + return requestHandler.sendSignedRequest(baseUrl, ASSET_LEVERAGE, null, HttpMethod.GET, showLimitUsage); + } } diff --git a/src/main/java/com/binance/connector/client/impl/spot/Savings.java b/src/main/java/com/binance/connector/client/impl/spot/Savings.java deleted file mode 100644 index 3dcdda8b..00000000 --- a/src/main/java/com/binance/connector/client/impl/spot/Savings.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.binance.connector.client.impl.spot; - -import java.util.Map; - -import com.binance.connector.client.enums.HttpMethod; -import com.binance.connector.client.utils.ParameterChecker; -import com.binance.connector.client.utils.ProxyAuth; -import com.binance.connector.client.utils.RequestHandler; -import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; -import com.binance.connector.client.utils.signaturegenerator.SignatureGenerator; - -/** - *

Savings Endpoints

- * All endpoints under the - * Savings Endpoint - * section of the API documentation will be implemented in this class. - *
- * Response will be returned in String format. - */ -public class Savings { - private final String baseUrl; - private final RequestHandler requestHandler; - private final boolean showLimitUsage; - - public Savings(String baseUrl, String apiKey, String secretKey, boolean showLimitUsage, ProxyAuth proxy) { - this.baseUrl = baseUrl; - this.requestHandler = new RequestHandler(apiKey, new HmacSignatureGenerator(secretKey), proxy); - this.showLimitUsage = showLimitUsage; - } - - public Savings(String baseUrl, String apiKey, SignatureGenerator signatureGenerator, boolean showLimitUsage, ProxyAuth proxy) { - this.baseUrl = baseUrl; - this.requestHandler = new RequestHandler(apiKey, signatureGenerator, proxy); - this.showLimitUsage = showLimitUsage; - } - - private final String ACTIVITY_PROJECT = "/sapi/v1/lending/project/list"; - /** - * GET /sapi/v1/lending/project/list - *
- * @param - * parameters Map of String,Object pair - * where String is the name of the parameter and Object is the value of the parameter - *

- * asset -- optional/string
- * type -- mandatory/enum -- "ACTIVITY", "CUSTOMIZED_FIXED"
- * status -- optional/enum -- "ALL", "SUBSCRIBABLE", "UNSUBSCRIBABLE"; default "ALL"
- * isSortAsc -- optional/boolean -- default "true"
- * sortBy -- optional/enum -- "START_TIME", "LOT_SIZE", "INTEREST_RATE", "DURATION"; default "START_TIME"
- * current -- optional/long -- Currently querying page. Start from 1. Default:1
- * size -- optional/long -- Default:10, Max:100
- * recvWindow -- optional/long
- * @return String - * @see - * https://binance-docs.github.io/apidocs/spot/en/#get-fixed-and-activity-project-list-user_data - */ - public String projectList(Map parameters) { - ParameterChecker.checkParameter(parameters, "type", String.class); - return requestHandler.sendSignedRequest(baseUrl, ACTIVITY_PROJECT, parameters, HttpMethod.GET, showLimitUsage); - } - - private final String PURCHASE_ACTIVITY = "/sapi/v1/lending/customizedFixed/purchase"; - /** - * POST /sapi/v1/lending/customizedFixed/purchase - *
- * @param - * parameters Map of String,Object pair - * where String is the name of the parameter and Object is the value of the parameter - *

- * projectId -- mandatory/string
- * lot -- mandatory/long
- * recvWindow -- optional/long
- * @return String - * @see - * https://binance-docs.github.io/apidocs/spot/en/#purchase-fixed-activity-project-user_data - */ - public String purchaseProject(Map parameters) { - ParameterChecker.checkParameter(parameters, "projectId", String.class); - ParameterChecker.checkParameter(parameters, "lot", Long.class); - return requestHandler.sendSignedRequest(baseUrl, PURCHASE_ACTIVITY, parameters, HttpMethod.POST, showLimitUsage); - } - - private final String PROJECT_POSITION = "/sapi/v1/lending/project/position/list"; - /** - * GET /sapi/v1/lending/project/position/list - *
- * @param - * parameters Map of String,Object pair - * where String is the name of the parameter and Object is the value of the parameter - *

- * asset -- optional/string
- * projectId -- optional/string
- * status -- optional/enum -- "HOLDING", "REDEEMED"
- * recvWindow -- optional/long
- * @return String - * @see - * https://binance-docs.github.io/apidocs/spot/en/#get-fixed-activity-project-position-user_data - */ - public String projectPosition(Map parameters) { - return requestHandler.sendSignedRequest(baseUrl, PROJECT_POSITION, parameters, HttpMethod.GET, showLimitUsage); - } - - private final String CHANGE_TO_DAILY_POSITION = "/sapi/v1/lending/positionChanged"; - /** - * POST /sapi/v1/lending/positionChanged - *
- * @param - * parameters Map of String,Object pair - * where String is the name of the parameter and Object is the value of the parameter - *

- * projectId -- mandatory/string
- * lot -- mandatory/long
- * positionId -- optional/long -- for fixed position
- * recvWindow -- optional/long
- * @return String - * @see - * https://binance-docs.github.io/apidocs/spot/en/#change-fixed-activity-position-to-daily-position-user_data - */ - public String changeToDailyPosition(Map parameters) { - ParameterChecker.checkParameter(parameters, "projectId", String.class); - ParameterChecker.checkParameter(parameters, "lot", Long.class); - return requestHandler.sendSignedRequest(baseUrl, CHANGE_TO_DAILY_POSITION, parameters, HttpMethod.POST, showLimitUsage); - } -} diff --git a/src/main/java/com/binance/connector/client/impl/spot/SimpleEarn.java b/src/main/java/com/binance/connector/client/impl/spot/SimpleEarn.java new file mode 100644 index 00000000..3f698bb2 --- /dev/null +++ b/src/main/java/com/binance/connector/client/impl/spot/SimpleEarn.java @@ -0,0 +1,534 @@ +package com.binance.connector.client.impl.spot; + +import java.util.Map; + +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.utils.ParameterChecker; +import com.binance.connector.client.utils.ProxyAuth; +import com.binance.connector.client.utils.RequestHandler; +import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; +import com.binance.connector.client.utils.signaturegenerator.SignatureGenerator; + +/** + *

Simple Earn Endpoints

+ * All endpoints under the + * Simple Earn Endpoints + * section of the API documentation will be implemented in this class. + *
+ * Response will be returned in String format. + */ +public class SimpleEarn { + private final String baseUrl; + private final RequestHandler requestHandler; + private final boolean showLimitUsage; + + public SimpleEarn(String baseUrl, String apiKey, String secretKey, boolean showLimitUsage, ProxyAuth proxy) { + this.baseUrl = baseUrl; + this.requestHandler = new RequestHandler(apiKey, new HmacSignatureGenerator(secretKey), proxy); + this.showLimitUsage = showLimitUsage; + } + + public SimpleEarn(String baseUrl, String apiKey, SignatureGenerator signatureGenerator, boolean showLimitUsage, ProxyAuth proxy) { + this.baseUrl = baseUrl; + this.requestHandler = new RequestHandler(apiKey, signatureGenerator, proxy); + this.showLimitUsage = showLimitUsage; + } + + private final String FLEXIBLE_PRODUCT_LIST = "/sapi/v1/simple-earn/flexible/list"; + /** + * Get available Simple Earn flexible product list + *

+ * GET /sapi/v1/simple-earn/flexible/list + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * asset -- optional/string
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-simple-earn-flexible-product-list-user_data + */ + public String flexibleProductList(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_PRODUCT_LIST, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String LOCKED_PRODUCT_LIST = "/sapi/v1/simple-earn/locked/list"; + /** + * GET /sapi/v1/simple-earn/locked/list + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * asset -- optional/string
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-simple-earn-locked-product-list-user_data + */ + public String lockedProductList(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, LOCKED_PRODUCT_LIST, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String SUBSCRIBE_FLEXIBLE_PRODUCT = "/sapi/v1/simple-earn/flexible/subscribe"; + /** + * POST /sapi/v1/simple-earn/flexible/subscribe + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * productId -- mandatory/string
+ * amount -- mandatory/decimal
+ * autoSubscribe -- optional/boolean -- true or false, default true.
+ * sourceAccount -- optional/enum -- SPOT,FUND,ALL, default SPOT
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#subscribe-flexible-product-trade + */ + public String subscribeFlexibleProduct(Map parameters) { + ParameterChecker.checkParameter(parameters, "productId", String.class); + ParameterChecker.checkRequiredParameter(parameters, "amount"); + return requestHandler.sendSignedRequest(baseUrl, SUBSCRIBE_FLEXIBLE_PRODUCT, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String SUBSCRIBE_LOCKED_PRODUCT = "/sapi/v1/simple-earn/locked/subscribe"; + /** + * POST /sapi/v1/simple-earn/locked/subscribe + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * projectId -- mandatory/string
+ * amount -- mandatory/decimal
+ * autoSubscribe -- optional/boolean -- true or false, default true.
+ * sourceAccount -- optional/enum -- SPOT,FUND,ALL, default SPOT
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#subscribe-locked-product-trade + */ + public String subscribeLockedProduct(Map parameters) { + ParameterChecker.checkParameter(parameters, "projectId", String.class); + ParameterChecker.checkRequiredParameter(parameters, "amount"); + return requestHandler.sendSignedRequest(baseUrl, SUBSCRIBE_LOCKED_PRODUCT, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String REDEEM_FLEXIBLE_PRODUCT = "/sapi/v1/simple-earn/flexible/redeem"; + /** + * POST /sapi/v1/simple-earn/flexible/redeem + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * productId -- mandatory/string
+ * redeemAll -- optional/boolean -- true or false, default to false
+ * amount -- optional/decimal -- if redeemAll is false, amount is mandatory
+ * destAccount -- optional/enum -- SPOT,FUND,ALL, default SPOT
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#redeem-flexible-product-trade + */ + public String redeemFlexibleProduct(Map parameters) { + ParameterChecker.checkParameter(parameters, "productId", String.class); + return requestHandler.sendSignedRequest(baseUrl, REDEEM_FLEXIBLE_PRODUCT, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String REDEEM_LOCKED_PRODUCT = "/sapi/v1/simple-earn/locked/redeem"; + /** + * POST /sapi/v1/simple-earn/locked/redeem + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * positionId -- mandatory/string -- 1234
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#redeem-locked-product-trade + */ + public String redeemLockedProduct(Map parameters) { + ParameterChecker.checkParameter(parameters, "positionId", String.class); + return requestHandler.sendSignedRequest(baseUrl, REDEEM_LOCKED_PRODUCT, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String FLEXIBLE_PRODUCT_POSITION = "/sapi/v1/simple-earn/flexible/position"; + /** + * GET /sapi/v1/simple-earn/flexible/position + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * asset -- optional/string
+ * productId -- optional/string
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-flexible-product-position-user_data + */ + public String flexibleProductPosition(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_PRODUCT_POSITION, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String LOCKED_PRODUCT_POSITION = "/sapi/v1/simple-earn/locked/position"; + /** + * GET /sapi/v1/simple-earn/locked/position + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * asset -- optional/string
+ * positionId -- optional/string
+ * projectId -- optional/string
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-locked-product-position-user_data + */ + public String lockedProductPosition(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, LOCKED_PRODUCT_POSITION, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String SIMPLE_ACCOUNT = "/sapi/v1/simple-earn/account"; + /** + * GET /sapi/v1/simple-earn/account + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#simple-account-user_data + */ + public String simpleAccount(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, SIMPLE_ACCOUNT, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String FLEXIBLE_SUBSCRIPTION_RECORD = "/sapi/v1/simple-earn/flexible/history/subscriptionRecord"; + /** + * GET /sapi/v1/simple-earn/flexible/history/subscriptionRecord + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * productId -- optional/string
+ * purchaseId -- optional/string
+ * asset -- optional/string
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-flexible-subscription-record-user_data + */ + public String flexibleSubscriptionRecord(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_SUBSCRIPTION_RECORD, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String LOCKED_SUBSCRIPTION_RECORD = "/sapi/v1/simple-earn/locked/history/subscriptionRecord"; + /** + * GET /sapi/v1/simple-earn/locked/history/subscriptionRecord + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * purchaseId -- optional/string
+ * asset -- optional/string
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-locked-subscription-record-user_data + */ + public String lockedSubscriptionRecord(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, LOCKED_SUBSCRIPTION_RECORD, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String FLEXIBLE_REDEMPTION_RECORD = "/sapi/v1/simple-earn/flexible/history/redemptionRecord"; + /** + * GET /sapi/v1/simple-earn/flexible/history/redemptionRecord + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * productId -- optional/string
+ * redeemId -- optional/string
+ * asset -- optional/string
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-flexible-redemption-record-user_data + */ + public String flexibleRedemptionRecord(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_REDEMPTION_RECORD, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String LOCKED_REDEMPTION_RECORD = "/sapi/v1/simple-earn/locked/history/redemptionRecord"; + /** + * GET /sapi/v1/simple-earn/locked/history/redemptionRecord + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * positionId -- optional/string
+ * redeemId -- optional/string
+ * asset -- optional/string
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-locked-redemption-record-user_data + */ + public String lockedRedemptionRecord(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, LOCKED_REDEMPTION_RECORD, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String FLEXIBLE_REWARDS_HISTORY = "/sapi/v1/simple-earn/flexible/history/rewardsRecord"; + /** + * GET /sapi/v1/simple-earn/flexible/history/rewardsRecord + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * productId -- optional/string
+ * asset -- optional/string
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * type -- mandatory/enum -- "BONUS", "REALTIME", "REWARDS"
+ * current -- optional/long -- Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-flexible-rewards-history-user_data + */ + public String flexibleRewardsHistory(Map parameters) { + ParameterChecker.checkParameter(parameters, "type", String.class); + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_REWARDS_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String LOCKED_REWARDS_HISTORY = "/sapi/v1/simple-earn/locked/history/rewardsRecord"; + /** + * GET /sapi/v1/simple-earn/locked/history/rewardsRecord + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * positionId -- optional/string
+ * asset -- optional/string
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Currently querying the page. Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-locked-rewards-history-user_data + */ + public String lockedRewardsHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, LOCKED_REWARDS_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String SET_FLEXIBLE_AUTO_SUBSCRIBE = "/sapi/v1/simple-earn/flexible/setAutoSubscribe"; + /** + * POST /sapi/v1/simple-earn/flexible/setAutoSubscribe + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * productId -- mandatory/string
+ * autoSubscribe -- mandatory/boolean -- true or false
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#set-flexible-auto-subscribe-user_data + */ + public String setFlexibleAutoSubscribe(Map parameters) { + ParameterChecker.checkParameter(parameters, "productId", String.class); + ParameterChecker.checkParameter(parameters, "autoSubscribe", Boolean.class); + return requestHandler.sendSignedRequest(baseUrl, SET_FLEXIBLE_AUTO_SUBSCRIBE, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String SET_LOCKED_AUTO_SUBSCRIBE = "/sapi/v1/simple-earn/locked/setAutoSubscribe"; + /** + * POST /sapi/v1/simple-earn/locked/setAutoSubscribe + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * positionId -- mandatory/string
+ * autoSubscribe -- mandatory/boolean -- true or false
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#set-locked-auto-subscribe-user_data + */ + public String setLockedAutoSubscribe(Map parameters) { + ParameterChecker.checkParameter(parameters, "positionId", String.class); + ParameterChecker.checkParameter(parameters, "autoSubscribe", Boolean.class); + return requestHandler.sendSignedRequest(baseUrl, SET_LOCKED_AUTO_SUBSCRIBE, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String FLEXIBLE_PERSONAL_LEFT_QUOTA = "/sapi/v1/simple-earn/flexible/personalLeftQuota"; + /** + * GET /sapi/v1/simple-earn/flexible/personalLeftQuota + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * productId -- mandatory/string
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-flexible-personal-left-quota-user_data + */ + public String flexiblePersonalLeftQuota(Map parameters) { + ParameterChecker.checkParameter(parameters, "productId", String.class); + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_PERSONAL_LEFT_QUOTA, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String LOCKED_PERSONAL_LEFT_QUOTA = "/sapi/v1/simple-earn/locked/personalLeftQuota"; + /** + * GET /sapi/v1/simple-earn/locked/personalLeftQuota + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * projectId -- mandatory/string
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-locked-personal-left-quota-user_data + */ + public String lockedPersonalLeftQuota(Map parameters) { + ParameterChecker.checkParameter(parameters, "projectId", String.class); + return requestHandler.sendSignedRequest(baseUrl, LOCKED_PERSONAL_LEFT_QUOTA, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String FLEXIBLE_SUBSCRIPTION_PREVIEW = "/sapi/v1/simple-earn/flexible/subscriptionPreview"; + /** + * GET /sapi/v1/simple-earn/flexible/subscriptionPreview + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * productId -- mandatory/string
+ * amount -- mandatory/decimal
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-flexible-subscription-preview-user_data + */ + public String flexibleSubscriptionPreview(Map parameters) { + ParameterChecker.checkParameter(parameters, "productId", String.class); + ParameterChecker.checkRequiredParameter(parameters, "amount"); + return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_SUBSCRIPTION_PREVIEW, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String LOCKED_SUBSCRIPTION_PREVIEW = "/sapi/v1/simple-earn/locked/subscriptionPreview"; + /** + * GET /sapi/v1/simple-earn/locked/subscriptionPreview + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * projectId -- mandatory/string
+ * amount -- mandatory/decimal
+ * autoSubscribe -- optional/boolean -- true or false, default true.
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-locked-subscription-preview-user_data + */ + public String lockedSubscriptionPreview(Map parameters) { + ParameterChecker.checkParameter(parameters, "projectId", String.class); + ParameterChecker.checkRequiredParameter(parameters, "amount"); + return requestHandler.sendSignedRequest(baseUrl, LOCKED_SUBSCRIPTION_PREVIEW, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String RATE_HISTORY = "/sapi/v1/simple-earn/flexible/history/rateHistory"; + /** + * GET /sapi/v1/simple-earn/flexible/history/rateHistory + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * productId -- mandatory/string
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-rate-history-user_data + */ + public String rateHistory(Map parameters) { + ParameterChecker.checkParameter(parameters, "productId", String.class); + return requestHandler.sendSignedRequest(baseUrl, RATE_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String COLLATERAL_RECORD = "/sapi/v1/simple-earn/flexible/history/collateralRecord"; + /** + * GET /sapi/v1/simple-earn/flexible/history/collateralRecord + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * productId -- optional/string
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * size -- optional/long -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-collateral-record-user_data + */ + public String collateralRecord(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, COLLATERAL_RECORD, parameters, HttpMethod.GET, showLimitUsage); + } +} diff --git a/src/main/java/com/binance/connector/client/impl/spot/SpotAlgo.java b/src/main/java/com/binance/connector/client/impl/spot/SpotAlgo.java new file mode 100644 index 00000000..26bd378c --- /dev/null +++ b/src/main/java/com/binance/connector/client/impl/spot/SpotAlgo.java @@ -0,0 +1,159 @@ +package com.binance.connector.client.impl.spot; + +import java.util.Map; + +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.utils.ParameterChecker; +import com.binance.connector.client.utils.ProxyAuth; +import com.binance.connector.client.utils.RequestHandler; +import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; +import com.binance.connector.client.utils.signaturegenerator.SignatureGenerator; + +/** + *

Spot Algo Endpoints

+ * All endpoints under the + * Spot Algo Endpoints + * section of the API documentation will be implemented in this class. + *
+ * Response will be returned in String format. + */ +public class SpotAlgo { + private final String baseUrl; + private final RequestHandler requestHandler; + private final boolean showLimitUsage; + + public SpotAlgo(String baseUrl, String apiKey, String secretKey, boolean showLimitUsage, ProxyAuth proxy) { + this.baseUrl = baseUrl; + this.requestHandler = new RequestHandler(apiKey, new HmacSignatureGenerator(secretKey), proxy); + this.showLimitUsage = showLimitUsage; + } + + public SpotAlgo(String baseUrl, String apiKey, SignatureGenerator signatureGenerator, boolean showLimitUsage, ProxyAuth proxy) { + this.baseUrl = baseUrl; + this.requestHandler = new RequestHandler(apiKey, signatureGenerator, proxy); + this.showLimitUsage = showLimitUsage; + } + + private final String TWAP_ORDER = "/sapi/v1/algo/spot/newOrderTwap"; + /** + * Place a new spot TWAP order with Algo service. + * + *

+ * POST /sapi/v1/algo/spot/newOrderTwap + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * symbol -- mandatory/string -- Trading symbol, e.g. BNBUSDT
+ * side -- mandatory/enum
+ * quantity -- mandatory/decimal -- Quantity of base asset; The notional (quantity * last price(base asset)) must be more than the equivalent of 1,000 USDT and less than the equivalent of 100,000 USDT.
+ * duration -- mandatory/long -- Duration for TWAP orders in seconds. [300, 86400]
+ * clientAlgoId -- optional/string -- A unique id among Algo orders (length should be 32 characters), If it is not sent, we will give default value.
+ * limitPrice -- optional/decimal -- Limit price of the order; If it is not sent, will place order by market price by default.
+ * stpMode -- optional/enum -- The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE + * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#time-weighted-average-price-twap-new-order-trade-2 + */ + public String twapOrder(Map parameters) { + ParameterChecker.checkParameter(parameters, "symbol", String.class); + ParameterChecker.checkParameter(parameters, "side", String.class); + ParameterChecker.checkRequiredParameter(parameters, "quantity"); + ParameterChecker.checkParameter(parameters, "duration", Long.class); + return requestHandler.sendSignedRequest(baseUrl, TWAP_ORDER, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String CANCEL_ORDER = "/sapi/v1/algo/spot/order"; + /** + * Cancel an open TWAP order + * + *

+ * DELETE /sapi/v1/algo/spot/order + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * algoId -- mandatory/long
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#cancel-algo-order-trade-2 + */ + public String cancelOrder(Map parameters) { + ParameterChecker.checkParameter(parameters, "algoId", Long.class); + return requestHandler.sendPublicRequest(baseUrl, CANCEL_ORDER, parameters, HttpMethod.DELETE, showLimitUsage); + } + + private final String OPEN_ORDERS = "/sapi/v1/algo/spot/openOrders"; + /** + * Get all open SPOT TWAP orders + * + *

+ * GET /sapi/v1/algo/spot/openOrders + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-current-algo-open-orders-user_data-2 + */ + public String getOpenOrders(Map parameters) { + return requestHandler.sendPublicRequest(baseUrl, OPEN_ORDERS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String HISTORICAL_ORDERS = "/sapi/v1/algo/spot/historicalOrders"; + /** + * Get all historical SPOT TWAP orders + * + *

+ * GET /sapi/v1/algo/spot/historicalOrders + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * symbol -- optional/string -- Trading symbol, e.g. BNBUSDT
+ * side -- optional/enum
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * page -- optional/int -- Default 1
+ * pageSize -- optional/int -- MIN 1, MAX 100; Default 100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-historical-algo-orders-user_data-2 + */ + public String getHistoricalOrders(Map parameters) { + return requestHandler.sendPublicRequest(baseUrl, HISTORICAL_ORDERS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String SUB_ORDERS = "/sapi/v1/algo/spot/subOrders"; + /** + * Get respective sub orders for a specified algoId + * + *

+ * GET /sapi/v1/algo/spot/subOrders + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * algoId -- mandatory/long
+ * page -- optional/int -- Default 1
+ * pageSize -- optional/int -- MIN 1, MAX 100; Default 100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-sub-orders-user_data-2 + */ + public String getSubOrders(Map parameters) { + ParameterChecker.checkParameter(parameters, "algoId", Long.class); + return requestHandler.sendPublicRequest(baseUrl, SUB_ORDERS, parameters, HttpMethod.GET, showLimitUsage); + } +} diff --git a/src/main/java/com/binance/connector/client/impl/spot/Staking.java b/src/main/java/com/binance/connector/client/impl/spot/Staking.java index c602eb0f..fa92150b 100644 --- a/src/main/java/com/binance/connector/client/impl/spot/Staking.java +++ b/src/main/java/com/binance/connector/client/impl/spot/Staking.java @@ -202,4 +202,249 @@ public String personalLeftQuota(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, LEFT_QUOTA, parameters, HttpMethod.GET, showLimitUsage); } + + private final String SUB_ETH_STAKING = "/sapi/v2/eth-staking/eth/stake"; + /** + * Stake ETH to get WBETH + * + *

+ * POST /sapi/v2/eth-staking/eth/stake + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * amount -- mandatory/decimal -- Amount in ETH, limit 4 decimals
+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#subscribe-eth-staking-trade + */ + public String subEthStaking(Map parameters) { + ParameterChecker.checkRequiredParameter(parameters, "amount"); + return requestHandler.sendSignedRequest(baseUrl, SUB_ETH_STAKING, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String REDEEM_ETH = "/sapi/v1/eth-staking/eth/redeem"; + /** + * Redeem WBETH or BETH and get ETH + * + *

+ * POST /sapi/v1/eth-staking/eth/redeem + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * amount -- mandatory/decimal -- Amount in ETH, limit 4 decimals
+ * asset -- optional/string -- "BETH" or "WBETH", default "BETH"
+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#redeem-eth-trade + */ + public String redeemEthStaking(Map parameters) { + ParameterChecker.checkRequiredParameter(parameters, "amount"); + return requestHandler.sendSignedRequest(baseUrl, REDEEM_ETH, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String ETH_STAKING_HISTORY = "/sapi/v1/eth-staking/eth/history/stakingHistory"; + /** + * GET /sapi/v1/eth-staking/eth/history/stakingHistory + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * startTime -- optional/long
+ * endTime -- optional/long
+ * current -- optional/long -- Currently querying page. Start from 1. Default:1
+ * size -- optional/long -- Default: 10, Max: 100
+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-eth-staking-history-user_data + */ + public String ethStakingSubHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String ETH_STAKING_REDEEM_HISTORY = "/sapi/v1/eth-staking/eth/history/redemptionHistory"; + /** + * GET /sapi/v1/eth-staking/eth/history/redemptionHistory + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * startTime -- optional/long
+ * endTime -- optional/long
+ * current -- optional/long -- Currently querying page. Start from 1. Default:1
+ * size -- optional/long -- Default: 10, Max: 100
+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-eth-redemption-history-user_data + */ + public String ethStakingRedeemHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_REDEEM_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String ETH_STAKING_REWARDS_HISTORY = "/sapi/v1/eth-staking/eth/history/rewardsHistory"; + /** + * GET /sapi/v1/eth-staking/eth/history/rewardsHistory + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * startTime -- optional/long
+ * endTime -- optional/long
+ * current -- optional/long -- Currently querying page. Start from 1. Default:1
+ * size -- optional/long -- Default: 10, Max: 100
+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-beth-rewards-distribution-history-user_data + */ + public String ethStakingRewardsHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_REWARDS_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String ETH_STAKING_QUOTA = "/sapi/v1/eth-staking/eth/quota"; + /** + * GET /sapi/v1/eth-staking/eth/quota + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-current-eth-staking-quota-user_data + */ + public String ethStakingQuota(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_QUOTA, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String ETH_STAKING_RATE_HISTORY = "/sapi/v1/eth-staking/eth/history/rateHistory"; + /** + * GET /sapi/v1/eth-staking/eth/history/rateHistory + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * startTime -- optional/long
+ * endTime -- optional/long
+ * current -- optional/long -- Currently querying page. Start from 1. Default:1
+ * size -- optional/long -- Default: 10, Max: 100
+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-wbeth-rate-history-user_data + */ + public String ethStakingRateHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_RATE_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String ETH_STAKING_ACCOUNT = "/sapi/v2/eth-staking/account"; + /** + * GET /sapi/v2/eth-staking/account + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#eth-staking-account-v2-user_data + */ + public String ethStakingAccount(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_ACCOUNT, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String WRAP_WBETH = "/sapi/v1/eth-staking/wbeth/wrap"; + /** + * POST /sapi/v1/eth-staking/wbeth/wrap + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * amount -- mandatory/decimal -- Amount in BETH, limit 4 decimals
+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#wrap-beth-trade + */ + public String wrapEthStakingWbeth(Map parameters) { + ParameterChecker.checkRequiredParameter(parameters, "amount"); + return requestHandler.sendSignedRequest(baseUrl, WRAP_WBETH, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String ETH_STAKING_WBETH_WRAP_HISTORY = "/sapi/v1/eth-staking/wbeth/history/wrapHistory"; + /** + * GET /sapi/v1/eth-staking/wbeth/history/wrapHistory + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * startTime -- optional/long
+ * endTime -- optional/long
+ * current -- optional/long -- Currently querying page. Start from 1. Default:1
+ * size -- optional/long -- Default: 10, Max: 100
+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-wbeth-wrap-history-user_data + */ + public String ethStakingWbethWrapHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_WBETH_WRAP_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String ETH_STAKING_WBETH_UNWRAP_HISTORY = "/sapi/v1/eth-staking/wbeth/history/unwrapHistory"; + /** + * GET /sapi/v1/eth-staking/wbeth/history/unwrapHistory + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * startTime -- optional/long
+ * endTime -- optional/long
+ * current -- optional/long -- Currently querying page. Start from 1. Default:1
+ * size -- optional/long -- Default: 10, Max: 100
+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-wbeth-unwrap-history-user_data + */ + public String ethStakingWbethUnwrapHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_WBETH_UNWRAP_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String ETH_STAKING_WBETH_REWARD_HISTORY = "/sapi/v1/eth-staking/eth/history/wbethRewardsHistory"; + /** + * GET /sapi/v1/eth-staking/eth/history/wbethRewardsHistory + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * startTime -- optional/long
+ * endTime -- optional/long
+ * current -- optional/long -- Currently querying page. Start from 1. Default:1
+ * size -- optional/long -- Default: 10, Max: 100
+ * recvWindow -- optional/long
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-wbeth-rewards-history-user_data + */ + public String ethStakingWbethRewardHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_WBETH_REWARD_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } } diff --git a/src/main/java/com/binance/connector/client/impl/spot/SubAccount.java b/src/main/java/com/binance/connector/client/impl/spot/SubAccount.java index 56d0253d..fe7703d5 100644 --- a/src/main/java/com/binance/connector/client/impl/spot/SubAccount.java +++ b/src/main/java/com/binance/connector/client/impl/spot/SubAccount.java @@ -161,8 +161,8 @@ public String futuresInternalTransfer(Map parameters) { * email -- mandatory/string -- Sub account email
* recvWindow -- optional/long
* @return String - * @see - * https://binance-docs.github.io/apidocs/spot/en/#sub-account-futures-asset-transfer-for-master-account + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-sub-account-assets-for-master-account */ public String assets(Map parameters) { ParameterChecker.checkParameter(parameters, "email", String.class); @@ -673,8 +673,7 @@ public String getIpRestriction(Map parameters) { *

* email -- mandatory/string -- Sub-account email
* subAccountApiKey -- mandatory/string
- * ipAddress -- mandatory/string -- Can be added in batches, separated by commas
- * thirdPartyName -- optional/string
+ * ipAddress -- optional/string -- Can be added in batches, separated by commas
* recvWindow -- optional/long
* @return String * @see @@ -683,7 +682,6 @@ public String getIpRestriction(Map parameters) { public String deleteIpList(Map parameters) { ParameterChecker.checkParameter(parameters, "email", String.class); ParameterChecker.checkParameter(parameters, "subAccountApiKey", String.class); - ParameterChecker.checkParameter(parameters, "ipAddress", String.class); return requestHandler.sendSignedRequest(baseUrl, IP_LIST, parameters, HttpMethod.DELETE, showLimitUsage); } diff --git a/src/main/java/com/binance/connector/client/impl/spot/Trade.java b/src/main/java/com/binance/connector/client/impl/spot/Trade.java index 858b64b5..d4a6a769 100644 --- a/src/main/java/com/binance/connector/client/impl/spot/Trade.java +++ b/src/main/java/com/binance/connector/client/impl/spot/Trade.java @@ -45,19 +45,8 @@ public Trade(String baseUrl, String apiKey, SignatureGenerator signatureGenerato * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

- * symbol -- mandatory/string
- * side -- mandatory/enum
- * type -- mandatory/enum
- * timeInForce -- optional/enum
- * quantity -- optional/decimal
- * quoteOrderQty -- optional/decimal
- * price -- optional/decimal
- * newClientOrderId -- optional/string
- * stopPrice -- optional/decimal
- * icebergQty -- optional/decimal
- * trailingDelta -- optional/long
- * newOrderRespType -- optional/enum
- * recvWindow -- optional/long
+ * In addition to all parameters accepted by POST /api/v3/order, the following optional parameters are also accepted:
+ * computeCommissionRates -- optional/boolean -- Default: false
* @return String * @see
* https://binance-docs.github.io/apidocs/spot/en/#test-new-order-trade @@ -86,11 +75,14 @@ public String testNewOrder(Map parameters) { * quantity -- optional/decimal
* quoteOrderQty -- optional/decimal
* price -- optional/decimal
- * newClientOrderId -- optional/string
- * stopPrice -- optional/decimal
- * icebergQty -- optional/decimal
- * trailingDelta -- optional/long
- * newOrderRespType -- optional/enum
+ * newClientOrderId -- optional/string -- A unique id among open orders. Automatically generated if not sent.
+ * strategyId -- optional/int
+ * strategyType -- optional/int -- The value cannot be less than 1000000.
+ * stopPrice -- optional/decimal -- Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
+ * trailingDelta -- optional/long -- Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
+ * icebergQty -- optional/decimal -- Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order.
+ * newOrderRespType -- optional/enum -- Set the response JSON. ACK, RESULT, or FULL; MARKET and LIMIT order types default to FULL, all other orders default to ACK.
+ * selfTradePrevention -- optional/enum -- The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.
s * recvWindow -- optional/long
* @return String * @see @@ -194,10 +186,14 @@ public String getOrder(Map parameters) { * cancelOrigClientOrderId -- optional/string -- Either the cancelOrigClientOrderId or cancelOrderId must be provided. If both are provided, cancelOrderId takes precedence.
* cancelOrderId -- optional/long -- Either the cancelOrigClientOrderId or cancelOrderId must be provided. If both are provided, cancelOrderId takes precedence.
* newClientOrderId -- optional/string -- Used to identify the new order.
+ * stopStrategyId -- optional/int
+ * stopStrategyType -- optional/int -- The value cannot be less than 1000000.
* stopPrice -- optional/decimal
* icebergQty -- optional/decimal
* trailingDelta -- optional/long
- * newOrderRespType -- optional/enum
+ * newOrderRespType -- optional/enum -- Allowed values: ACK, RESULT, FULL. MARKET and LIMIT orders types default to FULL; all other orders default to ACK
+ * selfTradePreventionMode -- optional/enum -- The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.
+ * cancelRestrictions -- optional/enum -- Supported values: ONLY_NEW - Cancel will succeed if the order status is NEW. ONLY_PARTIALLY_FILLED - Cancel will succeed if order status is PARTIALLY_FILLED.
* recvWindow -- optional/long
* @return String * @see
@@ -270,19 +266,24 @@ public String getOrders(Map parameters) { * side -- mandatory/enum
* quantity -- mandatory/decimal
* limitClientOrderId -- optional/string
+ * limitStrategyId -- optional/int
+ * limitStrategyType -- optional/int
* price -- mandatory/decimal
* limitIcebergQty -- optional/decimal
* trailingDelta -- optional/long
* stopClientOrderId -- optional/string
* stopPrice -- mandatory/decimal
- * stopLimitPrice -- optional/decimal
+ * stopStrategyId -- optional/int
+ * stopStrategyType -- optional/int -- The value cannot be less than 1000000.
+ * stopLimitPrice -- optional/decimal -- If provided, stopLimitTimeInForce is required.
* stopIcebergQty -- optional/decimal
* stopLimitTimeInForce -- optional/enum
* newOrderRespType -- optional/enum
+ * selfTradePreventionMode -- optional/enum -- The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.
* recvWindow -- optional/long
* @return String - * @see
- * https://binance-docs.github.io/apidocs/spot/en/#new-order-trade + * @see + * https://binance-docs.github.io/apidocs/spot/en/#new-oco-trade */ public String ocoOrder(Map parameters) { ParameterChecker.checkParameter(parameters, "symbol", String.class); @@ -440,4 +441,157 @@ public String myTrades(Map parameters) { public String rateLimitOrder(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, RATE_LIMIT, parameters, HttpMethod.GET, showLimitUsage); } + + private final String PREVENTED_MATCHES = "/api/v3/myPreventedMatches"; + /** + * Displays the list of orders that were expired because of STP. + * + * These are the combinations supported: + * + * * symbol + preventedMatchId + * * symbol + orderId + * * symbol + orderId + fromPreventedMatchId (limit will default to 500) + * * symbol + orderId + fromPreventedMatchId + limit + * + *

+ * GET /api/v3/myPreventedMatches + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * symbol -- mandatory/string
+ * preventedMatchId -- optional/long
+ * orderId -- optional/long -- Order id
+ * fromPreventedMatchId -- optional/long
+ * limit -- optional/int -- Default 500; max 1000.
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-prevented-matches-user_data + */ + public String preventedMatches(Map parameters) { + ParameterChecker.checkParameter(parameters, "symbol", String.class); + return requestHandler.sendSignedRequest(baseUrl, PREVENTED_MATCHES, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String SOR_ALLOCATIONS = "/api/v3/myAllocations"; + /** + * Retrieves allocations resulting from SOR order placement. + * + * + * Supported parameter combinations: + * Parameters Response + * symbol allocations from oldest to newest + * symbol + startTime oldest allocations since startTime + * symbol + endTime newest allocations until endTime + * symbol + startTime + endTime allocations within the time range + * symbol + fromAllocationId allocations by allocation ID + * symbol + orderId allocations related to an order starting with oldest + * symbol + orderId + fromAllocationId allocations related to an order by allocation ID + * + * Note: The time between startTime and endTime can't be longer than 24 hours. + *

+ * GET /api/v3/myAllocations + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * symbol -- mandatory/string -- Trading symbol, e.g. BNBUSDT
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * fromAllocationId -- optional/int
+ * limit -- optional/int -- Default 500; max 1000.
+ * orderId -- optional/long -- Order id
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-allocations-user_data + */ + public String sorAllocations(Map parameters) { + ParameterChecker.checkParameter(parameters, "symbol", String.class); + return requestHandler.sendSignedRequest(baseUrl, SOR_ALLOCATIONS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String COMMISSION = "/api/v3/account/commission"; + /** + * Get current account commission rates. + *

+ * GET /api/v3/account/commission + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * symbol -- mandatory/string
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-commission-rates-user_data + */ + public String commission(Map parameters) { + ParameterChecker.checkParameter(parameters, "symbol", String.class); + return requestHandler.sendSignedRequest(baseUrl, COMMISSION, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String SOR_ORDER = "/api/v3/sor/order"; + /** + * Places an order using smart order routing (SOR). + * + *

+ * POST /api/v3/sor/order + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * symbol -- mandatory/string -- Trading symbol, e.g. BNBUSDT
+ * side -- mandatory/enum
+ * type -- mandatory/enum -- only supports LIMIT and MARKET orders
+ * timeInForce -- optional/enum -- Order time in force
+ * quantity -- mandatory/decimal
+ * price -- optional/decimal
+ * newClientOrderId -- optional/string -- Used to uniquely identify this cancel. Automatically generated by default
+ * strategyId -- optional/int
+ * strategyType -- optional/int -- The value cannot be less than 1000000.
+ * icebergQty -- optional/decimal -- Used with LIMIT to create an iceberg order.
+ * newOrderRespType -- optional/enum -- Set the response JSON. MARKET and LIMIT order types default to FULL, all other orders default to ACK.
+ * selfTradePreventionMode -- optional/enum -- The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#new-order-using-sor-trade + */ + public String sorOrder(Map parameters) { + ParameterChecker.checkParameter(parameters, "symbol", String.class); + ParameterChecker.checkParameter(parameters, "side", String.class); + ParameterChecker.checkParameter(parameters, "type", String.class); + ParameterChecker.checkRequiredParameter(parameters, "quantity"); + return requestHandler.sendSignedRequest(baseUrl, SOR_ORDER, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String TEST_SOR_ORDER = "/api/v3/sor/order/test"; + /** + * Test new order creation and signature/recvWindow using smart order routing (SOR). + * Creates and validates a new order but does not send it into the matching engine. + *

+ * POST /api/v3/sor/order/test + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * In addition to all parameters accepted by POST /api/v3/sor/order, the following optional parameters are also accepted:
+ * computeCommissionRates -- optional/boolean -- Default: false
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#test-new-order-using-sor-trade + */ + public String testSorOrder(Map parameters) { + ParameterChecker.checkParameter(parameters, "symbol", String.class); + ParameterChecker.checkParameter(parameters, "side", String.class); + ParameterChecker.checkParameter(parameters, "type", String.class); + ParameterChecker.checkRequiredParameter(parameters, "quantity"); + return requestHandler.sendSignedRequest(baseUrl, TEST_SOR_ORDER, parameters, HttpMethod.POST, showLimitUsage); + } } diff --git a/src/main/java/com/binance/connector/client/impl/spot/VIPLoans.java b/src/main/java/com/binance/connector/client/impl/spot/VIPLoans.java new file mode 100644 index 00000000..44df4af4 --- /dev/null +++ b/src/main/java/com/binance/connector/client/impl/spot/VIPLoans.java @@ -0,0 +1,277 @@ +package com.binance.connector.client.impl.spot; + +import java.util.Map; + +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.utils.ParameterChecker; +import com.binance.connector.client.utils.ProxyAuth; +import com.binance.connector.client.utils.RequestHandler; +import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; +import com.binance.connector.client.utils.signaturegenerator.SignatureGenerator; + +/** + *

VIPLoans Endpoints

+ * All endpoints under the + * VIP Loans Endpoints + * section of the API documentation will be implemented in this class. + *
+ * Response will be returned in String format. + */ +public class VIPLoans { + private final String baseUrl; + private final RequestHandler requestHandler; + private final boolean showLimitUsage; + + public VIPLoans(String baseUrl, String apiKey, String secretKey, boolean showLimitUsage, ProxyAuth proxy) { + this.baseUrl = baseUrl; + this.requestHandler = new RequestHandler(apiKey, new HmacSignatureGenerator(secretKey), proxy); + this.showLimitUsage = showLimitUsage; + } + + public VIPLoans(String baseUrl, String apiKey, SignatureGenerator signatureGenerator, boolean showLimitUsage, ProxyAuth proxy) { + this.baseUrl = baseUrl; + this.requestHandler = new RequestHandler(apiKey, signatureGenerator, proxy); + this.showLimitUsage = showLimitUsage; + } + + private final String ONGOING_ORDERS = "/sapi/v1/loan/vip/ongoing/orders"; + /** + * VIP loan is available for VIP users only. + * + *

+ * GET /sapi/v1/loan/vip/ongoing/orders + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * orderId -- optional/long -- Order ID
+ * collateralAccountId -- optional/long
+ * loanCoin -- optional/string -- Coin loaned
+ * collateralCoin -- optional/string -- Coin used as collateral
+ * current -- optional/long -- Current querying page. Start from 1, Default:1, Max:1000
+ * limit -- optional/long -- Default 10; max 100.
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-vip-loan-ongoing-orders-user_data + */ + public String ongoingOrders(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, ONGOING_ORDERS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String REPAY = "/sapi/v1/loan/vip/repay"; + /** + * VIP loan is available for VIP users only. + * + *

+ * POST /sapi/v1/loan/vip/repay + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * orderId -- mandatory/long -- Order ID
+ * amount -- mandatory/decimal
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#vip-loan-repay-trade + */ + public String repay(Map parameters) { + ParameterChecker.checkParameter(parameters, "orderId", Long.class); + ParameterChecker.checkRequiredParameter(parameters, "amount"); + return requestHandler.sendSignedRequest(baseUrl, REPAY, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String REPAYMENT_HISTORY = "/sapi/v1/loan/vip/repay/history"; + /** + * VIP loan is available for VIP users only. + * + *

+ * GET /sapi/v1/loan/vip/repay/history + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * orderId -- optional/long -- Order ID
+ * loanCoin -- optional/string -- Coin loaned
+ * startTime -- optional/long -- UTC timestamp in ms
+ * endTime -- optional/long -- UTC timestamp in ms
+ * current -- optional/long -- Current querying page. Start from 1, Default:1, Max:1000
+ * limit -- optional/long -- Default 10; max 100.
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-vip-loan-repayment-history-user_data + */ + public String repaymentHistory(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, REPAYMENT_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String RENEW = "/sapi/v1/loan/vip/renew"; + /** + * VIP loan is available for VIP users only. + * + *

+ * POST /sapi/v1/loan/vip/renew + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * orderId -- mandatory/long -- Order ID
+ * loanTerm -- optional/int -- 30/60 days
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#vip-loan-renew-trade + */ + public String renew(Map parameters) { + ParameterChecker.checkParameter(parameters, "orderId", Long.class); + return requestHandler.sendSignedRequest(baseUrl, RENEW, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String COLLATERAL_ACCOUNT = "/sapi/v1/loan/vip/collateral/account"; + /** + * VIP loan is available for VIP users only. + * + *

+ * GET /sapi/v1/loan/vip/collateral/account + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * orderId -- optional/long -- Order ID
+ * collateralAccountId -- optional/long
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#check-locked-value-of-vip-collateral-account-user_data + */ + public String collateralAccount(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, COLLATERAL_ACCOUNT, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String BORROW = "/sapi/v1/loan/vip/borrow"; + /** + * VIP loan is available for VIP users only. + * + *

+ * POST /sapi/v1/loan/vip/borrow + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * loanAccountId -- mandatory/long
+ * loanCoin -- mandatory/string -- Coin loaned
+ * loanAmount -- mandatory/decimal
+ * collateralAccountId -- mandatory/string -- Multiple split by ','
+ * collateralCoin -- mandatory/string -- Multiple split by ','
+ * isFlexibleRate -- mandatory/boolean -- TRUE : flexible rate; FALSE: fixed rate. Default: TRUE.
+ * loanTerm -- optional/integer -- Mandatory for fixed rate. Optional for fixed interest rate. Eg: 30/60 days
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#vip-loan-borrow-trade + */ + public String borrow(Map parameters) { + ParameterChecker.checkParameter(parameters, "loanAccountId", Long.class); + ParameterChecker.checkParameter(parameters, "loanCoin", String.class); + ParameterChecker.checkRequiredParameter(parameters, "loanAmount"); + ParameterChecker.checkParameter(parameters, "collateralAccountId", String.class); + ParameterChecker.checkParameter(parameters, "collateralCoin", String.class); + ParameterChecker.checkParameter(parameters, "isFlexibleRate", Boolean.class); + return requestHandler.sendSignedRequest(baseUrl, BORROW, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String LOANABLE_ASSETS = "/sapi/v1/loan/vip/loanable/data"; + /** + * Get interest rate and borrow limit of loanable assets. The borrow limit is shown in USD value. + * + *

+ * GET /sapi/v1/loan/vip/loanable/data + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * loanCoin -- optional/string -- Coin loaned
+ * vipLevel -- optional/integer -- Defaults to user's vip level
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-loanable-assets-data-user_data + */ + public String loanableAssets(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, LOANABLE_ASSETS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String COLLATERAL_ASSET_DATA = "/sapi/v1/loan/vip/collateral/data"; + /** + * Get Collateral Asset Data + * + *

+ * GET /sapi/v1/loan/vip/collateral/data + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * collateralCoin -- optional/string
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-collateral-asset-data-user_data + */ + public String collateralAsset(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, COLLATERAL_ASSET_DATA, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String ORDER_STATUS = "/sapi/v1/loan/vip/request/data"; + /** + * Get order status + * + *

+ * GET /sapi/v1/loan/vip/request/data + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * current -- optional/long -- Current querying page. Start from 1. Default:1
+ * limit -- optional/long -- Default 10; max 100.
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-application-status-user_data + */ + public String orderStatus(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, ORDER_STATUS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String BORROW_INTEREST_RATE = "/sapi/v1/loan/vip/request/interestRate"; + /** + * Get Borrow Interest Rate + * + *

+ * GET /sapi/v1/loan/vip/request/interestRate + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * loanCoin -- mandatory/string -- Max 10 assets, Multiple split by ","
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#get-borrow-interest-rate-user_data + */ + public String borrowInterestRate(Map parameters) { + ParameterChecker.checkParameter(parameters, "loanCoin", String.class); + return requestHandler.sendSignedRequest(baseUrl, BORROW_INTEREST_RATE, parameters, HttpMethod.GET, showLimitUsage); + } +} diff --git a/src/main/java/com/binance/connector/client/impl/spot/Wallet.java b/src/main/java/com/binance/connector/client/impl/spot/Wallet.java index 828f0a17..c50ed8db 100644 --- a/src/main/java/com/binance/connector/client/impl/spot/Wallet.java +++ b/src/main/java/com/binance/connector/client/impl/spot/Wallet.java @@ -1,6 +1,5 @@ package com.binance.connector.client.impl.spot; -import java.math.BigDecimal; import java.util.ArrayList; import java.util.Map; @@ -69,8 +68,12 @@ public String coinInfo(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, COIN_INFO, parameters, HttpMethod.GET, showLimitUsage); } - private final String ACC_SNAP = "/sapi/v1/accountSnapshot"; + private final String ACCOUNT_SNAPSHOT = "/sapi/v1/accountSnapshot"; /** + * - The query time period must be less than 30 days + * - Support query within the last one month only + * - If startTime and endTime are both not sent, records from the last 7 days are returned by default + *

* GET /sapi/v1/accountSnapshot *
* @param @@ -88,11 +91,14 @@ public String coinInfo(Map parameters) { */ public String accountSnapshot(Map parameters) { ParameterChecker.checkParameter(parameters, "type", String.class); - return requestHandler.sendSignedRequest(baseUrl, ACC_SNAP, parameters, HttpMethod.GET, showLimitUsage); + return requestHandler.sendSignedRequest(baseUrl, ACCOUNT_SNAPSHOT, parameters, HttpMethod.GET, showLimitUsage); } - private final String DISABLE_FAST = "/sapi/v1/account/disableFastWithdrawSwitch"; + private final String DISABLE_FAST_WITHDRAW = "/sapi/v1/account/disableFastWithdrawSwitch"; /** + * - This request will disable fastwithdraw switch under your account. + * - You need to enable "trade" option for the api key which requests this endpoint. + *

* POST /sapi/v1/account/disableFastWithdrawSwitch *
* @param @@ -105,11 +111,14 @@ public String accountSnapshot(Map parameters) { * https://binance-docs.github.io/apidocs/spot/en/#disable-fast-withdraw-switch-user_data */ public String disableFastWithdraw(Map parameters) { - return requestHandler.sendSignedRequest(baseUrl, DISABLE_FAST, parameters, HttpMethod.POST, showLimitUsage); + return requestHandler.sendSignedRequest(baseUrl, DISABLE_FAST_WITHDRAW, parameters, HttpMethod.POST, showLimitUsage); } - private final String ENABLE_FAST = "/sapi/v1/account/enableFastWithdrawSwitch"; + private final String ENABLE_FAST_WITHDRAW = "/sapi/v1/account/enableFastWithdrawSwitch"; /** + * - This request will enable fastwithdraw switch under your account. You need to enable "trade" option for the api key which requests this endpoint. + * - When Fast Withdraw Switch is on, transferring funds to a Binance account will be done instantly. There is no on-chain transaction, no transaction ID and no withdrawal fee. + *

* POST /sapi/v1/account/enableFastWithdrawSwitch *
* @param @@ -122,12 +131,15 @@ public String disableFastWithdraw(Map parameters) { * https://binance-docs.github.io/apidocs/spot/en/#enable-fast-withdraw-switch-user_data */ public String enableFastWithdraw(Map parameters) { - return requestHandler.sendSignedRequest(baseUrl, ENABLE_FAST, parameters, HttpMethod.POST, showLimitUsage); + return requestHandler.sendSignedRequest(baseUrl, ENABLE_FAST_WITHDRAW, parameters, HttpMethod.POST, showLimitUsage); } private final String WITHDRAW = "/sapi/v1/capital/withdraw/apply"; /** * Submit a withdraw request. + * + * - If `network` not send, return with default network of the coin. + * - You can get `network` and `isDefault` in `networkList` of a coin in the response of `Get /sapi/v1/capital/config/getall (HMAC SHA256)`. *

* POST /sapi/v1/capital/withdraw/apply *
@@ -136,7 +148,7 @@ public String enableFastWithdraw(Map parameters) { * where String is the name of the parameter and Object is the value of the parameter *

* coin -- mandatory/string
- * withdrawOrderId -- optional/string -- client id for withdraw
+ * withdrawOrderId -- optional/string -- Client ID for withdraw
* network -- optional/string
* address -- mandatory/string
* addressTag -- optional/string -- Secondary address identifier for coins like XRP,XMR etc.
@@ -157,9 +169,12 @@ public String withdraw(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, WITHDRAW, parameters, HttpMethod.POST, showLimitUsage); } - private final String DEPOSIT_HIST = "/sapi/v1/capital/deposit/hisrec"; + private final String DEPOSIT_HISTORY = "/sapi/v1/capital/deposit/hisrec"; /** * Fetch deposit history. + * + * - Please notice the default `startTime` and `endTime` to make sure that time interval is within 0-90 days. + * - If both `startTime` and `endTime` are sent, time between `startTime` and `endTime` must be less than 90 days. *

* GET /sapi/v1/capital/deposit/hisrec *
@@ -179,12 +194,20 @@ public String withdraw(Map parameters) { * https://binance-docs.github.io/apidocs/spot/en/#deposit-history-supporting-network-user_data */ public String depositHistory(Map parameters) { - return requestHandler.sendSignedRequest(baseUrl, DEPOSIT_HIST, parameters, HttpMethod.GET, showLimitUsage); + return requestHandler.sendSignedRequest(baseUrl, DEPOSIT_HISTORY, parameters, HttpMethod.GET, showLimitUsage); } - private final String WITHDRAW_HIST = "/sapi/v1/capital/withdraw/history"; + private final String WITHDRAW_HISTORY = "/sapi/v1/capital/withdraw/history"; /** * Fetch withdraw history. + * + * This endpoint specifically uses per second UID rate limit, user's total second level IP rate limit is 180000/second. Response from the endpoint contains header key X-SAPI-USED-UID-WEIGHT-1S, which defines weight used by the current IP. + * + * - `network` may not be in the response for old withdraw. + * - Please notice the default `startTime` and `endTime` to make sure that time interval is within 0-90 days. + * - If both `startTime` and `endTime` are sent, time between `startTime` and `endTime` must be less than 90 days + * - If withdrawOrderId is sent, time between startTime and endTime must be less than 7 days. + * - If withdrawOrderId is sent, startTime and endTime are not sent, will return last 7 days records by default. *

* GET /sapi/v1/capital/withdraw/history *
@@ -193,6 +216,7 @@ public String depositHistory(Map parameters) { * where String is the name of the parameter and Object is the value of the parameter *

* coin -- optional/string
+ * withdrawOrderId -- optional/string
* status -- optional/int -- 0(0:Email Sent,1:Cancelled 2:Awaiting Approval 3:Rejected 4:Processing 5:Failure 6:Completed)
* startTime -- optional/long -- Default: 90 days from current timestamp
* endTime -- optional/long -- Default: present timestamp
@@ -204,14 +228,17 @@ public String depositHistory(Map parameters) { * https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data */ public String withdrawHistory(Map parameters) { - return requestHandler.sendSignedRequest(baseUrl, WITHDRAW_HIST, parameters, HttpMethod.GET, showLimitUsage); + return requestHandler.sendSignedRequest(baseUrl, WITHDRAW_HISTORY, parameters, HttpMethod.GET, showLimitUsage); } - private final String DEPOSIT_ADD = "/sapi/v1/capital/deposit/address"; + private final String DEPOSIT_ADDRESS = "/sapi/v1/capital/deposit/address"; /** * Fetch deposit address with network. + * + * - If network is not send, return with default network of the coin. + * - You can get network and isDefault in networkList in the response of Get /sapi/v1/capital/config/getall. *

- * GET /sapi/v1/capital/withdraw/history + * GET /sapi/v1/capital/deposit/address *
* @param * parameters Map of String,Object pair @@ -219,6 +246,7 @@ public String withdrawHistory(Map parameters) { *

* coin -- mandatory/string
* network -- optional/string
+ * amount -- optional/decimal -- mandatory if using LIGHTNING network
* recvWindow -- optional/long
* @return String * @see @@ -226,10 +254,35 @@ public String withdrawHistory(Map parameters) { */ public String depositAddress(Map parameters) { ParameterChecker.checkParameter(parameters, "coin", String.class); - return requestHandler.sendSignedRequest(baseUrl, DEPOSIT_ADD, parameters, HttpMethod.GET, showLimitUsage); + return requestHandler.sendSignedRequest(baseUrl, DEPOSIT_ADDRESS, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String DEPOSIT_ADDRESSES = "/sapi/v1/capital/deposit/address/list"; + /** + * Fetch deposit address list with network. + * + * - If network is not send, return with default network of the coin. + * - You can get network and isDefault in networkList in the response of Get /sapi/v1/capital/config/getall. + *

+ * GET /sapi/v1/capital/deposit/address/list + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * coin -- mandatory/string
+ * network -- optional/string
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see
+ * https://binance-docs.github.io/apidocs/spot/en/#fetch-deposit-address-list-with-network-user_data + */ + public String depositAddresses(Map parameters) { + ParameterChecker.checkParameter(parameters, "coin", String.class); + return requestHandler.sendSignedRequest(baseUrl, DEPOSIT_ADDRESSES, parameters, HttpMethod.GET, showLimitUsage); } - private final String ACC_STATUS = "/sapi/v1/account/status"; + private final String ACCOUNT_STATUS = "/sapi/v1/account/status"; /** * Fetch account status detail. *

@@ -245,12 +298,12 @@ public String depositAddress(Map parameters) { * https://binance-docs.github.io/apidocs/spot/en/#account-status-user_data */ public String accountStatus(Map parameters) { - return requestHandler.sendSignedRequest(baseUrl, ACC_STATUS, parameters, HttpMethod.GET, showLimitUsage); + return requestHandler.sendSignedRequest(baseUrl, ACCOUNT_STATUS, parameters, HttpMethod.GET, showLimitUsage); } private final String API_TRADE_STATUS = "/sapi/v1/account/apiTradingStatus"; /** - * Fetch account api trading status detail. + * Fetch account API trading status with details. *

* GET /sapi/v1/account/apiTradingStatus *
@@ -269,9 +322,7 @@ public String apiTradingStatus(Map parameters) { private final String DUST_LOG = "/sapi/v1/asset/dribblet"; /** - * Fetch account api trading status detail. - *

- * GET /sapi/v1/account/apiTradingStatus + * GET /sapi/v1/asset/dribblet *
* @param * parameters Map of String,Object pair @@ -288,7 +339,7 @@ public String dustLog(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, DUST_LOG, parameters, HttpMethod.GET, showLimitUsage); } - private final String BNB_CONVERTABLE_ASSETS = "/sapi/v1/asset/dust-btc"; + private final String BNB_CONVERTIBLE_ASSETS = "/sapi/v1/asset/dust-btc"; /** * POST /sapi/v1/asset/dust-btc *
@@ -302,7 +353,7 @@ public String dustLog(Map parameters) { * https://binance-docs.github.io/apidocs/spot/en/#get-assets-that-can-be-converted-into-bnb-user_data */ public String bnbConvertableAssets(Map parameters) { - return requestHandler.sendSignedRequest(baseUrl, BNB_CONVERTABLE_ASSETS, parameters, HttpMethod.POST, showLimitUsage); + return requestHandler.sendSignedRequest(baseUrl, BNB_CONVERTIBLE_ASSETS, parameters, HttpMethod.POST, showLimitUsage); } private final String DUST_TRANSFER = "/sapi/v1/asset/dust"; @@ -352,6 +403,8 @@ public String assetDividend(Map parameters) { private final String ASSET_DETAIL = "/sapi/v1/asset/assetDetail"; /** * Fetch details of assets supported on Binance. + * + * - Please get network and other deposit or withdraw details from `GET /sapi/v1/capital/config/getall`. *

* GET /sapi/v1/asset/assetDetail *
@@ -399,9 +452,9 @@ public String tradeFee(Map parameters) { * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

- * type -- mandatory/enum
+ * type -- mandatory/enum -- Universal transfer type
* asset -- mandatory/string
- * amount -- mandatory/string
+ * amount -- mandatory/decimal
* fromSymbol -- optional/string
* toSymbol -- optional/string
* recvWindow -- optional/long
@@ -500,6 +553,8 @@ public String getUserAsset(Map parameters) { private final String BUSD_CONVERT = "/sapi/v1/asset/convert-transfer"; /** * Convert transfer, convert between BUSD and stablecoins. + * + * - If the clientId has been used before, will not do the convert transfer, the original transfer will be returned. *

* POST /sapi/v1/asset/convert-transfer *
@@ -520,7 +575,7 @@ public String getUserAsset(Map parameters) { public String busdConvert(Map parameters) { ParameterChecker.checkParameter(parameters, "clientTranId", String.class); ParameterChecker.checkParameter(parameters, "asset", String.class); - ParameterChecker.checkParameter(parameters, "amount", BigDecimal.class); + ParameterChecker.checkRequiredParameter(parameters, "amount"); ParameterChecker.checkParameter(parameters, "targetAsset", String.class); return requestHandler.sendSignedRequest(baseUrl, BUSD_CONVERT, parameters, HttpMethod.POST, showLimitUsage); @@ -559,6 +614,7 @@ public String busdConvertHistory(Map parameters) { private final String CLOUD_MINING_HISTORY = "/sapi/v1/asset/ledger-transfer/cloud-mining/queryByPage"; /** + * The query of Cloud-Mining payment and refund history *

* GET /sapi/v1/asset/ledger-transfer/cloud-mining/queryByPage *
@@ -586,4 +642,117 @@ public String cloudMiningHistory(Map parameters) { return requestHandler.sendSignedRequest(baseUrl, CLOUD_MINING_HISTORY, parameters, HttpMethod.GET, showLimitUsage); } + private final String BUSD_AUTO_CONVERT = "/sapi/v1/capital/contract/convertible-coins"; + /** + * Get the stable coins set for auto-conversion to BUSD at deposit/withdrawal moments. + * + *

+ * GET /sapi/v1/capital/contract/convertible-coins + *
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-auto-converting-stable-coins-user_data + */ + public String getBusdAutoConvertions() { + return requestHandler.sendSignedRequest(baseUrl, BUSD_AUTO_CONVERT, null, HttpMethod.GET, showLimitUsage); + } + + /** + * Switch on/off the BUSD auto-conversion from/to a specific stable coin. + * + *

+ * POST /sapi/v1/capital/contract/convertible-coins + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * coin -- mandatory/string -- Must be USDC, USDP or TUSD
+ * enable -- mandatory/boolean -- true: turn on the auto-conversion. false: turn off the auto-conversion
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#switch-on-off-busd-and-stable-coins-conversion-user_data + */ + public String switchBusdAutoConversion(Map parameters) { + ParameterChecker.checkParameter(parameters, "coin", String.class); + ParameterChecker.checkParameter(parameters, "enable", Boolean.class); + return requestHandler.sendSignedRequest(baseUrl, BUSD_AUTO_CONVERT, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String APPLY_ONE_CLICK_ARRIVAL_DEPOSIT = "/sapi/v1/capital/deposit/credit-apply"; + /** + * Apply deposit credit for expired address (One click arrival) + * + *

+ * POST /sapi/v1/capital/deposit/credit-apply + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * depositId -- optional/long -- Deposit record ID, priority use
+ * txId -- optional/string -- Deposit txId, used when depositId is not specified
+ * subAccountId -- optional/long
+ * subUserId -- optional/long
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#one-click-arrival-deposit-apply-for-expired-address-deposit-user_data + */ + public String applyOneClickArrivalDeposit(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, APPLY_ONE_CLICK_ARRIVAL_DEPOSIT, parameters, HttpMethod.POST, showLimitUsage); + } + + private final String WALLET_BALANCE = "/sapi/v1/asset/wallet/balance"; + /** + * Query User Wallet Balance + * + *

+ * GET /sapi/v1/asset/wallet/balance + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-user-wallet-balance-user_data + */ + public String walletBalance(Map parameters) { + return requestHandler.sendSignedRequest(baseUrl, WALLET_BALANCE, parameters, HttpMethod.GET, showLimitUsage); + } + + private final String QUERY_USER_DELEGATION_HISTORY = "/sapi/v1/asset/custody/transfer-history"; + /** + * Query User Delegation History + * + * You need to open Enable Spot and Margin Trading permission for the API Key which requests this endpoint + * + *

+ * GET /sapi/v1/asset/custody/transfer-history + *
+ * @param + * parameters Map of String,Object pair + * where String is the name of the parameter and Object is the value of the parameter + *

+ * email -- mandatory/string
+ * startTime -- mandatory/long
+ * endTime -- mandatory/long
+ * type -- optional/enum -- "Delegate" or "Undelegate"
+ * asset -- optional/string
+ * current -- optional/integer -- Current querying page. Start from 1. Default:1
+ * size -- optional/integer -- Default:10 Max:100
+ * recvWindow -- optional/long -- The value cannot be greater than 60000
+ * @return String + * @see + * https://binance-docs.github.io/apidocs/spot/en/#query-user-delegation-history-for-master-account-user_data + */ + public String delegationHistory(Map parameters) { + ParameterChecker.checkParameter(parameters, "email", String.class); + ParameterChecker.checkParameter(parameters, "startTime", Long.class); + ParameterChecker.checkParameter(parameters, "endTime", Long.class); + return requestHandler.sendSignedRequest(baseUrl, QUERY_USER_DELEGATION_HISTORY, parameters, HttpMethod.GET, showLimitUsage); + } + } diff --git a/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiAccount.java b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiAccount.java index 3ac3a85d..2788dcbe 100644 --- a/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiAccount.java +++ b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiAccount.java @@ -14,7 +14,7 @@ *
* Response will be returned as callback. */ -public class WebSocketApiAccount { +public class WebSocketApiAccount implements WebSocketApiModule { private WebSocketApiRequestHandler handler; @@ -146,4 +146,46 @@ public void accountPreventedMatches(String symbol, JSONObject parameters) { this.handler.signedRequest("myPreventedMatches", parameters); } + + /** + * Retrieves allocations resulting from SOR order placement.
+ * + * @param symbol String + * @param parameters JSONObject composed by key-value pairs: + *

+ * startTime -- optional/long -- Timestamp in ms
+ * endTime -- optional/long -- Timestamp in ms
+ * fromAllocationId -- optional/int
+ * limit -- optional/int -- Default 500; max 1000.
+ * orderId -- optional/long
+ * recvWindow -- optional/int -- The value cannot be greater than 60000
+ * requestId -- optional/String or int
+ * + * @see + * https://binance-docs.github.io/apidocs/websocket_api/en/#account-allocations-user_data + */ + public void accountAllocations(String symbol, JSONObject parameters) { + ParameterChecker.checkParameterType(symbol, String.class, "symbol"); + parameters = JSONParser.addKeyValue(parameters, "symbol", symbol); + + this.handler.signedRequest("myAllocations", parameters); + } + + /** + * Get current account commission rates.
+ * + * @param symbol String + * @param parameters JSONObject composed by key-value pairs: + *

+ * requestId -- optional/String or int
+ * + * @see + * https://binance-docs.github.io/apidocs/websocket_api/en/#account-commission-rates-user_data + */ + public void accountCommissionRates(String symbol, JSONObject parameters) { + ParameterChecker.checkParameterType(symbol, String.class, "symbol"); + parameters = JSONParser.addKeyValue(parameters, "symbol", symbol); + + this.handler.signedRequest("account.commission", parameters); + } } diff --git a/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiAuth.java b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiAuth.java new file mode 100644 index 00000000..e5b3198d --- /dev/null +++ b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiAuth.java @@ -0,0 +1,73 @@ +package com.binance.connector.client.impl.websocketapi; + +import org.json.JSONObject; +import com.binance.connector.client.utils.websocketapi.WebSocketApiRequestHandler; + +/** + *

Authentication requests

+ * All requests under the + * Authentication requests + * section of the WebSocket API documentation will be implemented in this class. + *
+ * Response will be returned as callback. + */ +public class WebSocketApiAuth implements WebSocketApiModule { + private WebSocketApiRequestHandler handler; + + public WebSocketApiAuth(WebSocketApiRequestHandler handler) { + this.handler = handler; + } + + /** + * Authenticate WebSocket connection using the provided API key.
+ * + * After calling session.logon, future requests under same connection won't send apiKey and signature parameters.
+ * Calling session.logon multiple times changes the current authenticated API key.
+ * + * @param parameters JSONObject composed by key-value pairs: + *

+ * recvWindow -- optional/int -- The value cannot be greater than 60000
+ * requestId -- optional/String or int
+ * + * @see + * https://binance-docs.github.io/apidocs/websocket_api/en/#log-in-with-api-key-signed + */ + public void logon(JSONObject parameters) { + this.handler.signedRequest("session.logon", parameters); + + } + + /** + * Query the status of the WebSocket connection, inspecting which API key (if any) is used to authorize requests.
+ * + * @param parameters JSONObject composed by key-value pairs: + *

+ * requestId -- optional/String or int
+ * + * @see + * https://binance-docs.github.io/apidocs/websocket_api/en/#query-session-status + */ + public void status(JSONObject parameters) { + this.handler.publicRequest("session.status", parameters); + + } + + /** + * Forget the API key previously authenticated. If the connection is not authenticated, this request does nothing.
+ * + * Note that the WebSocket connection stays open after session.logout request.
+ * You can continue using the connection, but now the requests will send the apiKey and signature parameters where is needed.
+ * + * @param parameters JSONObject composed by key-value pairs: + *

+ * requestId -- optional/String or int
+ * + * @see + * https://binance-docs.github.io/apidocs/websocket_api/en/#log-out-of-the-session + */ + public void logout(JSONObject parameters) { + this.handler.publicRequest("session.logout", parameters); + + } + +} \ No newline at end of file diff --git a/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiGeneral.java b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiGeneral.java index 62dd4dda..5710adca 100644 --- a/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiGeneral.java +++ b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiGeneral.java @@ -13,7 +13,7 @@ *
* Response will be returned as callback. */ -public class WebSocketApiGeneral { +public class WebSocketApiGeneral implements WebSocketApiModule { private WebSocketApiRequestHandler handler; public WebSocketApiGeneral(WebSocketApiRequestHandler handler) { diff --git a/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiMarket.java b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiMarket.java index 7d2b65d0..c2a5444b 100644 --- a/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiMarket.java +++ b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiMarket.java @@ -14,7 +14,7 @@ *
* Response will be returned as callback. */ -public class WebSocketApiMarket { +public class WebSocketApiMarket implements WebSocketApiModule { private WebSocketApiRequestHandler handler; public WebSocketApiMarket(WebSocketApiRequestHandler handler) { @@ -76,13 +76,13 @@ public void recentTrades(String symbol, JSONObject parameters) { * limit -- optional/int -- Default 500; max 1000.
* requestId -- optional/String or int
* - * @see - * https://binance-docs.github.io/apidocs/websocket_api/en/#historical-trades-market_data + * @see + * https://binance-docs.github.io/apidocs/websocket_api/en/#historical-trades */ public void historicalTrades(String symbol, JSONObject parameters) { ParameterChecker.checkParameterType(symbol, String.class, "symbol"); parameters = JSONParser.addKeyValue(parameters, "symbol", symbol); - this.handler.apiRequest("trades.historical", parameters); + this.handler.publicRequest("trades.historical", parameters); } /** @@ -122,6 +122,7 @@ public void aggTrades(String symbol, JSONObject parameters) { * startTime -- optional/int
* endTime -- optional/int
* limit -- optional/int -- Default 500; max 1000.
+ * timeZone -- optional/String -- Default: 0 (UTC)
* requestId -- optional/String or int
* * @see @@ -149,6 +150,7 @@ public void klines(String symbol, String interval, JSONObject parameters) { * startTime -- optional/int
* endTime -- optional/int
* limit -- optional/int -- Default 500; max 1000.
+ * timeZone -- optional/String -- Default: 0 (UTC)
* requestId -- optional/String or int
* * @see
@@ -259,4 +261,27 @@ public void tickerBook(JSONObject parameters) { ParameterChecker.checkOnlyOneOfParameters(parameters, "symbol", "symbols"); this.handler.publicRequest("ticker.book", parameters); } + + /** + * Get the current best price and quantity on the order book.
+ * + * Note: Either symbol or symbols must be specified.
+ * + * @param parameters JSONObject composed by key-value pairs: + *

+ * symbol -- optional/String -- Query ticker for a single symbol
+ * symbols -- optional/Array of String -- Query ticker for multiple symbols
+ * timeZone -- optional/String -- Default: 0 (UTC)
+ * type -- optional/String -- Ticker type: FULL (default) or MINI
+ * requestId -- optional/String or int
+ * + * @see
+ * https://binance-docs.github.io/apidocs/websocket_api/en/#trading-day-ticker + */ + public void tickerTradingDay(JSONObject parameters) { + ParameterChecker.checkOnlyOneOfParameters(parameters, "symbol", "symbols"); + ParameterChecker.checkOneOfParametersRequired(parameters, "symbol", "symbols"); + this.handler.publicRequest("ticker.tradingDay", parameters); + } + } diff --git a/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiModule.java b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiModule.java new file mode 100644 index 00000000..801d5db4 --- /dev/null +++ b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiModule.java @@ -0,0 +1,5 @@ +package com.binance.connector.client.impl.websocketapi; + +public interface WebSocketApiModule { + +} diff --git a/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiTrade.java b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiTrade.java index 213e4444..5a3e9be0 100644 --- a/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiTrade.java +++ b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiTrade.java @@ -14,7 +14,7 @@ *
* Response will be returned as callback. */ -public class WebSocketApiTrade { +public class WebSocketApiTrade implements WebSocketApiModule { private WebSocketApiRequestHandler handler; public WebSocketApiTrade(WebSocketApiRequestHandler handler) { @@ -85,6 +85,7 @@ public void newOrder(String symbol, String side, String type, JSONObject paramet * strategyId -- optional/int -- Arbitrary numeric value identifying the order within an order strategy.
* strategyType -- optional/int -- Arbitrary numeric value identifying the order strategy. Values smaller than 1000000 are reserved and cannot be used.
* selfTradePreventionMode -- optional/String -- The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.
+ * computeCommissionRates -- optional/boolean -- Default: false.
* recvWindow -- optional/int -- The value cannot be greater than 60000
* requestId -- optional/String or int
* @@ -139,6 +140,7 @@ public void getOrder(String symbol, JSONObject parameters) { * orderId -- optional/int -- Cancel order by orderId
* origClientOrderId -- optional/String -- Cancel order by clientOrderId
* newClientOrderId -- optional/String -- New ID for the canceled order. Automatically generated if not sent
+ * cancelRestrictions -- optional/enum -- Supported values: ONLY_NEW - Cancel will succeed if the order status is NEW. ONLY_PARTIALLY_FILLED - Cancel will succeed if order status is PARTIALLY_FILLED.
* recvWindow -- optional/int -- The value cannot be greater than 60000
* requestId -- optional/String or int
* @@ -180,6 +182,7 @@ public void cancelOrder(String symbol, JSONObject parameters) { * strategyId -- optional/int -- Arbitrary numeric value identifying the order within an order strategy.
* strategyType -- optional/int -- Arbitrary numeric value identifying the order strategy. Values smaller than 1000000 are reserved and cannot be used.
* selfTradePreventionMode -- optional/String -- The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.
+ * cancelRestrictions -- optional/enum -- Supported values: ONLY_NEW - Cancel will succeed if the order status is NEW. ONLY_PARTIALLY_FILLED - Cancel will succeed if order status is PARTIALLY_FILLED.
* recvWindow -- optional/int -- The value cannot be greater than 60000
* requestId -- optional/String or int
* @@ -346,4 +349,82 @@ public void cancelOcoOrder(String symbol, JSONObject parameters) { public void getOpenOcoOrders(JSONObject parameters) { this.handler.signedRequest("openOrderLists.status", parameters); } + + /** + * Places an order using smart order routing (SOR). + * + * @param symbol String + * @param side String -- BUY or SELL + * @param type String + * @param quantity double + * @param parameters JSONObject composed by key-value pairs: + *

+ * timeInForce -- optional/String -- Applicable only to LIMIT order type.
+ * price -- optional/double -- Applicable only to LIMIT order type.
+ * newClientOrderId -- optional/String -- Arbitrary unique ID among open orders. Automatically generated if not sent
+ * newOrderRespType -- optional/String -- Select response format: ACK, RESULT, FULL. MARKET and LIMIT orders use FULL by default, other order types default to ACK.
+ * stopPrice -- optional/double
+ * icebergQty -- optional/double
+ * strategyId -- optional/int -- Arbitrary numeric value identifying the order within an order strategy.
+ * strategyType -- optional/int -- Arbitrary numeric value identifying the order strategy. Values smaller than 1000000 are reserved and cannot be used.
+ * selfTradePreventionMode -- optional/String -- The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.
+ * recvWindow -- optional/int -- The value cannot be greater than 60000
+ * requestId -- optional/String or int
+ * + * @see + * https://binance-docs.github.io/apidocs/websocket_api/en/#place-new-order-using-sor-trade + */ + public void newSorOrder(String symbol, String side, String type, double quantity, JSONObject parameters) { + ParameterChecker.checkParameterType(symbol, String.class, "symbol"); + ParameterChecker.checkParameterType(side, String.class, "side"); + ParameterChecker.checkParameterType(type, String.class, "type"); + ParameterChecker.checkParameterType(quantity, Double.class, "quantity"); + + parameters = JSONParser.addKeyValue(parameters, "symbol", symbol); + parameters = JSONParser.addKeyValue(parameters, "side", side); + parameters = JSONParser.addKeyValue(parameters, "type", type); + parameters = JSONParser.addKeyValue(parameters, "quantity", quantity); + + this.handler.signedRequest("sor.order.place", parameters); + } + + /** + * Test new order creation and signature/recvWindow using smart order routing (SOR). Creates and validates a new order but does not send it into the matching engine. + * + * @param symbol String + * @param side String -- BUY or SELL + * @param type String + * @param quantity double + * @param parameters JSONObject composed by key-value pairs: + *

+ * timeInForce -- optional/String -- Applicable only to LIMIT order type.
+ * price -- optional/double -- Applicable only to LIMIT order type.
+ * newClientOrderId -- optional/String -- Arbitrary unique ID among open orders. Automatically generated if not sent
+ * newOrderRespType -- optional/String -- Select response format: ACK, RESULT, FULL. MARKET and LIMIT orders use FULL by default, other order types default to ACK.
+ * stopPrice -- optional/double
+ * icebergQty -- optional/double
+ * strategyId -- optional/int -- Arbitrary numeric value identifying the order within an order strategy.
+ * strategyType -- optional/int -- Arbitrary numeric value identifying the order strategy. Values smaller than 1000000 are reserved and cannot be used.
+ * selfTradePreventionMode -- optional/String -- The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE.
+ * computeCommissionRates -- optional/boolean -- Default: false.
+ * recvWindow -- optional/int -- The value cannot be greater than 60000
+ * requestId -- optional/String or int
+ * + * @see + * https://binance-docs.github.io/apidocs/websocket_api/en/#test-new-order-using-sor-trade + */ + public void testNewSorOrder(String symbol, String side, String type, double quantity, JSONObject parameters) { + ParameterChecker.checkParameterType(symbol, String.class, "symbol"); + ParameterChecker.checkParameterType(side, String.class, "side"); + ParameterChecker.checkParameterType(type, String.class, "type"); + ParameterChecker.checkParameterType(quantity, Double.class, "quantity"); + + parameters = JSONParser.addKeyValue(parameters, "symbol", symbol); + parameters = JSONParser.addKeyValue(parameters, "side", side); + parameters = JSONParser.addKeyValue(parameters, "type", type); + parameters = JSONParser.addKeyValue(parameters, "quantity", quantity); + + this.handler.signedRequest("sor.order.test", parameters); + } + } \ No newline at end of file diff --git a/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiUserDataStream.java b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiUserDataStream.java index 590297ea..c59dee28 100644 --- a/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiUserDataStream.java +++ b/src/main/java/com/binance/connector/client/impl/websocketapi/WebSocketApiUserDataStream.java @@ -14,7 +14,7 @@ *
* Response will be returned as callback. */ -public class WebSocketApiUserDataStream { +public class WebSocketApiUserDataStream implements WebSocketApiModule { private WebSocketApiRequestHandler handler; diff --git a/src/main/java/com/binance/connector/client/utils/RequestBuilder.java b/src/main/java/com/binance/connector/client/utils/RequestBuilder.java index 45ef0154..694d1e5e 100644 --- a/src/main/java/com/binance/connector/client/utils/RequestBuilder.java +++ b/src/main/java/com/binance/connector/client/utils/RequestBuilder.java @@ -9,7 +9,7 @@ public final class RequestBuilder { private static final MediaType JSON_TYPE = MediaType.parse("application/json; charset=utf-8"); - private static final String USER_AGENT = "binance-connector-java/3.1.0"; + private static final String USER_AGENT = "binance-connector-java/3.2.0"; private static final String CONTENT_TYPE = "application/x-www-form-urlencoded"; private RequestBuilder() { diff --git a/src/main/java/com/binance/connector/client/utils/RequestHandler.java b/src/main/java/com/binance/connector/client/utils/RequestHandler.java index 5fdfb879..fc286496 100644 --- a/src/main/java/com/binance/connector/client/utils/RequestHandler.java +++ b/src/main/java/com/binance/connector/client/utils/RequestHandler.java @@ -1,5 +1,6 @@ package com.binance.connector.client.utils; +import java.util.HashMap; import java.util.Map; import org.slf4j.Logger; @@ -53,6 +54,8 @@ public String sendSignedRequest(String baseUrl, String urlPath, Map() : parameters; parameters.putIfAbsent("timestamp", UrlBuilder.buildTimestamp()); parameters.put("signature", this.signatureGenerator.getSignature(UrlBuilder.joinQueryParameters(parameters))); diff --git a/src/main/java/com/binance/connector/client/utils/WebSocketConnection.java b/src/main/java/com/binance/connector/client/utils/WebSocketConnection.java index 65ae5eb2..0a2ed7fe 100644 --- a/src/main/java/com/binance/connector/client/utils/WebSocketConnection.java +++ b/src/main/java/com/binance/connector/client/utils/WebSocketConnection.java @@ -2,6 +2,7 @@ import java.util.concurrent.atomic.AtomicInteger; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,6 +24,7 @@ public class WebSocketConnection extends WebSocketListener { private static final int NORMAL_CLOSURE_STATUS = 1000; private static final Logger logger = LoggerFactory.getLogger(WebSocketConnection.class); private static OkHttpClient client; + private static boolean sessionStatus; private final int connectionId; private final Object mutex; @@ -74,6 +76,10 @@ public int getConnectionId() { return connectionId; } + public boolean getSessionStatus() { + return sessionStatus; + } + public void send(String message) { if (null == webSocket) { throw new BinanceConnectorException("No WebSocket connection. Please connect first!"); @@ -108,6 +114,12 @@ public void onClosed(WebSocket ws, int code, String reason) { @Override public void onMessage(WebSocket ws, String text) { + + // session status + if (text.contains("authorizedSince")) { + JSONObject result = new JSONObject(text).getJSONObject("result"); + WebSocketConnection.sessionStatus = !result.isNull("authorizedSince"); + } onMessageCallback.onMessage(text); } diff --git a/src/main/java/com/binance/connector/client/utils/websocketapi/WebSocketApiRequestHandler.java b/src/main/java/com/binance/connector/client/utils/websocketapi/WebSocketApiRequestHandler.java index d7012d79..47d964ea 100644 --- a/src/main/java/com/binance/connector/client/utils/websocketapi/WebSocketApiRequestHandler.java +++ b/src/main/java/com/binance/connector/client/utils/websocketapi/WebSocketApiRequestHandler.java @@ -33,12 +33,13 @@ public void publicRequest(String method, JSONObject parameters) { } public void apiRequest(String method, JSONObject parameters) { - this.request(RequestType.WITH_API_KEY, method, parameters); - + RequestType requestType = this.connection.getSessionStatus() ? RequestType.PUBLIC : RequestType.WITH_API_KEY; + this.request(requestType, method, parameters); } public void signedRequest(String method, JSONObject parameters) { - this.request(RequestType.SIGNED, method, parameters); + RequestType requestType = this.connection.getSessionStatus() ? RequestType.PUBLIC : RequestType.SIGNED; + this.request(requestType, method, parameters); } public void request(RequestType requestType, String method, JSONObject parameters) { diff --git a/src/test/java/examples/spot/autoinvest/AllSourceAndTargetAssets.java b/src/test/java/examples/spot/autoinvest/AllSourceAndTargetAssets.java new file mode 100644 index 00000000..e3e99a93 --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/AllSourceAndTargetAssets.java @@ -0,0 +1,22 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class AllSourceAndTargetAssets { + private AllSourceAndTargetAssets() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().allSourceAndTargetAssets(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/ChangePlanStatus.java b/src/test/java/examples/spot/autoinvest/ChangePlanStatus.java new file mode 100644 index 00000000..595f25d4 --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/ChangePlanStatus.java @@ -0,0 +1,25 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class ChangePlanStatus { + private ChangePlanStatus() { + } + + private static final long planId = 1234; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("planId", planId); + parameters.put("status", "PAUSED"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().changePlanStatus(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/HoldingPlan.java b/src/test/java/examples/spot/autoinvest/HoldingPlan.java new file mode 100644 index 00000000..1a9026a7 --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/HoldingPlan.java @@ -0,0 +1,22 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class HoldingPlan { + private HoldingPlan() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().holdingPlan(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/IndexInfo.java b/src/test/java/examples/spot/autoinvest/IndexInfo.java new file mode 100644 index 00000000..6ccfdc7b --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/IndexInfo.java @@ -0,0 +1,24 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class IndexInfo { + private IndexInfo() { + } + + private static final long indexId = 1234; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("indexId", indexId); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().indexInfo(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/IndexPlanRebalanceInfo.java b/src/test/java/examples/spot/autoinvest/IndexPlanRebalanceInfo.java new file mode 100644 index 00000000..c8e2fce1 --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/IndexPlanRebalanceInfo.java @@ -0,0 +1,22 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class IndexPlanRebalanceInfo { + private IndexPlanRebalanceInfo() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().indexPlanRebalanceInfo(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/IndexPlanRedeemHistory.java b/src/test/java/examples/spot/autoinvest/IndexPlanRedeemHistory.java new file mode 100644 index 00000000..86c0852c --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/IndexPlanRedeemHistory.java @@ -0,0 +1,24 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class IndexPlanRedeemHistory { + private IndexPlanRedeemHistory() { + } + + private static final long requestId = 12345; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("requestId", requestId); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().indexPlanRedeemHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/OneTimeTransactionStatus.java b/src/test/java/examples/spot/autoinvest/OneTimeTransactionStatus.java new file mode 100644 index 00000000..1dcd8f31 --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/OneTimeTransactionStatus.java @@ -0,0 +1,24 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class OneTimeTransactionStatus { + private OneTimeTransactionStatus() { + } + + private static final long transactionId = 12345; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("transactionId", transactionId); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().oneTimeTransactionStatus(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/PlanSubsHistory.java b/src/test/java/examples/spot/autoinvest/PlanSubsHistory.java new file mode 100644 index 00000000..efff41ba --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/PlanSubsHistory.java @@ -0,0 +1,22 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class PlanSubsHistory { + private PlanSubsHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().planSubsHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/PlansList.java b/src/test/java/examples/spot/autoinvest/PlansList.java new file mode 100644 index 00000000..7243d6a4 --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/PlansList.java @@ -0,0 +1,23 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class PlansList { + private PlansList() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("planType", "SINGLE"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().plansList(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/RedeemIndexPlan.java b/src/test/java/examples/spot/autoinvest/RedeemIndexPlan.java new file mode 100644 index 00000000..9a4531c9 --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/RedeemIndexPlan.java @@ -0,0 +1,26 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class RedeemIndexPlan { + private RedeemIndexPlan() { + } + + private static final long indexId = 123456; + private static final Integer redemptionPercentage = 10; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("indexId", indexId); + parameters.put("redemptionPercentage", redemptionPercentage); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().redeemIndexPlan(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/SourceAssetList.java b/src/test/java/examples/spot/autoinvest/SourceAssetList.java new file mode 100644 index 00000000..98bf805f --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/SourceAssetList.java @@ -0,0 +1,23 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SourceAssetList { + private SourceAssetList() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("usageType", "RECURRING"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().sourceAssetList(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/SubmitOneTimeTransaction.java b/src/test/java/examples/spot/autoinvest/SubmitOneTimeTransaction.java new file mode 100644 index 00000000..aedfa44f --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/SubmitOneTimeTransaction.java @@ -0,0 +1,26 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SubmitOneTimeTransaction { + private SubmitOneTimeTransaction() { + } + + private static final double subscriptionAmount = 10.1; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("sourceType", "MAIN_SITE"); + parameters.put("subscriptionAmount", subscriptionAmount); + parameters.put("sourceAsset", "USDT"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().submitOneTimeTransaction(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/TargetAssetList.java b/src/test/java/examples/spot/autoinvest/TargetAssetList.java new file mode 100644 index 00000000..c0a8bc66 --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/TargetAssetList.java @@ -0,0 +1,22 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class TargetAssetList { + private TargetAssetList() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().targetAssetList(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/TargetAssetRoiList.java b/src/test/java/examples/spot/autoinvest/TargetAssetRoiList.java new file mode 100644 index 00000000..defbfadb --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/TargetAssetRoiList.java @@ -0,0 +1,24 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class TargetAssetRoiList { + private TargetAssetRoiList() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("targetAsset", "BTC"); + parameters.put("hisRoiType", "FIVE_YEAR"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().targetAssetRoiList(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/autoinvest/UserIndexPlans.java b/src/test/java/examples/spot/autoinvest/UserIndexPlans.java new file mode 100644 index 00000000..ddf77436 --- /dev/null +++ b/src/test/java/examples/spot/autoinvest/UserIndexPlans.java @@ -0,0 +1,24 @@ +package examples.spot.autoinvest; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class UserIndexPlans { + private UserIndexPlans() { + } + + private static final long indexId = 1234; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("indexId", indexId); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createAutoInvest().userIndexPlans(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/cryptoloans/FlexibleLoanAdjustLtv.java b/src/test/java/examples/spot/cryptoloans/FlexibleLoanAdjustLtv.java new file mode 100644 index 00000000..53bceac7 --- /dev/null +++ b/src/test/java/examples/spot/cryptoloans/FlexibleLoanAdjustLtv.java @@ -0,0 +1,27 @@ +package examples.spot.cryptoloans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleLoanAdjustLtv { + private FlexibleLoanAdjustLtv() { + } + private static final double adjustmentAmount = 5.235; + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("loanCoin", "BUSD"); + parameters.put("collateralCoin", "BNB"); + parameters.put("adjustmentAmount", adjustmentAmount); + parameters.put("direction", "ADDITIONAL"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createCryptoLoans().flexibleLoanAdjustLtv(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/cryptoloans/FlexibleLoanAssets.java b/src/test/java/examples/spot/cryptoloans/FlexibleLoanAssets.java new file mode 100644 index 00000000..f3f5cc82 --- /dev/null +++ b/src/test/java/examples/spot/cryptoloans/FlexibleLoanAssets.java @@ -0,0 +1,22 @@ +package examples.spot.cryptoloans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleLoanAssets { + private FlexibleLoanAssets() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createCryptoLoans().flexibleLoanAssets(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/cryptoloans/FlexibleLoanBorrow.java b/src/test/java/examples/spot/cryptoloans/FlexibleLoanBorrow.java new file mode 100644 index 00000000..bf09f4dc --- /dev/null +++ b/src/test/java/examples/spot/cryptoloans/FlexibleLoanBorrow.java @@ -0,0 +1,24 @@ +package examples.spot.cryptoloans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleLoanBorrow { + private FlexibleLoanBorrow() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("loanCoin", "USDT"); + parameters.put("collateralCoin", "BTC"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createCryptoLoans().flexibleLoanBorrow(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/cryptoloans/FlexibleLoanBorrowHistory.java b/src/test/java/examples/spot/cryptoloans/FlexibleLoanBorrowHistory.java new file mode 100644 index 00000000..634f8b53 --- /dev/null +++ b/src/test/java/examples/spot/cryptoloans/FlexibleLoanBorrowHistory.java @@ -0,0 +1,23 @@ +package examples.spot.cryptoloans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleLoanBorrowHistory { + private FlexibleLoanBorrowHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("loanCoin", "USDT"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createCryptoLoans().flexibleLoanBorrowHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/cryptoloans/FlexibleLoanCollateralAssets.java b/src/test/java/examples/spot/cryptoloans/FlexibleLoanCollateralAssets.java new file mode 100644 index 00000000..42a8608f --- /dev/null +++ b/src/test/java/examples/spot/cryptoloans/FlexibleLoanCollateralAssets.java @@ -0,0 +1,22 @@ +package examples.spot.cryptoloans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleLoanCollateralAssets { + private FlexibleLoanCollateralAssets() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createCryptoLoans().flexibleLoanCollateralAssets(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/cryptoloans/FlexibleLoanLtvAdjustHistory.java b/src/test/java/examples/spot/cryptoloans/FlexibleLoanLtvAdjustHistory.java new file mode 100644 index 00000000..07281a5a --- /dev/null +++ b/src/test/java/examples/spot/cryptoloans/FlexibleLoanLtvAdjustHistory.java @@ -0,0 +1,23 @@ +package examples.spot.cryptoloans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleLoanLtvAdjustHistory { + private FlexibleLoanLtvAdjustHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("loanCoin", "BUSD"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createCryptoLoans().flexibleLoanLtvAdjustHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/cryptoloans/FlexibleLoanOngoingOrders.java b/src/test/java/examples/spot/cryptoloans/FlexibleLoanOngoingOrders.java new file mode 100644 index 00000000..62250bf0 --- /dev/null +++ b/src/test/java/examples/spot/cryptoloans/FlexibleLoanOngoingOrders.java @@ -0,0 +1,22 @@ +package examples.spot.cryptoloans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleLoanOngoingOrders { + private FlexibleLoanOngoingOrders() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createCryptoLoans().flexibleLoanOngoingOrders(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/cryptoloans/FlexibleLoanRepay.java b/src/test/java/examples/spot/cryptoloans/FlexibleLoanRepay.java new file mode 100644 index 00000000..2d98359b --- /dev/null +++ b/src/test/java/examples/spot/cryptoloans/FlexibleLoanRepay.java @@ -0,0 +1,26 @@ +package examples.spot.cryptoloans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleLoanRepay { + private FlexibleLoanRepay() { + } + private static final double repayAmount = 0.1; + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("loanCoin", "BUSD"); + parameters.put("collateralCoin", "BNB"); + parameters.put("repayAmount", repayAmount); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createCryptoLoans().flexibleLoanRepay(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/cryptoloans/FlexibleLoanRepayHistory.java b/src/test/java/examples/spot/cryptoloans/FlexibleLoanRepayHistory.java new file mode 100644 index 00000000..a2e01f62 --- /dev/null +++ b/src/test/java/examples/spot/cryptoloans/FlexibleLoanRepayHistory.java @@ -0,0 +1,22 @@ +package examples.spot.cryptoloans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleLoanRepayHistory { + private FlexibleLoanRepayHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createCryptoLoans().flexibleLoanRepayHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/futures/FuturesOrderBookHistory.java b/src/test/java/examples/spot/futures/FuturesOrderBookHistory.java new file mode 100644 index 00000000..502c2612 --- /dev/null +++ b/src/test/java/examples/spot/futures/FuturesOrderBookHistory.java @@ -0,0 +1,28 @@ +package examples.spot.futures; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FuturesOrderBookHistory { + private FuturesOrderBookHistory() { + } + private static final Long startTime = 17024585109000L; + private static final Long endTime = 1702458517000L; + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BTCUSDT"); + parameters.put("dataType", "T_DEPTH"); + parameters.put("startTime", startTime); + parameters.put("endTime", endTime); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createFutures().futuresOrderBookHistory(parameters); + System.out.println(result); + } +} \ No newline at end of file diff --git a/src/test/java/examples/spot/giftcard/CreateDualTokensCode.java b/src/test/java/examples/spot/giftcard/CreateDualTokensCode.java new file mode 100644 index 00000000..e0f168d5 --- /dev/null +++ b/src/test/java/examples/spot/giftcard/CreateDualTokensCode.java @@ -0,0 +1,26 @@ +package examples.spot.giftcard; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class CreateDualTokensCode { + private CreateDualTokensCode() { + } + private static final double baseTokenAmount = 1.002; + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("baseToken", "BUSD"); + parameters.put("faceToken", "BNB"); + parameters.put("baseTokenAmount", baseTokenAmount); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createGiftCard().createDualTokensCode(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/giftcard/TokensLimit.java b/src/test/java/examples/spot/giftcard/TokensLimit.java new file mode 100644 index 00000000..a8c9c691 --- /dev/null +++ b/src/test/java/examples/spot/giftcard/TokensLimit.java @@ -0,0 +1,23 @@ +package examples.spot.giftcard; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class TokensLimit { + private TokensLimit() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("baseToken", "BUSD"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createGiftCard().tokensLimit(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/margin/AdjustCrossMarginMaxLeverage.java b/src/test/java/examples/spot/margin/AdjustCrossMarginMaxLeverage.java new file mode 100644 index 00000000..c6d3a286 --- /dev/null +++ b/src/test/java/examples/spot/margin/AdjustCrossMarginMaxLeverage.java @@ -0,0 +1,27 @@ +package examples.spot.margin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class AdjustCrossMarginMaxLeverage { + + private AdjustCrossMarginMaxLeverage() { + } + + private static final Integer leverage = 3; + + public static void main(String[] args) { + + Map parameters = new LinkedHashMap<>(); + parameters.put("maxLeverage", leverage); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createMargin().adjustCrossMarginMaxLeverage(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/margin/AvailableInventory.java b/src/test/java/examples/spot/margin/AvailableInventory.java new file mode 100644 index 00000000..c348525c --- /dev/null +++ b/src/test/java/examples/spot/margin/AvailableInventory.java @@ -0,0 +1,23 @@ +package examples.spot.margin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class AvailableInventory { + private AvailableInventory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("type", "MARGIN"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createMargin().availableInventory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/margin/BnbConvertibleAssets.java b/src/test/java/examples/spot/margin/BnbConvertibleAssets.java new file mode 100644 index 00000000..a49af703 --- /dev/null +++ b/src/test/java/examples/spot/margin/BnbConvertibleAssets.java @@ -0,0 +1,22 @@ +package examples.spot.margin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class BnbConvertibleAssets { + private BnbConvertibleAssets() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createMargin().bnbConvertibleAssets(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/margin/CapitalFlow.java b/src/test/java/examples/spot/margin/CapitalFlow.java new file mode 100644 index 00000000..58951b92 --- /dev/null +++ b/src/test/java/examples/spot/margin/CapitalFlow.java @@ -0,0 +1,22 @@ +package examples.spot.margin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class CapitalFlow { + private CapitalFlow() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createMargin().capitalFlow(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/savings/ProjectList.java b/src/test/java/examples/spot/margin/ConvertToBnB.java similarity index 69% rename from src/test/java/examples/spot/savings/ProjectList.java rename to src/test/java/examples/spot/margin/ConvertToBnB.java index ec318b98..78fe1a81 100644 --- a/src/test/java/examples/spot/savings/ProjectList.java +++ b/src/test/java/examples/spot/margin/ConvertToBnB.java @@ -1,4 +1,4 @@ -package examples.spot.savings; +package examples.spot.margin; import java.util.LinkedHashMap; import java.util.Map; @@ -8,16 +8,16 @@ import examples.PrivateConfig; -public final class ProjectList { - private ProjectList() { +public final class ConvertToBnB { + private ConvertToBnB() { } public static void main(String[] args) { Map parameters = new LinkedHashMap<>(); - parameters.put("type", "ACTIVITY"); + parameters.put("asset", "BTC,USDT"); SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); - String result = client.createSavings().projectList(parameters); + String result = client.createMargin().convertToBnB(parameters); System.out.println(result); } } diff --git a/src/test/java/examples/spot/margin/CrossMarginCollateralRatio.java b/src/test/java/examples/spot/margin/CrossMarginCollateralRatio.java new file mode 100644 index 00000000..297d5ba9 --- /dev/null +++ b/src/test/java/examples/spot/margin/CrossMarginCollateralRatio.java @@ -0,0 +1,18 @@ +package examples.spot.margin; + + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class CrossMarginCollateralRatio { + private CrossMarginCollateralRatio() { + } + + public static void main(String[] args) { + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createMargin().crossMarginCollateralRatio(); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/margin/DelistSchedule.java b/src/test/java/examples/spot/margin/DelistSchedule.java new file mode 100644 index 00000000..0183a3ee --- /dev/null +++ b/src/test/java/examples/spot/margin/DelistSchedule.java @@ -0,0 +1,22 @@ +package examples.spot.margin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class DelistSchedule { + private DelistSchedule() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createMargin().delistSchedule(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/margin/ExchangeSmallLiability.java b/src/test/java/examples/spot/margin/ExchangeSmallLiability.java new file mode 100644 index 00000000..63ecf178 --- /dev/null +++ b/src/test/java/examples/spot/margin/ExchangeSmallLiability.java @@ -0,0 +1,25 @@ +package examples.spot.margin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class ExchangeSmallLiability { + + private ExchangeSmallLiability() { + } + + public static void main(String[] args) { + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + Map parameters = new LinkedHashMap<>(); + parameters.put("assetNames", "BTC,ETH"); + + String result = client.createMargin().exchangeSmallLiability(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/margin/LeverageBracket.java b/src/test/java/examples/spot/margin/LeverageBracket.java new file mode 100644 index 00000000..7c21562a --- /dev/null +++ b/src/test/java/examples/spot/margin/LeverageBracket.java @@ -0,0 +1,18 @@ +package examples.spot.margin; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class LeverageBracket { + private LeverageBracket() { + } + + public static void main(String[] args) { + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createMargin().leverageBracket(); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/margin/NextHourlyInterestRate.java b/src/test/java/examples/spot/margin/NextHourlyInterestRate.java new file mode 100644 index 00000000..294da601 --- /dev/null +++ b/src/test/java/examples/spot/margin/NextHourlyInterestRate.java @@ -0,0 +1,24 @@ +package examples.spot.margin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class NextHourlyInterestRate { + private NextHourlyInterestRate() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("assets", "BTC,ETH"); + parameters.put("isIsolated", true); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createMargin().nextHourlyInterestRate(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/margin/SmallLiabilityAssets.java b/src/test/java/examples/spot/margin/SmallLiabilityAssets.java new file mode 100644 index 00000000..539008f9 --- /dev/null +++ b/src/test/java/examples/spot/margin/SmallLiabilityAssets.java @@ -0,0 +1,22 @@ +package examples.spot.margin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SmallLiabilityAssets { + private SmallLiabilityAssets() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createMargin().smallLiabilityAssets(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/margin/SmallLiabilityExchangeHistory.java b/src/test/java/examples/spot/margin/SmallLiabilityExchangeHistory.java new file mode 100644 index 00000000..f8f9d87d --- /dev/null +++ b/src/test/java/examples/spot/margin/SmallLiabilityExchangeHistory.java @@ -0,0 +1,27 @@ +package examples.spot.margin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SmallLiabilityExchangeHistory { + private SmallLiabilityExchangeHistory() { + } + + private static final int current = 3; + private static final int size = 3; + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("current", current); + parameters.put("size", size); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createMargin().smallLiabilityExchangeHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/margin/TradeCoeff.java b/src/test/java/examples/spot/margin/TradeCoeff.java new file mode 100644 index 00000000..abf3bb51 --- /dev/null +++ b/src/test/java/examples/spot/margin/TradeCoeff.java @@ -0,0 +1,22 @@ +package examples.spot.margin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class TradeCoeff { + private TradeCoeff() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createMargin().tradeCoeff(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/market/TradingDayTicker.java b/src/test/java/examples/spot/market/TradingDayTicker.java new file mode 100644 index 00000000..9610bf5c --- /dev/null +++ b/src/test/java/examples/spot/market/TradingDayTicker.java @@ -0,0 +1,36 @@ +package examples.spot.market; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; +import com.binance.connector.client.impl.spot.Market; + +import examples.PrivateConfig; + +public final class TradingDayTicker { + private TradingDayTicker() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + Market market = client.createMarket(); + + parameters.put("symbol", "BNBUSDT"); + parameters.put("type", "MINI"); + String result = market.tradingDayTicker(parameters); + System.out.println(result); + parameters.clear(); + + ArrayList symbols = new ArrayList<>(); + symbols.add("BTCUSDT"); + symbols.add("BNBUSDT"); + parameters.put("symbols", symbols); + result = market.tradingDayTicker(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/portfoliomargin/AssetCollection.java b/src/test/java/examples/spot/portfoliomargin/AssetCollection.java new file mode 100644 index 00000000..861df631 --- /dev/null +++ b/src/test/java/examples/spot/portfoliomargin/AssetCollection.java @@ -0,0 +1,23 @@ +package examples.spot.portfoliomargin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class AssetCollection { + private AssetCollection() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("asset", "BTC"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createPortfolioMargin().assetCollection(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/portfoliomargin/AssetIndexPrice.java b/src/test/java/examples/spot/portfoliomargin/AssetIndexPrice.java new file mode 100644 index 00000000..437395a0 --- /dev/null +++ b/src/test/java/examples/spot/portfoliomargin/AssetIndexPrice.java @@ -0,0 +1,22 @@ +package examples.spot.portfoliomargin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class AssetIndexPrice { + private AssetIndexPrice() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createPortfolioMargin().assetIndexPrice(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/portfoliomargin/AssetLeverage.java b/src/test/java/examples/spot/portfoliomargin/AssetLeverage.java new file mode 100644 index 00000000..93872cf6 --- /dev/null +++ b/src/test/java/examples/spot/portfoliomargin/AssetLeverage.java @@ -0,0 +1,18 @@ +package examples.spot.portfoliomargin; + + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class AssetLeverage { + private AssetLeverage() { + } + + public static void main(String[] args) { + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createPortfolioMargin().assetLeverage(); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/portfoliomargin/AutoCollection.java b/src/test/java/examples/spot/portfoliomargin/AutoCollection.java new file mode 100644 index 00000000..6c77b343 --- /dev/null +++ b/src/test/java/examples/spot/portfoliomargin/AutoCollection.java @@ -0,0 +1,22 @@ +package examples.spot.portfoliomargin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class AutoCollection { + private AutoCollection() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createPortfolioMargin().autoCollection(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/portfoliomargin/AutoRepayFuturesStatus.java b/src/test/java/examples/spot/portfoliomargin/AutoRepayFuturesStatus.java new file mode 100644 index 00000000..401fd50a --- /dev/null +++ b/src/test/java/examples/spot/portfoliomargin/AutoRepayFuturesStatus.java @@ -0,0 +1,22 @@ +package examples.spot.portfoliomargin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class AutoRepayFuturesStatus { + private AutoRepayFuturesStatus() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createPortfolioMargin().autoRepayFuturesStatus(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/savings/ChangeToDailyPosition.java b/src/test/java/examples/spot/portfoliomargin/BnbTransfer.java similarity index 58% rename from src/test/java/examples/spot/savings/ChangeToDailyPosition.java rename to src/test/java/examples/spot/portfoliomargin/BnbTransfer.java index 2f5abf8f..4794d502 100644 --- a/src/test/java/examples/spot/savings/ChangeToDailyPosition.java +++ b/src/test/java/examples/spot/portfoliomargin/BnbTransfer.java @@ -1,4 +1,4 @@ -package examples.spot.savings; +package examples.spot.portfoliomargin; import java.util.LinkedHashMap; import java.util.Map; @@ -8,18 +8,17 @@ import examples.PrivateConfig; -public final class ChangeToDailyPosition { - private ChangeToDailyPosition() { +public final class BnbTransfer { + private BnbTransfer() { } - private static final long lot = 1L; - + private static final double amount = 1.01; public static void main(String[] args) { Map parameters = new LinkedHashMap<>(); - parameters.put("projectId", "TKO001"); - parameters.put("lot", lot); + parameters.put("transferSide", "TO_UM"); + parameters.put("amount", amount); SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); - String result = client.createSavings().changeToDailyPosition(parameters); + String result = client.createPortfolioMargin().bnbTransfer(parameters); System.out.println(result); } } diff --git a/src/test/java/examples/spot/portfoliomargin/InterestHistory.java b/src/test/java/examples/spot/portfoliomargin/InterestHistory.java new file mode 100644 index 00000000..7da34918 --- /dev/null +++ b/src/test/java/examples/spot/portfoliomargin/InterestHistory.java @@ -0,0 +1,23 @@ +package examples.spot.portfoliomargin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class InterestHistory { + private InterestHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("asset", "BTC"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createPortfolioMargin().interestHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/portfoliomargin/RepayFutures.java b/src/test/java/examples/spot/portfoliomargin/RepayFutures.java new file mode 100644 index 00000000..562fc5b8 --- /dev/null +++ b/src/test/java/examples/spot/portfoliomargin/RepayFutures.java @@ -0,0 +1,22 @@ +package examples.spot.portfoliomargin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class RepayFutures { + private RepayFutures() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createPortfolioMargin().repayFutures(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/portfoliomargin/SwitchAutoRepayFutures.java b/src/test/java/examples/spot/portfoliomargin/SwitchAutoRepayFutures.java new file mode 100644 index 00000000..ddc803be --- /dev/null +++ b/src/test/java/examples/spot/portfoliomargin/SwitchAutoRepayFutures.java @@ -0,0 +1,23 @@ +package examples.spot.portfoliomargin; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SwitchAutoRepayFutures { + private SwitchAutoRepayFutures() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("autoRepay", true); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createPortfolioMargin().switchAutoRepayFutures(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/CollateralRecord.java b/src/test/java/examples/spot/simpleearn/CollateralRecord.java new file mode 100644 index 00000000..211a6718 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/CollateralRecord.java @@ -0,0 +1,22 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class CollateralRecord { + private CollateralRecord() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().collateralRecord(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/FlexiblePersonalLeftQuota.java b/src/test/java/examples/spot/simpleearn/FlexiblePersonalLeftQuota.java new file mode 100644 index 00000000..84e63688 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/FlexiblePersonalLeftQuota.java @@ -0,0 +1,23 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexiblePersonalLeftQuota { + private FlexiblePersonalLeftQuota() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("productId", "40607"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().flexiblePersonalLeftQuota(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/FlexibleProductList.java b/src/test/java/examples/spot/simpleearn/FlexibleProductList.java new file mode 100644 index 00000000..afad409c --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/FlexibleProductList.java @@ -0,0 +1,22 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleProductList { + private FlexibleProductList() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().flexibleProductList(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/FlexibleProductPosition.java b/src/test/java/examples/spot/simpleearn/FlexibleProductPosition.java new file mode 100644 index 00000000..ec41d355 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/FlexibleProductPosition.java @@ -0,0 +1,22 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleProductPosition { + private FlexibleProductPosition() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().flexibleProductPosition(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/FlexibleRedemptionRecord.java b/src/test/java/examples/spot/simpleearn/FlexibleRedemptionRecord.java new file mode 100644 index 00000000..fc0825c9 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/FlexibleRedemptionRecord.java @@ -0,0 +1,22 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleRedemptionRecord { + private FlexibleRedemptionRecord() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().flexibleRedemptionRecord(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/FlexibleRewardsHistory.java b/src/test/java/examples/spot/simpleearn/FlexibleRewardsHistory.java new file mode 100644 index 00000000..717fb5c6 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/FlexibleRewardsHistory.java @@ -0,0 +1,23 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleRewardsHistory { + private FlexibleRewardsHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("type", "BONUS"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().flexibleRewardsHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/FlexibleSubscriptionPreview.java b/src/test/java/examples/spot/simpleearn/FlexibleSubscriptionPreview.java new file mode 100644 index 00000000..eb69bb0f --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/FlexibleSubscriptionPreview.java @@ -0,0 +1,25 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleSubscriptionPreview { + private FlexibleSubscriptionPreview() { + } + + private static final double amount = 1.1; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("productId", "40607"); + parameters.put("amount", amount); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().flexibleSubscriptionPreview(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/FlexibleSubscriptionRecord.java b/src/test/java/examples/spot/simpleearn/FlexibleSubscriptionRecord.java new file mode 100644 index 00000000..f72ee5aa --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/FlexibleSubscriptionRecord.java @@ -0,0 +1,22 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class FlexibleSubscriptionRecord { + private FlexibleSubscriptionRecord() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().flexibleSubscriptionRecord(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/LockedPersonalLeftQuota.java b/src/test/java/examples/spot/simpleearn/LockedPersonalLeftQuota.java new file mode 100644 index 00000000..b8a33b04 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/LockedPersonalLeftQuota.java @@ -0,0 +1,23 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class LockedPersonalLeftQuota { + private LockedPersonalLeftQuota() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("projectId", "USDT001"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().lockedPersonalLeftQuota(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/LockedProductList.java b/src/test/java/examples/spot/simpleearn/LockedProductList.java new file mode 100644 index 00000000..e2f6c4ae --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/LockedProductList.java @@ -0,0 +1,22 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class LockedProductList { + private LockedProductList() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().lockedProductList(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/LockedProductPosition.java b/src/test/java/examples/spot/simpleearn/LockedProductPosition.java new file mode 100644 index 00000000..3bb1d2d2 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/LockedProductPosition.java @@ -0,0 +1,22 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class LockedProductPosition { + private LockedProductPosition() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().lockedProductPosition(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/LockedRedemptionRecord.java b/src/test/java/examples/spot/simpleearn/LockedRedemptionRecord.java new file mode 100644 index 00000000..ea622a9e --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/LockedRedemptionRecord.java @@ -0,0 +1,22 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class LockedRedemptionRecord { + private LockedRedemptionRecord() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().lockedRedemptionRecord(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/LockedRewardsHistory.java b/src/test/java/examples/spot/simpleearn/LockedRewardsHistory.java new file mode 100644 index 00000000..45bcd8c8 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/LockedRewardsHistory.java @@ -0,0 +1,22 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class LockedRewardsHistory { + private LockedRewardsHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().lockedRewardsHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/LockedSubscriptionPreview.java b/src/test/java/examples/spot/simpleearn/LockedSubscriptionPreview.java new file mode 100644 index 00000000..26bcf5c7 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/LockedSubscriptionPreview.java @@ -0,0 +1,25 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class LockedSubscriptionPreview { + private LockedSubscriptionPreview() { + } + + private static final double amount = 1.1; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("projectId", "USDT001"); + parameters.put("amount", amount); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().lockedSubscriptionPreview(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/LockedSubscriptionRecord.java b/src/test/java/examples/spot/simpleearn/LockedSubscriptionRecord.java new file mode 100644 index 00000000..c1cf1224 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/LockedSubscriptionRecord.java @@ -0,0 +1,22 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class LockedSubscriptionRecord { + private LockedSubscriptionRecord() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().lockedSubscriptionRecord(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/RateHistory.java b/src/test/java/examples/spot/simpleearn/RateHistory.java new file mode 100644 index 00000000..b208faf8 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/RateHistory.java @@ -0,0 +1,23 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class RateHistory { + private RateHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("productId", "40607"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().rateHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/RedeemFlexibleProduct.java b/src/test/java/examples/spot/simpleearn/RedeemFlexibleProduct.java new file mode 100644 index 00000000..062c3ab1 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/RedeemFlexibleProduct.java @@ -0,0 +1,23 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class RedeemFlexibleProduct { + private RedeemFlexibleProduct() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("productId", "40604"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().redeemFlexibleProduct(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/RedeemLockedProduct.java b/src/test/java/examples/spot/simpleearn/RedeemLockedProduct.java new file mode 100644 index 00000000..66fb5948 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/RedeemLockedProduct.java @@ -0,0 +1,23 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class RedeemLockedProduct { + private RedeemLockedProduct() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("positionId", "40604"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().redeemLockedProduct(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/SetFlexibleAutoSubscribe.java b/src/test/java/examples/spot/simpleearn/SetFlexibleAutoSubscribe.java new file mode 100644 index 00000000..ec13354a --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/SetFlexibleAutoSubscribe.java @@ -0,0 +1,24 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SetFlexibleAutoSubscribe { + private SetFlexibleAutoSubscribe() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("productId", "40607"); + parameters.put("autoSubscribe", true); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().setFlexibleAutoSubscribe(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/savings/PurchaseProject.java b/src/test/java/examples/spot/simpleearn/SetLockedAutoSubscribe.java similarity index 59% rename from src/test/java/examples/spot/savings/PurchaseProject.java rename to src/test/java/examples/spot/simpleearn/SetLockedAutoSubscribe.java index 55142448..1cbc2ab6 100644 --- a/src/test/java/examples/spot/savings/PurchaseProject.java +++ b/src/test/java/examples/spot/simpleearn/SetLockedAutoSubscribe.java @@ -1,4 +1,4 @@ -package examples.spot.savings; +package examples.spot.simpleearn; import java.util.LinkedHashMap; import java.util.Map; @@ -8,18 +8,17 @@ import examples.PrivateConfig; -public final class PurchaseProject { - private PurchaseProject() { +public final class SetLockedAutoSubscribe { + private SetLockedAutoSubscribe() { } - private static final long lot = 1L; - + public static void main(String[] args) { Map parameters = new LinkedHashMap<>(); - parameters.put("projectId", "TKO001"); - parameters.put("lot", lot); + parameters.put("positionId", "BUSD001"); + parameters.put("autoSubscribe", true); SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); - String result = client.createSavings().purchaseProject(parameters); + String result = client.createSimpleEarn().setLockedAutoSubscribe(parameters); System.out.println(result); } } diff --git a/src/test/java/examples/spot/simpleearn/SimpleAccount.java b/src/test/java/examples/spot/simpleearn/SimpleAccount.java new file mode 100644 index 00000000..1afff8e7 --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/SimpleAccount.java @@ -0,0 +1,22 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SimpleAccount { + private SimpleAccount() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().simpleAccount(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/SubscribeFlexibleProduct.java b/src/test/java/examples/spot/simpleearn/SubscribeFlexibleProduct.java new file mode 100644 index 00000000..1ce0247a --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/SubscribeFlexibleProduct.java @@ -0,0 +1,25 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SubscribeFlexibleProduct { + private SubscribeFlexibleProduct() { + } + + private static final double amount = 1.1; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("productId", "40607"); + parameters.put("amount", amount); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().subscribeFlexibleProduct(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/simpleearn/SubscribeLockedProduct.java b/src/test/java/examples/spot/simpleearn/SubscribeLockedProduct.java new file mode 100644 index 00000000..4beba6fe --- /dev/null +++ b/src/test/java/examples/spot/simpleearn/SubscribeLockedProduct.java @@ -0,0 +1,25 @@ +package examples.spot.simpleearn; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SubscribeLockedProduct { + private SubscribeLockedProduct() { + } + + private static final double amount = 1.1; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("projectId", "40607"); + parameters.put("amount", amount); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSimpleEarn().subscribeLockedProduct(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/spotalgo/CancelOrder.java b/src/test/java/examples/spot/spotalgo/CancelOrder.java new file mode 100644 index 00000000..d7a53789 --- /dev/null +++ b/src/test/java/examples/spot/spotalgo/CancelOrder.java @@ -0,0 +1,24 @@ +package examples.spot.spotalgo; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class CancelOrder { + private CancelOrder() { + } + + private static final long algoId = 1; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("algoId", algoId); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSpotAlgo().cancelOrder(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/spotalgo/GetHistoricalOrders.java b/src/test/java/examples/spot/spotalgo/GetHistoricalOrders.java new file mode 100644 index 00000000..8f8ac63a --- /dev/null +++ b/src/test/java/examples/spot/spotalgo/GetHistoricalOrders.java @@ -0,0 +1,24 @@ +package examples.spot.spotalgo; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class GetHistoricalOrders { + private GetHistoricalOrders() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + parameters.put("side", "SELL"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSpotAlgo().getHistoricalOrders(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/spotalgo/GetOpenOrders.java b/src/test/java/examples/spot/spotalgo/GetOpenOrders.java new file mode 100644 index 00000000..24006409 --- /dev/null +++ b/src/test/java/examples/spot/spotalgo/GetOpenOrders.java @@ -0,0 +1,22 @@ +package examples.spot.spotalgo; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class GetOpenOrders { + private GetOpenOrders() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSpotAlgo().getOpenOrders(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/spotalgo/GetSubOrders.java b/src/test/java/examples/spot/spotalgo/GetSubOrders.java new file mode 100644 index 00000000..14cbe599 --- /dev/null +++ b/src/test/java/examples/spot/spotalgo/GetSubOrders.java @@ -0,0 +1,24 @@ +package examples.spot.spotalgo; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class GetSubOrders { + private GetSubOrders() { + } + + private static final long algoId = 14511; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("algoId", algoId); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSpotAlgo().getSubOrders(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/spotalgo/TwapOrder.java b/src/test/java/examples/spot/spotalgo/TwapOrder.java new file mode 100644 index 00000000..ba504a28 --- /dev/null +++ b/src/test/java/examples/spot/spotalgo/TwapOrder.java @@ -0,0 +1,28 @@ +package examples.spot.spotalgo; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class TwapOrder { + private TwapOrder() { + } + + private static final double quantity = 1.1; + private static final long duration = 300; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + parameters.put("side", "SELL"); + parameters.put("quantity", quantity); + parameters.put("duration", duration); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createSpotAlgo().twapOrder(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/staking/EthStakingAccount.java b/src/test/java/examples/spot/staking/EthStakingAccount.java new file mode 100644 index 00000000..032b4209 --- /dev/null +++ b/src/test/java/examples/spot/staking/EthStakingAccount.java @@ -0,0 +1,23 @@ +package examples.spot.staking; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + + +public final class EthStakingAccount { + + private EthStakingAccount() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createStaking().ethStakingAccount(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/savings/ProjectPosition.java b/src/test/java/examples/spot/staking/EthStakingQuota.java similarity index 69% rename from src/test/java/examples/spot/savings/ProjectPosition.java rename to src/test/java/examples/spot/staking/EthStakingQuota.java index e2affe57..2a831aaf 100644 --- a/src/test/java/examples/spot/savings/ProjectPosition.java +++ b/src/test/java/examples/spot/staking/EthStakingQuota.java @@ -1,4 +1,4 @@ -package examples.spot.savings; +package examples.spot.staking; import java.util.LinkedHashMap; import java.util.Map; @@ -8,16 +8,16 @@ import examples.PrivateConfig; -public final class ProjectPosition { - private ProjectPosition() { + +public final class EthStakingQuota { + + private EthStakingQuota() { } public static void main(String[] args) { Map parameters = new LinkedHashMap<>(); - parameters.put("asset", "USDT"); - SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); - String result = client.createSavings().projectPosition(parameters); + String result = client.createStaking().ethStakingQuota(parameters); System.out.println(result); } } diff --git a/src/test/java/examples/spot/staking/EthStakingRateHistory.java b/src/test/java/examples/spot/staking/EthStakingRateHistory.java new file mode 100644 index 00000000..8c7d9fa7 --- /dev/null +++ b/src/test/java/examples/spot/staking/EthStakingRateHistory.java @@ -0,0 +1,23 @@ +package examples.spot.staking; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + + +public final class EthStakingRateHistory { + + private EthStakingRateHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createStaking().ethStakingRateHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/staking/EthStakingRedeemHistory.java b/src/test/java/examples/spot/staking/EthStakingRedeemHistory.java new file mode 100644 index 00000000..71738f50 --- /dev/null +++ b/src/test/java/examples/spot/staking/EthStakingRedeemHistory.java @@ -0,0 +1,23 @@ +package examples.spot.staking; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + + +public final class EthStakingRedeemHistory { + + private EthStakingRedeemHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createStaking().ethStakingRedeemHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/staking/EthStakingRewardsHistory.java b/src/test/java/examples/spot/staking/EthStakingRewardsHistory.java new file mode 100644 index 00000000..ac64564b --- /dev/null +++ b/src/test/java/examples/spot/staking/EthStakingRewardsHistory.java @@ -0,0 +1,23 @@ +package examples.spot.staking; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + + +public final class EthStakingRewardsHistory { + + private EthStakingRewardsHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createStaking().ethStakingRewardsHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/staking/EthStakingSubHistory.java b/src/test/java/examples/spot/staking/EthStakingSubHistory.java new file mode 100644 index 00000000..a77fc845 --- /dev/null +++ b/src/test/java/examples/spot/staking/EthStakingSubHistory.java @@ -0,0 +1,23 @@ +package examples.spot.staking; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + + +public final class EthStakingSubHistory { + + private EthStakingSubHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createStaking().ethStakingSubHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/staking/EthStakingWbethRewardHistory.java b/src/test/java/examples/spot/staking/EthStakingWbethRewardHistory.java new file mode 100644 index 00000000..420dc8e6 --- /dev/null +++ b/src/test/java/examples/spot/staking/EthStakingWbethRewardHistory.java @@ -0,0 +1,23 @@ +package examples.spot.staking; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + + +public final class EthStakingWbethRewardHistory { + + private EthStakingWbethRewardHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createStaking().ethStakingWbethRewardHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/staking/EthStakingWbethUnwrapHistory.java b/src/test/java/examples/spot/staking/EthStakingWbethUnwrapHistory.java new file mode 100644 index 00000000..f7f364b2 --- /dev/null +++ b/src/test/java/examples/spot/staking/EthStakingWbethUnwrapHistory.java @@ -0,0 +1,23 @@ +package examples.spot.staking; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + + +public final class EthStakingWbethUnwrapHistory { + + private EthStakingWbethUnwrapHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createStaking().ethStakingWbethUnwrapHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/staking/EthStakingWbethWrapHistory.java b/src/test/java/examples/spot/staking/EthStakingWbethWrapHistory.java new file mode 100644 index 00000000..0a7bcfed --- /dev/null +++ b/src/test/java/examples/spot/staking/EthStakingWbethWrapHistory.java @@ -0,0 +1,23 @@ +package examples.spot.staking; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + + +public final class EthStakingWbethWrapHistory { + + private EthStakingWbethWrapHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createStaking().ethStakingWbethWrapHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/staking/RedeemEthStaking.java b/src/test/java/examples/spot/staking/RedeemEthStaking.java new file mode 100644 index 00000000..d04de87a --- /dev/null +++ b/src/test/java/examples/spot/staking/RedeemEthStaking.java @@ -0,0 +1,26 @@ +package examples.spot.staking; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + + +public final class RedeemEthStaking { + + private RedeemEthStaking() { + } + + private static final double amount = 0.01; + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("amount", amount); + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createStaking().redeemEthStaking(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/staking/SubEthStaking.java b/src/test/java/examples/spot/staking/SubEthStaking.java new file mode 100644 index 00000000..f76bf6cb --- /dev/null +++ b/src/test/java/examples/spot/staking/SubEthStaking.java @@ -0,0 +1,25 @@ +package examples.spot.staking; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SubEthStaking { + + private SubEthStaking() { + } + + private static final double amount = 0.01; + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("amount", amount); + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createStaking().subEthStaking(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/staking/WrapEthStakingWbeth.java b/src/test/java/examples/spot/staking/WrapEthStakingWbeth.java new file mode 100644 index 00000000..a48810a9 --- /dev/null +++ b/src/test/java/examples/spot/staking/WrapEthStakingWbeth.java @@ -0,0 +1,25 @@ +package examples.spot.staking; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class WrapEthStakingWbeth { + + private WrapEthStakingWbeth() { + } + + private static final double amount = 0.1; + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("amount", amount); + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createStaking().wrapEthStakingWbeth(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/subaccount/SubAccountStatus.java b/src/test/java/examples/spot/subaccount/AccountStatus.java similarity index 88% rename from src/test/java/examples/spot/subaccount/SubAccountStatus.java rename to src/test/java/examples/spot/subaccount/AccountStatus.java index 93d120bf..93093b63 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountStatus.java +++ b/src/test/java/examples/spot/subaccount/AccountStatus.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountStatus { - private SubAccountStatus() { +public final class AccountStatus { + private AccountStatus() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/QuerySubAccountAssets.java b/src/test/java/examples/spot/subaccount/Assets.java similarity index 82% rename from src/test/java/examples/spot/subaccount/QuerySubAccountAssets.java rename to src/test/java/examples/spot/subaccount/Assets.java index c4b9c01e..c54366e8 100644 --- a/src/test/java/examples/spot/subaccount/QuerySubAccountAssets.java +++ b/src/test/java/examples/spot/subaccount/Assets.java @@ -8,13 +8,13 @@ import examples.PrivateConfig; -public final class QuerySubAccountAssets { - private QuerySubAccountAssets() { +public final class Assets { + private Assets() { } public static void main(String[] args) { Map parameters = new LinkedHashMap<>(); - parameters.put("email", ""); + parameters.put("email", "alice@test.com"); SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); String result = client.createSubAccount().assets(parameters); diff --git a/src/test/java/examples/spot/subaccount/SubAccountDepositAddress.java b/src/test/java/examples/spot/subaccount/DepositAddress.java similarity index 88% rename from src/test/java/examples/spot/subaccount/SubAccountDepositAddress.java rename to src/test/java/examples/spot/subaccount/DepositAddress.java index 2104e558..6529b3ee 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountDepositAddress.java +++ b/src/test/java/examples/spot/subaccount/DepositAddress.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountDepositAddress { - private SubAccountDepositAddress() { +public final class DepositAddress { + private DepositAddress() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/SubAccountDepositHistory.java b/src/test/java/examples/spot/subaccount/DepositHistory.java similarity index 87% rename from src/test/java/examples/spot/subaccount/SubAccountDepositHistory.java rename to src/test/java/examples/spot/subaccount/DepositHistory.java index ff337d5a..3413e819 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountDepositHistory.java +++ b/src/test/java/examples/spot/subaccount/DepositHistory.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountDepositHistory { - private SubAccountDepositHistory() { +public final class DepositHistory { + private DepositHistory() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/EnableFuturesSubAccount.java b/src/test/java/examples/spot/subaccount/EnableFutures.java similarity index 88% rename from src/test/java/examples/spot/subaccount/EnableFuturesSubAccount.java rename to src/test/java/examples/spot/subaccount/EnableFutures.java index 1b18ecce..4f285660 100644 --- a/src/test/java/examples/spot/subaccount/EnableFuturesSubAccount.java +++ b/src/test/java/examples/spot/subaccount/EnableFutures.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class EnableFuturesSubAccount { - private EnableFuturesSubAccount() { +public final class EnableFutures { + private EnableFutures() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/EnableMarginSubAccount.java b/src/test/java/examples/spot/subaccount/EnableMargin.java similarity index 88% rename from src/test/java/examples/spot/subaccount/EnableMarginSubAccount.java rename to src/test/java/examples/spot/subaccount/EnableMargin.java index 28821b4d..14419124 100644 --- a/src/test/java/examples/spot/subaccount/EnableMarginSubAccount.java +++ b/src/test/java/examples/spot/subaccount/EnableMargin.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class EnableMarginSubAccount { - private EnableMarginSubAccount() { +public final class EnableMargin { + private EnableMargin() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/SubAccountFuturesAccount.java b/src/test/java/examples/spot/subaccount/FuturesAccount.java similarity index 87% rename from src/test/java/examples/spot/subaccount/SubAccountFuturesAccount.java rename to src/test/java/examples/spot/subaccount/FuturesAccount.java index aa443d8d..41a6c10c 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountFuturesAccount.java +++ b/src/test/java/examples/spot/subaccount/FuturesAccount.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountFuturesAccount { - private SubAccountFuturesAccount() { +public final class FuturesAccount { + private FuturesAccount() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/SubAccountFuturesSummary.java b/src/test/java/examples/spot/subaccount/FuturesAccountSummary.java similarity index 86% rename from src/test/java/examples/spot/subaccount/SubAccountFuturesSummary.java rename to src/test/java/examples/spot/subaccount/FuturesAccountSummary.java index 791f74bf..0bfc444c 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountFuturesSummary.java +++ b/src/test/java/examples/spot/subaccount/FuturesAccountSummary.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountFuturesSummary { - private SubAccountFuturesSummary() { +public final class FuturesAccountSummary { + private FuturesAccountSummary() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/SubAccountFuturesInternalTransfer.java b/src/test/java/examples/spot/subaccount/FuturesInternalTransfer.java similarity index 89% rename from src/test/java/examples/spot/subaccount/SubAccountFuturesInternalTransfer.java rename to src/test/java/examples/spot/subaccount/FuturesInternalTransfer.java index 4115c75a..f0948739 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountFuturesInternalTransfer.java +++ b/src/test/java/examples/spot/subaccount/FuturesInternalTransfer.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountFuturesInternalTransfer { - private SubAccountFuturesInternalTransfer() { +public final class FuturesInternalTransfer { + private FuturesInternalTransfer() { } private static final double amount = 0.01; private static final int futuresType = 1; diff --git a/src/test/java/examples/spot/subaccount/SubAccountPositionRisk.java b/src/test/java/examples/spot/subaccount/FuturesPositionRisk.java similarity index 88% rename from src/test/java/examples/spot/subaccount/SubAccountPositionRisk.java rename to src/test/java/examples/spot/subaccount/FuturesPositionRisk.java index 15a29a56..14fe684a 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountPositionRisk.java +++ b/src/test/java/examples/spot/subaccount/FuturesPositionRisk.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountPositionRisk { - private SubAccountPositionRisk() { +public final class FuturesPositionRisk { + private FuturesPositionRisk() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/SubAccountFuturesTransfer.java b/src/test/java/examples/spot/subaccount/FuturesTransfer.java similarity index 90% rename from src/test/java/examples/spot/subaccount/SubAccountFuturesTransfer.java rename to src/test/java/examples/spot/subaccount/FuturesTransfer.java index 601d6b1b..8c8854bd 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountFuturesTransfer.java +++ b/src/test/java/examples/spot/subaccount/FuturesTransfer.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountFuturesTransfer { - private SubAccountFuturesTransfer() { +public final class FuturesTransfer { + private FuturesTransfer() { } private static final double amount = 100; private static final int type = 2; diff --git a/src/test/java/examples/spot/subaccount/QuerySubAccountFuturesTransfer.java b/src/test/java/examples/spot/subaccount/GetFuturesInternalTransfer.java similarity index 87% rename from src/test/java/examples/spot/subaccount/QuerySubAccountFuturesTransfer.java rename to src/test/java/examples/spot/subaccount/GetFuturesInternalTransfer.java index 0db2d8b0..b3912d57 100644 --- a/src/test/java/examples/spot/subaccount/QuerySubAccountFuturesTransfer.java +++ b/src/test/java/examples/spot/subaccount/GetFuturesInternalTransfer.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class QuerySubAccountFuturesTransfer { - private QuerySubAccountFuturesTransfer() { +public final class GetFuturesInternalTransfer { + private GetFuturesInternalTransfer() { } private static final int futuresType = 1; diff --git a/src/test/java/examples/spot/subaccount/SubAccountMarginAccount.java b/src/test/java/examples/spot/subaccount/MarginAccount.java similarity index 88% rename from src/test/java/examples/spot/subaccount/SubAccountMarginAccount.java rename to src/test/java/examples/spot/subaccount/MarginAccount.java index 8cbb482b..7e84c984 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountMarginAccount.java +++ b/src/test/java/examples/spot/subaccount/MarginAccount.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountMarginAccount { - private SubAccountMarginAccount() { +public final class MarginAccount { + private MarginAccount() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/SubAccountMarginSummary.java b/src/test/java/examples/spot/subaccount/MarginAccountSummary.java similarity index 87% rename from src/test/java/examples/spot/subaccount/SubAccountMarginSummary.java rename to src/test/java/examples/spot/subaccount/MarginAccountSummary.java index 8a035cf2..16f1c600 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountMarginSummary.java +++ b/src/test/java/examples/spot/subaccount/MarginAccountSummary.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountMarginSummary { - private SubAccountMarginSummary() { +public final class MarginAccountSummary { + private MarginAccountSummary() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/SubAccountMarginTransfer.java b/src/test/java/examples/spot/subaccount/MarginTransfer.java similarity index 90% rename from src/test/java/examples/spot/subaccount/SubAccountMarginTransfer.java rename to src/test/java/examples/spot/subaccount/MarginTransfer.java index c3ed70eb..4b9f471b 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountMarginTransfer.java +++ b/src/test/java/examples/spot/subaccount/MarginTransfer.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountMarginTransfer { - private SubAccountMarginTransfer() { +public final class MarginTransfer { + private MarginTransfer() { } private static final double amount = 0.01; private static final int type = 2; diff --git a/src/test/java/examples/spot/subaccount/QuerySubAccountSpotTransfer.java b/src/test/java/examples/spot/subaccount/SpotTransferHistory.java similarity index 85% rename from src/test/java/examples/spot/subaccount/QuerySubAccountSpotTransfer.java rename to src/test/java/examples/spot/subaccount/SpotTransferHistory.java index 1a2bf4d9..9776630a 100644 --- a/src/test/java/examples/spot/subaccount/QuerySubAccountSpotTransfer.java +++ b/src/test/java/examples/spot/subaccount/SpotTransferHistory.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class QuerySubAccountSpotTransfer { - private QuerySubAccountSpotTransfer() { +public final class SpotTransferHistory { + private SpotTransferHistory() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/QuerySubAccountList.java b/src/test/java/examples/spot/subaccount/SubAccountList.java similarity index 88% rename from src/test/java/examples/spot/subaccount/QuerySubAccountList.java rename to src/test/java/examples/spot/subaccount/SubAccountList.java index 1cbb19c7..aa62f495 100644 --- a/src/test/java/examples/spot/subaccount/QuerySubAccountList.java +++ b/src/test/java/examples/spot/subaccount/SubAccountList.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class QuerySubAccountList { - private QuerySubAccountList() { +public final class SubAccountList { + private SubAccountList() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/QuerySubAccountSpotSummary.java b/src/test/java/examples/spot/subaccount/SubAccountSummary.java similarity index 86% rename from src/test/java/examples/spot/subaccount/QuerySubAccountSpotSummary.java rename to src/test/java/examples/spot/subaccount/SubAccountSummary.java index 8e9dc3c7..90e7c1d1 100644 --- a/src/test/java/examples/spot/subaccount/QuerySubAccountSpotSummary.java +++ b/src/test/java/examples/spot/subaccount/SubAccountSummary.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class QuerySubAccountSpotSummary { - private QuerySubAccountSpotSummary() { +public final class SubAccountSummary { + private SubAccountSummary() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/SubAccountToSub.java b/src/test/java/examples/spot/subaccount/SubAccountToSubAccount.java similarity index 89% rename from src/test/java/examples/spot/subaccount/SubAccountToSub.java rename to src/test/java/examples/spot/subaccount/SubAccountToSubAccount.java index e93fc372..3e8108c0 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountToSub.java +++ b/src/test/java/examples/spot/subaccount/SubAccountToSubAccount.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountToSub { - private SubAccountToSub() { +public final class SubAccountToSubAccount { + private SubAccountToSubAccount() { } private static final double amount = 0.01; diff --git a/src/test/java/examples/spot/subaccount/SubAccountTransferHist.java b/src/test/java/examples/spot/subaccount/TransferHistory.java similarity index 87% rename from src/test/java/examples/spot/subaccount/SubAccountTransferHist.java rename to src/test/java/examples/spot/subaccount/TransferHistory.java index ee0cc929..fbeaf8c9 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountTransferHist.java +++ b/src/test/java/examples/spot/subaccount/TransferHistory.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountTransferHist { - private SubAccountTransferHist() { +public final class TransferHistory { + private TransferHistory() { } public static void main(String[] args) { diff --git a/src/test/java/examples/spot/subaccount/SubAccountUniversalTransfer.java b/src/test/java/examples/spot/subaccount/UniversalTransfer.java similarity index 89% rename from src/test/java/examples/spot/subaccount/SubAccountUniversalTransfer.java rename to src/test/java/examples/spot/subaccount/UniversalTransfer.java index cd70ecac..40cdedf1 100644 --- a/src/test/java/examples/spot/subaccount/SubAccountUniversalTransfer.java +++ b/src/test/java/examples/spot/subaccount/UniversalTransfer.java @@ -8,8 +8,8 @@ import examples.PrivateConfig; -public final class SubAccountUniversalTransfer { - private SubAccountUniversalTransfer() { +public final class UniversalTransfer { + private UniversalTransfer() { } private static final double amount = 0.01; diff --git a/src/test/java/examples/spot/trade/Commission.java b/src/test/java/examples/spot/trade/Commission.java new file mode 100644 index 00000000..79add5cb --- /dev/null +++ b/src/test/java/examples/spot/trade/Commission.java @@ -0,0 +1,23 @@ +package examples.spot.trade; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class Commission { + private Commission() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createTrade().commission(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/trade/PreventedMatches.java b/src/test/java/examples/spot/trade/PreventedMatches.java new file mode 100644 index 00000000..d0d473c2 --- /dev/null +++ b/src/test/java/examples/spot/trade/PreventedMatches.java @@ -0,0 +1,23 @@ +package examples.spot.trade; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class PreventedMatches { + private PreventedMatches() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createTrade().preventedMatches(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/trade/SorAllocations.java b/src/test/java/examples/spot/trade/SorAllocations.java new file mode 100644 index 00000000..146ec336 --- /dev/null +++ b/src/test/java/examples/spot/trade/SorAllocations.java @@ -0,0 +1,23 @@ +package examples.spot.trade; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SorAllocations { + private SorAllocations() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createTrade().sorAllocations(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/trade/SorOrder.java b/src/test/java/examples/spot/trade/SorOrder.java new file mode 100644 index 00000000..58961e89 --- /dev/null +++ b/src/test/java/examples/spot/trade/SorOrder.java @@ -0,0 +1,27 @@ +package examples.spot.trade; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SorOrder { + private SorOrder() { + } + + private static final double quantity = 1; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + parameters.put("side", "SELL"); + parameters.put("type", "LIMIT"); + parameters.put("quantity", quantity); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createTrade().sorOrder(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/trade/TestNewOrder.java b/src/test/java/examples/spot/trade/TestNewOrder.java index 527c9623..2a43ed07 100644 --- a/src/test/java/examples/spot/trade/TestNewOrder.java +++ b/src/test/java/examples/spot/trade/TestNewOrder.java @@ -14,7 +14,7 @@ public final class TestNewOrder { private TestNewOrder() { } private static final double quantity = 0.01; - private static final double price = 95000; + private static final int price = 95000; public static void main(String[] args) { Map parameters = new LinkedHashMap<>(); diff --git a/src/test/java/examples/spot/trade/TestSorOrder.java b/src/test/java/examples/spot/trade/TestSorOrder.java new file mode 100644 index 00000000..c03d7ac2 --- /dev/null +++ b/src/test/java/examples/spot/trade/TestSorOrder.java @@ -0,0 +1,27 @@ +package examples.spot.trade; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class TestSorOrder { + private TestSorOrder() { + } + + private static final double quantity = 1; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + parameters.put("side", "SELL"); + parameters.put("type", "LIMIT"); + parameters.put("quantity", quantity); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createTrade().testSorOrder(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/viploans/Borrow.java b/src/test/java/examples/spot/viploans/Borrow.java new file mode 100644 index 00000000..03a694a9 --- /dev/null +++ b/src/test/java/examples/spot/viploans/Borrow.java @@ -0,0 +1,30 @@ +package examples.spot.viploans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class Borrow { + private Borrow() { + } + + private static final long loanAccountId = 12345678; + private static final double loanAmount = 100.55; + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("loanAccountId", loanAccountId); + parameters.put("loanAmount", loanAmount); + parameters.put("loanCoin", "BUSD"); + parameters.put("collateralAccountId", "87654321"); + parameters.put("collateralCoin", "BUSD"); + parameters.put("isFlexibleRate", true); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createVIPLoans().borrow(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/viploans/BorrowInterestRate.java b/src/test/java/examples/spot/viploans/BorrowInterestRate.java new file mode 100644 index 00000000..b1d5dd61 --- /dev/null +++ b/src/test/java/examples/spot/viploans/BorrowInterestRate.java @@ -0,0 +1,23 @@ +package examples.spot.viploans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class BorrowInterestRate { + private BorrowInterestRate() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("loanCoin", "BUSD"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createVIPLoans().borrowInterestRate(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/viploans/CollateralAccount.java b/src/test/java/examples/spot/viploans/CollateralAccount.java new file mode 100644 index 00000000..44657d76 --- /dev/null +++ b/src/test/java/examples/spot/viploans/CollateralAccount.java @@ -0,0 +1,22 @@ +package examples.spot.viploans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class CollateralAccount { + private CollateralAccount() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createVIPLoans().collateralAsset(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/viploans/CollateralAsset.java b/src/test/java/examples/spot/viploans/CollateralAsset.java new file mode 100644 index 00000000..51713d31 --- /dev/null +++ b/src/test/java/examples/spot/viploans/CollateralAsset.java @@ -0,0 +1,22 @@ +package examples.spot.viploans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class CollateralAsset { + private CollateralAsset() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createVIPLoans().collateralAccount(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/viploans/LoanableAssets.java b/src/test/java/examples/spot/viploans/LoanableAssets.java new file mode 100644 index 00000000..7ce54b70 --- /dev/null +++ b/src/test/java/examples/spot/viploans/LoanableAssets.java @@ -0,0 +1,22 @@ +package examples.spot.viploans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class LoanableAssets { + private LoanableAssets() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createVIPLoans().loanableAssets(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/viploans/OngoingOrders.java b/src/test/java/examples/spot/viploans/OngoingOrders.java new file mode 100644 index 00000000..304bf60f --- /dev/null +++ b/src/test/java/examples/spot/viploans/OngoingOrders.java @@ -0,0 +1,23 @@ +package examples.spot.viploans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class OngoingOrders { + private OngoingOrders() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("orderId", "BUSD"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createVIPLoans().ongoingOrders(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/viploans/OrderStatus.java b/src/test/java/examples/spot/viploans/OrderStatus.java new file mode 100644 index 00000000..f8147b78 --- /dev/null +++ b/src/test/java/examples/spot/viploans/OrderStatus.java @@ -0,0 +1,22 @@ +package examples.spot.viploans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class OrderStatus { + private OrderStatus() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createVIPLoans().orderStatus(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/viploans/Renew.java b/src/test/java/examples/spot/viploans/Renew.java new file mode 100644 index 00000000..1edc5979 --- /dev/null +++ b/src/test/java/examples/spot/viploans/Renew.java @@ -0,0 +1,27 @@ +package examples.spot.viploans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class Renew { + private Renew() { + } + + private static final long orderId = 124; + private static final int loanTerm = 7; + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("orderId", orderId); + parameters.put("loanTerm", loanTerm); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createVIPLoans().renew(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/viploans/Repay.java b/src/test/java/examples/spot/viploans/Repay.java new file mode 100644 index 00000000..0afb3056 --- /dev/null +++ b/src/test/java/examples/spot/viploans/Repay.java @@ -0,0 +1,27 @@ +package examples.spot.viploans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class Repay { + private Repay() { + } + + private static final long orderId = 124; + private static final double amount = 100.55; + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("orderId", orderId); + parameters.put("amount", amount); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createVIPLoans().repay(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/viploans/RepaymentHistory.java b/src/test/java/examples/spot/viploans/RepaymentHistory.java new file mode 100644 index 00000000..21d2f1c2 --- /dev/null +++ b/src/test/java/examples/spot/viploans/RepaymentHistory.java @@ -0,0 +1,22 @@ +package examples.spot.viploans; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class RepaymentHistory { + private RepaymentHistory() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createVIPLoans().repaymentHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/wallet/ApplyOneClickArrivalDeposit.java b/src/test/java/examples/spot/wallet/ApplyOneClickArrivalDeposit.java new file mode 100644 index 00000000..bb6d2255 --- /dev/null +++ b/src/test/java/examples/spot/wallet/ApplyOneClickArrivalDeposit.java @@ -0,0 +1,22 @@ +package examples.spot.wallet; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class ApplyOneClickArrivalDeposit { + private ApplyOneClickArrivalDeposit() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createWallet().applyOneClickArrivalDeposit(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/wallet/DelegationHistory.java b/src/test/java/examples/spot/wallet/DelegationHistory.java new file mode 100644 index 00000000..0b3e60b7 --- /dev/null +++ b/src/test/java/examples/spot/wallet/DelegationHistory.java @@ -0,0 +1,28 @@ +package examples.spot.wallet; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class DelegationHistory { + private DelegationHistory() { + } + + private static final long startTime = 1695205406000L; + private static final long endTime = 1695205396000L; + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("email", "alice@test.com"); + parameters.put("startTime", startTime); + parameters.put("endTime", endTime); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createWallet().delegationHistory(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/wallet/DepositAddresses.java b/src/test/java/examples/spot/wallet/DepositAddresses.java new file mode 100644 index 00000000..a47c8eba --- /dev/null +++ b/src/test/java/examples/spot/wallet/DepositAddresses.java @@ -0,0 +1,23 @@ +package examples.spot.wallet; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class DepositAddresses { + private DepositAddresses() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("coin", "BTC"); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createWallet().depositAddresses(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/wallet/GetBusdAutoConvertions.java b/src/test/java/examples/spot/wallet/GetBusdAutoConvertions.java new file mode 100644 index 00000000..519a6aa8 --- /dev/null +++ b/src/test/java/examples/spot/wallet/GetBusdAutoConvertions.java @@ -0,0 +1,18 @@ +package examples.spot.wallet; + + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class GetBusdAutoConvertions { + private GetBusdAutoConvertions() { + } + + public static void main(String[] args) { + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createWallet().getBusdAutoConvertions(); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/wallet/SwitchBusdAutoConversion.java b/src/test/java/examples/spot/wallet/SwitchBusdAutoConversion.java new file mode 100644 index 00000000..ebacdd42 --- /dev/null +++ b/src/test/java/examples/spot/wallet/SwitchBusdAutoConversion.java @@ -0,0 +1,24 @@ +package examples.spot.wallet; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class SwitchBusdAutoConversion { + private SwitchBusdAutoConversion() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + parameters.put("coin", "USDC"); + parameters.put("enable", false); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createWallet().switchBusdAutoConversion(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/spot/wallet/WalletBalance.java b/src/test/java/examples/spot/wallet/WalletBalance.java new file mode 100644 index 00000000..9306410f --- /dev/null +++ b/src/test/java/examples/spot/wallet/WalletBalance.java @@ -0,0 +1,22 @@ +package examples.spot.wallet; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.impl.SpotClientImpl; + +import examples.PrivateConfig; + +public final class WalletBalance { + private WalletBalance() { + } + + public static void main(String[] args) { + Map parameters = new LinkedHashMap<>(); + + SpotClient client = new SpotClientImpl(PrivateConfig.API_KEY, PrivateConfig.SECRET_KEY); + String result = client.createWallet().walletBalance(parameters); + System.out.println(result); + } +} diff --git a/src/test/java/examples/websocketapi/WsApiwithAllCallbacks.java b/src/test/java/examples/websocketapi/WsApiwithAllCallbacks.java index bc548744..e892323b 100644 --- a/src/test/java/examples/websocketapi/WsApiwithAllCallbacks.java +++ b/src/test/java/examples/websocketapi/WsApiwithAllCallbacks.java @@ -21,7 +21,7 @@ private WsApiwithAllCallbacks() { private static WebSocketClosedCallback onClosedCallback; private static WebSocketFailureCallback onFailureCallback; - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/account/AccountAllOcoOrders.java b/src/test/java/examples/websocketapi/account/AccountAllOcoOrders.java index 96b1e7b5..49b6468a 100644 --- a/src/test/java/examples/websocketapi/account/AccountAllOcoOrders.java +++ b/src/test/java/examples/websocketapi/account/AccountAllOcoOrders.java @@ -12,7 +12,7 @@ public final class AccountAllOcoOrders { private AccountAllOcoOrders() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/account/AccountAllOrders.java b/src/test/java/examples/websocketapi/account/AccountAllOrders.java index 16e9e7a4..bbef632b 100644 --- a/src/test/java/examples/websocketapi/account/AccountAllOrders.java +++ b/src/test/java/examples/websocketapi/account/AccountAllOrders.java @@ -12,7 +12,7 @@ public final class AccountAllOrders { private AccountAllOrders() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/account/AccountAllocations.java b/src/test/java/examples/websocketapi/account/AccountAllocations.java new file mode 100644 index 00000000..c3840631 --- /dev/null +++ b/src/test/java/examples/websocketapi/account/AccountAllocations.java @@ -0,0 +1,31 @@ +package examples.websocketapi.account; + +import com.binance.connector.client.WebSocketApiClient; +import com.binance.connector.client.enums.DefaultUrls; +import com.binance.connector.client.impl.WebSocketApiClientImpl; +import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; + +import examples.PrivateConfig; + +public final class AccountAllocations { + + private AccountAllocations() { + } + + private static final int waitTime = 60000; + + public static void main(String[] args) throws InterruptedException { + + HmacSignatureGenerator signatureGenerator = new HmacSignatureGenerator(PrivateConfig.TESTNET_SECRET_KEY); + WebSocketApiClient client = new WebSocketApiClientImpl(PrivateConfig.TESTNET_API_KEY, signatureGenerator, DefaultUrls.TESTNET_WS_API_URL); + + client.connect(((event) -> { + System.out.println(event); + })); + + client.account().accountAllocations("BTCUSDT", null); + Thread.sleep(waitTime); + + client.close(); + } +} diff --git a/src/test/java/examples/websocketapi/account/AccountCommissionRates.java b/src/test/java/examples/websocketapi/account/AccountCommissionRates.java new file mode 100644 index 00000000..c89a8b2b --- /dev/null +++ b/src/test/java/examples/websocketapi/account/AccountCommissionRates.java @@ -0,0 +1,31 @@ +package examples.websocketapi.account; + +import com.binance.connector.client.WebSocketApiClient; +import com.binance.connector.client.enums.DefaultUrls; +import com.binance.connector.client.impl.WebSocketApiClientImpl; +import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; + +import examples.PrivateConfig; + +public final class AccountCommissionRates { + + private AccountCommissionRates() { + } + + private static final int waitTime = 60000; + + public static void main(String[] args) throws InterruptedException { + + HmacSignatureGenerator signatureGenerator = new HmacSignatureGenerator(PrivateConfig.TESTNET_SECRET_KEY); + WebSocketApiClient client = new WebSocketApiClientImpl(PrivateConfig.TESTNET_API_KEY, signatureGenerator, DefaultUrls.TESTNET_WS_API_URL); + + client.connect(((event) -> { + System.out.println(event); + })); + + client.account().accountCommissionRates("BTCUSDT", null); + Thread.sleep(waitTime); + + client.close(); + } +} diff --git a/src/test/java/examples/websocketapi/account/AccountPreventedMatches.java b/src/test/java/examples/websocketapi/account/AccountPreventedMatches.java index fe1d9a58..278fa1f2 100644 --- a/src/test/java/examples/websocketapi/account/AccountPreventedMatches.java +++ b/src/test/java/examples/websocketapi/account/AccountPreventedMatches.java @@ -14,7 +14,7 @@ public final class AccountPreventedMatches { private AccountPreventedMatches() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; private static final long preventedMatchId = 1234; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/account/AccountRateLimitsOrders.java b/src/test/java/examples/websocketapi/account/AccountRateLimitsOrders.java index 5f2f8ec7..eccf1437 100644 --- a/src/test/java/examples/websocketapi/account/AccountRateLimitsOrders.java +++ b/src/test/java/examples/websocketapi/account/AccountRateLimitsOrders.java @@ -12,7 +12,7 @@ public final class AccountRateLimitsOrders { private AccountRateLimitsOrders() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/account/AccountStatus.java b/src/test/java/examples/websocketapi/account/AccountStatus.java index bbcf4e67..52b53bc6 100644 --- a/src/test/java/examples/websocketapi/account/AccountStatus.java +++ b/src/test/java/examples/websocketapi/account/AccountStatus.java @@ -16,7 +16,7 @@ private AccountStatus() { private static final int recvWindow = 6000; private static final int requestId = 1234; - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/account/AccountTradeHistory.java b/src/test/java/examples/websocketapi/account/AccountTradeHistory.java index cf1d7f01..df0eb401 100644 --- a/src/test/java/examples/websocketapi/account/AccountTradeHistory.java +++ b/src/test/java/examples/websocketapi/account/AccountTradeHistory.java @@ -12,7 +12,7 @@ public final class AccountTradeHistory { private AccountTradeHistory() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/authentication/Logon.java b/src/test/java/examples/websocketapi/authentication/Logon.java new file mode 100644 index 00000000..a4d2578e --- /dev/null +++ b/src/test/java/examples/websocketapi/authentication/Logon.java @@ -0,0 +1,42 @@ +package examples.websocketapi.authentication; + +import org.json.JSONObject; + +import com.binance.connector.client.WebSocketApiClient; +import com.binance.connector.client.enums.DefaultUrls; +import com.binance.connector.client.impl.WebSocketApiClientImpl; +import com.binance.connector.client.impl.websocketapi.WebSocketApiAuth; +import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; + +import examples.PrivateConfig; + +public final class Logon { + + private Logon() { + } + + private static final int waitTime = 60000; + + public static void main(String[] args) throws InterruptedException { + + HmacSignatureGenerator signatureGenerator = new HmacSignatureGenerator(PrivateConfig.TESTNET_SECRET_KEY); + WebSocketApiClient wsApiClient = new WebSocketApiClientImpl(PrivateConfig.TESTNET_API_KEY, signatureGenerator, DefaultUrls.TESTNET_WS_API_URL); + + wsApiClient.connect(((message) -> { + System.out.println(message); + })); + + WebSocketApiAuth auth = wsApiClient.auth(); + + JSONObject params = new JSONObject(); + auth.logon(params); + + params.clear(); + wsApiClient.account().accountAllOrders("BTCUSDT", params); + + Thread.sleep(waitTime); + + wsApiClient.close(); + + } +} diff --git a/src/test/java/examples/websocketapi/authentication/Logout.java b/src/test/java/examples/websocketapi/authentication/Logout.java new file mode 100644 index 00000000..1bb8d34c --- /dev/null +++ b/src/test/java/examples/websocketapi/authentication/Logout.java @@ -0,0 +1,49 @@ +package examples.websocketapi.authentication; + +import org.json.JSONObject; + +import com.binance.connector.client.WebSocketApiClient; +import com.binance.connector.client.enums.DefaultUrls; +import com.binance.connector.client.impl.WebSocketApiClientImpl; +import com.binance.connector.client.impl.websocketapi.WebSocketApiAuth; +import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; + +import examples.PrivateConfig; + +public final class Logout { + + private Logout() { + } + + private static final int waitTime = 60000; + + public static void main(String[] args) throws InterruptedException { + + HmacSignatureGenerator signatureGenerator = new HmacSignatureGenerator(PrivateConfig.TESTNET_SECRET_KEY); + WebSocketApiClient wsApiClient = new WebSocketApiClientImpl(PrivateConfig.TESTNET_API_KEY, signatureGenerator, DefaultUrls.TESTNET_WS_API_URL); + + wsApiClient.connect(((message) -> { + System.out.println(message); + })); + + WebSocketApiAuth auth = wsApiClient.auth(); + + JSONObject params = new JSONObject(); + auth.logon(params); + + params.clear(); + params.put("requestId", "randomId"); + auth.status(params); + + params.clear(); + params.put("requestId", "randomId"); + auth.logout(params); + + params.clear(); + wsApiClient.account().accountAllOrders("BTCUSDT", params); + + Thread.sleep(waitTime); + + wsApiClient.close(); + } +} diff --git a/src/test/java/examples/websocketapi/authentication/Status.java b/src/test/java/examples/websocketapi/authentication/Status.java new file mode 100644 index 00000000..b435ff68 --- /dev/null +++ b/src/test/java/examples/websocketapi/authentication/Status.java @@ -0,0 +1,37 @@ +package examples.websocketapi.authentication; + +import org.json.JSONObject; + +import com.binance.connector.client.WebSocketApiClient; +import com.binance.connector.client.enums.DefaultUrls; +import com.binance.connector.client.impl.WebSocketApiClientImpl; +import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; + +import examples.PrivateConfig; + +public final class Status { + + private Status() { + } + + private static final int waitTime = 60000; + + public static void main(String[] args) throws InterruptedException { + + HmacSignatureGenerator signatureGenerator = new HmacSignatureGenerator(PrivateConfig.TESTNET_SECRET_KEY); + WebSocketApiClient wsApiClient = new WebSocketApiClientImpl(PrivateConfig.TESTNET_API_KEY, signatureGenerator, DefaultUrls.TESTNET_WS_API_URL); + + wsApiClient.connect(((message) -> { + System.out.println(message); + })); + + JSONObject params = new JSONObject(); + params.put("requestId", "randomId"); + wsApiClient.auth().status(params); + + Thread.sleep(waitTime); + + wsApiClient.close(); + + } +} diff --git a/src/test/java/examples/websocketapi/general/ExchangeInfo.java b/src/test/java/examples/websocketapi/general/ExchangeInfo.java index b9ac236e..65630c25 100644 --- a/src/test/java/examples/websocketapi/general/ExchangeInfo.java +++ b/src/test/java/examples/websocketapi/general/ExchangeInfo.java @@ -10,7 +10,7 @@ public final class ExchangeInfo { private ExchangeInfo() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/general/Ping.java b/src/test/java/examples/websocketapi/general/Ping.java index 732a4bf9..d559c7cf 100644 --- a/src/test/java/examples/websocketapi/general/Ping.java +++ b/src/test/java/examples/websocketapi/general/Ping.java @@ -9,7 +9,7 @@ public final class Ping { private Ping() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/general/ServerTime.java b/src/test/java/examples/websocketapi/general/ServerTime.java index 2ecf66a4..59442ccb 100644 --- a/src/test/java/examples/websocketapi/general/ServerTime.java +++ b/src/test/java/examples/websocketapi/general/ServerTime.java @@ -8,7 +8,7 @@ public final class ServerTime { private ServerTime() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/market/AggTrades.java b/src/test/java/examples/websocketapi/market/AggTrades.java index 421ce433..8f77561f 100644 --- a/src/test/java/examples/websocketapi/market/AggTrades.java +++ b/src/test/java/examples/websocketapi/market/AggTrades.java @@ -8,7 +8,7 @@ public final class AggTrades { private AggTrades() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/market/AvgPrice.java b/src/test/java/examples/websocketapi/market/AvgPrice.java index ce3d20ae..43c95d7d 100644 --- a/src/test/java/examples/websocketapi/market/AvgPrice.java +++ b/src/test/java/examples/websocketapi/market/AvgPrice.java @@ -8,7 +8,7 @@ public final class AvgPrice { private AvgPrice() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/market/Depth.java b/src/test/java/examples/websocketapi/market/Depth.java index d42fa8ac..168a1431 100644 --- a/src/test/java/examples/websocketapi/market/Depth.java +++ b/src/test/java/examples/websocketapi/market/Depth.java @@ -8,7 +8,7 @@ public final class Depth { private Depth() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/market/HistoricaTrades.java b/src/test/java/examples/websocketapi/market/HistoricaTrades.java index 74c012ff..132a4efe 100644 --- a/src/test/java/examples/websocketapi/market/HistoricaTrades.java +++ b/src/test/java/examples/websocketapi/market/HistoricaTrades.java @@ -12,7 +12,7 @@ public final class HistoricaTrades { private HistoricaTrades() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { HmacSignatureGenerator signatureGenerator = new HmacSignatureGenerator(PrivateConfig.TESTNET_SECRET_KEY); diff --git a/src/test/java/examples/websocketapi/market/Klines.java b/src/test/java/examples/websocketapi/market/Klines.java index ff5b17a7..44c93848 100644 --- a/src/test/java/examples/websocketapi/market/Klines.java +++ b/src/test/java/examples/websocketapi/market/Klines.java @@ -8,7 +8,7 @@ public final class Klines { private Klines() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/market/RecentTrades.java b/src/test/java/examples/websocketapi/market/RecentTrades.java index d0bb84dd..43cf0afe 100644 --- a/src/test/java/examples/websocketapi/market/RecentTrades.java +++ b/src/test/java/examples/websocketapi/market/RecentTrades.java @@ -8,7 +8,7 @@ public final class RecentTrades { private RecentTrades() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/market/Ticker.java b/src/test/java/examples/websocketapi/market/Ticker.java index 1e05ebd5..0e83af69 100644 --- a/src/test/java/examples/websocketapi/market/Ticker.java +++ b/src/test/java/examples/websocketapi/market/Ticker.java @@ -10,7 +10,7 @@ public final class Ticker { private Ticker() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/market/Ticker24H.java b/src/test/java/examples/websocketapi/market/Ticker24H.java index ef2d4a2f..0d249890 100644 --- a/src/test/java/examples/websocketapi/market/Ticker24H.java +++ b/src/test/java/examples/websocketapi/market/Ticker24H.java @@ -10,7 +10,7 @@ public final class Ticker24H { private Ticker24H() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/market/TickerBook.java b/src/test/java/examples/websocketapi/market/TickerBook.java index 1789235c..fbfa7f21 100644 --- a/src/test/java/examples/websocketapi/market/TickerBook.java +++ b/src/test/java/examples/websocketapi/market/TickerBook.java @@ -10,7 +10,7 @@ public final class TickerBook { private TickerBook() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/market/TickerPrice.java b/src/test/java/examples/websocketapi/market/TickerPrice.java index 18d36192..385abc27 100644 --- a/src/test/java/examples/websocketapi/market/TickerPrice.java +++ b/src/test/java/examples/websocketapi/market/TickerPrice.java @@ -10,7 +10,7 @@ public final class TickerPrice { private TickerPrice() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/market/TickerTradingDay.java b/src/test/java/examples/websocketapi/market/TickerTradingDay.java new file mode 100644 index 00000000..b094cd16 --- /dev/null +++ b/src/test/java/examples/websocketapi/market/TickerTradingDay.java @@ -0,0 +1,31 @@ +package examples.websocketapi.market; + +import org.json.JSONObject; + +import com.binance.connector.client.WebSocketApiClient; +import com.binance.connector.client.impl.WebSocketApiClientImpl; + +public final class TickerTradingDay { + + private TickerTradingDay() { + } + + private static final int waitTime = 60000; + + public static void main(String[] args) throws InterruptedException { + WebSocketApiClient client = new WebSocketApiClientImpl(); + client.connect(((event) -> { + System.out.println(event); + })); + + JSONObject params = new JSONObject(); + String[] symbols = new String[]{"BTCUSDT", "BNBUSDT"}; + + params.put("symbols", symbols); + client.market().tickerTradingDay(params); + + Thread.sleep(waitTime); + client.close(); + + } +} diff --git a/src/test/java/examples/websocketapi/market/UiKlines.java b/src/test/java/examples/websocketapi/market/UiKlines.java index 29af692a..20593443 100644 --- a/src/test/java/examples/websocketapi/market/UiKlines.java +++ b/src/test/java/examples/websocketapi/market/UiKlines.java @@ -8,7 +8,7 @@ public final class UiKlines { private UiKlines() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { WebSocketApiClient client = new WebSocketApiClientImpl(); diff --git a/src/test/java/examples/websocketapi/signature/Ed25519.java b/src/test/java/examples/websocketapi/signature/Ed25519.java index 479f2fd2..943c564f 100644 --- a/src/test/java/examples/websocketapi/signature/Ed25519.java +++ b/src/test/java/examples/websocketapi/signature/Ed25519.java @@ -14,7 +14,7 @@ public final class Ed25519 { private Ed25519() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException, FileNotFoundException, IOException { Ed25519SignatureGenerator signatureGenerator = new Ed25519SignatureGenerator(PrivateConfig.TESTNET_PRIVATE_KEY_PATH); diff --git a/src/test/java/examples/websocketapi/signature/Rsa.java b/src/test/java/examples/websocketapi/signature/Rsa.java index 57a80fe5..2b284109 100644 --- a/src/test/java/examples/websocketapi/signature/Rsa.java +++ b/src/test/java/examples/websocketapi/signature/Rsa.java @@ -14,7 +14,7 @@ private Rsa() { } private static final double quantity = 0.01; - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { RsaSignatureGenerator signatureGenerator = new RsaSignatureGenerator(PrivateConfig.TESTNET_PRIVATE_KEY_PATH); diff --git a/src/test/java/examples/websocketapi/trade/CancelAllOpenOrders.java b/src/test/java/examples/websocketapi/trade/CancelAllOpenOrders.java index def2b90b..69c275a4 100644 --- a/src/test/java/examples/websocketapi/trade/CancelAllOpenOrders.java +++ b/src/test/java/examples/websocketapi/trade/CancelAllOpenOrders.java @@ -14,7 +14,7 @@ public final class CancelAllOpenOrders { private CancelAllOpenOrders() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/trade/CancelOcoOrder.java b/src/test/java/examples/websocketapi/trade/CancelOcoOrder.java index 19dba368..7d5d0ad9 100644 --- a/src/test/java/examples/websocketapi/trade/CancelOcoOrder.java +++ b/src/test/java/examples/websocketapi/trade/CancelOcoOrder.java @@ -15,7 +15,7 @@ private CancelOcoOrder() { } private static final int orderListId = 3476; - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/trade/CancelOrder.java b/src/test/java/examples/websocketapi/trade/CancelOrder.java index 6becb08f..8f52ccc7 100644 --- a/src/test/java/examples/websocketapi/trade/CancelOrder.java +++ b/src/test/java/examples/websocketapi/trade/CancelOrder.java @@ -15,7 +15,7 @@ private CancelOrder() { } private static final int orderId = 3083708; - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/trade/CancelReplaceOrder.java b/src/test/java/examples/websocketapi/trade/CancelReplaceOrder.java index a3a3c99e..a1aae734 100644 --- a/src/test/java/examples/websocketapi/trade/CancelReplaceOrder.java +++ b/src/test/java/examples/websocketapi/trade/CancelReplaceOrder.java @@ -15,7 +15,7 @@ private CancelReplaceOrder() { } private static final double quantity = 0.01; - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/trade/GetOcoOrder.java b/src/test/java/examples/websocketapi/trade/GetOcoOrder.java index cdff6176..40a604e9 100644 --- a/src/test/java/examples/websocketapi/trade/GetOcoOrder.java +++ b/src/test/java/examples/websocketapi/trade/GetOcoOrder.java @@ -15,7 +15,7 @@ private GetOcoOrder() { } private static final int orderListId = 3475; - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/trade/GetOpenOcoOrders.java b/src/test/java/examples/websocketapi/trade/GetOpenOcoOrders.java index 3394066e..1f5166ab 100644 --- a/src/test/java/examples/websocketapi/trade/GetOpenOcoOrders.java +++ b/src/test/java/examples/websocketapi/trade/GetOpenOcoOrders.java @@ -12,7 +12,7 @@ public final class GetOpenOcoOrders { private GetOpenOcoOrders() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/trade/GetOpenOrders.java b/src/test/java/examples/websocketapi/trade/GetOpenOrders.java index 9e89dc41..b1e8ba6d 100644 --- a/src/test/java/examples/websocketapi/trade/GetOpenOrders.java +++ b/src/test/java/examples/websocketapi/trade/GetOpenOrders.java @@ -12,7 +12,7 @@ public final class GetOpenOrders { private GetOpenOrders() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/trade/GetOrder.java b/src/test/java/examples/websocketapi/trade/GetOrder.java index 4982711a..e04061f5 100644 --- a/src/test/java/examples/websocketapi/trade/GetOrder.java +++ b/src/test/java/examples/websocketapi/trade/GetOrder.java @@ -15,7 +15,7 @@ private GetOrder() { } private static final int orderId = 3083708; - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/trade/NewOcoOrder.java b/src/test/java/examples/websocketapi/trade/NewOcoOrder.java index 9133be71..25074f88 100644 --- a/src/test/java/examples/websocketapi/trade/NewOcoOrder.java +++ b/src/test/java/examples/websocketapi/trade/NewOcoOrder.java @@ -18,7 +18,7 @@ private NewOcoOrder() { private static final double stopPrice = 0.07050; private static final double stopLimitPrice = 0.07040; private static final double quantity = 0.01; - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/trade/NewOrder.java b/src/test/java/examples/websocketapi/trade/NewOrder.java index 85b10e4a..33f4fe7c 100644 --- a/src/test/java/examples/websocketapi/trade/NewOrder.java +++ b/src/test/java/examples/websocketapi/trade/NewOrder.java @@ -15,7 +15,7 @@ private NewOrder() { } private static final double quantity = 0.01; - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/trade/NewOrderTest.java b/src/test/java/examples/websocketapi/trade/NewOrderTest.java index 38a5b618..3eca6c5d 100644 --- a/src/test/java/examples/websocketapi/trade/NewOrderTest.java +++ b/src/test/java/examples/websocketapi/trade/NewOrderTest.java @@ -15,7 +15,7 @@ private NewOrderTest() { } private static final double quantity = 0.01; - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { diff --git a/src/test/java/examples/websocketapi/trade/NewSorOrder.java b/src/test/java/examples/websocketapi/trade/NewSorOrder.java new file mode 100644 index 00000000..c037474f --- /dev/null +++ b/src/test/java/examples/websocketapi/trade/NewSorOrder.java @@ -0,0 +1,39 @@ +package examples.websocketapi.trade; + +import org.json.JSONObject; + +import com.binance.connector.client.WebSocketApiClient; +import com.binance.connector.client.enums.DefaultUrls; +import com.binance.connector.client.impl.WebSocketApiClientImpl; +import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; + +import examples.PrivateConfig; + +public final class NewSorOrder { + + private NewSorOrder() { + } + + private static final double quantity = 0.01; + private static final int waitTime = 60000; + + public static void main(String[] args) throws InterruptedException { + + HmacSignatureGenerator signatureGenerator = new HmacSignatureGenerator(PrivateConfig.TESTNET_SECRET_KEY); + WebSocketApiClient wsApiClient = new WebSocketApiClientImpl(PrivateConfig.TESTNET_API_KEY, signatureGenerator, DefaultUrls.TESTNET_WS_API_URL); + + wsApiClient.connect(((message) -> { + System.out.println(message); + })); + + JSONObject params = new JSONObject(); + params.put("requestId", "randomId"); + + wsApiClient.trade().newSorOrder("BTCUSDT", "BUY", "MARKET", quantity, params); + + Thread.sleep(waitTime); + + wsApiClient.close(); + } +} + diff --git a/src/test/java/examples/websocketapi/trade/NewSorOrderTest.java b/src/test/java/examples/websocketapi/trade/NewSorOrderTest.java new file mode 100644 index 00000000..f95a8c07 --- /dev/null +++ b/src/test/java/examples/websocketapi/trade/NewSorOrderTest.java @@ -0,0 +1,40 @@ +package examples.websocketapi.trade; + +import org.json.JSONObject; + +import com.binance.connector.client.WebSocketApiClient; +import com.binance.connector.client.enums.DefaultUrls; +import com.binance.connector.client.impl.WebSocketApiClientImpl; +import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator; + +import examples.PrivateConfig; + +public final class NewSorOrderTest { + + private NewSorOrderTest() { + } + + private static final double quantity = 0.01; + private static final int waitTime = 60000; + + public static void main(String[] args) throws InterruptedException { + + HmacSignatureGenerator signatureGenerator = new HmacSignatureGenerator(PrivateConfig.TESTNET_SECRET_KEY); + WebSocketApiClient wsApiClient = new WebSocketApiClientImpl(PrivateConfig.TESTNET_API_KEY, signatureGenerator, DefaultUrls.TESTNET_WS_API_URL); + + wsApiClient.connect(((message) -> { + System.out.println(message); + })); + + JSONObject params = new JSONObject(); + params.put("requestId", "randomId"); + params.put("computeCommissionRates", true); + + wsApiClient.trade().testNewSorOrder("BTCUSDT", "BUY", "MARKET", quantity, params); + + Thread.sleep(waitTime); + + wsApiClient.close(); + } +} + diff --git a/src/test/java/examples/websocketapi/userdatastream/UserDataStreamPing.java b/src/test/java/examples/websocketapi/userdatastream/UserDataStreamPing.java index 26313b31..97b1266f 100644 --- a/src/test/java/examples/websocketapi/userdatastream/UserDataStreamPing.java +++ b/src/test/java/examples/websocketapi/userdatastream/UserDataStreamPing.java @@ -12,7 +12,7 @@ public final class UserDataStreamPing { private UserDataStreamPing() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { HmacSignatureGenerator signatureGenerator = new HmacSignatureGenerator(PrivateConfig.TESTNET_SECRET_KEY); diff --git a/src/test/java/examples/websocketapi/userdatastream/UserDataStreamStart.java b/src/test/java/examples/websocketapi/userdatastream/UserDataStreamStart.java index 32d440c3..3375abc8 100644 --- a/src/test/java/examples/websocketapi/userdatastream/UserDataStreamStart.java +++ b/src/test/java/examples/websocketapi/userdatastream/UserDataStreamStart.java @@ -12,7 +12,7 @@ public final class UserDataStreamStart { private UserDataStreamStart() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { HmacSignatureGenerator signatureGenerator = new HmacSignatureGenerator(PrivateConfig.TESTNET_SECRET_KEY); diff --git a/src/test/java/examples/websocketapi/userdatastream/UserDataStreamStop.java b/src/test/java/examples/websocketapi/userdatastream/UserDataStreamStop.java index 1e917a80..31240d36 100644 --- a/src/test/java/examples/websocketapi/userdatastream/UserDataStreamStop.java +++ b/src/test/java/examples/websocketapi/userdatastream/UserDataStreamStop.java @@ -12,7 +12,7 @@ public final class UserDataStreamStop { private UserDataStreamStop() { } - private static final int waitTime = 3000; + private static final int waitTime = 60000; public static void main(String[] args) throws InterruptedException { HmacSignatureGenerator signatureGenerator = new HmacSignatureGenerator(PrivateConfig.TESTNET_SECRET_KEY); diff --git a/src/test/java/unit/spot/autoinvest/TestAllSourceAndTargetAssets.java b/src/test/java/unit/spot/autoinvest/TestAllSourceAndTargetAssets.java new file mode 100644 index 00000000..3468afc9 --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestAllSourceAndTargetAssets.java @@ -0,0 +1,43 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestAllSourceAndTargetAssets { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testAllSourceAndTargetAssets() { + String path = "/sapi/v1/lending/auto-invest/all/asset"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().allSourceAndTargetAssets(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestChangePlanStatus.java b/src/test/java/unit/spot/autoinvest/TestChangePlanStatus.java new file mode 100644 index 00000000..5378b534 --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestChangePlanStatus.java @@ -0,0 +1,60 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestChangePlanStatus { + private MockWebServer mockWebServer; + private String baseUrl; + + private static final long planId = 1234; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testChangePlanStatusWithoutParameters() { + String path = "/sapi/v1/lending/auto-invest/plan/edit-status"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createAutoInvest().changePlanStatus(parameters)); + } + + @Test + public void testChangePlanStatus() { + String path = "/sapi/v1/lending/auto-invest/plan/edit-status?planId=1234&status=PAUSED"; + Map parameters = new LinkedHashMap<>(); + parameters.put("planId", planId); + parameters.put("status", "PAUSED"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().changePlanStatus(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestHoldingPlan.java b/src/test/java/unit/spot/autoinvest/TestHoldingPlan.java new file mode 100644 index 00000000..8cefe21e --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestHoldingPlan.java @@ -0,0 +1,43 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestHoldingPlan { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testHoldingPlan() { + String path = "/sapi/v1/lending/auto-invest/plan/id"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().holdingPlan(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestIndexInfo.java b/src/test/java/unit/spot/autoinvest/TestIndexInfo.java new file mode 100644 index 00000000..992d7f72 --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestIndexInfo.java @@ -0,0 +1,59 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestIndexInfo { + private MockWebServer mockWebServer; + private String baseUrl; + + private static final long indexId = 1234; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testIndexInfoWithoutParameters() { + String path = "/sapi/v1/lending/auto-invest/index/info"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createAutoInvest().indexInfo(parameters)); + } + + @Test + public void testIndexInfo() { + String path = "/sapi/v1/lending/auto-invest/index/info?indexId=1234"; + Map parameters = new LinkedHashMap<>(); + parameters.put("indexId", indexId); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().indexInfo(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestIndexPlanRebalanceInfo.java b/src/test/java/unit/spot/autoinvest/TestIndexPlanRebalanceInfo.java new file mode 100644 index 00000000..b853ccd2 --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestIndexPlanRebalanceInfo.java @@ -0,0 +1,43 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestIndexPlanRebalanceInfo { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testIndexPlanRebalanceInfo() { + String path = "/sapi/v1/lending/auto-invest/rebalance/history"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().indexPlanRebalanceInfo(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestIndexPlanRedeemHistory.java b/src/test/java/unit/spot/autoinvest/TestIndexPlanRedeemHistory.java new file mode 100644 index 00000000..6eb46519 --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestIndexPlanRedeemHistory.java @@ -0,0 +1,58 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestIndexPlanRedeemHistory { + private MockWebServer mockWebServer; + private String baseUrl; + private final long requestId = 12345; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testOnetimeTransactionStatusWithoutParameters() { + String path = "/sapi/v1/lending/auto-invest/redeem/history"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createAutoInvest().indexPlanRedeemHistory(parameters)); + } + + @Test + public void testIndexPlanRedeemHistory() { + String path = "/sapi/v1/lending/auto-invest/redeem/history?requestId=12345"; + Map parameters = new LinkedHashMap<>(); + parameters.put("requestId", requestId); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().indexPlanRedeemHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestOnetimeTransactionStatus.java b/src/test/java/unit/spot/autoinvest/TestOnetimeTransactionStatus.java new file mode 100644 index 00000000..4119d37d --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestOnetimeTransactionStatus.java @@ -0,0 +1,59 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestOnetimeTransactionStatus { + private MockWebServer mockWebServer; + private String baseUrl; + + private static final long transactionId = 12345; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testOnetimeTransactionStatusWithoutParameters() { + String path = "/sapi/v1/lending/auto-invest/one-off/status"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createAutoInvest().oneTimeTransactionStatus(parameters)); + } + + @Test + public void testOnetimeTransactionStatus() { + String path = "/sapi/v1/lending/auto-invest/one-off/status?transactionId=12345"; + Map parameters = new LinkedHashMap<>(); + parameters.put("transactionId", transactionId); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().oneTimeTransactionStatus(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestPlanSubsHistory.java b/src/test/java/unit/spot/autoinvest/TestPlanSubsHistory.java new file mode 100644 index 00000000..6301cf50 --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestPlanSubsHistory.java @@ -0,0 +1,43 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestPlanSubsHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testPlanSubsHistory() { + String path = "/sapi/v1/lending/auto-invest/history/list"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().planSubsHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestPlansList.java b/src/test/java/unit/spot/autoinvest/TestPlansList.java new file mode 100644 index 00000000..4c6e669c --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestPlansList.java @@ -0,0 +1,58 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestPlansList { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testPlansListWithoutParameters() { + String path = "/sapi/v1/lending/auto-invest/plan/list"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createAutoInvest().plansList(parameters)); + } + + @Test + public void testPlansList() { + String path = "/sapi/v1/lending/auto-invest/plan/list?planType=SINGLE"; + Map parameters = new LinkedHashMap<>(); + parameters.put("planType", "SINGLE"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().plansList(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestRedeemIndexPlan.java b/src/test/java/unit/spot/autoinvest/TestRedeemIndexPlan.java new file mode 100644 index 00000000..0f679e95 --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestRedeemIndexPlan.java @@ -0,0 +1,61 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestRedeemIndexPlan { + private MockWebServer mockWebServer; + private String baseUrl; + + private static final long indexId = 123456; + private static final Integer redemptionPercentage = 10; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testRedeemIndexPlanWithoutParameters() { + String path = "/sapi/v1/lending/auto-invest/redeem"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createAutoInvest().redeemIndexPlan(parameters)); + } + + @Test + public void testRedeemIndexPlan() { + String path = "/sapi/v1/lending/auto-invest/redeem?indexId=123456&redemptionPercentage=10"; + Map parameters = new LinkedHashMap<>(); + parameters.put("indexId", indexId); + parameters.put("redemptionPercentage", redemptionPercentage); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().redeemIndexPlan(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestSourceAssetList.java b/src/test/java/unit/spot/autoinvest/TestSourceAssetList.java new file mode 100644 index 00000000..c0303d7a --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestSourceAssetList.java @@ -0,0 +1,58 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSourceAssetList { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSourceAssetListWithoutParameters() { + String path = "/sapi/v1/lending/auto-invest/source-asset/list"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createAutoInvest().sourceAssetList(parameters)); + } + + @Test + public void testSourceAssetList() { + String path = "/sapi/v1/lending/auto-invest/source-asset/list?usageType=RECURRING"; + Map parameters = new LinkedHashMap<>(); + parameters.put("usageType", "RECURRING"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().sourceAssetList(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestSubmitOneTimeTransaction.java b/src/test/java/unit/spot/autoinvest/TestSubmitOneTimeTransaction.java new file mode 100644 index 00000000..48f61a7c --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestSubmitOneTimeTransaction.java @@ -0,0 +1,60 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSubmitOneTimeTransaction { + private MockWebServer mockWebServer; + private String baseUrl; + private static final double subscriptionAmount = 10.1; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSubmitOneTimeTransactionWithoutParameters() { + String path = "/sapi/v1/lending/auto-invest/one-off"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createAutoInvest().submitOneTimeTransaction(parameters)); + } + + @Test + public void testSubmitOneTimeTransaction() { + String path = "/sapi/v1/lending/auto-invest/one-off?sourceType=MAIN_SITE&subscriptionAmount=10.1&sourceAsset=USDT"; + Map parameters = new LinkedHashMap<>(); + parameters.put("sourceType", "MAIN_SITE"); + parameters.put("subscriptionAmount", subscriptionAmount); + parameters.put("sourceAsset", "USDT"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().submitOneTimeTransaction(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestTargetAssetList.java b/src/test/java/unit/spot/autoinvest/TestTargetAssetList.java new file mode 100644 index 00000000..858cfd8d --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestTargetAssetList.java @@ -0,0 +1,43 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestTargetAssetList { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testTargetAssetList() { + String path = "/sapi/v1/lending/auto-invest/target-asset/list"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().targetAssetList(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestTargetAssetRoiList.java b/src/test/java/unit/spot/autoinvest/TestTargetAssetRoiList.java new file mode 100644 index 00000000..f51ce677 --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestTargetAssetRoiList.java @@ -0,0 +1,58 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestTargetAssetRoiList { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testTargetAssetRoiListWithoutParameters() { + String path = "/sapi/v1/lending/auto-invest/target-asset/roi/list"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createAutoInvest().targetAssetRoiList(parameters)); + } + + @Test + public void testTargetAssetRoiList() { + String path = "/sapi/v1/lending/auto-invest/target-asset/roi/list?targetAsset=BTC&hisRoiType=FIVE_YEAR"; + Map parameters = new LinkedHashMap<>(); + parameters.put("targetAsset", "BTC"); + parameters.put("hisRoiType", "FIVE_YEAR"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().targetAssetRoiList(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/autoinvest/TestUserIndexPlans.java b/src/test/java/unit/spot/autoinvest/TestUserIndexPlans.java new file mode 100644 index 00000000..ee5ff706 --- /dev/null +++ b/src/test/java/unit/spot/autoinvest/TestUserIndexPlans.java @@ -0,0 +1,59 @@ +package unit.spot.autoinvest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestUserIndexPlans { + private MockWebServer mockWebServer; + private String baseUrl; + + private static final long indexId = 1234; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testUserIndexPlansWithoutParameters() { + String path = "/sapi/v1/lending/auto-invest/index/user-summary"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createAutoInvest().userIndexPlans(parameters)); + } + + @Test + public void testUserIndexPlans() { + String path = "/sapi/v1/lending/auto-invest/index/user-summary?indexId=1234"; + Map parameters = new LinkedHashMap<>(); + parameters.put("indexId", indexId); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createAutoInvest().userIndexPlans(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanAdjustLtv.java b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanAdjustLtv.java new file mode 100644 index 00000000..1d9128f6 --- /dev/null +++ b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanAdjustLtv.java @@ -0,0 +1,61 @@ +package unit.spot.cryptoloans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleLoanAdjustLtv { + private MockWebServer mockWebServer; + private String baseUrl; + private final double adjustmentAmount = 5.235; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexibleLoanAdjustLtvWithoutParameters() { + String path = "/sapi/v1/loan/flexible/adjust/ltv"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createCryptoLoans().flexibleLoanAdjustLtv(parameters)); + } + + @Test + public void testFlexibleLoanAdjustLtv() { + String path = "/sapi/v1/loan/flexible/adjust/ltv?loanCoin=BUSD&collateralCoin=BNB&adjustmentAmount=5.235&direction=ADDITIONAL"; + Map parameters = new LinkedHashMap<>(); + parameters.put("loanCoin", "BUSD"); + parameters.put("collateralCoin", "BNB"); + parameters.put("adjustmentAmount", adjustmentAmount); + parameters.put("direction", "ADDITIONAL"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createCryptoLoans().flexibleLoanAdjustLtv(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanAssets.java b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanAssets.java new file mode 100644 index 00000000..13273041 --- /dev/null +++ b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanAssets.java @@ -0,0 +1,42 @@ +package unit.spot.cryptoloans; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleLoanAssets { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexibleLoanAssets() { + String path = "/sapi/v1/loan/flexible/loanable/data"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createCryptoLoans().flexibleLoanAssets(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanBorrow.java b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanBorrow.java new file mode 100644 index 00000000..0fa27475 --- /dev/null +++ b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanBorrow.java @@ -0,0 +1,58 @@ +package unit.spot.cryptoloans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleLoanBorrow { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexibleLoanBorrowWithoutParameters() { + String path = "/sapi/v1/loan/flexible/borrow"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createCryptoLoans().flexibleLoanBorrow(parameters)); + } + + @Test + public void testFlexibleLoanBorrow() { + String path = "/sapi/v1/loan/flexible/borrow?loanCoin=USDT&collateralCoin=BTC"; + Map parameters = new LinkedHashMap<>(); + parameters.put("loanCoin", "USDT"); + parameters.put("collateralCoin", "BTC"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createCryptoLoans().flexibleLoanBorrow(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanBorrowHistory.java b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanBorrowHistory.java new file mode 100644 index 00000000..7b2c7803 --- /dev/null +++ b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanBorrowHistory.java @@ -0,0 +1,42 @@ +package unit.spot.cryptoloans; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleLoanBorrowHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexibleLoanBorrowHistory() { + String path = "/sapi/v1/loan/flexible/borrow/history"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createCryptoLoans().flexibleLoanBorrowHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanCollateralAssets.java b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanCollateralAssets.java new file mode 100644 index 00000000..9577a913 --- /dev/null +++ b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanCollateralAssets.java @@ -0,0 +1,42 @@ +package unit.spot.cryptoloans; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleLoanCollateralAssets { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testGetFlexibleLoanCollateralAssetsData() { + String path = "/sapi/v1/loan/flexible/collateral/data"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createCryptoLoans().flexibleLoanCollateralAssets(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanLtvAdjustHistory.java b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanLtvAdjustHistory.java new file mode 100644 index 00000000..a303ff72 --- /dev/null +++ b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanLtvAdjustHistory.java @@ -0,0 +1,43 @@ +package unit.spot.cryptoloans; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleLoanLtvAdjustHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + + @Test + public void testFlexibleLoanLtvAdjustHistory() { + String path = "/sapi/v1/loan/flexible/ltv/adjustment/history"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createCryptoLoans().flexibleLoanLtvAdjustHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanOngoingOrders.java b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanOngoingOrders.java new file mode 100644 index 00000000..96d54311 --- /dev/null +++ b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanOngoingOrders.java @@ -0,0 +1,43 @@ +package unit.spot.cryptoloans; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleLoanOngoingOrders { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexibleLoanOngoingOrders() { + String path = "/sapi/v1/loan/flexible/ongoing/orders?loanCoin=BUSD"; + Map parameters = new LinkedHashMap<>(); + parameters.put("loanCoin", "BUSD"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createCryptoLoans().flexibleLoanOngoingOrders(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanRepay.java b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanRepay.java new file mode 100644 index 00000000..3e59d5a8 --- /dev/null +++ b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanRepay.java @@ -0,0 +1,60 @@ +package unit.spot.cryptoloans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleLoanRepay { + private MockWebServer mockWebServer; + private String baseUrl; + private static final double repayAmount = 0.1; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexibleLoanRepayWithoutParameters() { + String path = "/sapi/v1/loan/flexible/repay"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createCryptoLoans().flexibleLoanRepay(parameters)); + } + + @Test + public void testFlexibleLoanRepay() { + String path = "/sapi/v1/loan/flexible/repay?loanCoin=USDT&collateralCoin=BTC&repayAmount=" + repayAmount; + Map parameters = new LinkedHashMap<>(); + parameters.put("loanCoin", "USDT"); + parameters.put("collateralCoin", "BTC"); + parameters.put("repayAmount", repayAmount); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createCryptoLoans().flexibleLoanRepay(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanRepayHistory.java b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanRepayHistory.java new file mode 100644 index 00000000..30c953dd --- /dev/null +++ b/src/test/java/unit/spot/cryptoloans/TestFlexibleLoanRepayHistory.java @@ -0,0 +1,42 @@ +package unit.spot.cryptoloans; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleLoanRepayHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testRepayGetFlexibleLoanRepaymentHistory() { + String path = "/sapi/v1/loan/flexible/repay/history"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createCryptoLoans().flexibleLoanRepayHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/futures/TestFuturesOrderBookHistory.java b/src/test/java/unit/spot/futures/TestFuturesOrderBookHistory.java new file mode 100644 index 00000000..757da24a --- /dev/null +++ b/src/test/java/unit/spot/futures/TestFuturesOrderBookHistory.java @@ -0,0 +1,63 @@ +package unit.spot.futures; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFuturesOrderBookHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + private final Long startTime = 17024585109000L; + private final Long endTime = 1702458517000L; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testTestFuturesOrderBookHistoryWithoutParameters() { + String path = "/sapi/v1/futures/histDataLink"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createFutures().futuresOrderBookHistory(parameters)); + } + + @Test + public void testTestFuturesOrderBookHistory() { + String path = String.format("/sapi/v1/futures/histDataLink?symbol=%s&dataType=%s&startTime=%s&endTime=%s", "BTCUSDT", "T_DEPTH", startTime, endTime); + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BTCUSDT"); + parameters.put("dataType", "T_DEPTH"); + parameters.put("startTime", startTime); + parameters.put("endTime", endTime); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createFutures().futuresOrderBookHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/giftcard/TestCreateDualTokensCode.java b/src/test/java/unit/spot/giftcard/TestCreateDualTokensCode.java new file mode 100644 index 00000000..4fe19887 --- /dev/null +++ b/src/test/java/unit/spot/giftcard/TestCreateDualTokensCode.java @@ -0,0 +1,60 @@ +package unit.spot.giftcard; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestCreateDualTokensCode { + private MockWebServer mockWebServer; + private String baseUrl; + private final double baseTokenAmount = 1.002; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testCreateDualTokensCodeWithoutParameters() { + String path = "/sapi/v1/giftcard/buyCode"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createGiftCard().createDualTokensCode(parameters)); + } + + @Test + public void testCreateDualTokensCode() { + String path = "/sapi/v1/giftcard/buyCode?baseToken=BUSD&faceToken=BNB&baseTokenAmount=1.002"; + Map parameters = new LinkedHashMap<>(); + parameters.put("baseToken", "BUSD"); + parameters.put("faceToken", "BNB"); + parameters.put("baseTokenAmount", baseTokenAmount); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createGiftCard().createDualTokensCode(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/giftcard/TestTokensLimit.java b/src/test/java/unit/spot/giftcard/TestTokensLimit.java new file mode 100644 index 00000000..2120f44b --- /dev/null +++ b/src/test/java/unit/spot/giftcard/TestTokensLimit.java @@ -0,0 +1,57 @@ +package unit.spot.giftcard; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestTokensLimit { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testTokensLimitWithoutParameters() { + String path = "/sapi/v1/giftcard/buyCode/token-limit"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createGiftCard().tokensLimit(parameters)); + } + + @Test + public void testTokensLimit() { + String path = "/sapi/v1/giftcard/buyCode/token-limit?baseToken=BUSD"; + Map parameters = new LinkedHashMap<>(); + parameters.put("baseToken", "BUSD"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createGiftCard().tokensLimit(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/savings/TestChangeToDailyPosition.java b/src/test/java/unit/spot/margin/TestAdjustCrossMarginMaxLeverage.java similarity index 75% rename from src/test/java/unit/spot/savings/TestChangeToDailyPosition.java rename to src/test/java/unit/spot/margin/TestAdjustCrossMarginMaxLeverage.java index 38c2634d..1fc19c44 100644 --- a/src/test/java/unit/spot/savings/TestChangeToDailyPosition.java +++ b/src/test/java/unit/spot/margin/TestAdjustCrossMarginMaxLeverage.java @@ -1,4 +1,4 @@ -package unit.spot.savings; +package unit.spot.margin; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; @@ -19,11 +19,11 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestChangeToDailyPosition { +public class TestAdjustCrossMarginMaxLeverage { private MockWebServer mockWebServer; private String baseUrl; - private final long lot = 1L; + private final Integer leverage = 3; @Before public void init() { @@ -32,29 +32,28 @@ public void init() { } @Test - public void testChangeToDailyPositionWithoutParameters() { - String path = "/sapi/v1/lending/positionChanged"; + public void testAdjustCrossMarginMaxLeverageWithoutParameters() { + String path = "/sapi/v1/margin/max-leverage"; Map parameters = new LinkedHashMap<>(); Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); mockWebServer.setDispatcher(dispatcher); SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); - assertThrows(BinanceConnectorException.class, () -> client.createSavings().changeToDailyPosition(parameters)); + assertThrows(BinanceConnectorException.class, () -> client.createMargin().adjustCrossMarginMaxLeverage(parameters)); } - + @Test - public void testChangeToDailyPosition() { - String path = "/sapi/v1/lending/positionChanged?projectId=123&lot=1"; + public void testAdjustCrossMarginMaxLeverage() { + String path = "/sapi/v1/margin/max-leverage?maxLeverage=3"; Map parameters = new LinkedHashMap<>(); - parameters.put("projectId", "123"); - parameters.put("lot", lot); + parameters.put("maxLeverage", leverage); Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); mockWebServer.setDispatcher(dispatcher); SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); - String result = client.createSavings().changeToDailyPosition(parameters); + String result = client.createMargin().adjustCrossMarginMaxLeverage(parameters); assertEquals(MockData.MOCK_RESPONSE, result); } } diff --git a/src/test/java/unit/spot/margin/TestAvailableInventory.java b/src/test/java/unit/spot/margin/TestAvailableInventory.java new file mode 100644 index 00000000..a2fc81a3 --- /dev/null +++ b/src/test/java/unit/spot/margin/TestAvailableInventory.java @@ -0,0 +1,57 @@ +package unit.spot.margin; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestAvailableInventory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testAvailableInventoryWithoutParameters() { + String path = "/sapi/v1/margin/available-inventory"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createMargin().availableInventory(parameters)); + } + + @Test + public void testAvailableInventory() { + String path = "/sapi/v1/margin/available-inventory?type=MARGIN"; + Map parameters = new LinkedHashMap<>(); + parameters.put("type", "MARGIN"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().availableInventory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/margin/TestBnbConvertibleAssets.java b/src/test/java/unit/spot/margin/TestBnbConvertibleAssets.java new file mode 100644 index 00000000..b0909358 --- /dev/null +++ b/src/test/java/unit/spot/margin/TestBnbConvertibleAssets.java @@ -0,0 +1,43 @@ +package unit.spot.margin; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestBnbConvertibleAssets { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + + @Test + public void testBnbConvertibleAssets() { + String path = "/sapi/v1/margin/dust"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().bnbConvertibleAssets(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/margin/TestCapitalFlow.java b/src/test/java/unit/spot/margin/TestCapitalFlow.java new file mode 100644 index 00000000..1e2576fe --- /dev/null +++ b/src/test/java/unit/spot/margin/TestCapitalFlow.java @@ -0,0 +1,56 @@ +package unit.spot.margin; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestCapitalFlow { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testCapitalFlowWithoutParameters() { + String path = "/sapi/v1/margin/capital-flow"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().capitalFlow(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } + + @Test + public void testCapitalFlow() { + String path = "/sapi/v1/margin/capital-flow?asset=USDT"; + Map parameters = new LinkedHashMap<>(); + parameters.put("asset", "USDT"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().capitalFlow(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/margin/TestConvertToBnB.java b/src/test/java/unit/spot/margin/TestConvertToBnB.java new file mode 100644 index 00000000..9c8dd3a0 --- /dev/null +++ b/src/test/java/unit/spot/margin/TestConvertToBnB.java @@ -0,0 +1,57 @@ +package unit.spot.margin; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestConvertToBnB { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testConvertToBnBWithoutParameters() { + String path = "/sapi/v1/margin/dust"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createMargin().convertToBnB(parameters)); + } + + @Test + public void testConvertToBnB() { + String path = "/sapi/v1/margin/dust?asset=BTC"; + Map parameters = new LinkedHashMap<>(); + parameters.put("asset", "BTC"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().convertToBnB(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/margin/TestCrossMarginCollateralRatio.java b/src/test/java/unit/spot/margin/TestCrossMarginCollateralRatio.java new file mode 100644 index 00000000..cee74fb5 --- /dev/null +++ b/src/test/java/unit/spot/margin/TestCrossMarginCollateralRatio.java @@ -0,0 +1,40 @@ +package unit.spot.margin; + +import static org.junit.Assert.assertEquals; + + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestCrossMarginCollateralRatio { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + + @Test + public void testCrossMarginCollateralRatio() { + String path = "/sapi/v1/margin/crossMarginCollateralRatio"; + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().crossMarginCollateralRatio(); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/margin/TestDelistSchedule.java b/src/test/java/unit/spot/margin/TestDelistSchedule.java new file mode 100644 index 00000000..eb3a0f13 --- /dev/null +++ b/src/test/java/unit/spot/margin/TestDelistSchedule.java @@ -0,0 +1,42 @@ +package unit.spot.margin; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestDelistSchedule { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testDelistSchedule() { + String path = "/sapi/v1/margin/delist-schedule"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().delistSchedule(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/margin/TestExchangeSmallLiability.java b/src/test/java/unit/spot/margin/TestExchangeSmallLiability.java new file mode 100644 index 00000000..ec1e39cb --- /dev/null +++ b/src/test/java/unit/spot/margin/TestExchangeSmallLiability.java @@ -0,0 +1,43 @@ +package unit.spot.margin; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestExchangeSmallLiability { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testExchangeSmallLiability() { + String path = "/sapi/v1/margin/exchange-small-liability?assetNames=BTC"; + Map parameters = new LinkedHashMap<>(); + parameters.put("assetNames", "BTC"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().exchangeSmallLiability(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/margin/TestLeverageBracket.java b/src/test/java/unit/spot/margin/TestLeverageBracket.java new file mode 100644 index 00000000..10168c7b --- /dev/null +++ b/src/test/java/unit/spot/margin/TestLeverageBracket.java @@ -0,0 +1,37 @@ +package unit.spot.margin; + +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestLeverageBracket { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testLeverageBracket() { + String path = "/sapi/v1/margin/leverageBracket"; + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().leverageBracket(); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/margin/TestNextHourlyInterestRate.java b/src/test/java/unit/spot/margin/TestNextHourlyInterestRate.java new file mode 100644 index 00000000..d328b5c5 --- /dev/null +++ b/src/test/java/unit/spot/margin/TestNextHourlyInterestRate.java @@ -0,0 +1,58 @@ +package unit.spot.margin; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestNextHourlyInterestRate { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testGetAFutureHourlyInterestRateWithoutParameters() { + String path = "/sapi/v1/margin/next-hourly-interest-rate"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createMargin().nextHourlyInterestRate(parameters)); + } + + @Test + public void testGetAFutureHourlyInterestRate() { + String path = "/sapi/v1/margin/next-hourly-interest-rate?assets=BTC&isIsolated=true"; + Map parameters = new LinkedHashMap<>(); + parameters.put("assets", "BTC"); + parameters.put("isIsolated", true); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().nextHourlyInterestRate(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/margin/TestSmallLiabilityAssets.java b/src/test/java/unit/spot/margin/TestSmallLiabilityAssets.java new file mode 100644 index 00000000..c5cd46aa --- /dev/null +++ b/src/test/java/unit/spot/margin/TestSmallLiabilityAssets.java @@ -0,0 +1,43 @@ +package unit.spot.margin; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSmallLiabilityAssets { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + + @Test + public void testSmallLiabilityAssets() { + String path = "/sapi/v1/margin/exchange-small-liability"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().smallLiabilityAssets(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/margin/TestSmallLiabilityExchangeHistory.java b/src/test/java/unit/spot/margin/TestSmallLiabilityExchangeHistory.java new file mode 100644 index 00000000..f33d04c7 --- /dev/null +++ b/src/test/java/unit/spot/margin/TestSmallLiabilityExchangeHistory.java @@ -0,0 +1,60 @@ +package unit.spot.margin; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSmallLiabilityExchangeHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + private final int current = 1; + private final int size = 10; + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSmallLiabilityExchangeHistoryWithoutParameters() { + String path = "/sapi/v1/margin/exchange-small-liability-history"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createMargin().smallLiabilityExchangeHistory(parameters)); + } + + @Test + public void testSmallLiabilityExchangeHistory() { + String path = "/sapi/v1/margin/exchange-small-liability-history?current=1&size=10"; + Map parameters = new LinkedHashMap<>(); + parameters.put("current", current); + parameters.put("size", size); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().smallLiabilityExchangeHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/margin/TestTradeCoeff.java b/src/test/java/unit/spot/margin/TestTradeCoeff.java new file mode 100644 index 00000000..afe0e5e1 --- /dev/null +++ b/src/test/java/unit/spot/margin/TestTradeCoeff.java @@ -0,0 +1,42 @@ +package unit.spot.margin; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestTradeCoeff { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testTradeCoeff() { + String path = "/sapi/v1/margin/tradeCoeff"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createMargin().tradeCoeff(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/market/TestTradingDayTicker.java b/src/test/java/unit/spot/market/TestTradingDayTicker.java new file mode 100644 index 00000000..bc7bb111 --- /dev/null +++ b/src/test/java/unit/spot/market/TestTradingDayTicker.java @@ -0,0 +1,109 @@ +package unit.spot.market; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; +import com.binance.connector.client.utils.UrlBuilder; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestTradingDayTicker { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testTradingDayTicker() { + String path = "/api/v3/ticker/tradingDay?symbol=BNBUSDT&type=MINI"; + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + parameters.put("type", "MINI"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(baseUrl); + String result = client.createMarket().tradingDayTicker(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } + + @Test + public void testTradingDayTickerWithMultipleSymbol() { + String path = String.format("/api/v3/ticker/tradingDay?symbols=%s", + UrlBuilder.urlEncode("[\"BNBUSDT\",\"BTCUSDT\"]")); + Map parameters = new LinkedHashMap<>(); + ArrayList symbols = new ArrayList<>(); + symbols.add("BNBUSDT"); + symbols.add("BTCUSDT"); + parameters.put("symbols", symbols); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(baseUrl); + String result = client.createMarket().tradingDayTicker(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } + + @Test + public void testTradingDayTickerWithoutParameters() { + String path = "/api/v3/ticker/tradingDay"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createMarket().tradingDayTicker(parameters)); + } + + @Test + public void testTradingDayTickerWithInvalidType() { + String path = String.format("/api/v3/ticker/tradingDay?symbols=%s", + UrlBuilder.urlEncode("[\"BNBUSDT\",\"BTCUSDT\"]")); + Map parameters = new LinkedHashMap<>(); + String[] symbols = {"BNBUSDT", "BTCUSDT"}; + parameters.put("symbols", symbols); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createMarket().tradingDayTicker(parameters)); + } + + @Test + public void testTradingDayTickerWithDoubleParameter() { + String path = String.format("/api/v3/ticker/tradingDay?symbols=%s", + UrlBuilder.urlEncode("[\"BNBUSDT\",\"BTCUSDT\"]")); + Map parameters = new LinkedHashMap<>(); + String[] symbols = {"BNBUSDT", "BTCUSDT"}; + parameters.put("symbols", symbols); + parameters.put("symbol", "ETHUSDT"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createMarket().tradingDayTicker(parameters)); + } +} diff --git a/src/test/java/unit/spot/portfoliomargin/TestAssetCollection.java b/src/test/java/unit/spot/portfoliomargin/TestAssetCollection.java new file mode 100644 index 00000000..ac0bc72e --- /dev/null +++ b/src/test/java/unit/spot/portfoliomargin/TestAssetCollection.java @@ -0,0 +1,57 @@ +package unit.spot.portfoliomargin; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestAssetCollection { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testAssetCollectionWithoutParameters() { + String path = "/sapi/v1/portfolio/asset-collection"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createPortfolioMargin().assetCollection(parameters)); + } + + @Test + public void testAssetCollection() { + String path = "/sapi/v1/portfolio/asset-collection?asset=BTC"; + Map parameters = new LinkedHashMap<>(); + parameters.put("asset", "BTC"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createPortfolioMargin().assetCollection(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/portfoliomargin/TestAssetIndexPrice.java b/src/test/java/unit/spot/portfoliomargin/TestAssetIndexPrice.java new file mode 100644 index 00000000..18579384 --- /dev/null +++ b/src/test/java/unit/spot/portfoliomargin/TestAssetIndexPrice.java @@ -0,0 +1,42 @@ +package unit.spot.portfoliomargin; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestAssetIndexPrice { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testQueryPortfolioMarginAssetIndexPrice() { + String path = "/sapi/v1/portfolio/asset-index-price"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createPortfolioMargin().assetIndexPrice(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/portfoliomargin/TestAssetLeverage.java b/src/test/java/unit/spot/portfoliomargin/TestAssetLeverage.java new file mode 100644 index 00000000..9491d26e --- /dev/null +++ b/src/test/java/unit/spot/portfoliomargin/TestAssetLeverage.java @@ -0,0 +1,40 @@ +package unit.spot.portfoliomargin; + +import static org.junit.Assert.assertEquals; + + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestAssetLeverage { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + + @Test + public void testAssetLeverage() { + String path = "/sapi/v1/portfolio/margin-asset-leverage"; + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createPortfolioMargin().assetLeverage(); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/portfoliomargin/TestAutoCollection.java b/src/test/java/unit/spot/portfoliomargin/TestAutoCollection.java new file mode 100644 index 00000000..8fa81bf4 --- /dev/null +++ b/src/test/java/unit/spot/portfoliomargin/TestAutoCollection.java @@ -0,0 +1,42 @@ +package unit.spot.portfoliomargin; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestAutoCollection { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFundAutocollection() { + String path = "/sapi/v1/portfolio/auto-collection"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createPortfolioMargin().autoCollection(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/portfoliomargin/TestAutoRepayFuturesStatus.java b/src/test/java/unit/spot/portfoliomargin/TestAutoRepayFuturesStatus.java new file mode 100644 index 00000000..47753aca --- /dev/null +++ b/src/test/java/unit/spot/portfoliomargin/TestAutoRepayFuturesStatus.java @@ -0,0 +1,42 @@ +package unit.spot.portfoliomargin; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestAutoRepayFuturesStatus { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testAutoRepayFuturesStatus() { + String path = "/sapi/v1/portfolio/repay-futures-switch"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createPortfolioMargin().autoRepayFuturesStatus(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/portfoliomargin/TestBnbTransfer.java b/src/test/java/unit/spot/portfoliomargin/TestBnbTransfer.java new file mode 100644 index 00000000..974227c2 --- /dev/null +++ b/src/test/java/unit/spot/portfoliomargin/TestBnbTransfer.java @@ -0,0 +1,58 @@ +package unit.spot.portfoliomargin; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestBnbTransfer { + private MockWebServer mockWebServer; + private String baseUrl; + private final double amount = 1.01; + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testBnbTransferWithoutParameters() { + String path = "/sapi/v1/portfolio/bnb-transfer"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createPortfolioMargin().bnbTransfer(parameters)); + } + + @Test + public void testBnbTransfer() { + String path = "/sapi/v1/portfolio/bnb-transfer?transferSide=TO_UM&amount=1.01"; + Map parameters = new LinkedHashMap<>(); + parameters.put("transferSide", "TO_UM"); + parameters.put("amount", amount); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createPortfolioMargin().bnbTransfer(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/portfoliomargin/TestInterestHistory.java b/src/test/java/unit/spot/portfoliomargin/TestInterestHistory.java new file mode 100644 index 00000000..58f27fc7 --- /dev/null +++ b/src/test/java/unit/spot/portfoliomargin/TestInterestHistory.java @@ -0,0 +1,43 @@ +package unit.spot.portfoliomargin; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestInterestHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testInterestHistory() { + String path = "/sapi/v1/portfolio/interest-history?asset=BTC"; + Map parameters = new LinkedHashMap<>(); + parameters.put("asset", "BTC"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createPortfolioMargin().interestHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/portfoliomargin/TestRepayFutures.java b/src/test/java/unit/spot/portfoliomargin/TestRepayFutures.java new file mode 100644 index 00000000..a1fa4830 --- /dev/null +++ b/src/test/java/unit/spot/portfoliomargin/TestRepayFutures.java @@ -0,0 +1,42 @@ +package unit.spot.portfoliomargin; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestRepayFutures { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testRepayFutures() { + String path = "/sapi/v1/portfolio/repay-futures-negative-balance"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createPortfolioMargin().repayFutures(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/savings/TestPurchaseProject.java b/src/test/java/unit/spot/portfoliomargin/TestSwitchAutoRepayFutures.java similarity index 75% rename from src/test/java/unit/spot/savings/TestPurchaseProject.java rename to src/test/java/unit/spot/portfoliomargin/TestSwitchAutoRepayFutures.java index 128cc9df..3d6ae84c 100644 --- a/src/test/java/unit/spot/savings/TestPurchaseProject.java +++ b/src/test/java/unit/spot/portfoliomargin/TestSwitchAutoRepayFutures.java @@ -1,4 +1,4 @@ -package unit.spot.savings; +package unit.spot.portfoliomargin; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; @@ -19,12 +19,10 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestPurchaseProject { +public class TestSwitchAutoRepayFutures { private MockWebServer mockWebServer; private String baseUrl; - private final long lot = 1L; - @Before public void init() { this.mockWebServer = new MockWebServer(); @@ -32,29 +30,28 @@ public void init() { } @Test - public void testPurchaseProjectWithoutParameters() { - String path = "/sapi/v1/lending/customizedFixed/purchase"; + public void testSwitchAutoRepayFuturesWithoutParameters() { + String path = "/sapi/v1/portfolio/repay-futures-switch"; Map parameters = new LinkedHashMap<>(); Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); mockWebServer.setDispatcher(dispatcher); SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); - assertThrows(BinanceConnectorException.class, () -> client.createSavings().purchaseProject(parameters)); + assertThrows(BinanceConnectorException.class, () -> client.createPortfolioMargin().switchAutoRepayFutures(parameters)); } - + @Test - public void testPurchaseProject() { - String path = "/sapi/v1/lending/customizedFixed/purchase?projectId=123&lot=1"; + public void testSwitchAutoRepayFutures() { + String path = "/sapi/v1/portfolio/repay-futures-switch?autoRepay=true"; Map parameters = new LinkedHashMap<>(); - parameters.put("projectId", "123"); - parameters.put("lot", lot); + parameters.put("autoRepay", true); Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); mockWebServer.setDispatcher(dispatcher); SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); - String result = client.createSavings().purchaseProject(parameters); + String result = client.createPortfolioMargin().switchAutoRepayFutures(parameters); assertEquals(MockData.MOCK_RESPONSE, result); } } diff --git a/src/test/java/unit/spot/simpleearn/TestCollateralRecord.java b/src/test/java/unit/spot/simpleearn/TestCollateralRecord.java new file mode 100644 index 00000000..ba18678e --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestCollateralRecord.java @@ -0,0 +1,43 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestCollateralRecord { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testCollateralRecord() { + String path = "/sapi/v1/simple-earn/flexible/history/collateralRecord"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().collateralRecord(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestFlexiblePersonalLeftQuota.java b/src/test/java/unit/spot/simpleearn/TestFlexiblePersonalLeftQuota.java new file mode 100644 index 00000000..9f8d3fb6 --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestFlexiblePersonalLeftQuota.java @@ -0,0 +1,58 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexiblePersonalLeftQuota { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexiblePersonalLeftQuotaWithoutParameters() { + String path = "/sapi/v1/simple-earn/flexible/personalLeftQuota"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSimpleEarn().flexiblePersonalLeftQuota(parameters)); + } + + @Test + public void testFlexiblePersonalLeftQuota() { + String path = "/sapi/v1/simple-earn/flexible/personalLeftQuota?productId=40607"; + Map parameters = new LinkedHashMap<>(); + parameters.put("productId", "40607"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().flexiblePersonalLeftQuota(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestFlexibleProductList.java b/src/test/java/unit/spot/simpleearn/TestFlexibleProductList.java new file mode 100644 index 00000000..e9660cb1 --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestFlexibleProductList.java @@ -0,0 +1,43 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleProductList { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexibleProductList() { + String path = "/sapi/v1/simple-earn/flexible/list"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().flexibleProductList(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestFlexibleProductPosition.java b/src/test/java/unit/spot/simpleearn/TestFlexibleProductPosition.java new file mode 100644 index 00000000..7949294e --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestFlexibleProductPosition.java @@ -0,0 +1,43 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleProductPosition { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexibleProductPosition() { + String path = "/sapi/v1/simple-earn/flexible/position"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().flexibleProductPosition(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestFlexibleRedemptionRecord.java b/src/test/java/unit/spot/simpleearn/TestFlexibleRedemptionRecord.java new file mode 100644 index 00000000..0fca8583 --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestFlexibleRedemptionRecord.java @@ -0,0 +1,43 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleRedemptionRecord { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexibleRedemptionRecord() { + String path = "/sapi/v1/simple-earn/flexible/history/redemptionRecord"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().flexibleRedemptionRecord(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestFlexibleRewardsHistory.java b/src/test/java/unit/spot/simpleearn/TestFlexibleRewardsHistory.java new file mode 100644 index 00000000..aadff954 --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestFlexibleRewardsHistory.java @@ -0,0 +1,58 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleRewardsHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexibleRewardsHistoryWithoutParameters() { + String path = "/sapi/v1/simple-earn/flexible/history/rewardsRecord"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSimpleEarn().flexibleRewardsHistory(parameters)); + } + + @Test + public void testFlexibleRewardsHistory() { + String path = "/sapi/v1/simple-earn/flexible/history/rewardsRecord?type=BONUS"; + Map parameters = new LinkedHashMap<>(); + parameters.put("type", "BONUS"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().flexibleRewardsHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestFlexibleSubscriptionPreview.java b/src/test/java/unit/spot/simpleearn/TestFlexibleSubscriptionPreview.java new file mode 100644 index 00000000..293e4adf --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestFlexibleSubscriptionPreview.java @@ -0,0 +1,59 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleSubscriptionPreview { + private MockWebServer mockWebServer; + private String baseUrl; + private static final double amount = 1.1; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexibleSubscriptionPreviewWithoutParameters() { + String path = "/sapi/v1/simple-earn/flexible/subscriptionPreview"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSimpleEarn().flexibleSubscriptionPreview(parameters)); + } + + @Test + public void testFlexibleSubscriptionPreview() { + String path = "/sapi/v1/simple-earn/flexible/subscriptionPreview?productId=40607&amount=1.1"; + Map parameters = new LinkedHashMap<>(); + parameters.put("productId", "40607"); + parameters.put("amount", amount); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().flexibleSubscriptionPreview(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestFlexibleSubscriptionRecord.java b/src/test/java/unit/spot/simpleearn/TestFlexibleSubscriptionRecord.java new file mode 100644 index 00000000..41efe999 --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestFlexibleSubscriptionRecord.java @@ -0,0 +1,43 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestFlexibleSubscriptionRecord { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testFlexibleSubscriptionRecord() { + String path = "/sapi/v1/simple-earn/flexible/history/subscriptionRecord"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().flexibleSubscriptionRecord(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestLockedPersonalLeftQuota.java b/src/test/java/unit/spot/simpleearn/TestLockedPersonalLeftQuota.java new file mode 100644 index 00000000..7cff436e --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestLockedPersonalLeftQuota.java @@ -0,0 +1,58 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestLockedPersonalLeftQuota { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testLockedPersonalLeftQuotaWithoutParameters() { + String path = "/sapi/v1/simple-earn/locked/personalLeftQuota"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSimpleEarn().lockedPersonalLeftQuota(parameters)); + } + + @Test + public void testLockedPersonalLeftQuota() { + String path = "/sapi/v1/simple-earn/locked/personalLeftQuota?projectId=USDT001"; + Map parameters = new LinkedHashMap<>(); + parameters.put("projectId", "USDT001"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().lockedPersonalLeftQuota(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestLockedProductList.java b/src/test/java/unit/spot/simpleearn/TestLockedProductList.java new file mode 100644 index 00000000..7a73e49f --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestLockedProductList.java @@ -0,0 +1,43 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestLockedProductList { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSimpleEarnLockedProductList() { + String path = "/sapi/v1/simple-earn/locked/list"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().lockedProductList(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestLockedProductPosition.java b/src/test/java/unit/spot/simpleearn/TestLockedProductPosition.java new file mode 100644 index 00000000..e5ba04d5 --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestLockedProductPosition.java @@ -0,0 +1,43 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestLockedProductPosition { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testLockedProductPosition() { + String path = "/sapi/v1/simple-earn/locked/position"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().lockedProductPosition(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestLockedRedemptionRecord.java b/src/test/java/unit/spot/simpleearn/TestLockedRedemptionRecord.java new file mode 100644 index 00000000..e4b19a4f --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestLockedRedemptionRecord.java @@ -0,0 +1,44 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestLockedRedemptionRecord { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + + @Test + public void testLockedRedemptionRecord() { + String path = "/sapi/v1/simple-earn/locked/history/redemptionRecord"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().lockedRedemptionRecord(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestLockedRewardsHistory.java b/src/test/java/unit/spot/simpleearn/TestLockedRewardsHistory.java new file mode 100644 index 00000000..6bb864db --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestLockedRewardsHistory.java @@ -0,0 +1,43 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestLockedRewardsHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testLockedRewardsHistory() { + String path = "/sapi/v1/simple-earn/locked/history/rewardsRecord"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().lockedRewardsHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestLockedSubscriptionPreview.java b/src/test/java/unit/spot/simpleearn/TestLockedSubscriptionPreview.java new file mode 100644 index 00000000..14d38575 --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestLockedSubscriptionPreview.java @@ -0,0 +1,59 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestLockedSubscriptionPreview { + private MockWebServer mockWebServer; + private String baseUrl; + private static final double amount = 1.1; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testLockedSubscriptionPreviewWithoutParameters() { + String path = "/sapi/v1/simple-earn/locked/subscriptionPreview"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSimpleEarn().lockedSubscriptionPreview(parameters)); + } + + @Test + public void testLockedSubscriptionPreview() { + String path = "/sapi/v1/simple-earn/locked/subscriptionPreview?projectId=USDT001&amount=1.1"; + Map parameters = new LinkedHashMap<>(); + parameters.put("projectId", "USDT001"); + parameters.put("amount", amount); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().lockedSubscriptionPreview(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestLockedSubscriptionRecord.java b/src/test/java/unit/spot/simpleearn/TestLockedSubscriptionRecord.java new file mode 100644 index 00000000..349edc29 --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestLockedSubscriptionRecord.java @@ -0,0 +1,43 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestLockedSubscriptionRecord { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testLockedSubscriptionRecord() { + String path = "/sapi/v1/simple-earn/locked/history/subscriptionRecord"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().lockedSubscriptionRecord(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestRateHistory.java b/src/test/java/unit/spot/simpleearn/TestRateHistory.java new file mode 100644 index 00000000..85e55d63 --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestRateHistory.java @@ -0,0 +1,58 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestRateHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testRateHistoryWithoutParameters() { + String path = "/sapi/v1/simple-earn/flexible/history/rateHistory"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSimpleEarn().rateHistory(parameters)); + } + + @Test + public void testRateHistory() { + String path = "/sapi/v1/simple-earn/flexible/history/rateHistory?productId=40607"; + Map parameters = new LinkedHashMap<>(); + parameters.put("productId", "40607"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().rateHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestRedeemFlexibleProduct.java b/src/test/java/unit/spot/simpleearn/TestRedeemFlexibleProduct.java new file mode 100644 index 00000000..71075530 --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestRedeemFlexibleProduct.java @@ -0,0 +1,58 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestRedeemFlexibleProduct { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testRedeemFlexibleProductWithoutParameters() { + String path = "/sapi/v1/simple-earn/flexible/redeem"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSimpleEarn().redeemFlexibleProduct(parameters)); + } + + @Test + public void testRedeemFlexibleProduct() { + String path = "/sapi/v1/simple-earn/flexible/redeem?productId=40607"; + Map parameters = new LinkedHashMap<>(); + parameters.put("productId", "40607"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().redeemFlexibleProduct(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestRedeemLockedProduct.java b/src/test/java/unit/spot/simpleearn/TestRedeemLockedProduct.java new file mode 100644 index 00000000..37ef4903 --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestRedeemLockedProduct.java @@ -0,0 +1,58 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestRedeemLockedProduct { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testRedeemLockedProductWithoutParameters() { + String path = "/sapi/v1/simple-earn/locked/redeem"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSimpleEarn().redeemLockedProduct(parameters)); + } + + @Test + public void testRedeemLockedProduct() { + String path = "/sapi/v1/simple-earn/locked/redeem?positionId=BUSD001"; + Map parameters = new LinkedHashMap<>(); + parameters.put("positionId", "BUSD001"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().redeemLockedProduct(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestSetFlexibleAutoSubscribe.java b/src/test/java/unit/spot/simpleearn/TestSetFlexibleAutoSubscribe.java new file mode 100644 index 00000000..c1baed0b --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestSetFlexibleAutoSubscribe.java @@ -0,0 +1,58 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSetFlexibleAutoSubscribe { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSetFlexibleAutoSubscribeWithoutParameters() { + String path = "/sapi/v1/simple-earn/flexible/setAutoSubscribe"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSimpleEarn().setFlexibleAutoSubscribe(parameters)); + } + + @Test + public void testSetFlexibleAutoSubscribe() { + String path = "/sapi/v1/simple-earn/flexible/setAutoSubscribe?productId=40607&autoSubscribe=true"; + Map parameters = new LinkedHashMap<>(); + parameters.put("productId", "40607"); + parameters.put("autoSubscribe", true); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().setFlexibleAutoSubscribe(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestSetLockedAutoSubscribe.java b/src/test/java/unit/spot/simpleearn/TestSetLockedAutoSubscribe.java new file mode 100644 index 00000000..3b33438c --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestSetLockedAutoSubscribe.java @@ -0,0 +1,58 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSetLockedAutoSubscribe { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSetLockedAutoSubscribeWithoutParameters() { + String path = "/sapi/v1/simple-earn/locked/setAutoSubscribe"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSimpleEarn().setLockedAutoSubscribe(parameters)); + } + + @Test + public void testSetLockedAutoSubscribe() { + String path = "/sapi/v1/simple-earn/locked/setAutoSubscribe?positionId=BUSD001&autoSubscribe=true"; + Map parameters = new LinkedHashMap<>(); + parameters.put("positionId", "BUSD001"); + parameters.put("autoSubscribe", true); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().setLockedAutoSubscribe(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestSimpleAccount.java b/src/test/java/unit/spot/simpleearn/TestSimpleAccount.java new file mode 100644 index 00000000..92a62105 --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestSimpleAccount.java @@ -0,0 +1,43 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSimpleAccount { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSimpleAccount() { + String path = "/sapi/v1/simple-earn/account"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().simpleAccount(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestSubscribeFlexibleProduct.java b/src/test/java/unit/spot/simpleearn/TestSubscribeFlexibleProduct.java new file mode 100644 index 00000000..1aab610d --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestSubscribeFlexibleProduct.java @@ -0,0 +1,45 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSubscribeFlexibleProduct { + private MockWebServer mockWebServer; + private String baseUrl; + private static final double amount = 1.1; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSubscribeFlexibleProduct() { + String path = "/sapi/v1/simple-earn/flexible/subscribe?productId=40607&amount=1.1"; + Map parameters = new LinkedHashMap<>(); + parameters.put("productId", "40607"); + parameters.put("amount", amount); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().subscribeFlexibleProduct(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/simpleearn/TestSubscribeLockedProduct.java b/src/test/java/unit/spot/simpleearn/TestSubscribeLockedProduct.java new file mode 100644 index 00000000..78db36da --- /dev/null +++ b/src/test/java/unit/spot/simpleearn/TestSubscribeLockedProduct.java @@ -0,0 +1,59 @@ +package unit.spot.simpleearn; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSubscribeLockedProduct { + private MockWebServer mockWebServer; + private String baseUrl; + private static final double amount = 1.1; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSubscribeLockedProductWithoutParameters() { + String path = "/sapi/v1/simple-earn/locked/subscribe"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSimpleEarn().subscribeLockedProduct(parameters)); + } + + @Test + public void testSubscribeLockedProduct() { + String path = "/sapi/v1/simple-earn/locked/subscribe?projectId=40607&amount=1.1"; + Map parameters = new LinkedHashMap<>(); + parameters.put("projectId", "40607"); + parameters.put("amount", amount); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSimpleEarn().subscribeLockedProduct(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/spotalgo/TestCancelOrder.java b/src/test/java/unit/spot/spotalgo/TestCancelOrder.java new file mode 100644 index 00000000..d400486f --- /dev/null +++ b/src/test/java/unit/spot/spotalgo/TestCancelOrder.java @@ -0,0 +1,59 @@ +package unit.spot.spotalgo; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestCancelOrder { + private MockWebServer mockWebServer; + private String baseUrl; + + private static final long algoId = 1; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testCancelOrderWithoutParameters() { + String path = "/sapi/v1/algo/spot/order"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.DELETE, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSpotAlgo().cancelOrder(parameters)); + } + + @Test + public void testCancelOrder() { + String path = "/sapi/v1/algo/spot/order?algoId=1"; + Map parameters = new LinkedHashMap<>(); + parameters.put("algoId", algoId); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.DELETE, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSpotAlgo().cancelOrder(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/spotalgo/TestGetHistoricalOrders.java b/src/test/java/unit/spot/spotalgo/TestGetHistoricalOrders.java new file mode 100644 index 00000000..37df3b4a --- /dev/null +++ b/src/test/java/unit/spot/spotalgo/TestGetHistoricalOrders.java @@ -0,0 +1,45 @@ +package unit.spot.spotalgo; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestGetHistoricalOrders { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testGetHistoricalOrders() { + String path = "/sapi/v1/algo/spot/historicalOrders?symbol=BNBUSDT&side=SELL"; + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + parameters.put("side", "SELL"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSpotAlgo().getHistoricalOrders(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/spotalgo/TestGetOpenTwapOrders.java b/src/test/java/unit/spot/spotalgo/TestGetOpenTwapOrders.java new file mode 100644 index 00000000..8b2f3e5e --- /dev/null +++ b/src/test/java/unit/spot/spotalgo/TestGetOpenTwapOrders.java @@ -0,0 +1,44 @@ +package unit.spot.spotalgo; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestGetOpenTwapOrders { + private MockWebServer mockWebServer; + private String baseUrl; + + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + + @Test + public void testGetOpenOrders() { + String path = "/sapi/v1/algo/spot/openOrders"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSpotAlgo().getOpenOrders(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/spotalgo/TestGetSubOrders.java b/src/test/java/unit/spot/spotalgo/TestGetSubOrders.java new file mode 100644 index 00000000..c6d245c2 --- /dev/null +++ b/src/test/java/unit/spot/spotalgo/TestGetSubOrders.java @@ -0,0 +1,59 @@ +package unit.spot.spotalgo; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestGetSubOrders { + private MockWebServer mockWebServer; + private String baseUrl; + + private static final long algoId = 14511; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testQuerySubOrdersWithoutParameters() { + String path = "/sapi/v1/algo/spot/subOrders"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSpotAlgo().getSubOrders(parameters)); + } + + @Test + public void testQuerySubOrders() { + String path = "/sapi/v1/algo/spot/subOrders?algoId=14511"; + Map parameters = new LinkedHashMap<>(); + parameters.put("algoId", algoId); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSpotAlgo().getSubOrders(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/spotalgo/TestTwapOrder.java b/src/test/java/unit/spot/spotalgo/TestTwapOrder.java new file mode 100644 index 00000000..dbdef637 --- /dev/null +++ b/src/test/java/unit/spot/spotalgo/TestTwapOrder.java @@ -0,0 +1,63 @@ +package unit.spot.spotalgo; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestTwapOrder { + private MockWebServer mockWebServer; + private String baseUrl; + + private static final double quantity = 1; + private static final long duration = 300; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testTwapOrderWithoutParameters() { + String path = "/sapi/v1/algo/spot/newOrderTwap"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createSpotAlgo().twapOrder(parameters)); + } + + @Test + public void testTwapOrder() { + String path = "/sapi/v1/algo/spot/newOrderTwap?symbol=BNBUSDT&side=SELL&quantity=1&duration=300"; + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + parameters.put("side", "SELL"); + parameters.put("quantity", quantity); + parameters.put("duration", duration); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createSpotAlgo().twapOrder(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/staking/TestEthStakingAccount.java b/src/test/java/unit/spot/staking/TestEthStakingAccount.java new file mode 100644 index 00000000..55faff56 --- /dev/null +++ b/src/test/java/unit/spot/staking/TestEthStakingAccount.java @@ -0,0 +1,42 @@ +package unit.spot.staking; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestEthStakingAccount { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testEthStakingQuota() { + String path = "/sapi/v2/eth-staking/account"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createStaking().ethStakingAccount(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/savings/TestProjectPosition.java b/src/test/java/unit/spot/staking/TestEthStakingQuota.java similarity index 80% rename from src/test/java/unit/spot/savings/TestProjectPosition.java rename to src/test/java/unit/spot/staking/TestEthStakingQuota.java index da1f72a8..cd755d1d 100644 --- a/src/test/java/unit/spot/savings/TestProjectPosition.java +++ b/src/test/java/unit/spot/staking/TestEthStakingQuota.java @@ -1,4 +1,4 @@ -package unit.spot.savings; +package unit.spot.staking; import static org.junit.Assert.assertEquals; @@ -17,7 +17,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestProjectPosition { +public class TestEthStakingQuota { private MockWebServer mockWebServer; private String baseUrl; @@ -28,16 +28,15 @@ public void init() { } @Test - public void testProjectPosition() { - String path = "/sapi/v1/lending/project/position/list?asset=BNB"; + public void testEthStakingQuota() { + String path = "/sapi/v1/eth-staking/eth/quota"; Map parameters = new LinkedHashMap<>(); - parameters.put("asset", "BNB"); Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); mockWebServer.setDispatcher(dispatcher); SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); - String result = client.createSavings().projectPosition(parameters); + String result = client.createStaking().ethStakingQuota(parameters); assertEquals(MockData.MOCK_RESPONSE, result); } } diff --git a/src/test/java/unit/spot/staking/TestEthStakingRateHistory.java b/src/test/java/unit/spot/staking/TestEthStakingRateHistory.java new file mode 100644 index 00000000..e557afa6 --- /dev/null +++ b/src/test/java/unit/spot/staking/TestEthStakingRateHistory.java @@ -0,0 +1,42 @@ +package unit.spot.staking; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestEthStakingRateHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testEthStakingRateHistory() { + String path = "/sapi/v1/eth-staking/eth/history/rateHistory"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createStaking().ethStakingRateHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/staking/TestEthStakingRedeemHistory.java b/src/test/java/unit/spot/staking/TestEthStakingRedeemHistory.java new file mode 100644 index 00000000..c5d97f61 --- /dev/null +++ b/src/test/java/unit/spot/staking/TestEthStakingRedeemHistory.java @@ -0,0 +1,42 @@ +package unit.spot.staking; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestEthStakingRedeemHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testEthStakingRedeemHistory() { + String path = "/sapi/v1/eth-staking/eth/history/redemptionHistory"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createStaking().ethStakingRedeemHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/staking/TestEthStakingRewardsHistory.java b/src/test/java/unit/spot/staking/TestEthStakingRewardsHistory.java new file mode 100644 index 00000000..eb8d91a7 --- /dev/null +++ b/src/test/java/unit/spot/staking/TestEthStakingRewardsHistory.java @@ -0,0 +1,42 @@ +package unit.spot.staking; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestEthStakingRewardsHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testEthStakingRewardsHistory() { + String path = "/sapi/v1/eth-staking/eth/history/rewardsHistory"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createStaking().ethStakingRewardsHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/staking/TestEthStakingSubHistory.java b/src/test/java/unit/spot/staking/TestEthStakingSubHistory.java new file mode 100644 index 00000000..62e0bba2 --- /dev/null +++ b/src/test/java/unit/spot/staking/TestEthStakingSubHistory.java @@ -0,0 +1,42 @@ +package unit.spot.staking; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestEthStakingSubHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testEthStakingSubHistory() { + String path = "/sapi/v1/eth-staking/eth/history/stakingHistory"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createStaking().ethStakingSubHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/staking/TestEthStakingWbethRewardHistory.java b/src/test/java/unit/spot/staking/TestEthStakingWbethRewardHistory.java new file mode 100644 index 00000000..8443c479 --- /dev/null +++ b/src/test/java/unit/spot/staking/TestEthStakingWbethRewardHistory.java @@ -0,0 +1,42 @@ +package unit.spot.staking; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestEthStakingWbethRewardHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testEthStakingWbethRewardHistory() { + String path = "/sapi/v1/eth-staking/eth/history/wbethRewardsHistory"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createStaking().ethStakingWbethRewardHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/staking/TestEthStakingWbethUnwrapHistory.java b/src/test/java/unit/spot/staking/TestEthStakingWbethUnwrapHistory.java new file mode 100644 index 00000000..43033e64 --- /dev/null +++ b/src/test/java/unit/spot/staking/TestEthStakingWbethUnwrapHistory.java @@ -0,0 +1,42 @@ +package unit.spot.staking; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestEthStakingWbethUnwrapHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testEthStakingWbethUnwrapHistory() { + String path = "/sapi/v1/eth-staking/wbeth/history/unwrapHistory"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createStaking().ethStakingWbethUnwrapHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/staking/TestEthStakingWbethWrapHistory.java b/src/test/java/unit/spot/staking/TestEthStakingWbethWrapHistory.java new file mode 100644 index 00000000..75c4bc30 --- /dev/null +++ b/src/test/java/unit/spot/staking/TestEthStakingWbethWrapHistory.java @@ -0,0 +1,42 @@ +package unit.spot.staking; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestEthStakingWbethWrapHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testEthStakingWbethWrapHistory() { + String path = "/sapi/v1/eth-staking/wbeth/history/wrapHistory"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createStaking().ethStakingWbethWrapHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/staking/TestRedeemEthStaking.java b/src/test/java/unit/spot/staking/TestRedeemEthStaking.java new file mode 100644 index 00000000..0537ba2c --- /dev/null +++ b/src/test/java/unit/spot/staking/TestRedeemEthStaking.java @@ -0,0 +1,58 @@ +package unit.spot.staking; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestRedeemEthStaking { + private MockWebServer mockWebServer; + private String baseUrl; + private final double amount = 0.01; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testRedeemEthStakingWithoutParameters() { + String path = "/sapi/v1/eth-staking/eth/redeem"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createStaking().redeemEthStaking(parameters)); + } + + @Test + public void testRedeemEthStaking() { + String path = "/sapi/v1/eth-staking/eth/redeem?amount=0.01"; + Map parameters = new LinkedHashMap<>(); + parameters.put("amount", amount); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createStaking().redeemEthStaking(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/staking/TestSubEthStaking.java b/src/test/java/unit/spot/staking/TestSubEthStaking.java new file mode 100644 index 00000000..4a5c30c4 --- /dev/null +++ b/src/test/java/unit/spot/staking/TestSubEthStaking.java @@ -0,0 +1,58 @@ +package unit.spot.staking; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSubEthStaking { + private MockWebServer mockWebServer; + private String baseUrl; + private final double amount = 0.01; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSubEthStakingWithoutParameters() { + String path = "/sapi/v2/eth-staking/eth/stake"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createStaking().subEthStaking(parameters)); + } + + @Test + public void testSubEthStaking() { + String path = "/sapi/v2/eth-staking/eth/stake?amount=0.01"; + Map parameters = new LinkedHashMap<>(); + parameters.put("amount", amount); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createStaking().subEthStaking(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/staking/TestWrapEthStakingWbeth.java b/src/test/java/unit/spot/staking/TestWrapEthStakingWbeth.java new file mode 100644 index 00000000..a81cc087 --- /dev/null +++ b/src/test/java/unit/spot/staking/TestWrapEthStakingWbeth.java @@ -0,0 +1,58 @@ +package unit.spot.staking; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestWrapEthStakingWbeth { + private MockWebServer mockWebServer; + private String baseUrl; + private final double amount = 0.1; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testWrapEthStakingWbethWithoutParameters() { + String path = "/sapi/v1/eth-staking/wbeth/wrap"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createStaking().wrapEthStakingWbeth(parameters)); + } + + @Test + public void testWrapEthStakingWbeth() { + String path = "/sapi/v1/eth-staking/wbeth/wrap?amount=0.1"; + Map parameters = new LinkedHashMap<>(); + parameters.put("amount", amount); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createStaking().wrapEthStakingWbeth(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountStatus.java b/src/test/java/unit/spot/subaccount/TestAccountStatus.java similarity index 97% rename from src/test/java/unit/spot/subaccount/TestSubAccountStatus.java rename to src/test/java/unit/spot/subaccount/TestAccountStatus.java index a6ebb917..b4e234d4 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountStatus.java +++ b/src/test/java/unit/spot/subaccount/TestAccountStatus.java @@ -18,7 +18,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountStatus { +public class TestAccountStatus { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestQuerySubAccountAssets.java b/src/test/java/unit/spot/subaccount/TestAssets.java similarity index 98% rename from src/test/java/unit/spot/subaccount/TestQuerySubAccountAssets.java rename to src/test/java/unit/spot/subaccount/TestAssets.java index 81a5d65f..98ef6073 100644 --- a/src/test/java/unit/spot/subaccount/TestQuerySubAccountAssets.java +++ b/src/test/java/unit/spot/subaccount/TestAssets.java @@ -20,9 +20,10 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestQuerySubAccountAssets { +public class TestAssets { private MockWebServer mockWebServer; private String baseUrl; + @Before public void init() { @@ -41,7 +42,7 @@ public void testAssetsWithoutParameters() { SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); assertThrows(BinanceConnectorException.class, () -> client.createSubAccount().assets(parameters)); } - + @Test public void testAssets() { String path = String.format("/sapi/v3/sub-account/assets?email=%s", diff --git a/src/test/java/unit/spot/subaccount/TestCreateVirtualSubAccount.java b/src/test/java/unit/spot/subaccount/TestCreateVirtualSubAccount.java index 73a79e7b..c550c555 100644 --- a/src/test/java/unit/spot/subaccount/TestCreateVirtualSubAccount.java +++ b/src/test/java/unit/spot/subaccount/TestCreateVirtualSubAccount.java @@ -30,7 +30,7 @@ public void init() { } @Test - public void testCreateSubAccountWithoutString() { + public void testCreateVirtualSubAccountWithoutString() { String path = "/sapi/v1/sub-account/virtualSubAccount"; Map parameters = new LinkedHashMap<>(); @@ -42,7 +42,7 @@ public void testCreateSubAccountWithoutString() { } @Test - public void testCreateSubAccount() { + public void testCreateVirtualSubAccount() { String path = "/sapi/v1/sub-account/virtualSubAccount?subAccountString=sub.account"; Map parameters = new LinkedHashMap<>(); parameters.put("subAccountString", "sub.account"); diff --git a/src/test/java/unit/spot/subaccount/TestDeleteIpList.java b/src/test/java/unit/spot/subaccount/TestDeleteIpList.java index 6ac7e9ae..27f82ae2 100644 --- a/src/test/java/unit/spot/subaccount/TestDeleteIpList.java +++ b/src/test/java/unit/spot/subaccount/TestDeleteIpList.java @@ -44,12 +44,11 @@ public void testDeleteIpListWithoutParameters() { @Test public void testDeleteIpList() { - String path = String.format("/sapi/v1/sub-account/subAccountApi/ipRestriction/ipList?email=%s&subAccountApiKey=abc&ipAddress=1.1.1.1", + String path = String.format("/sapi/v1/sub-account/subAccountApi/ipRestriction/ipList?email=%s&subAccountApiKey=abc", UrlBuilder.urlEncode("alice@test.com")); Map parameters = new LinkedHashMap<>(); parameters.put("email", "alice@test.com"); parameters.put("subAccountApiKey", "abc"); - parameters.put("ipAddress", "1.1.1.1"); Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.DELETE, MockData.HTTP_STATUS_OK); mockWebServer.setDispatcher(dispatcher); diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountDepositAddress.java b/src/test/java/unit/spot/subaccount/TestDepositAddress.java similarity index 94% rename from src/test/java/unit/spot/subaccount/TestSubAccountDepositAddress.java rename to src/test/java/unit/spot/subaccount/TestDepositAddress.java index 57a97c79..6246eb6d 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountDepositAddress.java +++ b/src/test/java/unit/spot/subaccount/TestDepositAddress.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountDepositAddress { +public class TestDepositAddress { private MockWebServer mockWebServer; private String baseUrl; @@ -31,7 +31,7 @@ public void init() { } @Test - public void testDepositAddWithoutParameters() { + public void testDepositAddressWithoutParameters() { String path = "/sapi/v1/capital/deposit/subAddress"; Map parameters = new LinkedHashMap<>(); @@ -43,7 +43,7 @@ public void testDepositAddWithoutParameters() { } @Test - public void testDepositAdd() { + public void testDepositAddress() { String path = String.format("/sapi/v1/capital/deposit/subAddress?email=%s&coin=BNB", UrlBuilder.urlEncode("alice@test.com")); Map parameters = new LinkedHashMap<>(); diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountDepositHistory.java b/src/test/java/unit/spot/subaccount/TestDepositHistory.java similarity index 98% rename from src/test/java/unit/spot/subaccount/TestSubAccountDepositHistory.java rename to src/test/java/unit/spot/subaccount/TestDepositHistory.java index ba20c4e8..8aea33c4 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountDepositHistory.java +++ b/src/test/java/unit/spot/subaccount/TestDepositHistory.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountDepositHistory { +public class TestDepositHistory { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestEnableFuturesSubAccount.java b/src/test/java/unit/spot/subaccount/TestEnableFutures.java similarity index 98% rename from src/test/java/unit/spot/subaccount/TestEnableFuturesSubAccount.java rename to src/test/java/unit/spot/subaccount/TestEnableFutures.java index a545e2f9..90e8f5e0 100644 --- a/src/test/java/unit/spot/subaccount/TestEnableFuturesSubAccount.java +++ b/src/test/java/unit/spot/subaccount/TestEnableFutures.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestEnableFuturesSubAccount { +public class TestEnableFutures { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestEnableMarginSubAccount.java b/src/test/java/unit/spot/subaccount/TestEnableMargin.java similarity index 98% rename from src/test/java/unit/spot/subaccount/TestEnableMarginSubAccount.java rename to src/test/java/unit/spot/subaccount/TestEnableMargin.java index 8c8d343a..26c767ed 100644 --- a/src/test/java/unit/spot/subaccount/TestEnableMarginSubAccount.java +++ b/src/test/java/unit/spot/subaccount/TestEnableMargin.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestEnableMarginSubAccount { +public class TestEnableMargin { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountFuturesAccount.java b/src/test/java/unit/spot/subaccount/TestFuturesAccount.java similarity index 98% rename from src/test/java/unit/spot/subaccount/TestSubAccountFuturesAccount.java rename to src/test/java/unit/spot/subaccount/TestFuturesAccount.java index 243fc8bd..c4c00212 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountFuturesAccount.java +++ b/src/test/java/unit/spot/subaccount/TestFuturesAccount.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountFuturesAccount { +public class TestFuturesAccount { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountFuturesInternalTransfer.java b/src/test/java/unit/spot/subaccount/TestFuturesInternalTransfer.java similarity index 98% rename from src/test/java/unit/spot/subaccount/TestSubAccountFuturesInternalTransfer.java rename to src/test/java/unit/spot/subaccount/TestFuturesInternalTransfer.java index c457b066..4160bc30 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountFuturesInternalTransfer.java +++ b/src/test/java/unit/spot/subaccount/TestFuturesInternalTransfer.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountFuturesInternalTransfer { +public class TestFuturesInternalTransfer { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountPositionRisk.java b/src/test/java/unit/spot/subaccount/TestFuturesPositionRisk.java similarity index 93% rename from src/test/java/unit/spot/subaccount/TestSubAccountPositionRisk.java rename to src/test/java/unit/spot/subaccount/TestFuturesPositionRisk.java index 9c500adc..299cd996 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountPositionRisk.java +++ b/src/test/java/unit/spot/subaccount/TestFuturesPositionRisk.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountPositionRisk { +public class TestFuturesPositionRisk { private MockWebServer mockWebServer; private String baseUrl; @@ -31,7 +31,7 @@ public void init() { } @Test - public void testPositionRiskWithoutParameters() { + public void testFuturesPositionRiskWithoutParameters() { String path = "/sapi/v1/sub-account/futures/positionRisk"; Map parameters = new LinkedHashMap<>(); @@ -43,7 +43,7 @@ public void testPositionRiskWithoutParameters() { } @Test - public void testPositionRisk() { + public void testFuturesPositionRisk() { String path = String.format("/sapi/v1/sub-account/futures/positionRisk?email=%s", UrlBuilder.urlEncode("alice@test.com")); Map parameters = new LinkedHashMap<>(); diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountFuturesSummary.java b/src/test/java/unit/spot/subaccount/TestFuturesSummary.java similarity index 96% rename from src/test/java/unit/spot/subaccount/TestSubAccountFuturesSummary.java rename to src/test/java/unit/spot/subaccount/TestFuturesSummary.java index e760e2c4..bc329d6a 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountFuturesSummary.java +++ b/src/test/java/unit/spot/subaccount/TestFuturesSummary.java @@ -17,7 +17,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountFuturesSummary { +public class TestFuturesSummary { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountFuturesTransfer.java b/src/test/java/unit/spot/subaccount/TestFuturesTransfer.java similarity index 98% rename from src/test/java/unit/spot/subaccount/TestSubAccountFuturesTransfer.java rename to src/test/java/unit/spot/subaccount/TestFuturesTransfer.java index 29c211b2..09097c87 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountFuturesTransfer.java +++ b/src/test/java/unit/spot/subaccount/TestFuturesTransfer.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountFuturesTransfer { +public class TestFuturesTransfer { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestQuerySubAccountFuturesTransfer.java b/src/test/java/unit/spot/subaccount/TestGetFuturesInternalTransfer.java similarity index 94% rename from src/test/java/unit/spot/subaccount/TestQuerySubAccountFuturesTransfer.java rename to src/test/java/unit/spot/subaccount/TestGetFuturesInternalTransfer.java index 99cdf53f..563061f1 100644 --- a/src/test/java/unit/spot/subaccount/TestQuerySubAccountFuturesTransfer.java +++ b/src/test/java/unit/spot/subaccount/TestGetFuturesInternalTransfer.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestQuerySubAccountFuturesTransfer { +public class TestGetFuturesInternalTransfer { private MockWebServer mockWebServer; private String baseUrl; @@ -37,7 +37,7 @@ public void init() { } @Test - public void testFuturesInternalTransferWithoutParameters() { + public void testGetFuturesInternalTransferWithoutParameters() { String path = "/sapi/v1/sub-account/futures/internalTransfer"; Map parameters = new LinkedHashMap<>(); @@ -49,7 +49,7 @@ public void testFuturesInternalTransferWithoutParameters() { } @Test - public void testFuturesInternalTransfer() { + public void testGetFuturesInternalTransfer() { String path = String.format("/sapi/v1/sub-account/futures/internalTransfer?email=%s&futuresType=1&startTime=100001&endTime=100002&page=1&limit=1", UrlBuilder.urlEncode("alice@test.com")); Map parameters = new LinkedHashMap<>(); diff --git a/src/test/java/unit/spot/subaccount/TestMangedSubDeposit.java b/src/test/java/unit/spot/subaccount/TestManagedSubDeposit.java similarity index 98% rename from src/test/java/unit/spot/subaccount/TestMangedSubDeposit.java rename to src/test/java/unit/spot/subaccount/TestManagedSubDeposit.java index ecd89bca..7a71acb6 100644 --- a/src/test/java/unit/spot/subaccount/TestMangedSubDeposit.java +++ b/src/test/java/unit/spot/subaccount/TestManagedSubDeposit.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestMangedSubDeposit { +public class TestManagedSubDeposit { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountMarginAccount.java b/src/test/java/unit/spot/subaccount/TestMarginAccount.java similarity index 98% rename from src/test/java/unit/spot/subaccount/TestSubAccountMarginAccount.java rename to src/test/java/unit/spot/subaccount/TestMarginAccount.java index 5112277a..86c6d048 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountMarginAccount.java +++ b/src/test/java/unit/spot/subaccount/TestMarginAccount.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountMarginAccount { +public class TestMarginAccount { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountMarginSummary.java b/src/test/java/unit/spot/subaccount/TestMarginAccountSummary.java similarity index 96% rename from src/test/java/unit/spot/subaccount/TestSubAccountMarginSummary.java rename to src/test/java/unit/spot/subaccount/TestMarginAccountSummary.java index d7a0f2bc..19baefe2 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountMarginSummary.java +++ b/src/test/java/unit/spot/subaccount/TestMarginAccountSummary.java @@ -17,7 +17,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountMarginSummary { +public class TestMarginAccountSummary { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountMarginTransfer.java b/src/test/java/unit/spot/subaccount/TestMarginTransfer.java similarity index 98% rename from src/test/java/unit/spot/subaccount/TestSubAccountMarginTransfer.java rename to src/test/java/unit/spot/subaccount/TestMarginTransfer.java index 09660ba1..e0dc3662 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountMarginTransfer.java +++ b/src/test/java/unit/spot/subaccount/TestMarginTransfer.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountMarginTransfer { +public class TestMarginTransfer { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestQuerySubAccountSpotSummary.java b/src/test/java/unit/spot/subaccount/TestSpotAccountSummary.java similarity index 95% rename from src/test/java/unit/spot/subaccount/TestQuerySubAccountSpotSummary.java rename to src/test/java/unit/spot/subaccount/TestSpotAccountSummary.java index 6aa4ff0d..3e2ac2d8 100644 --- a/src/test/java/unit/spot/subaccount/TestQuerySubAccountSpotSummary.java +++ b/src/test/java/unit/spot/subaccount/TestSpotAccountSummary.java @@ -18,7 +18,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestQuerySubAccountSpotSummary { +public class TestSpotAccountSummary { private MockWebServer mockWebServer; private String baseUrl; @@ -33,7 +33,7 @@ public void init() { } @Test - public void testSpotSummary() { + public void testSpotAccountSummary() { String path = String.format("/sapi/v1/sub-account/spotSummary?email=%s&page=1&size=1", UrlBuilder.urlEncode("alice@test.com")); Map parameters = new LinkedHashMap<>(); diff --git a/src/test/java/unit/spot/subaccount/TestQuerySubAccountSpotTransfer.java b/src/test/java/unit/spot/subaccount/TestSpotTransferHistory.java similarity index 95% rename from src/test/java/unit/spot/subaccount/TestQuerySubAccountSpotTransfer.java rename to src/test/java/unit/spot/subaccount/TestSpotTransferHistory.java index e71a979e..74b641d2 100644 --- a/src/test/java/unit/spot/subaccount/TestQuerySubAccountSpotTransfer.java +++ b/src/test/java/unit/spot/subaccount/TestSpotTransferHistory.java @@ -18,7 +18,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestQuerySubAccountSpotTransfer { +public class TestSpotTransferHistory { private MockWebServer mockWebServer; private String baseUrl; @@ -35,7 +35,7 @@ public void init() { } @Test - public void testSpotSummary() { + public void testSpotTransferHistory() { String path = String.format("/sapi/v1/sub-account/sub/transfer/history?fromEmail=%s&toEmail=%s&startTime=100001&endTime=100002&page=1&limit=1", UrlBuilder.urlEncode("alice@test.com"), UrlBuilder.urlEncode("bob@test.com")); Map parameters = new LinkedHashMap<>(); diff --git a/src/test/java/unit/spot/subaccount/TestQuerySubAccountList.java b/src/test/java/unit/spot/subaccount/TestSubAccountList.java similarity index 97% rename from src/test/java/unit/spot/subaccount/TestQuerySubAccountList.java rename to src/test/java/unit/spot/subaccount/TestSubAccountList.java index 0fb3735e..b3532e59 100644 --- a/src/test/java/unit/spot/subaccount/TestQuerySubAccountList.java +++ b/src/test/java/unit/spot/subaccount/TestSubAccountList.java @@ -18,7 +18,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestQuerySubAccountList { +public class TestSubAccountList { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountToSub.java b/src/test/java/unit/spot/subaccount/TestSubAccountToSubAccount.java similarity index 98% rename from src/test/java/unit/spot/subaccount/TestSubAccountToSub.java rename to src/test/java/unit/spot/subaccount/TestSubAccountToSubAccount.java index 87d8d198..61369be3 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountToSub.java +++ b/src/test/java/unit/spot/subaccount/TestSubAccountToSubAccount.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountToSub { +public class TestSubAccountToSubAccount { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountTransferHist.java b/src/test/java/unit/spot/subaccount/TestTransferHistory.java similarity index 97% rename from src/test/java/unit/spot/subaccount/TestSubAccountTransferHist.java rename to src/test/java/unit/spot/subaccount/TestTransferHistory.java index 445b7b9f..a0e90044 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountTransferHist.java +++ b/src/test/java/unit/spot/subaccount/TestTransferHistory.java @@ -17,7 +17,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountTransferHist { +public class TestTransferHistory { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/subaccount/TestSubAccountUniversalTransfer.java b/src/test/java/unit/spot/subaccount/TestUniversalTransfer.java similarity index 98% rename from src/test/java/unit/spot/subaccount/TestSubAccountUniversalTransfer.java rename to src/test/java/unit/spot/subaccount/TestUniversalTransfer.java index f3bb1ffe..dbedc8ef 100644 --- a/src/test/java/unit/spot/subaccount/TestSubAccountUniversalTransfer.java +++ b/src/test/java/unit/spot/subaccount/TestUniversalTransfer.java @@ -20,7 +20,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestSubAccountUniversalTransfer { +public class TestUniversalTransfer { private MockWebServer mockWebServer; private String baseUrl; diff --git a/src/test/java/unit/spot/savings/TestProjectList.java b/src/test/java/unit/spot/trade/TestCommission.java similarity index 79% rename from src/test/java/unit/spot/savings/TestProjectList.java rename to src/test/java/unit/spot/trade/TestCommission.java index 1f7888c6..b5c9410e 100644 --- a/src/test/java/unit/spot/savings/TestProjectList.java +++ b/src/test/java/unit/spot/trade/TestCommission.java @@ -1,4 +1,4 @@ -package unit.spot.savings; +package unit.spot.trade; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; @@ -19,7 +19,7 @@ import unit.MockData; import unit.MockWebServerDispatcher; -public class TestProjectList { +public class TestCommission { private MockWebServer mockWebServer; private String baseUrl; @@ -30,28 +30,28 @@ public void init() { } @Test - public void testProjectListWithoutParameters() { - String path = "/sapi/v1/lending/project/list"; + public void testCommissionWithoutParameters() { + String path = "/api/v3/account/commission"; Map parameters = new LinkedHashMap<>(); Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); mockWebServer.setDispatcher(dispatcher); SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); - assertThrows(BinanceConnectorException.class, () -> client.createSavings().projectList(parameters)); + assertThrows(BinanceConnectorException.class, () -> client.createTrade().commission(parameters)); } - + @Test - public void testProjectList() { - String path = "/sapi/v1/lending/project/list?type=ACTIVITY"; + public void testCommission() { + String path = "/api/v3/account/commission?symbol=BNBUSDT"; Map parameters = new LinkedHashMap<>(); - parameters.put("type", "ACTIVITY"); + parameters.put("symbol", "BNBUSDT"); Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); mockWebServer.setDispatcher(dispatcher); SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); - String result = client.createSavings().projectList(parameters); + String result = client.createTrade().commission(parameters); assertEquals(MockData.MOCK_RESPONSE, result); } } diff --git a/src/test/java/unit/spot/trade/TestPreventedMatches.java b/src/test/java/unit/spot/trade/TestPreventedMatches.java new file mode 100644 index 00000000..899c0f27 --- /dev/null +++ b/src/test/java/unit/spot/trade/TestPreventedMatches.java @@ -0,0 +1,57 @@ +package unit.spot.trade; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestPreventedMatches { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testPreventedMatchesWithoutParameters() { + String path = "/api/v3/myPreventedMatches"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createTrade().preventedMatches(parameters)); + } + + @Test + public void testPreventedMatches() { + String path = "/api/v3/myPreventedMatches?symbol=BNBUSDT"; + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createTrade().preventedMatches(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/trade/TestSorAllocations.java b/src/test/java/unit/spot/trade/TestSorAllocations.java new file mode 100644 index 00000000..d448294a --- /dev/null +++ b/src/test/java/unit/spot/trade/TestSorAllocations.java @@ -0,0 +1,57 @@ +package unit.spot.trade; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSorAllocations { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSorAllocationsWithoutParameters() { + String path = "/api/v3/myAllocations"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createTrade().sorAllocations(parameters)); + } + + @Test + public void testSorAllocations() { + String path = "/api/v3/myAllocations?symbol=BNBUSDT"; + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createTrade().sorAllocations(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/trade/TestSorOrder.java b/src/test/java/unit/spot/trade/TestSorOrder.java new file mode 100644 index 00000000..b870d770 --- /dev/null +++ b/src/test/java/unit/spot/trade/TestSorOrder.java @@ -0,0 +1,61 @@ +package unit.spot.trade; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSorOrder { + private MockWebServer mockWebServer; + private String baseUrl; + private final double quantity = 1; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSorOrderWithoutParameters() { + String path = "/api/v3/sor/order"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createTrade().sorOrder(parameters)); + } + + @Test + public void testSorOrder() { + String path = "/api/v3/sor/order?symbol=BNBUSDT&side=SELL&type=LIMIT&quantity=1"; + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + parameters.put("side", "SELL"); + parameters.put("type", "LIMIT"); + parameters.put("quantity", quantity); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createTrade().sorOrder(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/trade/TestTestSorOrder.java b/src/test/java/unit/spot/trade/TestTestSorOrder.java new file mode 100644 index 00000000..61bb41cc --- /dev/null +++ b/src/test/java/unit/spot/trade/TestTestSorOrder.java @@ -0,0 +1,61 @@ +package unit.spot.trade; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestTestSorOrder { + private MockWebServer mockWebServer; + private String baseUrl; + private final double quantity = 1; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testTestSorOrderWithoutParameters() { + String path = "/api/v3/sor/order/test"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createTrade().testSorOrder(parameters)); + } + + @Test + public void testTestSorOrder() { + String path = "/api/v3/sor/order/test?symbol=BNBUSDT&side=SELL&type=LIMIT&quantity=1"; + Map parameters = new LinkedHashMap<>(); + parameters.put("symbol", "BNBUSDT"); + parameters.put("side", "SELL"); + parameters.put("type", "LIMIT"); + parameters.put("quantity", quantity); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createTrade().testSorOrder(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/viploans/TestBorrow.java b/src/test/java/unit/spot/viploans/TestBorrow.java new file mode 100644 index 00000000..94437537 --- /dev/null +++ b/src/test/java/unit/spot/viploans/TestBorrow.java @@ -0,0 +1,65 @@ +package unit.spot.viploans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestBorrow { + private MockWebServer mockWebServer; + private String baseUrl; + + private static final long loanAccountId = 12345678; + private static final double loanAmount = 100.55; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testBorrowWithoutParameters() { + String path = "/sapi/v1/loan/vip/borrow"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createVIPLoans().borrow(parameters)); + } + + @Test + public void testBorrow() { + String path = String.format("/sapi/v1/loan/vip/borrow?loanAccountId=%s&loanAmount=%s&loanCoin=%s&collateralAccountId=%s&collateralCoin=%s&isFlexibleRate=true", loanAccountId, loanAmount, "BTC", "87654321", "BUSD"); + Map parameters = new LinkedHashMap<>(); + parameters.put("loanAccountId", loanAccountId); + parameters.put("loanAmount", loanAmount); + parameters.put("loanCoin", "BTC"); + parameters.put("collateralAccountId", "87654321"); + parameters.put("collateralCoin", "BUSD"); + parameters.put("isFlexibleRate", true); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createVIPLoans().borrow(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/viploans/TestBorrowInterestRate.java b/src/test/java/unit/spot/viploans/TestBorrowInterestRate.java new file mode 100644 index 00000000..82c3b4d4 --- /dev/null +++ b/src/test/java/unit/spot/viploans/TestBorrowInterestRate.java @@ -0,0 +1,58 @@ +package unit.spot.viploans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestBorrowInterestRate { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testBorrowInterestRateWithoutParameters() { + String path = "/sapi/v1/loan/vip/request/interestRate"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createVIPLoans().borrowInterestRate(parameters)); + } + + @Test + public void testBorrowInterestRate() { + String path = "/sapi/v1/loan/vip/request/interestRate?loanCoin=BTC"; + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + + Map parameters = new LinkedHashMap<>(); + parameters.put("loanCoin", "BTC"); + String result = client.createVIPLoans().borrowInterestRate(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/viploans/TestCollateralAccount.java b/src/test/java/unit/spot/viploans/TestCollateralAccount.java new file mode 100644 index 00000000..0eab6d15 --- /dev/null +++ b/src/test/java/unit/spot/viploans/TestCollateralAccount.java @@ -0,0 +1,42 @@ +package unit.spot.viploans; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestCollateralAccount { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testCollateralAccount() { + String path = "/sapi/v1/loan/vip/collateral/account"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createVIPLoans().collateralAccount(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/viploans/TestCollateralAsset.java b/src/test/java/unit/spot/viploans/TestCollateralAsset.java new file mode 100644 index 00000000..5e7b716e --- /dev/null +++ b/src/test/java/unit/spot/viploans/TestCollateralAsset.java @@ -0,0 +1,43 @@ +package unit.spot.viploans; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestCollateralAsset { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testCollateralAsset() { + String path = "/sapi/v1/loan/vip/collateral/data?collateralCoin=BTC"; + Map parameters = new LinkedHashMap<>(); + parameters.put("collateralCoin", "BTC"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createVIPLoans().collateralAsset(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/viploans/TestLoanableAssets.java b/src/test/java/unit/spot/viploans/TestLoanableAssets.java new file mode 100644 index 00000000..5bd6fc8b --- /dev/null +++ b/src/test/java/unit/spot/viploans/TestLoanableAssets.java @@ -0,0 +1,42 @@ +package unit.spot.viploans; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestLoanableAssets { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testLoanableAssets() { + String path = "/sapi/v1/loan/vip/loanable/data"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createVIPLoans().loanableAssets(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/viploans/TestOngoingOrders.java b/src/test/java/unit/spot/viploans/TestOngoingOrders.java new file mode 100644 index 00000000..8cab1dcd --- /dev/null +++ b/src/test/java/unit/spot/viploans/TestOngoingOrders.java @@ -0,0 +1,42 @@ +package unit.spot.viploans; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestOngoingOrders { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testOngoingOrders() { + String path = "/sapi/v1/loan/vip/ongoing/orders"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createVIPLoans().ongoingOrders(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/viploans/TestOrderStatus.java b/src/test/java/unit/spot/viploans/TestOrderStatus.java new file mode 100644 index 00000000..1b15bdd4 --- /dev/null +++ b/src/test/java/unit/spot/viploans/TestOrderStatus.java @@ -0,0 +1,42 @@ +package unit.spot.viploans; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestOrderStatus { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testOrderStatus() { + String path = "/sapi/v1/loan/vip/request/data"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createVIPLoans().orderStatus(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/viploans/TestRenew.java b/src/test/java/unit/spot/viploans/TestRenew.java new file mode 100644 index 00000000..40f2351e --- /dev/null +++ b/src/test/java/unit/spot/viploans/TestRenew.java @@ -0,0 +1,61 @@ +package unit.spot.viploans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestRenew { + private MockWebServer mockWebServer; + private String baseUrl; + + private static final long orderId = 123; + private static final int loanTerm = 30; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testRenewWithoutParameters() { + String path = "/sapi/v1/loan/vip/renew"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createVIPLoans().renew(parameters)); + } + + @Test + public void testRenew() { + String path = String.format("/sapi/v1/loan/vip/renew?orderId=%d", orderId, loanTerm); + System.out.println(path); + Map parameters = new LinkedHashMap<>(); + parameters.put("orderId", orderId); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createVIPLoans().renew(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/viploans/TestRepay.java b/src/test/java/unit/spot/viploans/TestRepay.java new file mode 100644 index 00000000..80902a39 --- /dev/null +++ b/src/test/java/unit/spot/viploans/TestRepay.java @@ -0,0 +1,61 @@ +package unit.spot.viploans; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestRepay { + private MockWebServer mockWebServer; + private String baseUrl; + + private static final long orderId = 12345678; + private static final double amount = 100.55; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testRepayWithoutParameters() { + String path = "/sapi/v1/loan/vip/repay"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createVIPLoans().repay(parameters)); + } + + @Test + public void testRepay() { + String path = "/sapi/v1/loan/vip/repay?orderId=12345678&amount=100.55"; + Map parameters = new LinkedHashMap<>(); + parameters.put("orderId", orderId); + parameters.put("amount", amount); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createVIPLoans().repay(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/viploans/TestRepaymentHistory.java b/src/test/java/unit/spot/viploans/TestRepaymentHistory.java new file mode 100644 index 00000000..27deb343 --- /dev/null +++ b/src/test/java/unit/spot/viploans/TestRepaymentHistory.java @@ -0,0 +1,42 @@ +package unit.spot.viploans; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestRepaymentHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testRepaymentHistory() { + String path = "/sapi/v1/loan/vip/repay/history"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createVIPLoans().repaymentHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/wallet/TestApplyOneClickArrivalDeposit.java b/src/test/java/unit/spot/wallet/TestApplyOneClickArrivalDeposit.java new file mode 100644 index 00000000..a3e66256 --- /dev/null +++ b/src/test/java/unit/spot/wallet/TestApplyOneClickArrivalDeposit.java @@ -0,0 +1,43 @@ +package unit.spot.wallet; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestApplyOneClickArrivalDeposit { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testApplyOneClickArrivalDeposit() { + String path = "/sapi/v1/capital/deposit/credit-apply?txId=123"; + Map parameters = new LinkedHashMap<>(); + parameters.put("txId", "123"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createWallet().applyOneClickArrivalDeposit(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/wallet/TestBusdConvert.java b/src/test/java/unit/spot/wallet/TestBusdConvert.java index a0eed372..3bbb72db 100644 --- a/src/test/java/unit/spot/wallet/TestBusdConvert.java +++ b/src/test/java/unit/spot/wallet/TestBusdConvert.java @@ -25,7 +25,6 @@ public class TestBusdConvert { private String baseUrl; private final BigDecimal amount = new BigDecimal(1); - private final double wrongAmountType = 0.01; @Before public void init() { @@ -33,23 +32,6 @@ public void init() { this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); } - @Test - public void testBusdConverWithWrongParamType() { - String path = "/sapi/v1/asset/convert-transfer"; - Map parameters = new LinkedHashMap<>(); - parameters.put("clientTranId", "118263407119"); - parameters.put("asset", "BUSD"); - parameters.put("amount", wrongAmountType); - parameters.put("targetAsset", "USDC"); - parameters.put("accountType", "MAIN"); - - Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); - mockWebServer.setDispatcher(dispatcher); - - SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); - assertThrows(BinanceConnectorException.class, () -> client.createWallet().busdConvert(parameters)); - } - @Test public void testBusdConverWithoutMandatoryParam() { String path = "/sapi/v1/asset/convert-transfer"; diff --git a/src/test/java/unit/spot/wallet/TestDelegationHistory.java b/src/test/java/unit/spot/wallet/TestDelegationHistory.java new file mode 100644 index 00000000..21166a13 --- /dev/null +++ b/src/test/java/unit/spot/wallet/TestDelegationHistory.java @@ -0,0 +1,64 @@ +package unit.spot.wallet; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; +import com.binance.connector.client.utils.UrlBuilder; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestDelegationHistory { + private MockWebServer mockWebServer; + private String baseUrl; + + private final long startTime = 1695205406000L; + private final long endTime = 1695205396000L; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testDelegationHistoryWithoutParameters() { + String path = "/sapi/v1/asset/custody/transfer-history"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createWallet().delegationHistory(parameters)); + } + + @Test + public void testDelegationHistory() { + String path = String.format("/sapi/v1/asset/custody/transfer-history?email=%s&startTime=%s&endTime=%s", + UrlBuilder.urlEncode("alice@test.com"), startTime, endTime); + Map parameters = new LinkedHashMap<>(); + parameters.put("email", "alice@test.com"); + parameters.put("startTime", startTime); + parameters.put("endTime", endTime); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createWallet().delegationHistory(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/wallet/TestDepositAddresses.java b/src/test/java/unit/spot/wallet/TestDepositAddresses.java new file mode 100644 index 00000000..43ecb815 --- /dev/null +++ b/src/test/java/unit/spot/wallet/TestDepositAddresses.java @@ -0,0 +1,57 @@ +package unit.spot.wallet; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestDepositAddresses { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testDepositAddressesWithoutParameters() { + String path = "/sapi/v1/capital/deposit/address/list"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createWallet().depositAddresses(parameters)); + } + + @Test + public void testDepositAddresses() { + String path = "/sapi/v1/capital/deposit/address/list?coin=BTC"; + Map parameters = new LinkedHashMap<>(); + parameters.put("coin", "BTC"); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createWallet().depositAddresses(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/wallet/TestGetBusdAutoConvertions.java b/src/test/java/unit/spot/wallet/TestGetBusdAutoConvertions.java new file mode 100644 index 00000000..c4d264e2 --- /dev/null +++ b/src/test/java/unit/spot/wallet/TestGetBusdAutoConvertions.java @@ -0,0 +1,40 @@ +package unit.spot.wallet; + +import static org.junit.Assert.assertEquals; + + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestGetBusdAutoConvertions { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + + @Test + public void testGetBusdAutoConvertions() { + String path = "/sapi/v1/capital/contract/convertible-coins"; + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createWallet().getBusdAutoConvertions(); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/wallet/TestSwitchBusdAutoConversion.java b/src/test/java/unit/spot/wallet/TestSwitchBusdAutoConversion.java new file mode 100644 index 00000000..43f0efff --- /dev/null +++ b/src/test/java/unit/spot/wallet/TestSwitchBusdAutoConversion.java @@ -0,0 +1,58 @@ +package unit.spot.wallet; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.exceptions.BinanceConnectorException; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestSwitchBusdAutoConversion { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testSwitchBusdAutoConversionWithoutParameters() { + String path = "/sapi/v1/capital/contract/convertible-coins"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + assertThrows(BinanceConnectorException.class, () -> client.createWallet().switchBusdAutoConversion(parameters)); + } + + @Test + public void testSwitchBusdAutoConversion() { + String path = "/sapi/v1/capital/contract/convertible-coins?coin=USDC&enable=false"; + Map parameters = new LinkedHashMap<>(); + parameters.put("coin", "USDC"); + parameters.put("enable", false); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.POST, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createWallet().switchBusdAutoConversion(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +} diff --git a/src/test/java/unit/spot/wallet/TestWalletBalance.java b/src/test/java/unit/spot/wallet/TestWalletBalance.java new file mode 100644 index 00000000..4e5f90f4 --- /dev/null +++ b/src/test/java/unit/spot/wallet/TestWalletBalance.java @@ -0,0 +1,42 @@ +package unit.spot.wallet; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.binance.connector.client.SpotClient; +import com.binance.connector.client.enums.HttpMethod; +import com.binance.connector.client.impl.SpotClientImpl; + +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockWebServer; +import unit.MockData; +import unit.MockWebServerDispatcher; + +public class TestWalletBalance { + private MockWebServer mockWebServer; + private String baseUrl; + + @Before + public void init() { + this.mockWebServer = new MockWebServer(); + this.baseUrl = mockWebServer.url(MockData.PREFIX).toString(); + } + + @Test + public void testWalletBalance() { + String path = "/sapi/v1/asset/wallet/balance"; + Map parameters = new LinkedHashMap<>(); + + Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK); + mockWebServer.setDispatcher(dispatcher); + + SpotClient client = new SpotClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl); + String result = client.createWallet().walletBalance(parameters); + assertEquals(MockData.MOCK_RESPONSE, result); + } +}