-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BPUB-204 poloniex exchange integration
- Loading branch information
Showing
7 changed files
with
196 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...eneralbytes/batm/server/extensions/extra/bitcoin/exchanges/poloniex/PoloniexExchange.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/************************************************************************************* | ||
* Copyright (C) 2014-2021 GENERAL BYTES s.r.o. All rights reserved. | ||
* | ||
* This software may be distributed and modified under the terms of the GNU | ||
* General Public License version 2 (GPL2) as published by the Free Software | ||
* Foundation and appearing in the file GPL2.TXT included in the packaging of | ||
* this file. Please note that GPL2 Section 2[b] requires that all works based | ||
* on this software must also be made publicly available under the terms of | ||
* the GPL2 ("Copyleft"). | ||
* | ||
* Contact information | ||
* ------------------- | ||
* | ||
* GENERAL BYTES s.r.o. | ||
* Web : http://www.generalbytes.com | ||
* | ||
************************************************************************************/ | ||
package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.poloniex; | ||
|
||
import com.generalbytes.batm.common.currencies.CryptoCurrency; | ||
import com.generalbytes.batm.common.currencies.FiatCurrency; | ||
import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.XChangeExchange; | ||
import org.knowm.xchange.ExchangeSpecification; | ||
import org.knowm.xchange.dto.account.AccountInfo; | ||
import org.knowm.xchange.dto.account.Wallet; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class PoloniexExchange extends XChangeExchange { | ||
|
||
public PoloniexExchange(String preferredFiatCurrency) { | ||
super(getDefaultSpecification(), preferredFiatCurrency); | ||
} | ||
|
||
public PoloniexExchange(String key, String secret, String preferredFiatCurrency) { | ||
super(getSpecification(key, secret), preferredFiatCurrency); | ||
} | ||
|
||
private static ExchangeSpecification getDefaultSpecification() { | ||
return new org.knowm.xchange.poloniex.PoloniexExchange().getDefaultExchangeSpecification(); | ||
} | ||
|
||
private static ExchangeSpecification getSpecification(String key, String secret) { | ||
ExchangeSpecification spec = getDefaultSpecification(); | ||
spec.setApiKey(key); | ||
spec.setSecretKey(secret); | ||
return spec; | ||
} | ||
|
||
@Override | ||
public Set<String> getCryptoCurrencies() { | ||
Set<String> cryptoCurrencies = new HashSet<>(); | ||
cryptoCurrencies.add(CryptoCurrency.BCH.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.BTC.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.BURST.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.ETH.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.LTC.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.DASH.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.DAI.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.DGB.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.DOGE.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.LSK.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.NXT.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.POT.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.REP.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.SYS.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.VIA.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.XMR.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.XRP.getCode()); | ||
cryptoCurrencies.add(CryptoCurrency.XPM.getCode()); | ||
return cryptoCurrencies; | ||
} | ||
|
||
@Override | ||
public Set<String> getFiatCurrencies() { | ||
Set<String> fiatCurrencies = new HashSet<>(); | ||
fiatCurrencies.add(FiatCurrency.USD.getCode()); | ||
return fiatCurrencies; | ||
} | ||
|
||
@Override | ||
protected boolean isWithdrawSuccessful(String result) { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected double getAllowedCallsPerSecond() { | ||
return 10; | ||
} | ||
|
||
@Override | ||
public Wallet getWallet(AccountInfo accountInfo, String currency) { | ||
return accountInfo.getWallet(); | ||
} | ||
|
||
@Override | ||
protected String translateFiatCurrencySymbolToExchangeSpecificSymbol(String currency) { | ||
if (FiatCurrency.USD.getCode().equalsIgnoreCase(currency)) { | ||
return "USDT"; | ||
} | ||
return currency; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters