Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] - Account Information V3 #48

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,25 @@ public String accountInformation(LinkedHashMap<String, Object> parameters) {
return getRequestHandler().sendSignedRequest(getProductUrl(), ACCOUNT_INFORMATION, parameters, HttpMethod.GET, getShowLimitUsage());
}

private final String ACCOUNT_INFORMATION_V3 = "/v3/account";
/**
* Get current account information. User in single-asset/ multi-assets mode will see different value, see comments in response section for detail.
* <br><br>
* GET /v3/account
* <br>
* @param
* parameters LinkedHashedMap of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
* <br><br>
* recvWindow -- optional/long <br>
* @return String
* @see <a href="https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V3">
* https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V3</a>
*/
public String accountInformationV3(LinkedHashMap<String, Object> parameters) {
return getRequestHandler().sendSignedRequest(getProductUrl(), ACCOUNT_INFORMATION_V3, parameters, HttpMethod.GET, getShowLimitUsage());
}

private final String POSITION_RISK = "/v2/positionRisk";
/**
* Get current position information.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package examples.um_futures.account;

import com.binance.connector.futures.client.exceptions.BinanceClientException;
import com.binance.connector.futures.client.exceptions.BinanceConnectorException;
import com.binance.connector.futures.client.impl.UMFuturesClientImpl;
import examples.PrivateConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.LinkedHashMap;

public final class AccountInformationV3 {
private AccountInformationV3() {
}

private static final Logger logger = LoggerFactory.getLogger(AccountInformationV3.class);
public static void main(String[] args) {
LinkedHashMap<String, Object> parameters = new LinkedHashMap<>();

UMFuturesClientImpl client = new UMFuturesClientImpl(PrivateConfig.TESTNET_API_KEY, PrivateConfig.TESTNET_SECRET_KEY, PrivateConfig.TESTNET_BASE_URL);

try {
String result = client.account().accountInformationV3(parameters);
logger.info(result);
} catch (BinanceConnectorException e) {
logger.error("fullErrMessage: {}", e.getMessage(), e);
} catch (BinanceClientException e) {
logger.error("fullErrMessage: {} \nerrMessage: {} \nerrCode: {} \nHTTPStatusCode: {}",
e.getMessage(), e.getErrMsg(), e.getErrorCode(), e.getHttpStatusCode(), e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package unit.um_futures.account;

import com.binance.connector.futures.client.enums.HttpMethod;
import com.binance.connector.futures.client.impl.UMFuturesClientImpl;
import okhttp3.mockwebserver.Dispatcher;
import okhttp3.mockwebserver.MockWebServer;
import org.junit.Before;
import org.junit.Test;
import unit.MockData;
import unit.MockWebServerDispatcher;
import java.util.LinkedHashMap;
import static org.junit.Assert.assertEquals;

public class TestUMAccountInformationV3 {
private MockWebServer mockWebServer;
private String baseUrl;

@Before
public void init() {
this.mockWebServer = new MockWebServer();
this.baseUrl = mockWebServer.url(MockData.PREFIX).toString();
}

@Test
public void testAccountInformation() {
String path = "fapi/v3/account";
LinkedHashMap<String, Object> parameters = new LinkedHashMap<>();
Dispatcher dispatcher = MockWebServerDispatcher.getDispatcher(MockData.PREFIX, path, MockData.MOCK_RESPONSE, HttpMethod.GET, MockData.HTTP_STATUS_OK);
mockWebServer.setDispatcher(dispatcher);

UMFuturesClientImpl client = new UMFuturesClientImpl(MockData.API_KEY, MockData.SECRET_KEY, baseUrl);
String result = client.account().accountInformationV3(parameters);
assertEquals(MockData.MOCK_RESPONSE, result);
}
}