Search in sources :

Example 1 with GeminiException

use of org.knowm.xchange.gemini.v1.dto.GeminiException in project XChange by knowm.

the class GeminiAccountServiceRaw method getGeminiAccountInfo.

public GeminiBalancesResponse[] getGeminiAccountInfo() throws IOException {
    try {
        GeminiBalancesRequest request = new GeminiBalancesRequest(String.valueOf(exchange.getNonceFactory().createValue()));
        GeminiBalancesResponse[] balances = gemini.balances(apiKey, payloadCreator, signatureCreator, request);
        return balances;
    } catch (GeminiException e) {
        throw handleException(e);
    }
}
Also used : GeminiBalancesRequest(org.knowm.xchange.gemini.v1.dto.account.GeminiBalancesRequest) GeminiBalancesResponse(org.knowm.xchange.gemini.v1.dto.account.GeminiBalancesResponse) GeminiException(org.knowm.xchange.gemini.v1.dto.GeminiException)

Example 2 with GeminiException

use of org.knowm.xchange.gemini.v1.dto.GeminiException in project XChange by knowm.

the class GeminiAccountServiceRaw method Get30DayTrailingVolumeDescription.

public GeminiTrailingVolumeResponse Get30DayTrailingVolumeDescription() throws IOException {
    try {
        GeminiTrailingVolumeRequest request = new GeminiTrailingVolumeRequest(String.valueOf(exchange.getNonceFactory().createValue()));
        GeminiTrailingVolumeResponse trailingVolResp = gemini.TrailingVolume(apiKey, payloadCreator, signatureCreator, request);
        return trailingVolResp;
    } catch (GeminiException e) {
        throw handleException(e);
    }
}
Also used : GeminiTrailingVolumeResponse(org.knowm.xchange.gemini.v1.dto.account.GeminiTrailingVolumeResponse) GeminiTrailingVolumeRequest(org.knowm.xchange.gemini.v1.dto.account.GeminiTrailingVolumeRequest) GeminiException(org.knowm.xchange.gemini.v1.dto.GeminiException)

Example 3 with GeminiException

use of org.knowm.xchange.gemini.v1.dto.GeminiException in project XChange by knowm.

the class GeminiAccountServiceRaw method withdraw.

public String withdraw(Currency currency, BigDecimal amount, String address) throws IOException {
    try {
        String ccy = convertToGeminiCcyName(currency.getCurrencyCode());
        GeminiWithdrawalRequest request = new GeminiWithdrawalRequest(String.valueOf(exchange.getNonceFactory().createValue()), ccy, amount, address);
        GeminiWithdrawalResponse withdrawRepsonse = gemini.withdraw(apiKey, payloadCreator, signatureCreator, ccy, request);
        return withdrawRepsonse.txHash;
    } catch (GeminiException e) {
        throw handleException(e);
    }
}
Also used : GeminiWithdrawalResponse(org.knowm.xchange.gemini.v1.dto.account.GeminiWithdrawalResponse) GeminiWithdrawalRequest(org.knowm.xchange.gemini.v1.dto.account.GeminiWithdrawalRequest) GeminiException(org.knowm.xchange.gemini.v1.dto.GeminiException)

Example 4 with GeminiException

use of org.knowm.xchange.gemini.v1.dto.GeminiException in project XChange by knowm.

the class GeminiTradeServiceRaw method placeGeminiLimitOrder.

public GeminiOrderStatusResponse placeGeminiLimitOrder(LimitOrder limitOrder, GeminiOrderType GeminiOrderType) throws IOException {
    String pair = GeminiUtils.toPairString(limitOrder.getCurrencyPair());
    String type = limitOrder.getType().equals(Order.OrderType.BID) ? "buy" : "sell";
    String orderType = GeminiOrderType.toString();
    Set<IOrderFlags> flags = limitOrder.getOrderFlags();
    Object[] options;
    if (flags.isEmpty()) {
        options = null;
    } else {
        ArrayList<String> list = new ArrayList<String>();
        if (flags.contains(GeminiOrderFlags.IMMEDIATE_OR_CANCEL)) {
            list.add("immediate-or-cancel");
        }
        if (flags.contains(GeminiOrderFlags.POST_ONLY)) {
            list.add("maker-or-cancel");
        }
        if (flags.contains(GeminiOrderFlags.FILL_OR_KILL)) {
            list.add("fill-or-kill");
        }
        if (flags.contains(GeminiOrderFlags.AUCTION_ONLY)) {
            list.add("auction-only");
        }
        if (flags.contains(GeminiOrderFlags.INDICATION_OF_INTEREST)) {
            list.add("indication-of-interest");
        }
        options = list.toArray();
    }
    GeminiNewOrderRequest request = new GeminiNewOrderRequest(String.valueOf(exchange.getNonceFactory().createValue()), limitOrder.getUserReference(), pair, limitOrder.getOriginalAmount(), limitOrder.getLimitPrice(), "Gemini", type, orderType, options);
    try {
        GeminiOrderStatusResponse newOrder = gemini.newOrder(apiKey, payloadCreator, signatureCreator, request);
        return newOrder;
    } catch (GeminiException e) {
        throw handleException(e);
    }
}
Also used : IOrderFlags(org.knowm.xchange.dto.Order.IOrderFlags) ArrayList(java.util.ArrayList) GeminiOrderStatusResponse(org.knowm.xchange.gemini.v1.dto.trade.GeminiOrderStatusResponse) GeminiException(org.knowm.xchange.gemini.v1.dto.GeminiException) GeminiNewOrderRequest(org.knowm.xchange.gemini.v1.dto.trade.GeminiNewOrderRequest)

Example 5 with GeminiException

use of org.knowm.xchange.gemini.v1.dto.GeminiException in project XChange by knowm.

the class GeminiAccountServiceRaw method requestDepositAddressRaw.

public GeminiDepositAddressResponse requestDepositAddressRaw(Currency currency) throws IOException {
    try {
        String ccy = convertToGeminiCcyName(currency.getCurrencyCode());
        GeminiDepositAddressRequest exchange = new GeminiDepositAddressRequest(String.valueOf(this.exchange.getNonceFactory().createValue()), ccy, null);
        GeminiDepositAddressResponse requestDepositAddressResponse = gemini.requestNewAddress(apiKey, payloadCreator, signatureCreator, ccy, exchange);
        if (requestDepositAddressResponse != null) {
            return requestDepositAddressResponse;
        } else {
            return null;
        }
    } catch (GeminiException e) {
        throw handleException(e);
    }
}
Also used : GeminiDepositAddressResponse(org.knowm.xchange.gemini.v1.dto.account.GeminiDepositAddressResponse) GeminiDepositAddressRequest(org.knowm.xchange.gemini.v1.dto.account.GeminiDepositAddressRequest) GeminiException(org.knowm.xchange.gemini.v1.dto.GeminiException)

Aggregations

GeminiException (org.knowm.xchange.gemini.v1.dto.GeminiException)5 ArrayList (java.util.ArrayList)1 IOrderFlags (org.knowm.xchange.dto.Order.IOrderFlags)1 GeminiBalancesRequest (org.knowm.xchange.gemini.v1.dto.account.GeminiBalancesRequest)1 GeminiBalancesResponse (org.knowm.xchange.gemini.v1.dto.account.GeminiBalancesResponse)1 GeminiDepositAddressRequest (org.knowm.xchange.gemini.v1.dto.account.GeminiDepositAddressRequest)1 GeminiDepositAddressResponse (org.knowm.xchange.gemini.v1.dto.account.GeminiDepositAddressResponse)1 GeminiTrailingVolumeRequest (org.knowm.xchange.gemini.v1.dto.account.GeminiTrailingVolumeRequest)1 GeminiTrailingVolumeResponse (org.knowm.xchange.gemini.v1.dto.account.GeminiTrailingVolumeResponse)1 GeminiWithdrawalRequest (org.knowm.xchange.gemini.v1.dto.account.GeminiWithdrawalRequest)1 GeminiWithdrawalResponse (org.knowm.xchange.gemini.v1.dto.account.GeminiWithdrawalResponse)1 GeminiNewOrderRequest (org.knowm.xchange.gemini.v1.dto.trade.GeminiNewOrderRequest)1 GeminiOrderStatusResponse (org.knowm.xchange.gemini.v1.dto.trade.GeminiOrderStatusResponse)1