├── archetype ├── src │ └── main │ │ └── resources │ │ ├── archetype-resources │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── at.outdated.bitcoin.exchange.api.Market │ │ └── pom.xml │ │ └── META-INF │ │ └── archetype.xml └── pom.xml ├── btc-e ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── at.outdated.bitcoin.exchange.api.market.Market │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ └── btce │ │ ├── InfoResponse.java │ │ ├── TickerResponse.java │ │ ├── BtcEAccountInfo.java │ │ ├── BtceFunds.java │ │ ├── BtceTrade.java │ │ ├── BtcETickerValue.java │ │ └── BtcEMarket.java └── pom.xml ├── bter ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── at.outdated.bitcoin.exchange.api.market.Market │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ └── bter │ │ ├── BterTradeHistory.java │ │ ├── BterAccountInfo.java │ │ ├── BterResult.java │ │ ├── BterTrade.java │ │ ├── BterTicker.java │ │ └── BterMarket.java └── pom.xml ├── icbit ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── at.outdated.bitcoin.exchange.api.market.Market │ │ └── java │ │ │ └── at │ │ │ └── outdated │ │ │ └── bitcoin │ │ │ └── exchange │ │ │ └── icbit │ │ │ ├── IcbitMarket.java │ │ │ └── IcbitWebsocketClient.java │ └── test │ │ └── java │ │ └── IcbitTest.java └── pom.xml ├── kraken ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── at.outdated.bitcoin.exchange.api.market.Market │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ └── kraken │ │ ├── jaxb │ │ ├── KrakenOpenOrderResult.java │ │ ├── KrakenResponse.java │ │ ├── KrakenTickerResponse.java │ │ ├── TickerResponseResult.java │ │ ├── KrakenOrderCancelResult.java │ │ ├── KrakenDepthValue.java │ │ └── KrakenTickerValue.java │ │ ├── KrakenAccountInfo.java │ │ ├── KrakenJsonResolver.java │ │ └── KrakenMarket.java ├── pom.xml └── kraken.iml ├── mtgox ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── at.outdated.bitcoin.exchange.api.market.Market │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ └── mtgox │ │ ├── ResponseData.java │ │ ├── ResponseResult.java │ │ ├── ApiDepthResponse.java │ │ ├── OrderDeletion.java │ │ ├── MtgoxOrderPlaced.java │ │ ├── ApiTickerResponse.java │ │ ├── ApiResponse.java │ │ ├── ApiWalletHistory.java │ │ ├── ApiTradesResponse.java │ │ ├── OrderDeletionResult.java │ │ ├── ApiLagResponse.java │ │ ├── ApiAccountInfo.java │ │ ├── MtGoxOrderList.java │ │ ├── auth │ │ ├── Nonce.java │ │ └── RequestAuth.java │ │ ├── LagResponse.java │ │ ├── DepthResponse.java │ │ ├── DepthEntry.java │ │ ├── MtGoxWalletHistory.java │ │ ├── MtGoxMarket.java │ │ ├── MtGoxWallets.java │ │ ├── MtGoxWallet.java │ │ ├── MtGoxTrade.java │ │ └── MtGoxOrder.java └── pom.xml ├── coins-e ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── at.outdated.bitcoin.exchange.api.market.Market │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ └── coinse │ │ ├── CoinseAccountInfo.java │ │ ├── jaxb │ │ ├── SingleOrder.java │ │ ├── DepositAddress.java │ │ ├── BaseResponse.java │ │ └── ListOrders.java │ │ └── CoinseMarket.java └── pom.xml ├── cryptsy ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── at.outdated.bitcoin.exchange.api.market.Market │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ └── cryptsy │ │ ├── MarketTradesResult.java │ │ ├── CryptsyResult.java │ │ ├── CryptsyAccountInfo.java │ │ └── CryptsyTrade.java └── pom.xml ├── bitcurex ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── at.outdated.bitcoin.exchange.api.market.Market │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ └── bitcurex │ │ ├── jaxb │ │ ├── BitcurexTransaction.java │ │ ├── BaseApiResponse.java │ │ ├── BitcurexTransactionType.java │ │ ├── BitcurexOrderTypeAdapter.java │ │ ├── Funds.java │ │ ├── Orders.java │ │ ├── BitcurexOrder.java │ │ └── BitcurexTickerValue.java │ │ └── BitcurexMarket.java └── pom.xml ├── bitkonan ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── at.outdated.bitcoin.exchange.api.market.Market │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ └── bitkonan │ │ ├── BitkonanAccountInfo.java │ │ ├── BitkonanOrderTypeAdapter.java │ │ ├── BitkonanBalance.java │ │ ├── BitkonanMarket.java │ │ ├── BitkonanTickerValue.java │ │ └── BitkonanOrder.java └── pom.xml ├── bitstamp ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── at.outdated.bitcoin.exchange.api.market.Market │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ └── bitstamp │ │ ├── OrderDeletion.java │ │ ├── BitstampAddress.java │ │ ├── BitstampAccountInfo.java │ │ ├── BitstampOrderTypeAdapter.java │ │ ├── BitstampMarketDepth.java │ │ ├── BitstampOrder.java │ │ ├── BitstampMarket.java │ │ ├── BitstampTickerValue.java │ │ └── BitstampAccountBalance.java └── pom.xml ├── vircurex ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── at.outdated.bitcoin.exchange.api.market.Market │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ └── vircurex │ │ ├── VircurexAccountInfo.java │ │ ├── VircurexTrade.java │ │ └── VircurexTicker.java └── pom.xml ├── btcde ├── src │ ├── main │ │ └── java │ │ │ └── at │ │ │ └── outdated │ │ │ └── bitcoin │ │ │ └── exchange │ │ │ └── App.java │ └── test │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ └── AppTest.java └── pom.xml ├── api ├── src │ └── main │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ └── api │ │ ├── market │ │ ├── transfer │ │ │ ├── TransferType.java │ │ │ └── TransferMethod.java │ │ ├── MarketParameter.java │ │ ├── fee │ │ │ ├── ZeroFee.java │ │ │ ├── InfiniteFee.java │ │ │ ├── Fee.java │ │ │ ├── SimplePercentageFee.java │ │ │ └── ConstantFee.java │ │ ├── MarketContainer.java │ │ ├── TimedValue.java │ │ ├── OrderType.java │ │ ├── OrderComparator.java │ │ ├── Markets.java │ │ ├── ExchangeRateCalculator.java │ │ ├── AssetPair.java │ │ └── MarketOrder.java │ │ ├── track │ │ ├── NumberTrackCollection.java │ │ ├── NumberTrack.java │ │ ├── TrackInterval.java │ │ ├── ValueTrackCollection.java │ │ ├── TickerValueTrack.java │ │ ├── TickerTrackCollection.java │ │ └── ValueTrack.java │ │ ├── account │ │ ├── WalletTransactionTimestampComparator.java │ │ ├── TransactionType.java │ │ ├── WalletTransaction.java │ │ └── AccountInfo.java │ │ ├── container │ │ ├── CurrencyContainer.java │ │ ├── MarketAssetContainer.java │ │ └── EnumContainer.java │ │ ├── performance │ │ ├── BalanceComparator.java │ │ ├── PercentComparator.java │ │ ├── AbsoluteComparator.java │ │ ├── Performance.java │ │ └── CurrencyPerformance.java │ │ ├── jaxb │ │ ├── CurrencyAdapter.java │ │ ├── UnixTimeDateAdapter.java │ │ ├── UnixTimeMicroDateAdapter.java │ │ ├── JsonEnforcingFilter.java │ │ ├── StringNumberAdapter.java │ │ ├── DateIso8601SpacedAdapter.java │ │ ├── DateIso8601Adapter.java │ │ ├── OrderTypeAdapter.java │ │ ├── StringBigDecimalAdapter.java │ │ └── NestedArrayAdapter.java │ │ ├── client │ │ ├── MarketClient.java │ │ └── TradeClient.java │ │ ├── OrderId.java │ │ └── currency │ │ ├── CurrencyAddress.java │ │ └── Currency.java ├── pom.xml └── api.iml ├── .gitignore ├── tests ├── src │ └── test │ │ └── java │ │ └── at │ │ └── outdated │ │ └── bitcoin │ │ └── exchange │ │ ├── TestMarketDiscovery.java │ │ ├── TickerTest.java │ │ └── AccountInfoTest.java └── pom.xml ├── campbx └── pom.xml ├── bitcoin-exchange.properties.example └── LICENSE /archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/services/at.outdated.bitcoin.exchange.api.Market: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /btc-e/src/main/resources/META-INF/services/at.outdated.bitcoin.exchange.api.market.Market: -------------------------------------------------------------------------------- 1 | at.outdated.bitcoin.exchange.btce.BtcEMarket 2 | -------------------------------------------------------------------------------- /bter/src/main/resources/META-INF/services/at.outdated.bitcoin.exchange.api.market.Market: -------------------------------------------------------------------------------- 1 | at.outdated.bitcoin.exchange.bter.BterMarket 2 | -------------------------------------------------------------------------------- /icbit/src/main/resources/META-INF/services/at.outdated.bitcoin.exchange.api.market.Market: -------------------------------------------------------------------------------- 1 | at.outdated.bitcoin.exchange.icbit.IcbitMarket 2 | -------------------------------------------------------------------------------- /kraken/src/main/resources/META-INF/services/at.outdated.bitcoin.exchange.api.market.Market: -------------------------------------------------------------------------------- 1 | at.outdated.bitcoin.exchange.kraken.KrakenMarket 2 | -------------------------------------------------------------------------------- /mtgox/src/main/resources/META-INF/services/at.outdated.bitcoin.exchange.api.market.Market: -------------------------------------------------------------------------------- 1 | at.outdated.bitcoin.exchange.mtgox.MtGoxMarket 2 | -------------------------------------------------------------------------------- /coins-e/src/main/resources/META-INF/services/at.outdated.bitcoin.exchange.api.market.Market: -------------------------------------------------------------------------------- 1 | at.outdated.bitcoin.exchange.coinse.CoinseMarket 2 | -------------------------------------------------------------------------------- /cryptsy/src/main/resources/META-INF/services/at.outdated.bitcoin.exchange.api.market.Market: -------------------------------------------------------------------------------- 1 | at.outdated.bitcoin.exchange.cryptsy.CryptsyMarket 2 | -------------------------------------------------------------------------------- /bitcurex/src/main/resources/META-INF/services/at.outdated.bitcoin.exchange.api.market.Market: -------------------------------------------------------------------------------- 1 | at.outdated.bitcoin.exchange.bitcurex.BitcurexMarket 2 | -------------------------------------------------------------------------------- /bitkonan/src/main/resources/META-INF/services/at.outdated.bitcoin.exchange.api.market.Market: -------------------------------------------------------------------------------- 1 | at.outdated.bitcoin.exchange.bitkonan.BitkonanMarket 2 | -------------------------------------------------------------------------------- /bitstamp/src/main/resources/META-INF/services/at.outdated.bitcoin.exchange.api.market.Market: -------------------------------------------------------------------------------- 1 | at.outdated.bitcoin.exchange.bitstamp.BitstampMarket 2 | -------------------------------------------------------------------------------- /vircurex/src/main/resources/META-INF/services/at.outdated.bitcoin.exchange.api.market.Market: -------------------------------------------------------------------------------- 1 | at.outdated.bitcoin.exchange.vircurex.VircurexMarket 2 | -------------------------------------------------------------------------------- /bitcurex/src/main/java/at/outdated/bitcoin/exchange/bitcurex/jaxb/BitcurexTransaction.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitcurex.jaxb; 2 | 3 | /** 4 | * Created by ebirn on 20.10.13. 5 | */ 6 | public class BitcurexTransaction { 7 | 8 | 9 | } 10 | -------------------------------------------------------------------------------- /btcde/src/main/java/at/outdated/bitcoin/exchange/App.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange; 2 | 3 | /** 4 | * Hello world! 5 | * 6 | */ 7 | public class App 8 | { 9 | public static void main( String[] args ) 10 | { 11 | System.out.println( "Hello World!" ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/transfer/TransferType.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market.transfer; 2 | 3 | /** 4 | * Created by ebirn on 12.10.13. 5 | */ 6 | public enum TransferType { 7 | BANK, 8 | VIRTUAL, 9 | TRADE, 10 | OTHER 11 | 12 | } 13 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/ResponseData.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | /** 4 | * Created with IntelliJ IDEA. 5 | * User: ebirn 6 | * Date: 02.05.13 7 | * Time: 20:12 8 | * To change this template use File | Settings | File Templates. 9 | */ 10 | public interface ResponseData { 11 | } 12 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/ResponseResult.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | /** 4 | * Created with IntelliJ IDEA. 5 | * User: ebirn 6 | * Date: 02.05.13 7 | * Time: 20:12 8 | * To change this template use File | Settings | File Templates. 9 | */ 10 | public enum ResponseResult { 11 | SUCCESS, 12 | FAILURE 13 | } 14 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/ApiDepthResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | 5 | /** 6 | * Created by ebirn on 03.10.13. 7 | */ 8 | public class ApiDepthResponse extends ApiResponse { 9 | 10 | 11 | @XmlElement 12 | protected DepthResponse data; 13 | 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/MarketParameter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market; 2 | 3 | /** 4 | * Created with IntelliJ IDEA. 5 | * User: ebirn 6 | * Date: 08.06.13 7 | * Time: 07:35 8 | * To change this template use File | Settings | File Templates. 9 | */ 10 | public enum MarketParameter { 11 | LAST, 12 | BID, 13 | ASK, 14 | VOLUME 15 | } 16 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/track/NumberTrackCollection.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.track; 2 | 3 | /** 4 | * Created with IntelliJ IDEA. 5 | * User: ebirn 6 | * Date: 30.05.13 7 | * Time: 22:15 8 | * To change this template use File | Settings | File Templates. 9 | */ 10 | public class NumberTrackCollection extends ValueTrackCollection { 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bitcoin-exchange.properties 2 | .idea 3 | target 4 | *.iml 5 | */*.iml 6 | */target 7 | bitstamp/target 8 | bitstamp/bitstamp.iml 9 | mtgox/target 10 | mtgox/mtgox.iml 11 | btc-e/target 12 | btc-e/btce.iml 13 | btcde/target 14 | btcde/btcde.iml 15 | kraken/target 16 | kraken/kraken.iml 17 | bitkonan/target 18 | bitkonan/bitkonan.iml 19 | coins-e/target 20 | coins-e/coins-e.iml 21 | cryptsy/target 22 | cryotsy/cryptsy.iml 23 | -------------------------------------------------------------------------------- /archetype/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | at.outdated.bitcoin.exchange 6 | exchange-template 7 | 1.0-SNAPSHOT 8 | jar 9 | 10 | 11 | -------------------------------------------------------------------------------- /kraken/src/main/java/at/outdated/bitcoin/exchange/kraken/jaxb/KrakenOpenOrderResult.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.kraken.jaxb; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | import javax.xml.bind.annotation.XmlRootElement; 5 | 6 | /** 7 | * Created by ebirn on 05.01.14. 8 | */ 9 | @XmlRootElement 10 | public class KrakenOpenOrderResult { 11 | 12 | 13 | @XmlElement 14 | String open; 15 | 16 | public String getOpen() { 17 | return open; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/account/WalletTransactionTimestampComparator.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.account; 2 | 3 | import java.util.Comparator; 4 | 5 | /** 6 | * Created by ebirn on 25.01.14. 7 | */ 8 | public class WalletTransactionTimestampComparator implements Comparator { 9 | 10 | @Override 11 | public int compare(WalletTransaction t1, WalletTransaction t2) { 12 | return t1.getTimestamp().compareTo(t2.getTimestamp()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /icbit/src/test/java/IcbitTest.java: -------------------------------------------------------------------------------- 1 | import at.outdated.bitcoin.exchange.api.market.Markets; 2 | import at.outdated.bitcoin.exchange.icbit.IcbitClient; 3 | import org.junit.Test; 4 | 5 | /** 6 | * Created by ebirn on 31.10.13. 7 | */ 8 | public class IcbitTest { 9 | 10 | IcbitClient client = new IcbitClient(Markets.getMarket("icbit")); 11 | 12 | @Test 13 | public void myTest() { 14 | //FIXME: cleanup 15 | //client.getTicker(new AssetPair(Currency.BTC, Currency.LTC)); 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/OrderDeletion.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | 5 | /** 6 | * Created by ebirn on 14.01.14. 7 | */ 8 | public class OrderDeletion { 9 | 10 | 11 | @XmlElement 12 | String oid; 13 | 14 | @XmlElement 15 | String qid; 16 | 17 | 18 | public String getOid() { 19 | return oid; 20 | } 21 | 22 | public String getQid() { 23 | return qid; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bitcurex/src/main/java/at/outdated/bitcoin/exchange/bitcurex/jaxb/BaseApiResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitcurex.jaxb; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | 5 | /** 6 | * Created by ebirn on 30.01.14. 7 | */ 8 | public class BaseApiResponse { 9 | 10 | 11 | @XmlElement 12 | String error; 13 | 14 | public String getError() { 15 | return error; 16 | } 17 | 18 | public boolean isError() { 19 | return error != null && error.isEmpty() == false; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/fee/ZeroFee.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market.fee; 2 | 3 | /** 4 | * Created with IntelliJ IDEA. 5 | * User: ebirn 6 | * Date: 10.06.13 7 | * Time: 16:30 8 | * To change this template use File | Settings | File Templates. 9 | */ 10 | public class ZeroFee extends ConstantFee { 11 | 12 | public ZeroFee() { 13 | super("0.0"); 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | return super.toString() + " 0."; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /archetype/src/main/resources/META-INF/archetype.xml: -------------------------------------------------------------------------------- 1 | 3 | exchange 4 | 5 | src/main/java/App.java 6 | 7 | 8 | src/test/java/AppTest.java 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /icbit/src/main/java/at/outdated/bitcoin/exchange/icbit/IcbitMarket.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.icbit; 2 | 3 | import at.outdated.bitcoin.exchange.api.client.ExchangeClient; 4 | import at.outdated.bitcoin.exchange.api.market.Market; 5 | 6 | /** 7 | * Created by ebirn on 31.10.13. 8 | */ 9 | public class IcbitMarket extends Market { 10 | 11 | public IcbitMarket() { 12 | super("icbit", "https://icbit.se", "icbit.se"); 13 | } 14 | 15 | @Override 16 | public ExchangeClient createClient() { 17 | return new IcbitClient(this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /btc-e/src/main/java/at/outdated/bitcoin/exchange/btce/InfoResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.btce; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created by ebirn on 06.10.13. 10 | */ 11 | @XmlRootElement 12 | @XmlAccessorType(XmlAccessType.FIELD) 13 | public class InfoResponse { 14 | 15 | @XmlElement 16 | int success; 17 | 18 | @XmlElement(name="return") 19 | BtcEAccountInfo result; 20 | } 21 | -------------------------------------------------------------------------------- /bter/src/main/java/at/outdated/bitcoin/exchange/bter/BterTradeHistory.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bter; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | import java.util.List; 7 | 8 | /** 9 | * Created by ebirn on 09.02.14. 10 | */ 11 | @XmlRootElement 12 | @XmlAccessorType(XmlAccessType.FIELD) 13 | public class BterTradeHistory extends BterResult { 14 | 15 | List data; 16 | 17 | public List getData() { 18 | return data; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/MtgoxOrderPlaced.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | import javax.xml.bind.annotation.XmlRootElement; 5 | 6 | /** 7 | * Created by ebirn on 14.01.14. 8 | */ 9 | @XmlRootElement 10 | public class MtgoxOrderPlaced { 11 | 12 | @XmlElement 13 | String result; 14 | 15 | @XmlElement 16 | String data; 17 | 18 | 19 | public String getResult() { 20 | return result; 21 | } 22 | 23 | public String getData() { 24 | return data; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/container/CurrencyContainer.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.container; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | 5 | import java.util.Set; 6 | 7 | /** 8 | * Created with IntelliJ IDEA. 9 | * User: ebirn 10 | * Date: 11.05.13 11 | * Time: 16:50 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class CurrencyContainer extends EnumContainer { 15 | 16 | 17 | public Set getCurrencies() { 18 | 19 | return getKeys(); 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/performance/BalanceComparator.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.performance; 2 | 3 | import java.util.Comparator; 4 | 5 | /** 6 | * Created with IntelliJ IDEA. 7 | * User: ebirn 8 | * Date: 25.06.13 9 | * Time: 14:07 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class BalanceComparator implements Comparator { 13 | 14 | @Override 15 | public int compare(Performance o1, Performance o2) { 16 | return o1.getEndBalance().getValue().compareTo(o2.getEndBalance().getValue()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /kraken/src/main/java/at/outdated/bitcoin/exchange/kraken/jaxb/KrakenResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.kraken.jaxb; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | import javax.xml.bind.annotation.XmlRootElement; 5 | 6 | /** 7 | * Created by ebirn on 05.01.14. 8 | */ 9 | @XmlRootElement 10 | public class KrakenResponse { 11 | 12 | @XmlElement 13 | Object[] error; 14 | 15 | 16 | @XmlElement 17 | R result; 18 | 19 | 20 | public Object[] getError() { 21 | return error; 22 | } 23 | 24 | public R getResult() { 25 | return result; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bitstamp/src/main/java/at/outdated/bitcoin/exchange/bitstamp/OrderDeletion.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitstamp; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created by ebirn on 13.01.14. 10 | */ 11 | @XmlRootElement 12 | @XmlAccessorType(XmlAccessType.FIELD) 13 | public class OrderDeletion { 14 | 15 | @XmlElement 16 | String error; 17 | 18 | 19 | public String getError() { 20 | return error; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /bitstamp/src/main/java/at/outdated/bitcoin/exchange/bitstamp/BitstampAddress.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitstamp; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created by ebirn on 22.11.13. 10 | */ 11 | @XmlRootElement 12 | @XmlAccessorType(XmlAccessType.FIELD) 13 | public class BitstampAddress { 14 | 15 | @XmlElement 16 | String address; 17 | 18 | public String getAddress() { 19 | return address; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/performance/PercentComparator.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.performance; 2 | 3 | import java.io.Serializable; 4 | import java.util.Comparator; 5 | 6 | /** 7 | * Created with IntelliJ IDEA. 8 | * User: ebirn 9 | * Date: 25.06.13 10 | * Time: 14:02 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class PercentComparator implements Comparator, Serializable { 14 | 15 | @Override 16 | public int compare(Performance o1, Performance o2) { 17 | return o1.getPercent().compareTo(o2.getPercent()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /coins-e/src/main/java/at/outdated/bitcoin/exchange/coinse/CoinseAccountInfo.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.coinse; 2 | 3 | import at.outdated.bitcoin.exchange.api.account.AccountInfo; 4 | import at.outdated.bitcoin.exchange.api.market.OrderType; 5 | import at.outdated.bitcoin.exchange.api.market.fee.Fee; 6 | import at.outdated.bitcoin.exchange.api.market.fee.SimplePercentageFee; 7 | 8 | /** 9 | * Created by ebirn on 06.01.14. 10 | */ 11 | public class CoinseAccountInfo extends AccountInfo { 12 | 13 | @Override 14 | public Fee getTradeFee(OrderType type) { 15 | return new SimplePercentageFee(0.002); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/jaxb/CurrencyAdapter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.jaxb; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | 5 | import javax.xml.bind.annotation.adapters.XmlAdapter; 6 | 7 | /** 8 | * Created by ebirn on 17.02.14. 9 | */ 10 | public class CurrencyAdapter extends XmlAdapter { 11 | 12 | @Override 13 | public Currency unmarshal(String v) throws Exception { 14 | return Currency.valueOf(v); 15 | } 16 | 17 | @Override 18 | public String marshal(Currency v) throws Exception { 19 | return v.name(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /coins-e/src/main/java/at/outdated/bitcoin/exchange/coinse/jaxb/SingleOrder.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.coinse.jaxb; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created by ebirn on 30.01.14. 10 | */ 11 | 12 | @XmlRootElement 13 | @XmlAccessorType(XmlAccessType.FIELD) 14 | public class SingleOrder extends BaseResponse { 15 | 16 | @XmlElement 17 | CoinseOrder order; 18 | 19 | public CoinseOrder getOrder() { 20 | return order; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/ApiTickerResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | import javax.xml.bind.annotation.XmlRootElement; 5 | 6 | /** 7 | * Created with IntelliJ IDEA. 8 | * User: ebirn 9 | * Date: 02.05.13 10 | * Time: 20:26 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | 14 | @XmlRootElement 15 | public class ApiTickerResponse extends ApiResponse { 16 | 17 | 18 | @XmlElement 19 | protected TickerResponse data; 20 | 21 | public TickerResponse getData() { 22 | return data; 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /bter/src/main/java/at/outdated/bitcoin/exchange/bter/BterAccountInfo.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bter; 2 | 3 | import at.outdated.bitcoin.exchange.api.account.AccountInfo; 4 | import at.outdated.bitcoin.exchange.api.market.OrderType; 5 | import at.outdated.bitcoin.exchange.api.market.fee.Fee; 6 | import at.outdated.bitcoin.exchange.api.market.fee.SimplePercentageFee; 7 | 8 | /** 9 | * Created by ebirn on 19.10.13. 10 | */ 11 | public class BterAccountInfo extends AccountInfo { 12 | 13 | Fee tradingFee = new SimplePercentageFee(0.002); 14 | 15 | @Override 16 | public Fee getTradeFee(OrderType trade) { 17 | return tradingFee; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/ApiResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | import javax.xml.bind.annotation.XmlRootElement; 5 | 6 | /** 7 | * Created with IntelliJ IDEA. 8 | * User: ebirn 9 | * Date: 02.05.13 10 | * Time: 20:10 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | 14 | @XmlRootElement 15 | public abstract class ApiResponse { 16 | 17 | @XmlElement 18 | protected ResponseResult result = ResponseResult.SUCCESS; 19 | 20 | public ResponseResult getResult() { 21 | return result; 22 | } 23 | 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /bter/src/main/java/at/outdated/bitcoin/exchange/bter/BterResult.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bter; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created by ebirn on 09.02.14. 10 | */ 11 | @XmlRootElement 12 | @XmlAccessorType(XmlAccessType.FIELD) 13 | public class BterResult { 14 | // {"result":"true","data":[ ... 15 | 16 | @XmlElement 17 | String result; 18 | 19 | public boolean isSuccess() { 20 | return "true".equalsIgnoreCase(result); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/ApiWalletHistory.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | import javax.xml.bind.annotation.XmlRootElement; 5 | 6 | /** 7 | * Created with IntelliJ IDEA. 8 | * User: ebirn 9 | * Date: 10.05.13 10 | * Time: 20:18 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | @XmlRootElement 14 | public class ApiWalletHistory extends ApiResponse { 15 | 16 | 17 | @XmlElement(name="data") 18 | private MtGoxWalletHistory walletHistory; 19 | 20 | public MtGoxWalletHistory getData() { 21 | return walletHistory; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vircurex/src/main/java/at/outdated/bitcoin/exchange/vircurex/VircurexAccountInfo.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.vircurex; 2 | 3 | import at.outdated.bitcoin.exchange.api.account.AccountInfo; 4 | import at.outdated.bitcoin.exchange.api.market.OrderType; 5 | import at.outdated.bitcoin.exchange.api.market.fee.Fee; 6 | import at.outdated.bitcoin.exchange.api.market.fee.SimplePercentageFee; 7 | 8 | /** 9 | * Created by ebirn on 27.10.13. 10 | */ 11 | public class VircurexAccountInfo extends AccountInfo { 12 | 13 | Fee tradeFee = new SimplePercentageFee(0.002); 14 | 15 | @Override 16 | public Fee getTradeFee(OrderType trade) { 17 | return tradeFee; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/ApiTradesResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | import java.util.List; 7 | 8 | /** 9 | * Created by ebirn on 08.02.14. 10 | */ 11 | @XmlRootElement 12 | @XmlAccessorType(XmlAccessType.FIELD) 13 | public class ApiTradesResponse extends ApiResponse { 14 | 15 | 16 | List data; 17 | 18 | public List getData() { 19 | return data; 20 | } 21 | 22 | public List getTrades() { 23 | return data; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/performance/AbsoluteComparator.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.performance; 2 | 3 | import java.util.Comparator; 4 | 5 | /** 6 | * Created with IntelliJ IDEA. 7 | * User: ebirn 8 | * Date: 25.06.13 9 | * Time: 14:06 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class AbsoluteComparator implements Comparator { 13 | 14 | @Override 15 | public int compare(Performance o1, Performance o2) { 16 | return o1.getTotalDifference().getValue().compareTo(o2.getTotalDifference().getValue()); 17 | //return Math.round( (float)(o1.getTotalDifference()- o2.getTotalDifference())*100.0f ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cryptsy/src/main/java/at/outdated/bitcoin/exchange/cryptsy/MarketTradesResult.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.cryptsy; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by ebirn on 09.02.14. 8 | */ 9 | public class MarketTradesResult extends CryptsyResult { 10 | /* 11 | success - Either a 1 or a 0. 1 Represents sucessful call, 0 Represents unsuccessful 12 | error - If unsuccessful, this will be the error message 13 | return - If successful, this will be the data returned 14 | */ 15 | 16 | @XmlElement(name="return") 17 | List result; 18 | 19 | public List getResult() { 20 | return result; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cryptsy/src/main/java/at/outdated/bitcoin/exchange/cryptsy/CryptsyResult.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.cryptsy; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | /** 8 | * Created by ebirn on 09.02.14. 9 | */ 10 | @XmlRootElement 11 | @XmlAccessorType(XmlAccessType.FIELD) 12 | public class CryptsyResult { 13 | 14 | int success; 15 | 16 | String error; 17 | 18 | public int getSuccess() { 19 | return success; 20 | } 21 | 22 | public boolean isSuccess() { 23 | return success == 1; 24 | } 25 | 26 | public String getError() { 27 | return error; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/jaxb/UnixTimeDateAdapter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.jaxb; 2 | 3 | import javax.xml.bind.annotation.adapters.XmlAdapter; 4 | import java.util.Date; 5 | 6 | /** 7 | * Created with IntelliJ IDEA. 8 | * User: ebirn 9 | * Date: 30.05.13 10 | * Time: 13:50 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class UnixTimeDateAdapter extends XmlAdapter { 14 | 15 | @Override 16 | public Date unmarshal(Number v) throws Exception { 17 | return new Date(v.longValue()*1000L); 18 | } 19 | 20 | @Override 21 | public Number marshal(Date v) throws Exception { 22 | return v.getTime()/1000L; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/jaxb/UnixTimeMicroDateAdapter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.jaxb; 2 | 3 | import javax.xml.bind.annotation.adapters.XmlAdapter; 4 | import java.util.Date; 5 | 6 | /** 7 | * Created with IntelliJ IDEA. 8 | * User: ebirn 9 | * Date: 30.05.13 10 | * Time: 13:50 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class UnixTimeMicroDateAdapter extends XmlAdapter { 14 | 15 | @Override 16 | public Date unmarshal(Number v) throws Exception { 17 | return new Date(v.longValue()/1000L); 18 | } 19 | 20 | @Override 21 | public Number marshal(Date v) throws Exception { 22 | return v.getTime()*1000L; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /kraken/src/main/java/at/outdated/bitcoin/exchange/kraken/jaxb/KrakenTickerResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.kraken.jaxb; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created by ebirn on 29.09.13. 10 | */ 11 | 12 | @XmlRootElement 13 | @XmlAccessorType(XmlAccessType.FIELD) 14 | public class KrakenTickerResponse { 15 | 16 | 17 | @XmlElement 18 | protected Object[] error; 19 | 20 | 21 | @XmlElement 22 | protected TickerResponseResult result; 23 | 24 | public TickerResponseResult getResult() { 25 | return result; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/jaxb/JsonEnforcingFilter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.jaxb; 2 | 3 | import javax.ws.rs.client.ClientRequestContext; 4 | import javax.ws.rs.client.ClientResponseContext; 5 | import javax.ws.rs.client.ClientResponseFilter; 6 | import javax.ws.rs.core.MediaType; 7 | import java.io.IOException; 8 | 9 | /** 10 | * Created by ebirn on 21.01.14. 11 | */ 12 | 13 | public class JsonEnforcingFilter implements ClientResponseFilter { 14 | 15 | 16 | @Override 17 | public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { 18 | 19 | responseContext.getHeaders().putSingle("Content-Type", MediaType.APPLICATION_JSON); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/OrderDeletionResult.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created by ebirn on 14.01.14. 10 | */ 11 | @XmlRootElement 12 | @XmlAccessorType(XmlAccessType.FIELD) 13 | public class OrderDeletionResult { 14 | 15 | @XmlElement 16 | String result; 17 | 18 | @XmlElement 19 | OrderDeletion data; 20 | 21 | public String getResult() { 22 | return result; 23 | } 24 | 25 | public OrderDeletion getData() { 26 | return data; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /btc-e/src/main/java/at/outdated/bitcoin/exchange/btce/TickerResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.btce; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: ebirn 11 | * Date: 26.05.13 12 | * Time: 23:50 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | @XmlRootElement 16 | @XmlAccessorType(XmlAccessType.FIELD) 17 | public class TickerResponse { 18 | 19 | @XmlElement(name="ticker") 20 | BtcETickerValue ticker; 21 | 22 | 23 | public BtcETickerValue getTicker() { 24 | return ticker; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/ApiLagResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: ebirn 11 | * Date: 03.05.13 12 | * Time: 11:00 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | @XmlRootElement 16 | @XmlAccessorType(XmlAccessType.FIELD) 17 | public class ApiLagResponse extends ApiResponse { 18 | 19 | @XmlElement 20 | protected LagResponse data; 21 | 22 | public LagResponse getData() { 23 | return data; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/ApiAccountInfo.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: ebirn 11 | * Date: 03.05.13 12 | * Time: 11:21 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | @XmlRootElement 16 | @XmlAccessorType(XmlAccessType.FIELD) 17 | public class ApiAccountInfo extends ApiResponse { 18 | 19 | @XmlElement(name="data") 20 | protected MtGoxAccountInfo data; 21 | 22 | public MtGoxAccountInfo getData() { 23 | return data; 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /kraken/src/main/java/at/outdated/bitcoin/exchange/kraken/jaxb/TickerResponseResult.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.kraken.jaxb; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created by ebirn on 29.09.13. 10 | */ 11 | @XmlRootElement 12 | @XmlAccessorType(XmlAccessType.FIELD) 13 | public class TickerResponseResult { 14 | 15 | @XmlElement 16 | private KrakenTickerValue XXBTZEUR; 17 | 18 | 19 | public KrakenTickerValue getXXBTZEUR() { 20 | return XXBTZEUR; 21 | } 22 | 23 | public void setXXBTZEUR(KrakenTickerValue XXBTZEUR) { 24 | 25 | this.XXBTZEUR = XXBTZEUR; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /kraken/src/main/java/at/outdated/bitcoin/exchange/kraken/KrakenAccountInfo.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.kraken; 2 | 3 | import at.outdated.bitcoin.exchange.api.account.AccountInfo; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | import at.outdated.bitcoin.exchange.api.market.OrderType; 6 | import at.outdated.bitcoin.exchange.api.market.fee.Fee; 7 | import at.outdated.bitcoin.exchange.api.market.fee.SimplePercentageFee; 8 | 9 | import java.math.BigDecimal; 10 | 11 | /** 12 | * Created by ebirn on 07.10.13. 13 | */ 14 | public class KrakenAccountInfo extends AccountInfo { 15 | 16 | 17 | 18 | @Override 19 | public Fee getTradeFee(OrderType trade) { 20 | 21 | return new SimplePercentageFee(new BigDecimal("0.002", CurrencyValue.CURRENCY_MATH_CONTEXT)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/MtGoxOrderList.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by ebirn on 14.01.14. 12 | */ 13 | @XmlRootElement 14 | @XmlAccessorType(XmlAccessType.FIELD) 15 | public class MtGoxOrderList { 16 | 17 | @XmlElement 18 | String result; 19 | 20 | @XmlElement 21 | List data = new ArrayList<>(); 22 | 23 | public String getResult() { 24 | return result; 25 | } 26 | 27 | public List getData() { 28 | return data; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/jaxb/StringNumberAdapter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.jaxb; 2 | 3 | import javax.xml.bind.annotation.adapters.XmlAdapter; 4 | import java.text.NumberFormat; 5 | import java.util.Locale; 6 | 7 | /** 8 | * Created with IntelliJ IDEA. 9 | * User: ebirn 10 | * Date: 25.05.13 11 | * Time: 16:25 12 | * @deprecated should not be used in favor of StringBigDecimalAdapter 13 | */ 14 | @Deprecated 15 | public class StringNumberAdapter extends XmlAdapter { 16 | 17 | NumberFormat nf = NumberFormat.getInstance(Locale.US); 18 | 19 | @Override 20 | public Number unmarshal(String v) throws Exception { 21 | return nf.parse(v); 22 | } 23 | 24 | @Override 25 | public String marshal(Number v) throws Exception { 26 | return nf.format(v); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/fee/InfiniteFee.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market.fee; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 4 | import at.outdated.bitcoin.exchange.api.market.OrderType; 5 | 6 | import java.math.BigDecimal; 7 | 8 | 9 | /** 10 | * Created with IntelliJ IDEA. 11 | * User: ebirn 12 | * Date: 10.06.13 13 | * Time: 16:31 14 | * To change this template use File | Settings | File Templates. 15 | */ 16 | public class InfiniteFee extends Fee { 17 | 18 | @Override 19 | public CurrencyValue calculate(OrderType orderType, CurrencyValue volume) { 20 | return new CurrencyValue(new BigDecimal("10e100"), volume.getCurrency()); 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return super.toString() + "+Inf"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bitkonan/src/main/java/at/outdated/bitcoin/exchange/bitkonan/BitkonanAccountInfo.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitkonan; 2 | 3 | import at.outdated.bitcoin.exchange.api.account.AccountInfo; 4 | import at.outdated.bitcoin.exchange.api.market.OrderType; 5 | import at.outdated.bitcoin.exchange.api.market.fee.Fee; 6 | import at.outdated.bitcoin.exchange.api.market.fee.SimplePercentageFee; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: ebirn 11 | * Date: 26.05.13 12 | * Time: 23:44 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class BitkonanAccountInfo extends AccountInfo { 16 | 17 | @Override 18 | public Fee getTradeFee(OrderType trade) { 19 | 20 | return new SimplePercentageFee(0.0029); //To change body of implemented methods use File | Settings | File Templates. 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /bitstamp/src/main/java/at/outdated/bitcoin/exchange/bitstamp/BitstampAccountInfo.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitstamp; 2 | 3 | import at.outdated.bitcoin.exchange.api.account.AccountInfo; 4 | import at.outdated.bitcoin.exchange.api.market.OrderType; 5 | import at.outdated.bitcoin.exchange.api.market.fee.Fee; 6 | 7 | /** 8 | * Created with IntelliJ IDEA. 9 | * User: ebirn 10 | * Date: 26.05.13 11 | * Time: 17:01 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class BitstampAccountInfo extends AccountInfo { 15 | 16 | protected Fee fee; 17 | 18 | public void setFee(Fee fee) { 19 | this.fee = fee; 20 | } 21 | 22 | @Override 23 | public Fee getTradeFee(OrderType trade) { 24 | return fee; //To change body of implemented methods use File | Settings | File Templates. 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /btcde/src/test/java/at/outdated/bitcoin/exchange/AppTest.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /kraken/src/main/java/at/outdated/bitcoin/exchange/kraken/jaxb/KrakenOrderCancelResult.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.kraken.jaxb; 2 | 3 | import javax.xml.bind.annotation.XmlElement; 4 | import javax.xml.bind.annotation.XmlRootElement; 5 | import java.util.List; 6 | 7 | /** 8 | * Created by ebirn on 05.01.14. 9 | */ 10 | @XmlRootElement 11 | public class KrakenOrderCancelResult { 12 | 13 | @XmlElement 14 | int count; 15 | 16 | @XmlElement 17 | List pending; 18 | 19 | public int getCount() { 20 | return count; 21 | } 22 | 23 | public List getPending() { 24 | return pending; 25 | } 26 | 27 | public boolean isSuccess() { 28 | 29 | if(count > 0) return true; 30 | 31 | if(pending != null && pending.isEmpty() == false) return true; 32 | 33 | return false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/track/NumberTrack.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.track; 2 | 3 | import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; 4 | 5 | /** 6 | * Created with IntelliJ IDEA. 7 | * User: ebirn 8 | * Date: 10.05.13 9 | * Time: 14:03 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class NumberTrack extends ValueTrack { 13 | 14 | DescriptiveStatistics stats; 15 | 16 | public NumberTrack(int count) { 17 | super(count); 18 | stats = new DescriptiveStatistics(count); 19 | } 20 | 21 | @Override 22 | public void insert(Number value) { 23 | super.insert(value); 24 | stats.addValue(value.doubleValue()); 25 | } 26 | 27 | public DescriptiveStatistics getStatistics() { 28 | return stats; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /coins-e/src/main/java/at/outdated/bitcoin/exchange/coinse/jaxb/DepositAddress.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.coinse.jaxb; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created by ebirn on 30.01.14. 10 | */ 11 | @XmlRootElement 12 | @XmlAccessorType(XmlAccessType.FIELD) 13 | public class DepositAddress extends BaseResponse { 14 | /* 15 | { 16 | "status": true, 17 | "message": "success", 18 | "deposit_address": "1Q1RaxqZipDgaUg4r7KYqgoftZGhba1CyV", 19 | "systime": 1372852975 20 | } 21 | */ 22 | 23 | @XmlElement 24 | String deposit_address; 25 | 26 | public String getDepositAddress() { 27 | return deposit_address; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/container/MarketAssetContainer.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.container; 2 | 3 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 4 | import at.outdated.bitcoin.exchange.api.market.Market; 5 | import at.outdated.bitcoin.exchange.api.market.MarketContainer; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * Created with IntelliJ IDEA. 11 | * User: ebirn 12 | * Date: 27.05.13 13 | * Time: 12:44 14 | * To change this template use File | Settings | File Templates. 15 | */ 16 | public class MarketAssetContainer extends MarketContainer> { 17 | 18 | 19 | public T get(Market market, AssetPair asset) { 20 | return this.get(market).get(asset); 21 | } 22 | 23 | 24 | public void set(Market market, AssetPair asset, T value) { 25 | this.get(market).put(asset, value); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/jaxb/DateIso8601SpacedAdapter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.jaxb; 2 | 3 | import javax.xml.bind.annotation.adapters.XmlAdapter; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | 7 | /** 8 | * Created with IntelliJ IDEA. 9 | * User: ebirn 10 | * Date: 03.05.13 11 | * Time: 14:00 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | 15 | public class DateIso8601SpacedAdapter extends XmlAdapter { 16 | 17 | private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 18 | 19 | @Override 20 | public String marshal(Date v) throws Exception { 21 | return dateFormat.format(v); 22 | } 23 | 24 | @Override 25 | public Date unmarshal(String v) throws Exception { 26 | return dateFormat.parse(v); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /cryptsy/src/main/java/at/outdated/bitcoin/exchange/cryptsy/CryptsyAccountInfo.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.cryptsy; 2 | 3 | import at.outdated.bitcoin.exchange.api.account.AccountInfo; 4 | import at.outdated.bitcoin.exchange.api.market.OrderType; 5 | import at.outdated.bitcoin.exchange.api.market.fee.Fee; 6 | import at.outdated.bitcoin.exchange.api.market.fee.SimplePercentageFee; 7 | 8 | /** 9 | * Created by ebirn on 06.01.14. 10 | */ 11 | public class CryptsyAccountInfo extends AccountInfo { 12 | 13 | @Override 14 | public Fee getTradeFee(OrderType type) { 15 | 16 | switch(type) { 17 | case BID: 18 | return new SimplePercentageFee(0.002); 19 | 20 | case ASK: 21 | return new SimplePercentageFee(0.003); 22 | } 23 | 24 | 25 | // you sould never come here 26 | return null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/jaxb/DateIso8601Adapter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.jaxb; 2 | 3 | import javax.xml.bind.annotation.adapters.XmlAdapter; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | 7 | /** 8 | * Created with IntelliJ IDEA. 9 | * User: ebirn 10 | * Date: 03.05.13 11 | * Time: 14:00 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | 15 | public class DateIso8601Adapter extends XmlAdapter { 16 | 17 | private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); 18 | 19 | @Override 20 | public String marshal(Date v) throws Exception { 21 | return dateFormat.format(v); 22 | } 23 | 24 | @Override 25 | public Date unmarshal(String v) throws Exception { 26 | 27 | return dateFormat.parse(v); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /tests/src/test/java/at/outdated/bitcoin/exchange/TestMarketDiscovery.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange; 2 | 3 | import at.outdated.bitcoin.exchange.api.market.Market; 4 | import at.outdated.bitcoin.exchange.api.market.Markets; 5 | import org.junit.Test; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: ebirn 11 | * Date: 23.05.13 12 | * Time: 21:41 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class TestMarketDiscovery { 16 | 17 | @Test 18 | public void testLoadMarkets() { 19 | 20 | for(Market m : Markets.allMarkets()) { 21 | //System.out.println("market: " + m); 22 | //TickerValue ticker = m.createClient().getUpdate(Currency.USD); 23 | LoggerFactory.getLogger(TestMarketDiscovery.class).info("check: {}", m); 24 | } 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/auth/Nonce.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox.auth; 2 | 3 | import java.util.Date; 4 | import java.util.Random; 5 | 6 | /** 7 | * Created with IntelliJ IDEA. 8 | * User: ebirn 9 | * Date: 03.05.13 10 | * Time: 10:47 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public class Nonce { 14 | 15 | static long nonce = 0; 16 | static Random rnd = new Random(); 17 | 18 | static { 19 | Date now = new Date(); 20 | rnd.setSeed(now.getTime()); 21 | 22 | nonce = rnd.nextInt(10000); 23 | } 24 | 25 | public static long next() { 26 | //nonce += increment(); 27 | 28 | 29 | Date now = new Date(); 30 | 31 | return now.getTime(); 32 | } 33 | 34 | private static long increment() { 35 | return rnd.nextInt(1000); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/client/MarketClient.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.client; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 5 | import at.outdated.bitcoin.exchange.api.market.MarketDepth; 6 | import at.outdated.bitcoin.exchange.api.market.MarketOrder; 7 | import at.outdated.bitcoin.exchange.api.market.TickerValue; 8 | 9 | import java.math.BigDecimal; 10 | import java.util.Date; 11 | import java.util.List; 12 | 13 | /** 14 | * Created by ebirn on 09.11.13. 15 | */ 16 | public interface MarketClient { 17 | TickerValue getTicker(AssetPair asset); 18 | 19 | BigDecimal getQuote(Currency base, Currency quote); 20 | 21 | MarketDepth getMarketDepth(AssetPair asset); 22 | 23 | // get historic trade data 24 | List getTradeHistory(AssetPair asset, Date since); 25 | 26 | double getApiLag(); 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/OrderId.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api; 2 | 3 | import at.outdated.bitcoin.exchange.api.market.Market; 4 | 5 | /** 6 | * Created by ebirn on 05.01.14. 7 | */ 8 | public class OrderId { 9 | 10 | String identifier; 11 | 12 | Market market; 13 | 14 | public OrderId(Market market, String identifier) { 15 | this.identifier = identifier; 16 | this.market = market; 17 | } 18 | 19 | public OrderId(Market market) { 20 | this.market = market; 21 | } 22 | 23 | public String getIdentifier() { 24 | return identifier; 25 | } 26 | 27 | public void setIdentifier(String identifier) { 28 | this.identifier = identifier; 29 | } 30 | 31 | public Market getMarket() { 32 | return market; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return market + ":" + identifier; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /campbx/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | parent 7 | at.outdated.bitcoin.exchange 8 | 1 9 | 10 | 4.0.0 11 | 12 | campbx 13 | 14 | 1.0-SNAPSHOT 15 | 16 | jar 17 | 18 | CampBX client API 19 | 20 | 21 | 22 | at.outdated.bitcoin.exchange 23 | api 24 | ${project.version} 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /bter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | parent 7 | at.outdated.bitcoin.exchange 8 | 1 9 | 10 | 4.0.0 11 | 12 | bter 13 | 14 | 1.0-SNAPSHOT 15 | 16 | jar 17 | 18 | Bter.com client API 19 | 20 | 21 | 22 | at.outdated.bitcoin.exchange 23 | api 24 | ${project.version} 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /kraken/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | parent 7 | at.outdated.bitcoin.exchange 8 | 1 9 | 10 | 4.0.0 11 | 12 | kraken 13 | 14 | 1.0-SNAPSHOT 15 | 16 | jar 17 | 18 | Kraken.com client API 19 | 20 | 21 | 22 | at.outdated.bitcoin.exchange 23 | api 24 | ${project.version} 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /coins-e/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | parent 7 | at.outdated.bitcoin.exchange 8 | 1 9 | 10 | 4.0.0 11 | 12 | coins-e 13 | 14 | 1.0-SNAPSHOT 15 | 16 | jar 17 | 18 | Coins-e.com client API 19 | 20 | 21 | 22 | at.outdated.bitcoin.exchange 23 | api 24 | ${project.version} 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /cryptsy/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | parent 7 | at.outdated.bitcoin.exchange 8 | 1 9 | 10 | 4.0.0 11 | 12 | cryptsy 13 | 14 | 1.0-SNAPSHOT 15 | 16 | jar 17 | 18 | Cryptsy.com client API 19 | 20 | 21 | 22 | at.outdated.bitcoin.exchange 23 | api 24 | ${project.version} 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /vircurex/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | parent 7 | at.outdated.bitcoin.exchange 8 | 1 9 | 10 | 4.0.0 11 | 12 | vircurex 13 | 14 | 1.0-SNAPSHOT 15 | 16 | jar 17 | 18 | Vircurex client API 19 | 20 | 21 | 22 | at.outdated.bitcoin.exchange 23 | api 24 | ${project.version} 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /bitkonan/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | at.outdated.bitcoin.exchange 7 | parent 8 | 1 9 | 10 | 11 | bitkonan 12 | 1.0-SNAPSHOT 13 | jar 14 | 15 | Bitkonan.com client API 16 | 17 | 18 | UTF-8 19 | 20 | 21 | 22 | 23 | at.outdated.bitcoin.exchange 24 | api 25 | 1.0-SNAPSHOT 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /btcde/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | at.outdated.bitcoin.exchange 7 | parent 8 | 1 9 | 10 | 11 | btcde 12 | 1.0-SNAPSHOT 13 | btcde 14 | 15 | http://maven.apache.org 16 | 17 | 18 | UTF-8 19 | 20 | 21 | 22 | 23 | at.outdated.bitcoin.exchange 24 | api 25 | ${project.version} 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/jaxb/OrderTypeAdapter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.jaxb; 2 | 3 | import at.outdated.bitcoin.exchange.api.market.OrderType; 4 | 5 | import javax.xml.bind.annotation.adapters.XmlAdapter; 6 | 7 | /** 8 | * Created by ebirn on 08.02.14. 9 | */ 10 | public class OrderTypeAdapter extends XmlAdapter { 11 | 12 | @Override 13 | public OrderType unmarshal(String v) throws Exception { 14 | 15 | String raw = v.toLowerCase(); 16 | 17 | switch(raw) { 18 | case "bid": 19 | case "buy": 20 | return OrderType.BID; 21 | 22 | case "ask": 23 | case "sell": 24 | return OrderType.ASK; 25 | 26 | } 27 | 28 | return null; 29 | } 30 | 31 | @Override 32 | public String marshal(OrderType v) throws Exception { 33 | 34 | throw new UnsupportedOperationException("cannot convert"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bitkonan/src/main/java/at/outdated/bitcoin/exchange/bitkonan/BitkonanOrderTypeAdapter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitkonan; 2 | 3 | import at.outdated.bitcoin.exchange.api.market.OrderType; 4 | 5 | import javax.xml.bind.annotation.adapters.XmlAdapter; 6 | 7 | /** 8 | * Created by ebirn on 09.02.14. 9 | */ 10 | public class BitkonanOrderTypeAdapter extends XmlAdapter { 11 | @Override 12 | public OrderType unmarshal(Integer v) throws Exception { 13 | 14 | switch(v) { 15 | case 1: 16 | return OrderType.BID; 17 | 18 | case 2: 19 | return OrderType.ASK; 20 | } 21 | 22 | return OrderType.UNDEF; 23 | } 24 | 25 | @Override 26 | public Integer marshal(OrderType v) throws Exception { 27 | 28 | switch(v) { 29 | case BID: 30 | return 1; 31 | 32 | case ASK: 33 | return 2; 34 | } 35 | 36 | return -1; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/currency/CurrencyAddress.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.currency; 2 | 3 | /** 4 | * Created by ebirn on 10.11.13. 5 | */ 6 | public class CurrencyAddress { 7 | 8 | Currency reference; 9 | 10 | String address; 11 | 12 | public CurrencyAddress(Currency c, String address) { 13 | this.reference = c; 14 | this.address = address; 15 | } 16 | 17 | public void setAddress(String rawAddress) { 18 | 19 | // if(validateAddress(rawAddress)) 20 | this.address = rawAddress; 21 | // else 22 | // throw new IllegalArgumentException("Invalid address '" + rawAddress + "' for " + reference); 23 | } 24 | 25 | public Currency getReference() { 26 | return reference; 27 | } 28 | 29 | public String getAddress() { 30 | return address; 31 | } 32 | 33 | 34 | @Override 35 | public String toString() { 36 | return reference + ":" + address; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /bitcurex/src/main/java/at/outdated/bitcoin/exchange/bitcurex/jaxb/BitcurexTransactionType.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitcurex.jaxb; 2 | 3 | import javax.xml.bind.annotation.XmlEnum; 4 | 5 | /** 6 | * Created by ebirn on 20.10.13. 7 | */ 8 | @XmlEnum 9 | public enum BitcurexTransactionType { 10 | 11 | /* 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | */ 22 | 23 | NONE, 24 | BTC_DEPOST, 25 | BTC_WITHDRAWAL, 26 | EUR_DEPOSIT, 27 | EUR_WITHDRAWAL, 28 | SELL_OFFERS, 29 | BUY_OFFERS, 30 | BTC_TRANSACTION, 31 | EUR_TRANSACTION 32 | 33 | } 34 | -------------------------------------------------------------------------------- /bitstamp/src/main/java/at/outdated/bitcoin/exchange/bitstamp/BitstampOrderTypeAdapter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitstamp; 2 | 3 | import at.outdated.bitcoin.exchange.api.market.OrderType; 4 | 5 | import javax.xml.bind.annotation.adapters.XmlAdapter; 6 | 7 | /** 8 | * Created by ebirn on 09.02.14. 9 | */ 10 | public class BitstampOrderTypeAdapter extends XmlAdapter { 11 | 12 | @Override 13 | public OrderType unmarshal(Integer v) throws Exception { 14 | 15 | switch(v) { 16 | case 0: 17 | return OrderType.BID; 18 | 19 | case 1: 20 | return OrderType.ASK; 21 | } 22 | 23 | return OrderType.UNDEF; 24 | } 25 | 26 | @Override 27 | public Integer marshal(OrderType v) throws Exception { 28 | 29 | switch(v) { 30 | case BID: 31 | return 0; 32 | 33 | case ASK: 34 | return 1; 35 | } 36 | return -1; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/fee/Fee.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market.fee; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 4 | import at.outdated.bitcoin.exchange.api.market.OrderType; 5 | 6 | /** 7 | * Created with IntelliJ IDEA. 8 | * User: ebirn 9 | * Date: 09.06.13 10 | * Time: 17:30 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | public abstract class Fee { 14 | 15 | 16 | public abstract CurrencyValue calculate(OrderType type, CurrencyValue volume); 17 | 18 | 19 | // what remains after paying the fee 20 | public CurrencyValue remaining(OrderType type, CurrencyValue volume) { 21 | 22 | CurrencyValue remaining = new CurrencyValue(volume); 23 | 24 | CurrencyValue fee = calculate(type, volume); 25 | 26 | remaining.subtract(fee); 27 | 28 | return remaining; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "Fee: "; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bitcurex/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | at.outdated.bitcoin.exchange 7 | parent 8 | 1 9 | 10 | 11 | bitcurex 12 | 1.0-SNAPSHOT 13 | Bitcurex API 14 | 15 | http://maven.apache.org 16 | 17 | 18 | UTF-8 19 | 20 | 21 | 22 | 23 | 24 | at.outdated.bitcoin.exchange 25 | api 26 | 1.0-SNAPSHOT 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /bitstamp/src/main/java/at/outdated/bitcoin/exchange/bitstamp/BitstampMarketDepth.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitstamp; 2 | 3 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeDateAdapter; 4 | 5 | import javax.xml.bind.annotation.XmlAccessType; 6 | import javax.xml.bind.annotation.XmlAccessorType; 7 | import javax.xml.bind.annotation.XmlElement; 8 | import javax.xml.bind.annotation.XmlRootElement; 9 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 10 | import java.util.Date; 11 | import java.util.List; 12 | 13 | /** 14 | * Created by ebirn on 30.09.13. 15 | */ 16 | 17 | @XmlRootElement 18 | @XmlAccessorType(XmlAccessType.FIELD) 19 | public class BitstampMarketDepth { 20 | 21 | @XmlElement 22 | @XmlJavaTypeAdapter(UnixTimeDateAdapter.class) 23 | Date timestamp; 24 | 25 | @XmlElement 26 | //@XmlJavaTypeAdapter(NestedArrayAdapter.class) 27 | List> bids; 28 | 29 | @XmlElement 30 | //@XmlJavaTypeAdapter(NestedArrayAdapter.class) 31 | List> asks; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /bitcoin-exchange.properties.example: -------------------------------------------------------------------------------- 1 | # config file for at.outdated.bitcoin.exchange 2 | # 2014, Erich Birngruber 3 | # see README.md for more information 4 | # 5 | 6 | bitcurex.deposit.btc= 7 | bitcurex.secret= 8 | bitcurex.userid= 9 | 10 | bitkonan.deposit.btc= 11 | bitkonan.secret= 12 | bitkonan.userid= 13 | 14 | bitstamp.customerid= 15 | bitstamp.secret= 16 | bitstamp.userid= 17 | 18 | btce.deposit.btc= 19 | btce.deposit.ltc= 20 | btce.deposit.nmc= 21 | btce.deposit.ppc= 22 | btce.secret= 23 | btce.userid= 24 | 25 | bter.deposit.btc= 26 | bter.deposit.ltc= 27 | bter.deposit.ppc= 28 | bter.secret= 29 | bter.userid= 30 | 31 | kraken.deposit.btc= 32 | kraken.deposit.ltc= 33 | kraken.deposit.nmc= 34 | kraken.deposit.xrp= 35 | kraken.secret= 36 | kraken.userid= 37 | 38 | mtgox.secret= 39 | mtgox.userid= 40 | mtgox.accountid= 41 | 42 | vircurex.deposit.btc= 43 | vircurex.deposit.ftc= 44 | vircurex.deposit.ltc= 45 | vircurex.deposit.nmc= 46 | vircurex.deposit.nvc= 47 | vircurex.deposit.ppc= 48 | vircurex.userid= 49 | vircurex.words.balance= 50 | 51 | -------------------------------------------------------------------------------- /coins-e/src/main/java/at/outdated/bitcoin/exchange/coinse/jaxb/BaseResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.coinse.jaxb; 2 | 3 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeDateAdapter; 4 | 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 7 | import java.util.Date; 8 | 9 | /** 10 | * Created by ebirn on 30.01.14. 11 | */ 12 | public class BaseResponse { 13 | 14 | @XmlElement 15 | boolean status; 16 | 17 | @XmlElement 18 | String message; 19 | 20 | @XmlJavaTypeAdapter(UnixTimeDateAdapter.class) 21 | @XmlElement 22 | Date systime; 23 | 24 | public String getMessage() { 25 | return message; 26 | } 27 | 28 | public boolean isStatus() { 29 | return status; 30 | } 31 | 32 | public Date getSystime() { 33 | return systime; 34 | } 35 | 36 | public boolean isSuccess() { 37 | return status == true; 38 | } 39 | 40 | public boolean isFailure() { 41 | return status == false; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/MarketContainer.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market; 2 | 3 | import java.util.HashMap; 4 | import java.util.Iterator; 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: ebirn 11 | * Date: 16.05.13 12 | * Time: 21:48 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class MarketContainer { 16 | 17 | 18 | protected Map container = new HashMap<>(); 19 | 20 | 21 | public Iterator iterator() { 22 | return container.values().iterator(); 23 | } 24 | 25 | public void clear() { 26 | container.clear(); 27 | } 28 | 29 | 30 | public T get(Market e) { 31 | T t = container.get(e); 32 | 33 | return t; 34 | } 35 | 36 | public void set(Market e, T t) { 37 | if(t != null) { 38 | container.put(e, t); 39 | } 40 | } 41 | 42 | public Set getKeys() { 43 | return container.keySet(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/jaxb/StringBigDecimalAdapter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.jaxb; 2 | 3 | import javax.xml.bind.annotation.adapters.XmlAdapter; 4 | import java.math.BigDecimal; 5 | import java.text.NumberFormat; 6 | import java.util.Locale; 7 | 8 | /** 9 | * Created by ebirn on 13.01.14. 10 | */ 11 | public class StringBigDecimalAdapter extends XmlAdapter { 12 | 13 | 14 | 15 | @Override 16 | public BigDecimal unmarshal(String v) throws Exception { 17 | return new BigDecimal(v); 18 | } 19 | 20 | //TODO: is this good enough converting from double - BigDecimal direct would be better! 21 | @Override 22 | public String marshal(BigDecimal v) throws Exception { 23 | 24 | NumberFormat format = NumberFormat.getInstance(Locale.US); 25 | format.setGroupingUsed(false); 26 | format.setMinimumIntegerDigits(1); 27 | format.setMinimumFractionDigits(4); 28 | format.setMaximumFractionDigits(7); 29 | 30 | return format.format(v.doubleValue()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bitcurex/src/main/java/at/outdated/bitcoin/exchange/bitcurex/jaxb/BitcurexOrderTypeAdapter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitcurex.jaxb; 2 | 3 | import at.outdated.bitcoin.exchange.api.market.OrderType; 4 | 5 | import javax.xml.bind.annotation.adapters.XmlAdapter; 6 | 7 | /** 8 | * Created by ebirn on 20.10.13. 9 | */ 10 | 11 | public class BitcurexOrderTypeAdapter extends XmlAdapter { 12 | /* UNKNOWN, 13 | ASK, 14 | BID 15 | 16 | */ 17 | 18 | @Override 19 | public OrderType unmarshal(Integer v) throws Exception { 20 | 21 | switch(v) { 22 | case 1: 23 | return OrderType.ASK; 24 | 25 | case 2: 26 | return OrderType.BID; 27 | } 28 | 29 | return OrderType.UNDEF; 30 | } 31 | 32 | @Override 33 | public Integer marshal(OrderType v) throws Exception { 34 | 35 | switch(v) { 36 | case ASK: 37 | return 1; 38 | 39 | case BID: 40 | return 2; 41 | } 42 | 43 | return -1; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/container/EnumContainer.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.container; 2 | 3 | import java.util.HashMap; 4 | import java.util.Iterator; 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: ebirn 11 | * Date: 16.05.13 12 | * Time: 21:14 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class EnumContainer implements Iterable { 16 | 17 | 18 | protected Map container = new HashMap<>(); 19 | 20 | 21 | public Iterator iterator() { 22 | return container.values().iterator(); 23 | } 24 | 25 | public void clear() { 26 | container.clear(); 27 | } 28 | 29 | 30 | public T get(E e) { 31 | T t = container.get(e); 32 | 33 | return t; 34 | } 35 | 36 | public void set(E e, T t) { 37 | if(t != null) { 38 | container.put(e, t); 39 | } 40 | } 41 | 42 | public Set getKeys() { 43 | return container.keySet(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/TimedValue.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * Created with IntelliJ IDEA. 7 | * User: ebirn 8 | * Date: 04.05.13 9 | * Time: 18:18 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | public class TimedValue implements Comparable> { 13 | 14 | protected Date timestamp = new Date(); 15 | protected V value; 16 | 17 | public TimedValue() { 18 | 19 | } 20 | 21 | public TimedValue(V value) { 22 | this.timestamp = new Date(); 23 | this.value = value; 24 | } 25 | 26 | public TimedValue(V value, Date timestamp) { 27 | this.timestamp = timestamp; 28 | this.value = value; 29 | } 30 | 31 | 32 | public V getValue() { 33 | return value; 34 | } 35 | 36 | public Date getTimestamp() { 37 | return timestamp; 38 | } 39 | 40 | @Override 41 | public int compareTo(TimedValue o) { 42 | return this.getTimestamp().compareTo(o.getTimestamp()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bitkonan/src/main/java/at/outdated/bitcoin/exchange/bitkonan/BitkonanBalance.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitkonan; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created by ebirn on 05.10.13. 10 | */ 11 | @XmlRootElement 12 | @XmlAccessorType(XmlAccessType.FIELD) 13 | public class BitkonanBalance { 14 | 15 | /* 16 | usd_balance - USD balance 17 | btc_balance - BTC balance 18 | usd_reserved - USD reserved in open orders 19 | btc_reserved - BTC reserved in open orders 20 | usd_available- USD available for trading 21 | btc_available - BTC available for trading 22 | */ 23 | 24 | @XmlElement 25 | double usd_balance; 26 | 27 | @XmlElement 28 | double btc_balance; 29 | 30 | @XmlElement 31 | double usd_reserved; 32 | 33 | @XmlElement 34 | double btc_reserved; 35 | 36 | @XmlElement 37 | double usd_available; 38 | 39 | @XmlElement 40 | double btc_available; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /mtgox/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | at.outdated.bitcoin.exchange 7 | parent 8 | 1 9 | 10 | 11 | mtgox 12 | 1.0-SNAPSHOT 13 | 14 | jar 15 | 16 | Mt.Gox client API 17 | 18 | 19 | ${project.build.directory}/endorsed 20 | UTF-8 21 | 22 | 23 | 24 | 25 | at.outdated.bitcoin.exchange 26 | api 27 | 1.0-SNAPSHOT 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /bitstamp/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | at.outdated.bitcoin.exchange 7 | parent 8 | 1 9 | 10 | 11 | bitstamp 12 | 1.0-SNAPSHOT 13 | 14 | jar 15 | 16 | Bitstamp client API 17 | 18 | 19 | ${project.build.directory}/endorsed 20 | UTF-8 21 | 22 | 23 | 24 | 25 | at.outdated.bitcoin.exchange 26 | api 27 | 1.0-SNAPSHOT 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/currency/Currency.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.currency; 2 | 3 | import javax.xml.bind.annotation.XmlEnum; 4 | 5 | /** 6 | * Created with IntelliJ IDEA. 7 | * User: ebirn 8 | * Date: 02.05.13 9 | * Time: 20:15 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | @XmlEnum 13 | public enum Currency { 14 | BTC, // Bitcoin 15 | LTC, // Litecoin 16 | PPC, // Peer-to-Peer coin 17 | FTC, // Feathercoin 18 | NMC, // Namecoin 19 | XRP, // Ripple 20 | NVC, // Novacoin 21 | QRK, // Quarkcoin 22 | 23 | 24 | EUR(false), // Euro 25 | USD(false), // US Dollars 26 | JPY(false), // Japanese Yen 27 | CNY(false), // Chinese 28 | PLN(false) //Polish Zloty 29 | ; 30 | 31 | private Currency() { 32 | 33 | } 34 | 35 | private Currency(boolean crypto) { 36 | this.crypto = crypto; 37 | } 38 | 39 | private boolean crypto = true; 40 | 41 | public boolean isCrypto() { 42 | return crypto; 43 | } 44 | 45 | public boolean isFiat() { 46 | return !crypto; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /btc-e/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | at.outdated.bitcoin.exchange 7 | parent 8 | 1 9 | 10 | 11 | btc-e 12 | 1.0-SNAPSHOT 13 | jar 14 | 15 | btc-e client API 16 | 17 | 18 | UTF-8 19 | 20 | 21 | 22 | 23 | at.outdated.bitcoin.exchange 24 | api 25 | 1.0-SNAPSHOT 26 | 27 | 28 | javax.json 29 | javax.json-api 30 | 1.0 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/account/TransactionType.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.account; 2 | 3 | import javax.xml.bind.annotation.XmlEnum; 4 | import javax.xml.bind.annotation.XmlEnumValue; 5 | 6 | /** 7 | * Created with IntelliJ IDEA. 8 | * User: ebirn 9 | * Date: 10.05.13 10 | * Time: 20:32 11 | * To change this template use File | Settings | File Templates. 12 | */ 13 | 14 | @XmlEnum 15 | public enum TransactionType { 16 | @XmlEnumValue("withdraw") WITHDRAW, // Money being withdrawn (eg to bank account) 17 | @XmlEnumValue("deposit") DEPOSIT, // Incoming deposit of currency 18 | @XmlEnumValue("in") IN, // BTC gained after a bid order 19 | @XmlEnumValue("spent") SPENT, // Auxiliary currency removed after a bid order 20 | @XmlEnumValue("out") OUT, // BTC removed after an ask order 21 | @XmlEnumValue("earned") EARNED, // Auxiliary currency gained after an ask order 22 | @XmlEnumValue("fee") FEE; //Fee deducted from balance, e.g. during an order. The currency from which the fee is taken depends on the type of order and whether you specified for the fee to be taken from your order or added on top. 23 | } 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Erich Birngruber 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/LagResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import javax.xml.bind.annotation.XmlAccessType; 4 | import javax.xml.bind.annotation.XmlAccessorType; 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: ebirn 11 | * Date: 03.05.13 12 | * Time: 11:00 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | 16 | @XmlRootElement 17 | @XmlAccessorType(XmlAccessType.FIELD) 18 | public class LagResponse { 19 | 20 | @XmlElement(name="lag") 21 | private long lag; 22 | 23 | @XmlElement(name = "lag_text") 24 | private String text; 25 | 26 | @XmlElement(name ="lag_secs") 27 | private double seconds; 28 | 29 | @XmlElement 30 | private String length; 31 | 32 | public long getLag() { 33 | return lag; 34 | } 35 | 36 | public String getText() { 37 | return text; 38 | } 39 | 40 | public double getSeconds() { 41 | return seconds; 42 | } 43 | 44 | public String getLength() { 45 | return length; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | at.outdated.bitcoin.exchange 7 | parent 8 | 1 9 | 10 | 11 | api 12 | 1.0-SNAPSHOT 13 | Bitcoin Exchange API 14 | http://maven.apache.org 15 | 16 | UTF-8 17 | 18 | 19 | 20 | 21 | 22 | commons-collections 23 | commons-collections 24 | 3.2.2 25 | 26 | 27 | 28 | org.apache.commons 29 | commons-math3 30 | 3.2 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/DepthResponse.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeMicroDateAdapter; 4 | 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 7 | import java.util.ArrayList; 8 | import java.util.Date; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by ebirn on 03.10.13. 13 | */ 14 | public class DepthResponse { 15 | 16 | 17 | @XmlElement 18 | @XmlJavaTypeAdapter(UnixTimeMicroDateAdapter.class) 19 | Date now; 20 | 21 | @XmlElement 22 | @XmlJavaTypeAdapter(UnixTimeMicroDateAdapter.class) 23 | Date cached; 24 | 25 | @XmlElement 26 | List asks = new ArrayList<>(); 27 | 28 | @XmlElement 29 | List bids = new ArrayList<>(); 30 | 31 | 32 | public Date getNow() { 33 | return now; 34 | } 35 | 36 | public Date getCached() { 37 | return cached; 38 | } 39 | 40 | public List getAsks() { 41 | return asks; 42 | } 43 | 44 | public List getBids() { 45 | return bids; 46 | } 47 | 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/track/TrackInterval.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.track; 2 | 3 | /** 4 | * Created with IntelliJ IDEA. 5 | * User: ebirn 6 | * Date: 09.05.13 7 | * Time: 15:42 8 | * To change this template use File | Settings | File Templates. 9 | */ 10 | public enum TrackInterval { 11 | 12 | MIN1(1000L * 60L), 13 | MIN5(1000L * 60L * 5L), 14 | MIN10(1000L * 60L * 10L), 15 | MIN15(1000L * 60L * 15L), 16 | MIN20(1000L * 60L* 20L), 17 | MIN30(1000L * 60L* 30L), 18 | H1(1000L * 60L * 60L), 19 | H2(1000L * 60L * 60L * 2L), 20 | H3(1000L * 60L * 60L * 3L), 21 | H4(1000L * 60L * 60L * 4L), 22 | H6(1000L * 60L * 60L * 6L), 23 | H12(1000L * 60L * 60L * 12L), 24 | H24(1000L * 60L * 60L * 24L); 25 | 26 | 27 | private long duration; 28 | 29 | private static final long SAMPLES_PER_MINUTE = 1; 30 | 31 | private TrackInterval(long durationInMillis) { 32 | this.duration = durationInMillis; 33 | } 34 | 35 | public long duration() { 36 | return duration; 37 | } 38 | 39 | public int numSamples() { 40 | return (int) (duration/1000/60/SAMPLES_PER_MINUTE); 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /bitcurex/src/main/java/at/outdated/bitcoin/exchange/bitcurex/jaxb/Funds.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitcurex.jaxb; 2 | 3 | import at.outdated.bitcoin.exchange.api.jaxb.StringBigDecimalAdapter; 4 | 5 | import javax.xml.bind.annotation.XmlAccessType; 6 | import javax.xml.bind.annotation.XmlAccessorType; 7 | import javax.xml.bind.annotation.XmlElement; 8 | import javax.xml.bind.annotation.XmlRootElement; 9 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 10 | import java.math.BigDecimal; 11 | 12 | /** 13 | * Created by ebirn on 20.10.13. 14 | */ 15 | @XmlRootElement 16 | @XmlAccessorType(XmlAccessType.FIELD) 17 | public class Funds extends BaseApiResponse { 18 | 19 | @XmlElement 20 | @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 21 | private BigDecimal eurs; 22 | 23 | @XmlElement 24 | @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 25 | private BigDecimal btcs; 26 | 27 | @XmlElement 28 | private String address; 29 | 30 | public BigDecimal getEurs() { 31 | return eurs; 32 | } 33 | 34 | public BigDecimal getBtcs() { 35 | return btcs; 36 | } 37 | 38 | public String getAddress() { 39 | return address; 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/auth/RequestAuth.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox.auth; 2 | 3 | import org.apache.commons.codec.binary.Base64; 4 | 5 | import javax.crypto.Mac; 6 | import javax.crypto.spec.SecretKeySpec; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: ebirn 11 | * Date: 03.05.13 12 | * Time: 10:51 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class RequestAuth { 16 | 17 | 18 | 19 | public String hmac(String path, String message, String secret) { 20 | 21 | try { 22 | // args signature 23 | Mac mac = Mac.getInstance("HmacSHA512"); 24 | SecretKeySpec secret_spec = new SecretKeySpec(Base64.decodeBase64(secret), "HmacSHA512"); 25 | mac.init(secret_spec); 26 | 27 | // path + NUL + POST (incl. nonce) 28 | String payload = path + "\0" + message; 29 | String signature = new String(Base64.encodeBase64(mac.doFinal(payload.getBytes()), false)); 30 | 31 | // cleanup string 32 | return signature.replaceAll("\n", ""); 33 | } 34 | catch(Exception e) { 35 | return null; 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /icbit/src/main/java/at/outdated/bitcoin/exchange/icbit/IcbitWebsocketClient.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.icbit; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import javax.websocket.*; 7 | 8 | /** 9 | * Created by ebirn on 31.10.13. 10 | */ 11 | 12 | @ClientEndpoint 13 | public class IcbitWebsocketClient { 14 | 15 | Logger log = LoggerFactory.getLogger("icbit.ws"); 16 | 17 | Session session; 18 | @OnOpen 19 | public void connect(Session session) { 20 | log.info("opened with session: {}", session); 21 | } 22 | 23 | @OnClose 24 | public void disconnect(CloseReason reason) { 25 | log.info("bye. - {}", reason); 26 | } 27 | 28 | @OnMessage 29 | public void message(String textMsg) { 30 | log.info("receiving: {}", textMsg); 31 | } 32 | 33 | @OnError 34 | public void error(Throwable t) { 35 | log.error("problem: {}", t); 36 | } 37 | 38 | public void sendMessage(String msg) { 39 | try { 40 | log.info("sending: {}", msg); 41 | session.getBasicRemote().sendText(msg); 42 | } 43 | catch(Exception e) { 44 | log.error("failed to send", e); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/track/ValueTrackCollection.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.track; 2 | 3 | import java.util.HashMap; 4 | import java.util.Iterator; 5 | import java.util.Map; 6 | 7 | /** 8 | * Created with IntelliJ IDEA. 9 | * User: ebirn 10 | * Date: 30.05.13 11 | * Time: 21:59 12 | * To change this template use File | Settings | File Templates. 13 | */ 14 | public class ValueTrackCollection> implements Iterable { 15 | 16 | protected Map tracks = new HashMap<>(TrackInterval.values().length); 17 | 18 | protected V latest; 19 | 20 | 21 | public void insert(V value) { 22 | this.latest = value; 23 | for(ValueTrack track : tracks.values()) { 24 | track.insert(value); 25 | } 26 | } 27 | 28 | public V getLatest() { 29 | return latest; 30 | } 31 | 32 | 33 | public T getTrack(TrackInterval interval) { 34 | T track = tracks.get(interval); 35 | return track; 36 | } 37 | 38 | 39 | @Override 40 | public Iterator iterator() { 41 | return tracks.values().iterator(); 42 | } 43 | 44 | public void setTrack(TrackInterval ti, T track) { 45 | tracks.put(ti, track); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/DepthEntry.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeMicroDateAdapter; 4 | 5 | import javax.xml.bind.annotation.XmlAccessType; 6 | import javax.xml.bind.annotation.XmlAccessorType; 7 | import javax.xml.bind.annotation.XmlElement; 8 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 9 | import java.math.BigDecimal; 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by ebirn on 03.10.13. 14 | */ 15 | @XmlAccessorType(XmlAccessType.FIELD) 16 | public class DepthEntry { 17 | 18 | @XmlElement 19 | BigDecimal price; 20 | 21 | @XmlElement 22 | BigDecimal amount; 23 | 24 | @XmlElement 25 | int price_int; 26 | 27 | @XmlElement 28 | int amount_int; 29 | 30 | 31 | @XmlElement 32 | @XmlJavaTypeAdapter(UnixTimeMicroDateAdapter.class) 33 | Date stamp; 34 | 35 | 36 | public BigDecimal getPrice() { 37 | return price; 38 | } 39 | 40 | public BigDecimal getAmount() { 41 | return amount; 42 | } 43 | 44 | public int getPrice_int() { 45 | return price_int; 46 | } 47 | 48 | public int getAmount_int() { 49 | return amount_int; 50 | } 51 | 52 | public Date getStamp() { 53 | return stamp; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/MtGoxWalletHistory.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | 4 | import javax.xml.bind.annotation.XmlAccessType; 5 | import javax.xml.bind.annotation.XmlAccessorType; 6 | import javax.xml.bind.annotation.XmlElement; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Created with IntelliJ IDEA. 12 | * User: ebirn 13 | * Date: 10.05.13 14 | * Time: 20:18 15 | * To change this template use File | Settings | File Templates. 16 | */ 17 | 18 | @XmlAccessorType(XmlAccessType.FIELD) 19 | public class MtGoxWalletHistory { 20 | 21 | private int records; 22 | 23 | private int current_page; 24 | 25 | private int max_page; 26 | 27 | private int max_results; 28 | 29 | @XmlElement(name="result") 30 | private List transactions = new ArrayList<>(); 31 | 32 | 33 | public int getRecords() { 34 | return records; 35 | } 36 | 37 | public int getCurrentPage() { 38 | return current_page; 39 | } 40 | 41 | public int getMaxPage() { 42 | return max_page; 43 | } 44 | 45 | public int getMaxResults() { 46 | return max_results; 47 | } 48 | 49 | public List getTransactions() { 50 | return transactions; 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/OrderType.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market; 2 | 3 | /** 4 | * Created with IntelliJ IDEA. 5 | * User: ebirn 6 | * Date: 10.05.13 7 | * Time: 20:09 8 | * 9 | * http://en.wikipedia.org/wiki/Ask_price 10 | * http://en.wikipedia.org/wiki/Bid_price 11 | */ 12 | public enum OrderType { 13 | BID("buy"), // BUY, A bid price is the highest price that a buyer (i.e., bidder) is willing to pay for a good. 14 | ASK("sell"), // SELL, Ask price, also called offer price, offer, asking price, or simply ask, is the price a seller states she or he will accept for a good. 15 | UNDEF("unknown") //no mans land value 16 | ; 17 | 18 | 19 | private OrderType(String v) { 20 | this.verb = v; 21 | } 22 | String verb; 23 | 24 | public String verb() { 25 | return verb; 26 | } 27 | 28 | public static OrderType parse(String str) { 29 | OrderType parsed = UNDEF; 30 | 31 | str = str.toLowerCase(); 32 | switch(str) { 33 | case "buy": 34 | case "bid": 35 | parsed = BID; 36 | break; 37 | 38 | case "sell": 39 | case "ask": 40 | parsed = ASK; 41 | break; 42 | } 43 | 44 | return parsed; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /archetype/src/main/resources/archetype-resources/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | at.outdated.bitcoin.exchange 7 | parent 8 | 1 9 | 10 | 11 | ${artifactId} 12 | ${version} 13 | jar 14 | 15 | ${artefactId} exchange 16 | 17 | 18 | 19 | 20 | at.outdated.bitcoin.exchange 21 | api 22 | ${version} 23 | 24 | 25 | 26 | junit 27 | junit 28 | 3.8.1 29 | test 30 | 31 | 32 | 33 | 34 | at.outdated.bitcoin.exchange 35 | api 36 | ${version} 37 | test-jar 38 | test 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /btc-e/src/main/java/at/outdated/bitcoin/exchange/btce/BtcEAccountInfo.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.btce; 2 | 3 | import at.outdated.bitcoin.exchange.api.account.AccountInfo; 4 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeDateAdapter; 5 | import at.outdated.bitcoin.exchange.api.market.OrderType; 6 | import at.outdated.bitcoin.exchange.api.market.fee.Fee; 7 | import at.outdated.bitcoin.exchange.api.market.fee.SimplePercentageFee; 8 | 9 | import javax.xml.bind.annotation.XmlAccessType; 10 | import javax.xml.bind.annotation.XmlAccessorType; 11 | import javax.xml.bind.annotation.XmlElement; 12 | import javax.xml.bind.annotation.XmlRootElement; 13 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 14 | import java.util.Date; 15 | 16 | /** 17 | * Created with IntelliJ IDEA. 18 | * User: ebirn 19 | * Date: 26.05.13 20 | * Time: 23:44 21 | * To change this template use File | Settings | File Templates. 22 | */ 23 | @XmlRootElement 24 | @XmlAccessorType(XmlAccessType.FIELD) 25 | public class BtcEAccountInfo extends AccountInfo { 26 | 27 | 28 | @XmlElement(name = "server_time") 29 | @XmlJavaTypeAdapter(UnixTimeDateAdapter.class) 30 | Date serverTime; 31 | 32 | @XmlElement 33 | BtceFunds funds; 34 | 35 | 36 | @Override 37 | public Fee getTradeFee(OrderType trade) { 38 | 39 | return new SimplePercentageFee(0.002); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/jaxb/NestedArrayAdapter.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.jaxb; 2 | 3 | import javax.json.Json; 4 | import javax.json.JsonArray; 5 | import javax.json.JsonReader; 6 | import javax.xml.bind.annotation.adapters.XmlAdapter; 7 | import java.io.StringReader; 8 | 9 | /** 10 | * Created by ebirn on 30.09.13. 11 | */ 12 | public class NestedArrayAdapter extends XmlAdapter { 13 | 14 | @Override 15 | public float[][] unmarshal(String v) throws Exception { 16 | 17 | JsonReader jsonReader = Json.createReader(new StringReader(v)); 18 | JsonArray jsonArray = jsonReader.readArray(); 19 | jsonReader.close(); 20 | 21 | int len = jsonArray.size(); 22 | float[][] resultArray = new float[len][]; 23 | 24 | for(int i=0; i orders; 36 | 37 | 38 | public BigDecimal getEurs() { 39 | return eurs; 40 | } 41 | 42 | public BigDecimal getBtcs() { 43 | return btcs; 44 | } 45 | 46 | public List getOrders() { 47 | return orders; 48 | } 49 | 50 | public BigDecimal getPlns() { 51 | return plns; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /coins-e/src/main/java/at/outdated/bitcoin/exchange/coinse/jaxb/ListOrders.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.coinse.jaxb; 2 | 3 | import javax.xml.bind.annotation.*; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * Created by ebirn on 30.01.14. 9 | */ 10 | @XmlRootElement 11 | @XmlAccessorType(XmlAccessType.FIELD) 12 | public class ListOrders extends BaseResponse { 13 | /* 14 | { 15 | "status": true, 16 | "message": "success", 17 | "next_cursor": "E-ABAOsB8gEHY3JlYXRlZPoBCQiI-ab9jJO4AuwBggJiagtkZXZ-Qw", 18 | "orders": [ 19 | { 20 | "status": "cancelled", 21 | "order_type": "buy", 22 | "created": 1372847281, 23 | "quantity_remaining": "0.0", 24 | "fee_rate": "0.00300000", 25 | "rate": "0.00212300", 26 | "is_open": false, 27 | "pair": "WDC_BTC", 28 | "id": "B/0.00212300/6643661571883008", 29 | "quantity": "1.00000000" 30 | }, 31 | */ 32 | 33 | @XmlElement(name = "next_cursor") 34 | String nextCursor; 35 | 36 | @XmlElements({ 37 | @XmlElement(name="orders"), 38 | @XmlElement(name="trades") 39 | }) 40 | List orders = new ArrayList<>(); 41 | 42 | public String getNextCursor() { 43 | return nextCursor; 44 | } 45 | 46 | public List getOrders() { 47 | return orders; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /icbit/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | parent 7 | at.outdated.bitcoin.exchange 8 | 1 9 | 10 | 4.0.0 11 | 12 | icbit 13 | 14 | 15 | icbit.se client API 16 | 17 | 18 | 19 | at.outdated.bitcoin.exchange 20 | api 21 | 1.0-SNAPSHOT 22 | 23 | 24 | javax.websocket 25 | javax.websocket-api 26 | 1.0 27 | provided 28 | 29 | 30 | 31 | org.glassfish.tyrus 32 | tyrus-client 33 | 1.2.1 34 | test 35 | 36 | 37 | 38 | org.glassfish.tyrus 39 | tyrus-container-grizzly 40 | 1.2.1 41 | test 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/client/TradeClient.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.client; 2 | 3 | import at.outdated.bitcoin.exchange.api.OrderId; 4 | import at.outdated.bitcoin.exchange.api.account.Balance; 5 | import at.outdated.bitcoin.exchange.api.account.WalletTransaction; 6 | import at.outdated.bitcoin.exchange.api.currency.Currency; 7 | import at.outdated.bitcoin.exchange.api.currency.CurrencyAddress; 8 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 9 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 10 | import at.outdated.bitcoin.exchange.api.market.MarketOrder; 11 | import at.outdated.bitcoin.exchange.api.market.OrderType; 12 | import at.outdated.bitcoin.exchange.api.market.fee.Fee; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * Created by ebirn on 09.11.13. 18 | */ 19 | public interface TradeClient { 20 | 21 | public Balance getBalance(); 22 | public List getTransactions(); 23 | 24 | //public void updateFees(); 25 | public Fee getTradeFee(OrderType trade); 26 | public Fee getDepositFee(Currency curr); 27 | public Fee getWithdrawalFee(Currency curr); 28 | 29 | public List getOpenOrders(); 30 | 31 | public OrderId placeOrder(MarketOrder order); 32 | public OrderId placeOrder(AssetPair asset, OrderType type, CurrencyValue volume, CurrencyValue price); 33 | 34 | public boolean cancelOrder(OrderId order); 35 | 36 | public CurrencyAddress getDepositAddress(Currency currency); 37 | public boolean withdrawFunds(CurrencyValue volume, CurrencyAddress destination); 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /bitkonan/src/main/java/at/outdated/bitcoin/exchange/bitkonan/BitkonanMarket.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitkonan; 2 | 3 | import at.outdated.bitcoin.exchange.api.client.ExchangeClient; 4 | import at.outdated.bitcoin.exchange.api.currency.Currency; 5 | import at.outdated.bitcoin.exchange.api.market.Market; 6 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferMethod; 7 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferType; 8 | 9 | /** 10 | * Created with IntelliJ IDEA. 11 | * User: ebirn 12 | * Date: 26.05.13 13 | * Time: 23:41 14 | * To change this template use File | Settings | File Templates. 15 | */ 16 | public class BitkonanMarket extends Market { 17 | 18 | 19 | public BitkonanMarket() { 20 | super("bitkonan", "http://bitkonan.com", "BitKonan"); 21 | 22 | addDeposit(new TransferMethod(Currency.BTC, TransferType.VIRTUAL)); 23 | addDeposit(new TransferMethod(Currency.LTC, TransferType.VIRTUAL)); 24 | addDeposit(new TransferMethod(Currency.USD, TransferType.BANK)); 25 | 26 | addWithdrawal(new TransferMethod(Currency.BTC, TransferType.VIRTUAL)); 27 | addWithdrawal(new TransferMethod(Currency.LTC, TransferType.VIRTUAL)); 28 | addWithdrawal(new TransferMethod(Currency.USD, TransferType.BANK)); 29 | 30 | addAsset(Currency.BTC, Currency.USD); 31 | addAsset(Currency.LTC, Currency.USD); 32 | } 33 | 34 | @Override 35 | public ExchangeClient createClient() { 36 | return new BitkonanApiClient(this); //To change body of implemented methods use File | Settings | File Templates. 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/OrderComparator.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 4 | 5 | import java.util.Comparator; 6 | 7 | /** 8 | * Created by ebirn on 11.01.14. 9 | */ 10 | public class OrderComparator implements Comparator { 11 | 12 | OrderType orderType; 13 | 14 | public OrderComparator() { 15 | } 16 | 17 | public OrderComparator(OrderType orderType) { 18 | this.orderType = orderType; 19 | } 20 | 21 | public void setOrderType(OrderType type) { 22 | this.orderType = type; 23 | } 24 | 25 | 26 | @Override 27 | public int compare(MarketOrder o1, MarketOrder o2) { 28 | 29 | switch (orderType) { 30 | case ASK: 31 | return compareAsk(o1.getPrice(), o2.getPrice()); 32 | 33 | case BID: 34 | return compareBid(o1.getPrice(), o2.getPrice()); 35 | } 36 | 37 | return 0; 38 | } 39 | 40 | 41 | // sort ascending 42 | private int compareAsk(CurrencyValue price1, CurrencyValue price2) { 43 | 44 | if(price1.getValue() == price2.getValue()) return 0; 45 | 46 | if(price1.isMoreThan(price2)) { 47 | return 1; 48 | } 49 | 50 | return -1; 51 | } 52 | 53 | // sort descending 54 | private int compareBid(CurrencyValue price1, CurrencyValue price2) { 55 | 56 | if(price1.getValue() == price2.getValue()) return 0; 57 | 58 | if(price1.isLessThan(price2)) { 59 | return 1; 60 | } 61 | return -1; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/fee/SimplePercentageFee.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market.fee; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 4 | import at.outdated.bitcoin.exchange.api.market.OrderType; 5 | 6 | import java.math.BigDecimal; 7 | import java.text.NumberFormat; 8 | 9 | /** 10 | * Created with IntelliJ IDEA. 11 | * User: ebirn 12 | * Date: 09.06.13 13 | * Time: 17:37 14 | * To change this template use File | Settings | File Templates. 15 | */ 16 | public class SimplePercentageFee extends Fee { 17 | 18 | BigDecimal percentage = BigDecimal.ZERO; 19 | 20 | public SimplePercentageFee() { 21 | 22 | } 23 | 24 | public SimplePercentageFee(String percentage) { 25 | this.percentage = new BigDecimal(percentage); 26 | } 27 | 28 | public SimplePercentageFee(BigDecimal percentage) { 29 | this.percentage = percentage; 30 | } 31 | 32 | @Deprecated 33 | public SimplePercentageFee(double percentage) { 34 | this.percentage = new BigDecimal(percentage); 35 | } 36 | 37 | @Override 38 | public CurrencyValue calculate(OrderType type, CurrencyValue volume) { 39 | 40 | CurrencyValue fee = new CurrencyValue(volume); 41 | fee.multiply(percentage); 42 | 43 | return fee; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | NumberFormat format = NumberFormat.getPercentInstance(); 49 | 50 | format.setMinimumFractionDigits(2); 51 | 52 | String percentStr = format.format(percentage.doubleValue()); 53 | 54 | return super.toString() + percentStr; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/MtGoxMarket.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import at.outdated.bitcoin.exchange.api.client.ExchangeClient; 4 | import at.outdated.bitcoin.exchange.api.currency.Currency; 5 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 6 | import at.outdated.bitcoin.exchange.api.market.Market; 7 | import at.outdated.bitcoin.exchange.api.market.fee.ConstantFee; 8 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferMethod; 9 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferType; 10 | 11 | /** 12 | * Created with IntelliJ IDEA. 13 | * User: ebirn 14 | * Date: 23.05.13 15 | * Time: 21:32 16 | * To change this template use File | Settings | File Templates. 17 | */ 18 | public class MtGoxMarket extends Market { 19 | 20 | public MtGoxMarket() { 21 | super("mtgox", "http://www.mtgox.com", "Mt.Gox"); 22 | 23 | withdrawals.put(Currency.BTC, new TransferMethod(Currency.BTC, TransferType.VIRTUAL)); 24 | withdrawals.put(Currency.EUR, new TransferMethod(Currency.EUR, TransferType.BANK)); 25 | 26 | deposits.put(Currency.BTC, new TransferMethod(Currency.BTC, TransferType.VIRTUAL)); 27 | deposits.put(Currency.EUR, new TransferMethod(Currency.EUR, TransferType.BANK, new ConstantFee(new CurrencyValue("2.5", Currency.EUR)))); 28 | 29 | addAsset(Currency.BTC, Currency.USD); 30 | addAsset(Currency.BTC, Currency.EUR); 31 | addAsset(Currency.BTC, Currency.JPY); 32 | 33 | } 34 | 35 | @Override 36 | public ExchangeClient createClient() { 37 | return new MtGoxClient(this); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /cryptsy/src/main/java/at/outdated/bitcoin/exchange/cryptsy/CryptsyTrade.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.cryptsy; 2 | 3 | import at.outdated.bitcoin.exchange.api.OrderId; 4 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 5 | import at.outdated.bitcoin.exchange.api.market.Market; 6 | import at.outdated.bitcoin.exchange.api.market.MarketOrder; 7 | 8 | import javax.xml.bind.annotation.XmlAccessType; 9 | import javax.xml.bind.annotation.XmlAccessorType; 10 | import javax.xml.bind.annotation.XmlRootElement; 11 | import java.math.BigDecimal; 12 | import java.util.Date; 13 | 14 | /** 15 | * Created by ebirn on 09.02.14. 16 | */ 17 | @XmlRootElement 18 | @XmlAccessorType(XmlAccessType.FIELD) 19 | public class CryptsyTrade { 20 | /* 21 | 22 | tradeid A unique ID for the trade 23 | datetime Server datetime trade occurred 24 | tradeprice The price the trade occurred at 25 | quantity Quantity traded 26 | total Total value of trade (tradeprice * quantity) 27 | initiate_ordertype The type of order which initiated this trade 28 | */ 29 | 30 | String tradeid; 31 | 32 | Date datetime; 33 | 34 | BigDecimal tradeprice; 35 | 36 | BigDecimal quantity; 37 | 38 | BigDecimal total; 39 | 40 | String initiate_ordertype; 41 | 42 | 43 | 44 | public MarketOrder getOrder(Market m, AssetPair asset) { 45 | 46 | MarketOrder order = new MarketOrder(new OrderId(m, tradeid)); 47 | 48 | order.setAsset(asset); 49 | order.setTimestamp(datetime); 50 | 51 | order.setPrice(tradeprice); 52 | order.setVolume(quantity); 53 | 54 | //TODO: set order type based on initiate_ordertype value 55 | 56 | return order; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /bter/src/main/java/at/outdated/bitcoin/exchange/bter/BterTrade.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bter; 2 | 3 | import at.outdated.bitcoin.exchange.api.OrderId; 4 | import at.outdated.bitcoin.exchange.api.jaxb.OrderTypeAdapter; 5 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeDateAdapter; 6 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 7 | import at.outdated.bitcoin.exchange.api.market.Market; 8 | import at.outdated.bitcoin.exchange.api.market.MarketOrder; 9 | import at.outdated.bitcoin.exchange.api.market.OrderType; 10 | 11 | import javax.xml.bind.annotation.XmlAccessType; 12 | import javax.xml.bind.annotation.XmlAccessorType; 13 | import javax.xml.bind.annotation.XmlRootElement; 14 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 15 | import java.math.BigDecimal; 16 | import java.util.Date; 17 | 18 | /** 19 | * Created by ebirn on 09.02.14. 20 | */ 21 | @XmlRootElement 22 | @XmlAccessorType(XmlAccessType.FIELD) 23 | public class BterTrade { 24 | 25 | // {"date":"1391940727","price":4576,"amount":0.1962,"tid":"4422029","type":"buy"}, 26 | 27 | @XmlJavaTypeAdapter(UnixTimeDateAdapter.class) 28 | Date date; 29 | 30 | 31 | BigDecimal price; 32 | 33 | BigDecimal amount; 34 | 35 | String tid; 36 | 37 | @XmlJavaTypeAdapter(OrderTypeAdapter.class) 38 | OrderType type; 39 | 40 | public MarketOrder getOrder(Market m, AssetPair asset) { 41 | 42 | MarketOrder o = new MarketOrder(); 43 | o.setAsset(asset); 44 | 45 | o.setId(new OrderId(m, tid)); 46 | o.setType(type); 47 | o.setTimestamp(date); 48 | 49 | o.setVolume(amount); 50 | o.setPrice(price); 51 | 52 | return o; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vircurex/src/main/java/at/outdated/bitcoin/exchange/vircurex/VircurexTrade.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.vircurex; 2 | 3 | import at.outdated.bitcoin.exchange.api.OrderId; 4 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeDateAdapter; 5 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 6 | import at.outdated.bitcoin.exchange.api.market.Market; 7 | import at.outdated.bitcoin.exchange.api.market.MarketOrder; 8 | import at.outdated.bitcoin.exchange.api.market.OrderType; 9 | 10 | import javax.xml.bind.annotation.XmlElement; 11 | import javax.xml.bind.annotation.XmlRootElement; 12 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 13 | import java.math.BigDecimal; 14 | import java.util.Date; 15 | 16 | /** 17 | * Created by ebirn on 09.02.14. 18 | */ 19 | @XmlRootElement 20 | public class VircurexTrade { 21 | 22 | /* 23 | [{"date":1391011966,"tid":1331206,"amount":"1.0","price":"0.02669999"}, 24 | {"date":1391011966,"tid":1331208,"amount":"2.9995","price":"0.0267"}, 25 | */ 26 | 27 | @XmlElement 28 | int tid; 29 | 30 | @XmlElement 31 | @XmlJavaTypeAdapter(UnixTimeDateAdapter.class) 32 | Date date; 33 | 34 | @XmlElement 35 | BigDecimal amount; 36 | 37 | @XmlElement 38 | BigDecimal price; 39 | 40 | public MarketOrder getOrder(Market m, AssetPair asset) { 41 | 42 | MarketOrder order = new MarketOrder(); 43 | 44 | order.setId(new OrderId(m, Integer.toString(tid))); 45 | order.setAsset(asset); 46 | 47 | order.setVolume(amount); 48 | order.setPrice(price); 49 | 50 | order.setTimestamp(date); 51 | 52 | order.setType(OrderType.UNDEF); 53 | 54 | return order; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /bitcurex/src/main/java/at/outdated/bitcoin/exchange/bitcurex/BitcurexMarket.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitcurex; 2 | 3 | import at.outdated.bitcoin.exchange.api.client.ExchangeClient; 4 | import at.outdated.bitcoin.exchange.api.currency.Currency; 5 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 6 | import at.outdated.bitcoin.exchange.api.market.Market; 7 | import at.outdated.bitcoin.exchange.api.market.fee.ConstantFee; 8 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferMethod; 9 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferType; 10 | 11 | /** 12 | * Created with IntelliJ IDEA. 13 | * User: ebirn 14 | * Date: 30.05.13 15 | * Time: 12:50 16 | * To change this template use File | Settings | File Templates. 17 | */ 18 | public class BitcurexMarket extends Market { 19 | 20 | 21 | public BitcurexMarket() { 22 | super("bitcurex", "https://eur.bitcurex.com/", "Bitcurex"); 23 | 24 | addDeposit(new TransferMethod(Currency.BTC, TransferType.VIRTUAL)); 25 | addDeposit(new TransferMethod(Currency.EUR, TransferType.BANK, new ConstantFee(new CurrencyValue("0.30", Currency.EUR)))); 26 | 27 | addWithdrawal(new TransferMethod(Currency.BTC, TransferType.VIRTUAL)); 28 | addWithdrawal(new TransferMethod(Currency.EUR, TransferType.BANK, new ConstantFee(new CurrencyValue("1.15", Currency.EUR)))); 29 | 30 | addAsset(Currency.BTC, Currency.EUR); 31 | addAsset(Currency.BTC, Currency.PLN); 32 | } 33 | 34 | @Override 35 | public ExchangeClient createClient() { 36 | return new BitcurexApiClient(this); //To change body of implemented methods use File | Settings | File Templates. 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/fee/ConstantFee.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market.fee; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | import at.outdated.bitcoin.exchange.api.market.OrderType; 6 | 7 | import java.math.BigDecimal; 8 | 9 | /** 10 | * Created with IntelliJ IDEA. 11 | * User: ebirn 12 | * Date: 10.06.13 13 | * Time: 16:27 14 | * To change this template use File | Settings | File Templates. 15 | */ 16 | public class ConstantFee extends Fee { 17 | 18 | BigDecimal constantFee; 19 | Currency currency; 20 | 21 | public ConstantFee(CurrencyValue currencyFee) { 22 | this.constantFee = currencyFee.getValue(); 23 | this.currency = currencyFee.getCurrency(); 24 | } 25 | 26 | 27 | public ConstantFee(Number feeValue) { 28 | super(); 29 | constantFee = new BigDecimal(feeValue.doubleValue()); 30 | } 31 | 32 | 33 | public ConstantFee(String feeValue) { 34 | super(); 35 | constantFee = new BigDecimal(feeValue); 36 | } 37 | 38 | @Override 39 | public CurrencyValue calculate(OrderType type, CurrencyValue volume) { 40 | 41 | Currency feeCurrency = currency == null ? volume.getCurrency() : currency; 42 | 43 | return new CurrencyValue(constantFee, feeCurrency); //To change body of implemented methods use File | Settings | File Templates. 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | 49 | String curr = this.currency == null ? constantFee.toString() : new CurrencyValue(constantFee, currency).toString(); 50 | 51 | return super.toString() + curr; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /bitcurex/src/main/java/at/outdated/bitcoin/exchange/bitcurex/jaxb/BitcurexOrder.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitcurex.jaxb; 2 | 3 | import at.outdated.bitcoin.exchange.api.jaxb.StringBigDecimalAdapter; 4 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeDateAdapter; 5 | import at.outdated.bitcoin.exchange.api.market.OrderType; 6 | 7 | import javax.xml.bind.annotation.XmlElement; 8 | import javax.xml.bind.annotation.XmlElements; 9 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 10 | import java.math.BigDecimal; 11 | import java.util.Date; 12 | 13 | /** 14 | * Created by ebirn on 20.10.13. 15 | */ 16 | 17 | public class BitcurexOrder { 18 | 19 | @XmlElements({ 20 | @XmlElement(name="oid"), 21 | @XmlElement(name="tid") 22 | }) 23 | String oid; 24 | 25 | @XmlElement 26 | @XmlJavaTypeAdapter(BitcurexOrderTypeAdapter.class) 27 | OrderType type; 28 | 29 | @XmlElement 30 | @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 31 | BigDecimal amount; 32 | 33 | @XmlElement 34 | @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 35 | BigDecimal price; 36 | 37 | @XmlElements({ 38 | @XmlElement(name="timestamp"), 39 | @XmlElement(name="date") 40 | }) 41 | @XmlJavaTypeAdapter(UnixTimeDateAdapter.class) 42 | Date timestamp; 43 | 44 | public String getOid() { 45 | return oid; 46 | } 47 | 48 | public OrderType getType() { 49 | return type; 50 | } 51 | 52 | public BigDecimal getAmount() { 53 | return amount; 54 | } 55 | 56 | public BigDecimal getPrice() { 57 | return price; 58 | } 59 | 60 | public Date getTimestamp() { 61 | return timestamp; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vircurex/src/main/java/at/outdated/bitcoin/exchange/vircurex/VircurexTicker.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.vircurex; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 6 | import at.outdated.bitcoin.exchange.api.market.TickerValue; 7 | 8 | import javax.xml.bind.annotation.XmlAccessType; 9 | import javax.xml.bind.annotation.XmlAccessorType; 10 | import javax.xml.bind.annotation.XmlElement; 11 | import javax.xml.bind.annotation.XmlRootElement; 12 | import java.math.BigDecimal; 13 | 14 | /** 15 | * Created by ebirn on 11.10.13. 16 | */ 17 | @XmlRootElement 18 | @XmlAccessorType(XmlAccessType.FIELD) 19 | public class VircurexTicker { 20 | 21 | // {"base":"BTC","alt":"LTC","lowest_ask":"62.30141425","highest_bid":"61.12503063","last_trade":"62.30529595","volume":"82.92624028"}% 22 | 23 | @XmlElement(name="base") 24 | Currency base; 25 | 26 | @XmlElement(name="alt") 27 | Currency quote; 28 | 29 | @XmlElement(name="lowest_ask") 30 | BigDecimal ask; 31 | 32 | @XmlElement(name="highest_bid") 33 | BigDecimal bid; 34 | 35 | @XmlElement(name="last_trade") 36 | BigDecimal last; 37 | 38 | @XmlElement(name="volume") 39 | BigDecimal volume; 40 | 41 | public TickerValue getValue() { 42 | 43 | AssetPair asset = new AssetPair(base, quote); 44 | 45 | TickerValue val = new TickerValue(asset); 46 | 47 | val.setLast(new CurrencyValue(last, quote)); 48 | 49 | val.setAsk(new CurrencyValue(ask, quote)); 50 | val.setBid(new CurrencyValue(bid, quote)); 51 | 52 | val.setVolume(new CurrencyValue(volume, base)); 53 | 54 | return val; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /bitkonan/src/main/java/at/outdated/bitcoin/exchange/bitkonan/BitkonanTickerValue.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitkonan; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 6 | import at.outdated.bitcoin.exchange.api.market.TickerValue; 7 | 8 | import javax.xml.bind.annotation.XmlAccessType; 9 | import javax.xml.bind.annotation.XmlAccessorType; 10 | import javax.xml.bind.annotation.XmlElement; 11 | import java.math.BigDecimal; 12 | 13 | /** 14 | * Created with IntelliJ IDEA. 15 | * User: ebirn 16 | * Date: 26.05.13 17 | * Time: 23:50 18 | * To change this template use File | Settings | File Templates. 19 | */ 20 | @XmlAccessorType(XmlAccessType.FIELD) 21 | public class BitkonanTickerValue { 22 | 23 | 24 | @XmlElement 25 | BigDecimal last; 26 | 27 | @XmlElement 28 | BigDecimal bid; 29 | 30 | @XmlElement 31 | BigDecimal ask; 32 | 33 | @XmlElement 34 | BigDecimal high; 35 | 36 | @XmlElement 37 | BigDecimal low; 38 | 39 | @XmlElement 40 | BigDecimal volume; 41 | 42 | @XmlElement 43 | double open; 44 | 45 | 46 | public TickerValue getTickerValue(AssetPair asset) { 47 | 48 | Currency quote = asset.getQuote(); 49 | TickerValue ticker = new TickerValue(asset); 50 | 51 | ticker.setLast(new CurrencyValue(last, quote)); 52 | ticker.setBid(new CurrencyValue(bid, quote)); 53 | ticker.setAsk(new CurrencyValue(ask, quote)); 54 | ticker.setHigh(new CurrencyValue(high, quote)); 55 | ticker.setLow(new CurrencyValue(low, quote)); 56 | 57 | ticker.setVolume(new CurrencyValue(volume, asset.getBase())); 58 | 59 | 60 | return ticker; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/performance/Performance.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.performance; 2 | 3 | import at.outdated.bitcoin.exchange.api.account.WalletTransaction; 4 | import at.outdated.bitcoin.exchange.api.currency.Currency; 5 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 6 | 7 | import java.math.BigDecimal; 8 | import java.text.NumberFormat; 9 | import java.util.Collection; 10 | 11 | /** 12 | * Created with IntelliJ IDEA. 13 | * User: ebirn 14 | * Date: 17.05.13 15 | * Time: 01:02 16 | * To change this template use File | Settings | File Templates. 17 | */ 18 | public abstract class Performance { 19 | 20 | 21 | // throw Exception if transaction does not match performance currency 22 | abstract public boolean includeTransaction(WalletTransaction transaction); 23 | 24 | public boolean includeAllTransactions(Collection transactions) { 25 | boolean didit = true; 26 | 27 | for(WalletTransaction t : transactions) { 28 | boolean single = includeTransaction(t); 29 | if(single == false) { 30 | didit = false; 31 | } 32 | } 33 | 34 | return didit; 35 | } 36 | 37 | abstract public BigDecimal getPercent(); 38 | 39 | abstract public CurrencyValue getTotalDifference(); 40 | 41 | abstract public CurrencyValue getEndBalance(); 42 | 43 | abstract public CurrencyValue getStartBalance(); 44 | 45 | abstract public Currency getCurrency(); 46 | 47 | 48 | @Override 49 | public String toString() { 50 | 51 | String percentChange = NumberFormat.getPercentInstance().format(getPercent()); 52 | 53 | return "Performance: " + getStartBalance() + " -> " + getEndBalance() + " = " + getTotalDifference() + " (" + percentChange + ")"; 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/track/TickerValueTrack.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.track; 2 | 3 | import at.outdated.bitcoin.exchange.api.market.TickerValue; 4 | import org.apache.commons.math3.stat.descriptive.MultivariateSummaryStatistics; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Collection; 8 | import java.util.Date; 9 | import java.util.List; 10 | 11 | /** 12 | * Created with IntelliJ IDEA. 13 | * User: ebirn 14 | * Date: 10.05.13 15 | * Time: 13:58 16 | * To change this template use File | Settings | File Templates. 17 | */ 18 | public class TickerValueTrack extends ValueTrack { 19 | 20 | public TickerValueTrack(TickerValueTrack track) { 21 | super(track.valueBuffer); 22 | } 23 | 24 | public TickerValueTrack(Collection c) { 25 | super(c); 26 | } 27 | 28 | public TickerValueTrack(int length) { 29 | super(length); 30 | } 31 | 32 | @Override 33 | public void insert(TickerValue value) { 34 | super.insert(value); //To change body of overridden methods use File | Settings | File Templates. 35 | } 36 | 37 | public MultivariateSummaryStatistics getStatistics() { 38 | 39 | MultivariateSummaryStatistics stats = new MultivariateSummaryStatistics(TickerValue.DIMENSIONS+1, false); 40 | 41 | for (TickerValue observation : this.valueBuffer) { 42 | stats.addValue(observation.getValue()); 43 | } 44 | 45 | return stats; 46 | } 47 | 48 | public TickerValueTrack until(final Date date) { 49 | List selected = new ArrayList<>(); 50 | 51 | for(TickerValue ticker : valueBuffer) { 52 | if(ticker.getTimestamp().before(date)) 53 | selected.add(ticker); 54 | } 55 | 56 | return new TickerValueTrack(selected); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /kraken/src/main/java/at/outdated/bitcoin/exchange/kraken/KrakenJsonResolver.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.kraken; 2 | 3 | import javax.ws.rs.ext.Provider; 4 | 5 | /** 6 | * Created with IntelliJ IDEA. 7 | * User: ebirn 8 | * Date: 25.05.13 9 | * Time: 13:55 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | 13 | 14 | @Provider 15 | public class KrakenJsonResolver {} /*implements ContextResolver { 16 | 17 | protected static final Logger log = LoggerFactory.getLogger("KrakenJsonResolver"); 18 | protected final Class[] cTypes = {KrakenTickerResponse.class}; 19 | private final JSONJAXBContext context; 20 | private final Set> types; 21 | 22 | public KrakenJsonResolver() throws JAXBException { 23 | this.types = new HashSet<>(Arrays.asList(cTypes)); 24 | this.context = new JSONJAXBContext(JSONConfiguration.natural().build(), cTypes); 25 | } 26 | 27 | public static String convert2Json(Object obj) { 28 | 29 | String result = null; 30 | 31 | try (StringWriter writer = new StringWriter()) { 32 | 33 | JAXBContext jc = JSONJAXBContext.newInstance(obj.getClass()); 34 | Marshaller marshaller = jc.createMarshaller(); 35 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); 36 | marshaller.marshal(obj, writer); 37 | 38 | writer.flush(); 39 | 40 | result = writer.getBuffer().toString(); 41 | 42 | } catch (IOException | JAXBException e) { 43 | e.printStackTrace(); 44 | } 45 | 46 | return result; 47 | } 48 | 49 | @Override 50 | public JSONJAXBContext getContext(Class objectType) { 51 | log.info("resolving json {}", objectType); 52 | return (types.contains(objectType)) ? context : null; 53 | } 54 | 55 | 56 | } 57 | */ 58 | -------------------------------------------------------------------------------- /bitkonan/src/main/java/at/outdated/bitcoin/exchange/bitkonan/BitkonanOrder.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitkonan; 2 | 3 | import at.outdated.bitcoin.exchange.api.OrderId; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | import at.outdated.bitcoin.exchange.api.jaxb.DateIso8601Adapter; 6 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 7 | import at.outdated.bitcoin.exchange.api.market.Market; 8 | import at.outdated.bitcoin.exchange.api.market.MarketOrder; 9 | import at.outdated.bitcoin.exchange.api.market.OrderType; 10 | 11 | import javax.xml.bind.annotation.XmlAccessType; 12 | import javax.xml.bind.annotation.XmlAccessorType; 13 | import javax.xml.bind.annotation.XmlRootElement; 14 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 15 | import java.math.BigDecimal; 16 | import java.util.Date; 17 | 18 | /** 19 | * Created by ebirn on 08.02.14. 20 | */ 21 | 22 | @XmlRootElement 23 | @XmlAccessorType(XmlAccessType.FIELD) 24 | public class BitkonanOrder { 25 | // {"total":111.75,"btc":0.15,"usd":745,"time":"2014-02-08T21:07:48.000Z","tradetype":1} 26 | 27 | BigDecimal total; 28 | 29 | BigDecimal btc; 30 | 31 | BigDecimal usd; 32 | 33 | @XmlJavaTypeAdapter(DateIso8601Adapter.class) 34 | Date time; 35 | 36 | @XmlJavaTypeAdapter(BitkonanOrderTypeAdapter.class) 37 | OrderType tradetype; 38 | 39 | public MarketOrder getOrder(Market m, AssetPair asset) { 40 | 41 | MarketOrder order = new MarketOrder(); 42 | 43 | order.setId(new OrderId(m, Long.toString(time.getTime()))); 44 | order.setAsset(asset); 45 | 46 | order.setTimestamp(time); 47 | 48 | order.setVolume(new CurrencyValue(btc, asset.getBase())); 49 | order.setPrice(new CurrencyValue(usd, asset.getQuote())); 50 | 51 | order.setType(tradetype); 52 | 53 | return order; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/Markets.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Created with IntelliJ IDEA. 7 | * User: ebirn 8 | * Date: 23.05.13 9 | * Time: 21:21 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | // FIXME: this class should be refactored to Singleton 13 | public class Markets { 14 | 15 | private static Market defaultMarket; 16 | private static Map marketMap = new HashMap<>(); 17 | 18 | private static String defaultMarketKey = "kraken"; 19 | 20 | static { 21 | loadMarkets(); 22 | } 23 | 24 | public static void loadMarkets() { 25 | ServiceLoader loader = ServiceLoader.load(Market.class); 26 | for(Market m : loader) { 27 | 28 | if(m.getKey().equalsIgnoreCase(defaultMarketKey)) defaultMarket = m; 29 | registerMarket(m); 30 | } 31 | } 32 | 33 | public static void setDefaultMarket(Market market) { 34 | defaultMarket = market; 35 | } 36 | 37 | public static boolean unregisterMarket(Market m) { 38 | return m == marketMap.remove(m.getKey()); 39 | } 40 | 41 | public static boolean registerMarket(Market m) { 42 | 43 | boolean wasAdded = false; 44 | if(!marketMap.containsKey(m.getKey())) { 45 | wasAdded = (m == marketMap.put(m.getKey(), m)); 46 | } 47 | else { 48 | wasAdded = false; 49 | } 50 | 51 | return wasAdded; 52 | } 53 | 54 | public static Market getDefaultMarket() { 55 | return defaultMarket; 56 | } 57 | 58 | public static Market getMarket(String key) { 59 | return marketMap.get(key); 60 | } 61 | 62 | public static Set allMarkets() { 63 | return new HashSet(marketMap.values()); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/MtGoxWallets.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | 5 | import javax.xml.bind.annotation.XmlAccessType; 6 | import javax.xml.bind.annotation.XmlAccessorType; 7 | import javax.xml.bind.annotation.XmlElement; 8 | 9 | /** 10 | * Created with IntelliJ IDEA. 11 | * User: ebirn 12 | * Date: 04.05.13 13 | * Time: 19:32 14 | * I only do this because I am to lazy to write a real JAXB/Map adapter for this 15 | */ 16 | 17 | //TODO: replace this class with a real JAXB adapter 18 | @XmlAccessorType(XmlAccessType.FIELD) 19 | public class MtGoxWallets { 20 | 21 | @XmlElement(name = "EUR") 22 | private MtGoxWallet eur; 23 | 24 | @XmlElement(name="BTC") 25 | private MtGoxWallet btc; 26 | 27 | @XmlElement(name="USD") 28 | private MtGoxWallet usd; 29 | 30 | public MtGoxWallet getBTC() { 31 | return btc; 32 | } 33 | 34 | public MtGoxWallet getEUR() { 35 | return eur; 36 | } 37 | 38 | public MtGoxWallet getUSD() { 39 | return usd; 40 | } 41 | 42 | public Currency[] getCurrencies() { 43 | return new Currency[] {Currency.USD, Currency.EUR, Currency.BTC}; 44 | } 45 | 46 | public MtGoxWallet getWallet(Currency curr) { 47 | 48 | MtGoxWallet wallet = null; 49 | switch (curr) { 50 | case USD: 51 | wallet = getUSD(); 52 | break; 53 | 54 | 55 | case EUR: 56 | wallet = getEUR(); 57 | break; 58 | 59 | 60 | case BTC: 61 | wallet = getBTC(); 62 | break; 63 | 64 | default: 65 | } 66 | 67 | 68 | 69 | return wallet; 70 | } 71 | 72 | private void setWalletCurrency(MtGoxWallet wallet, Currency curr) { 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /bter/src/main/java/at/outdated/bitcoin/exchange/bter/BterTicker.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bter; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 6 | import at.outdated.bitcoin.exchange.api.market.TickerValue; 7 | 8 | import javax.xml.bind.annotation.XmlAccessType; 9 | import javax.xml.bind.annotation.XmlAccessorType; 10 | import javax.xml.bind.annotation.XmlElement; 11 | import javax.xml.bind.annotation.XmlRootElement; 12 | import java.math.BigDecimal; 13 | 14 | /** 15 | * Created by ebirn on 11.10.13. 16 | */ 17 | @XmlRootElement 18 | @XmlAccessorType(XmlAccessType.FIELD) 19 | public class BterTicker { 20 | 21 | 22 | // {"result":"true","last":798,"high":806,"low":795.01,"avg":799.69,"sell":805.7,"buy":798,"vol_btc":738.7863,"vol_cny":590796.48}% 23 | 24 | @XmlElement(name="buy") 25 | BigDecimal ask; 26 | 27 | @XmlElement(name="sell") 28 | BigDecimal bid; 29 | 30 | @XmlElement 31 | double high; 32 | 33 | @XmlElement 34 | double low; 35 | 36 | @XmlElement 37 | BigDecimal last; 38 | 39 | /* 40 | @XmlElementRefs({ 41 | @XmlElementRef(name = "vol_btc"), 42 | @XmlElementRef(name = "vol_ltc"), 43 | @XmlElementRef(name = "vol_ftc") 44 | })*/ 45 | @XmlElement(name="vol_btc") 46 | BigDecimal volume; 47 | 48 | public TickerValue getValue(AssetPair asset) { 49 | 50 | Currency quote = asset.getQuote(); 51 | TickerValue val = new TickerValue(asset); 52 | 53 | val.setAsk(new CurrencyValue(ask, quote)); 54 | val.setBid(new CurrencyValue(bid, quote)); 55 | 56 | val.setLast(new CurrencyValue(last, quote)); 57 | 58 | val.setVolume(new CurrencyValue(volume, asset.getBase())); 59 | 60 | return val; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/MtGoxWallet.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | 6 | import javax.xml.bind.annotation.XmlAccessType; 7 | import javax.xml.bind.annotation.XmlAccessorType; 8 | import javax.xml.bind.annotation.XmlElement; 9 | 10 | /** 11 | * Created with IntelliJ IDEA. 12 | * User: ebirn 13 | * Date: 03.05.13 14 | * Time: 14:05 15 | * To change this template use File | Settings | File Templates. 16 | */ 17 | @XmlAccessorType(XmlAccessType.FIELD) 18 | public class MtGoxWallet { 19 | 20 | @XmlElement(name="Operations") 21 | private long transactionCount; 22 | 23 | @XmlElement(name="Daily_Withdraw_Limit") 24 | private CurrencyValue Daily_Withdraw_Limit; 25 | 26 | @XmlElement(name="Monthly_Withdraw_Limit") 27 | private CurrencyValue Monthly_Withdraw_Limit; 28 | 29 | @XmlElement(name="Max_Withdraw") 30 | private CurrencyValue Max_Withdraw; 31 | 32 | @XmlElement 33 | private CurrencyValue Balance; 34 | 35 | @XmlElement 36 | private CurrencyValue Open_Orders; 37 | 38 | 39 | public Currency getCurrency() { 40 | return Balance.getCurrency(); 41 | } 42 | 43 | public CurrencyValue getBalance() { 44 | return Balance; 45 | } 46 | 47 | public CurrencyValue getOpenOrders() { 48 | return Open_Orders; 49 | } 50 | 51 | public long getTransactionCount() { 52 | return transactionCount; 53 | } 54 | 55 | 56 | public CurrencyValue getDaily_Withdraw_Limit() { 57 | return Daily_Withdraw_Limit; 58 | } 59 | 60 | public CurrencyValue getMonthly_Withdraw_Limit() { 61 | return Monthly_Withdraw_Limit; 62 | } 63 | 64 | public CurrencyValue getMax_Withdraw() { 65 | return Max_Withdraw; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/track/TickerTrackCollection.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.track; 2 | 3 | import at.outdated.bitcoin.exchange.api.market.TickerValue; 4 | import org.apache.commons.math3.stat.descriptive.MultivariateSummaryStatistics; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: ebirn 11 | * Date: 09.05.13 12 | * Time: 15:41 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | 16 | public class TickerTrackCollection extends ValueTrackCollection { 17 | 18 | 19 | 20 | public TickerTrackCollection() { 21 | 22 | for(TrackInterval interval : TrackInterval.values()) { 23 | tracks.put(interval, new TickerValueTrack(interval.numSamples())); 24 | } 25 | } 26 | 27 | 28 | 29 | // return statistics for a specific window 30 | public MultivariateSummaryStatistics getStatistics(TrackInterval interval) { 31 | return tracks.get(interval).getStatistics(); 32 | } 33 | 34 | 35 | /* 36 | // TODO: return cumulative Statistics for all tracks 37 | public DescriptiveStatistics getStatistics() { 38 | MultivariateSummaryStatistics stats = new MultivariateSummaryStatistics(TickerValue.DIMENSIONS, false); 39 | return null; 40 | } 41 | */ 42 | 43 | 44 | public Date getOldestTimestamp() { 45 | Date oldest = new Date(); 46 | 47 | for(TickerValueTrack track : tracks.values()) { 48 | 49 | TickerValue tickerValue = track.getOldest(); 50 | if(tickerValue == null) continue; 51 | 52 | Date timestamp = tickerValue.getTimestamp(); 53 | if(timestamp != null && timestamp.before(oldest)) { 54 | // also: make sure we copy information 55 | oldest.setTime(timestamp.getTime()); 56 | } 57 | } 58 | 59 | return oldest; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /api/api.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /bitstamp/src/main/java/at/outdated/bitcoin/exchange/bitstamp/BitstampOrder.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitstamp; 2 | 3 | import at.outdated.bitcoin.exchange.api.jaxb.DateIso8601SpacedAdapter; 4 | import at.outdated.bitcoin.exchange.api.jaxb.StringBigDecimalAdapter; 5 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeDateAdapter; 6 | import at.outdated.bitcoin.exchange.api.market.OrderType; 7 | 8 | import javax.xml.bind.annotation.*; 9 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 10 | import java.math.BigDecimal; 11 | import java.util.Date; 12 | 13 | /** 14 | * Created by ebirn on 13.01.14. 15 | */ 16 | @XmlRootElement 17 | @XmlAccessorType(XmlAccessType.FIELD) 18 | public class BitstampOrder { 19 | 20 | @XmlElements({ 21 | @XmlElement(name="id"), 22 | @XmlElement(name="tid") 23 | }) 24 | int id; 25 | 26 | //FIXME: is there a way to limit formatter to a total number of digits? 27 | // {"error": {"price": ["Ensure that there are no more than 7 digits in total."]}} 28 | @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 29 | BigDecimal price; 30 | 31 | @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 32 | BigDecimal amount; 33 | 34 | //time comes in UTC 35 | @XmlElement 36 | @XmlJavaTypeAdapter(DateIso8601SpacedAdapter.class) 37 | Date datetime; 38 | 39 | @XmlElement 40 | @XmlJavaTypeAdapter(UnixTimeDateAdapter.class) 41 | Date date; 42 | 43 | 44 | @XmlElement 45 | @XmlJavaTypeAdapter(BitstampOrderTypeAdapter.class) 46 | OrderType type = OrderType.UNDEF; 47 | 48 | 49 | public int getId() { 50 | return id; 51 | } 52 | 53 | public BigDecimal getPrice() { 54 | return price; 55 | } 56 | 57 | public BigDecimal getAmount() { 58 | return amount; 59 | } 60 | 61 | public OrderType getType() { 62 | return type; 63 | } 64 | 65 | public Date getDatetime() { 66 | return datetime; 67 | } 68 | 69 | public Date getDate() { 70 | return date; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /btc-e/src/main/java/at/outdated/bitcoin/exchange/btce/BtceTrade.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.btce; 2 | 3 | import at.outdated.bitcoin.exchange.api.OrderId; 4 | import at.outdated.bitcoin.exchange.api.currency.Currency; 5 | import at.outdated.bitcoin.exchange.api.jaxb.OrderTypeAdapter; 6 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeDateAdapter; 7 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 8 | import at.outdated.bitcoin.exchange.api.market.Market; 9 | import at.outdated.bitcoin.exchange.api.market.MarketOrder; 10 | import at.outdated.bitcoin.exchange.api.market.OrderType; 11 | 12 | import javax.xml.bind.annotation.XmlAccessType; 13 | import javax.xml.bind.annotation.XmlAccessorType; 14 | import javax.xml.bind.annotation.XmlRootElement; 15 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 16 | import java.math.BigDecimal; 17 | import java.util.Date; 18 | 19 | /** 20 | * Created by ebirn on 09.02.14. 21 | */ 22 | @XmlRootElement 23 | @XmlAccessorType(XmlAccessType.FIELD) 24 | public class BtceTrade { 25 | /* 26 | {"date":1391940472,"price":701.39,"amount":0.01,"tid":29283411,"price_currency":"USD","item":"BTC","trade_type":"ask"}, 27 | {"date":1391940441,"price":698.213,"amount":0.13,"tid":29283401,"price_currency":"USD","item":"BTC","trade_type":"ask"},{ 28 | */ 29 | 30 | @XmlJavaTypeAdapter(UnixTimeDateAdapter.class) 31 | Date date; 32 | 33 | BigDecimal price; 34 | 35 | BigDecimal amount; 36 | 37 | long tid; 38 | 39 | Currency price_currency; 40 | 41 | Currency item; 42 | 43 | @XmlJavaTypeAdapter(OrderTypeAdapter.class) 44 | OrderType trade_type; 45 | 46 | public MarketOrder getOrder(Market m) { 47 | MarketOrder order = new MarketOrder(); 48 | 49 | order.setId(new OrderId(m, Long.toString(tid))); 50 | 51 | order.setAsset(new AssetPair(item, price_currency)); 52 | order.setTimestamp(date); 53 | 54 | order.setPrice(price); 55 | order.setVolume(amount); 56 | 57 | order.setType(trade_type); 58 | 59 | return order; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /bter/src/main/java/at/outdated/bitcoin/exchange/bter/BterMarket.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bter; 2 | 3 | import at.outdated.bitcoin.exchange.api.client.ExchangeClient; 4 | import at.outdated.bitcoin.exchange.api.currency.Currency; 5 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 6 | import at.outdated.bitcoin.exchange.api.market.Market; 7 | import at.outdated.bitcoin.exchange.api.market.fee.ConstantFee; 8 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferMethod; 9 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferType; 10 | 11 | /** 12 | * Created by ebirn on 11.10.13. 13 | */ 14 | public class BterMarket extends Market { 15 | 16 | public BterMarket() { 17 | super("bter", "http://bter.com", "Bter.com"); 18 | 19 | addWithdrawal(new TransferMethod(Currency.BTC, TransferType.VIRTUAL, new ConstantFee(new CurrencyValue("0.0005", Currency.BTC)))); 20 | addWithdrawal(new TransferMethod(Currency.LTC, TransferType.VIRTUAL, new ConstantFee(new CurrencyValue("0.02", Currency.LTC)))); 21 | addWithdrawal(new TransferMethod(Currency.PPC, TransferType.VIRTUAL,new ConstantFee(new CurrencyValue("0.001", Currency.PPC)))); 22 | addWithdrawal(new TransferMethod(Currency.NMC, TransferType.VIRTUAL, new ConstantFee(new CurrencyValue("0.001", Currency.NMC)))); 23 | 24 | addDeposit(new TransferMethod(Currency.BTC, TransferType.VIRTUAL)); 25 | addDeposit(new TransferMethod(Currency.LTC, TransferType.VIRTUAL)); 26 | addDeposit(new TransferMethod(Currency.PPC, TransferType.VIRTUAL)); 27 | addDeposit(new TransferMethod(Currency.NMC, TransferType.VIRTUAL)); 28 | 29 | addAsset(Currency.LTC, Currency.BTC); 30 | //addAsset(Currency.FTC, Currency.BTC); 31 | addAsset(Currency.PPC, Currency.BTC); 32 | //addAsset(Currency.NVC, Currency.BTC); 33 | addAsset(Currency.QRK, Currency.BTC); 34 | addAsset(Currency.NMC, Currency.BTC); 35 | } 36 | 37 | @Override 38 | public ExchangeClient createClient() { 39 | return new BterApiClient(this); 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /kraken/kraken.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /kraken/src/main/java/at/outdated/bitcoin/exchange/kraken/jaxb/KrakenDepthValue.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.kraken.jaxb; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | import at.outdated.bitcoin.exchange.api.market.MarketDepth; 6 | import at.outdated.bitcoin.exchange.api.market.MarketOrder; 7 | import at.outdated.bitcoin.exchange.api.market.OrderType; 8 | 9 | import javax.xml.bind.annotation.XmlAccessType; 10 | import javax.xml.bind.annotation.XmlAccessorType; 11 | import javax.xml.bind.annotation.XmlElement; 12 | import javax.xml.bind.annotation.XmlRootElement; 13 | import java.math.BigDecimal; 14 | import java.util.List; 15 | 16 | /** 17 | * Created by ebirn on 22.09.13. 18 | */ 19 | @XmlRootElement 20 | @XmlAccessorType(XmlAccessType.FIELD) 21 | public class KrakenDepthValue { 22 | 23 | @XmlElement 24 | float[][] asks; 25 | 26 | @XmlElement 27 | float[][] bids; 28 | 29 | public float[][] getAsks() { 30 | return asks; 31 | } 32 | 33 | public float[][] getBids() { 34 | return bids; 35 | } 36 | 37 | public MarketDepth getValue() { 38 | MarketDepth depth = new MarketDepth(); 39 | 40 | /* 41 | KrakenDepthValue krakenDepth = result.getXXBTZEUR(); 42 | 43 | Currency base = Currency.BTC; 44 | Currency quote = Currency.EUR; 45 | 46 | 47 | depth.setBaseCurrency(base); 48 | 49 | addOrders(TradeDecision.BUY, krakenDepth.asks, depth.getAsks(), base, quote); 50 | addOrders(TradeDecision.SELL, krakenDepth.bids, depth.getBids(), base, quote); 51 | */ 52 | return depth; 53 | } 54 | 55 | private void addOrders(OrderType dec, double[][] raw, List orders, Currency base, Currency quote) { 56 | for(double[] val : raw) { 57 | 58 | CurrencyValue price = new CurrencyValue(new BigDecimal(val[0]), quote); 59 | CurrencyValue volume = new CurrencyValue(new BigDecimal(val[1]), base); 60 | 61 | orders.add(new MarketOrder(dec, volume, price)); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/MtGoxTrade.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import at.outdated.bitcoin.exchange.api.OrderId; 4 | import at.outdated.bitcoin.exchange.api.currency.Currency; 5 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 6 | import at.outdated.bitcoin.exchange.api.jaxb.OrderTypeAdapter; 7 | import at.outdated.bitcoin.exchange.api.jaxb.StringBigDecimalAdapter; 8 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeDateAdapter; 9 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 10 | import at.outdated.bitcoin.exchange.api.market.Market; 11 | import at.outdated.bitcoin.exchange.api.market.MarketOrder; 12 | import at.outdated.bitcoin.exchange.api.market.OrderType; 13 | 14 | import javax.xml.bind.annotation.XmlElement; 15 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 16 | import java.math.BigDecimal; 17 | import java.util.Date; 18 | 19 | /** 20 | * Created by ebirn on 08.02.14. 21 | */ 22 | 23 | public class MtGoxTrade { 24 | 25 | 26 | Currency price_currency; 27 | 28 | Currency item; 29 | 30 | @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 31 | BigDecimal amount; 32 | 33 | @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 34 | BigDecimal price; 35 | 36 | long tid; 37 | 38 | @XmlJavaTypeAdapter(UnixTimeDateAdapter.class) 39 | Date date; 40 | 41 | // "trade_type":"bid","primary":"Y","properties":"limit" 42 | 43 | @XmlElement(name="trade_type") 44 | @XmlJavaTypeAdapter(OrderTypeAdapter.class) 45 | OrderType type; 46 | 47 | String primary; 48 | 49 | String properties; 50 | 51 | 52 | 53 | 54 | public MarketOrder getOrder(Market market) { 55 | 56 | MarketOrder order = new MarketOrder(new OrderId(market, Long.toString(tid))); 57 | 58 | order.setTimestamp(date); 59 | 60 | order.setAsset(new AssetPair(item, price_currency)); 61 | order.setPrice(new CurrencyValue(price, price_currency)); 62 | order.setVolume(new CurrencyValue(amount, item)); 63 | 64 | order.setType(type); 65 | 66 | return order; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /bitstamp/src/main/java/at/outdated/bitcoin/exchange/bitstamp/BitstampMarket.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitstamp; 2 | 3 | import at.outdated.bitcoin.exchange.api.client.ExchangeClient; 4 | import at.outdated.bitcoin.exchange.api.currency.Currency; 5 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 6 | import at.outdated.bitcoin.exchange.api.market.Market; 7 | import at.outdated.bitcoin.exchange.api.market.fee.ConstantFee; 8 | import at.outdated.bitcoin.exchange.api.market.fee.SimplePercentageFee; 9 | import at.outdated.bitcoin.exchange.api.market.fee.ZeroFee; 10 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferMethod; 11 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferType; 12 | 13 | /** 14 | * Created with IntelliJ IDEA. 15 | * User: ebirn 16 | * Date: 24.05.13 17 | * Time: 15:41 18 | * To change this template use File | Settings | File Templates. 19 | */ 20 | public class BitstampMarket extends Market { 21 | 22 | 23 | public BitstampMarket() { 24 | super("bitstamp", "https://www.bitstamp.net", "Bitstamp.net"); 25 | 26 | addWithdrawal(new TransferMethod(Currency.BTC, TransferType.VIRTUAL, new ZeroFee())); 27 | addWithdrawal(new TransferMethod(Currency.XRP, TransferType.VIRTUAL, new SimplePercentageFee("0.002"))); 28 | 29 | addWithdrawal(new TransferMethod(Currency.EUR, TransferType.BANK, new ConstantFee(new CurrencyValue("0.90", Currency.EUR)))); 30 | addWithdrawal(new TransferMethod(Currency.USD, TransferType.BANK, new SimplePercentageFee("0.0009"))); 31 | 32 | 33 | addDeposit(new TransferMethod(Currency.BTC, TransferType.VIRTUAL)); 34 | addDeposit(new TransferMethod(Currency.XRP, TransferType.VIRTUAL)); 35 | 36 | addDeposit(new TransferMethod(Currency.EUR, TransferType.BANK)); 37 | addDeposit(new TransferMethod(Currency.USD, TransferType.BANK)); 38 | 39 | addAsset(Currency.BTC, Currency.USD); 40 | } 41 | 42 | @Override 43 | public ExchangeClient createClient() { 44 | return new BitstampClient(this); //To change body of implemented methods use File | Settings | File Templates. 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /tests/src/test/java/at/outdated/bitcoin/exchange/TickerTest.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange; 2 | 3 | import at.outdated.bitcoin.exchange.api.client.MarketClient; 4 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 5 | import at.outdated.bitcoin.exchange.api.market.Market; 6 | import at.outdated.bitcoin.exchange.api.market.Markets; 7 | import at.outdated.bitcoin.exchange.api.market.TickerValue; 8 | import org.junit.Assert; 9 | import org.junit.experimental.theories.DataPoints; 10 | import org.junit.experimental.theories.Theories; 11 | import org.junit.experimental.theories.Theory; 12 | import org.junit.runner.RunWith; 13 | 14 | /** 15 | * Created by ebirn on 11.02.14. 16 | */ 17 | 18 | @RunWith(Theories.class) 19 | public class TickerTest extends BaseTest { 20 | 21 | 22 | public TickerTest(Market m) { 23 | super(m.getKey(), m, m.createClient()); 24 | } 25 | 26 | 27 | @DataPoints 28 | public static TickerValue[] loadTickers() { 29 | 30 | Market m = Markets.getMarket("kraken"); 31 | MarketClient client = m.createClient(); 32 | 33 | AssetPair[] assets = new AssetPair[m.getTradedAssets().size()]; 34 | m.getTradedAssets().toArray(assets); 35 | 36 | TickerValue[] values = new TickerValue[assets.length]; 37 | 38 | 39 | 40 | for(int i =0; i< assets.length; i++) { 41 | values[i] = client.getTicker(assets[i]); 42 | } 43 | 44 | return values; 45 | } 46 | 47 | /* 48 | @Test 49 | public void testTicker() { 50 | TickerValue ticker = client.getTicker(asset); 51 | log.info("ticker {}: {}", asset, ticker); 52 | 53 | assertTicker(ticker); 54 | } 55 | */ 56 | 57 | @Theory 58 | public void assertTicker(TickerValue ticker) { 59 | 60 | Assert.assertNotNull(ticker); 61 | 62 | notNull("invalid ticker timestamp", ticker.getTimestamp()); 63 | notNull(ticker.getAsset()); 64 | 65 | Assert.assertNotEquals(ticker.getBid().doubleValue(), 0.0, Double.MIN_NORMAL); 66 | Assert.assertNotEquals(ticker.getBid().doubleValue(), Double.NaN, 0.0); 67 | 68 | Assert.assertNotEquals(ticker.getAsk().doubleValue(), 0.0, Double.MIN_NORMAL); 69 | Assert.assertNotEquals(ticker.getAsk().doubleValue(), Double.NaN, 0.0); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | parent 7 | at.outdated.bitcoin.exchange 8 | 1 9 | 10 | 4.0.0 11 | 12 | tests 13 | 14 | 15 | 1.0-SNAPSHOT 16 | 17 | 18 | 19 | 20 | 21 | 22 | org.apache.maven.plugins 23 | maven-surefire-plugin 24 | 2.16 25 | 26 | both 27 | 4 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | at.outdated.bitcoin.exchange 39 | all 40 | 1.0-SNAPSHOT 41 | pom 42 | 43 | 44 | org.glassfish.jersey.core 45 | jersey-client 46 | 2.0 47 | 48 | 49 | org.glassfish.jersey.media 50 | jersey-media-moxy 51 | 2.0 52 | 53 | 54 | org.glassfish.jersey.media 55 | jersey-media-multipart 56 | 2.0 57 | 58 | 59 | org.glassfish.jersey.media 60 | jersey-media-json 61 | 2.0-m05-1 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /coins-e/src/main/java/at/outdated/bitcoin/exchange/coinse/CoinseMarket.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.coinse; 2 | 3 | import at.outdated.bitcoin.exchange.api.client.ExchangeClient; 4 | import at.outdated.bitcoin.exchange.api.currency.Currency; 5 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 6 | import at.outdated.bitcoin.exchange.api.market.Market; 7 | import at.outdated.bitcoin.exchange.api.market.fee.ConstantFee; 8 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferMethod; 9 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferType; 10 | 11 | /** 12 | * Created by ebirn on 06.01.14. 13 | */ 14 | public class CoinseMarket extends Market { 15 | 16 | public CoinseMarket() { 17 | super("coinse", "http://coins-e.com", "Coins-e.com"); 18 | 19 | 20 | addDeposit(new TransferMethod(Currency.BTC, TransferType.VIRTUAL)); 21 | addDeposit(new TransferMethod(Currency.LTC, TransferType.VIRTUAL)); 22 | addDeposit(new TransferMethod(Currency.NVC, TransferType.VIRTUAL)); 23 | addDeposit(new TransferMethod(Currency.PPC, TransferType.VIRTUAL)); 24 | addDeposit(new TransferMethod(Currency.QRK, TransferType.VIRTUAL)); 25 | 26 | addWithdrawal(new TransferMethod(Currency.BTC, TransferType.VIRTUAL, new ConstantFee(new CurrencyValue(0.00200000, Currency.BTC)))); 27 | addWithdrawal(new TransferMethod(Currency.LTC, TransferType.VIRTUAL, new ConstantFee(new CurrencyValue(0.05000000, Currency.LTC)))); 28 | addWithdrawal(new TransferMethod(Currency.NVC, TransferType.VIRTUAL, new ConstantFee(new CurrencyValue(0.01000000, Currency.NVC)))); 29 | addWithdrawal(new TransferMethod(Currency.PPC, TransferType.VIRTUAL, new ConstantFee(new CurrencyValue(0.01000000, Currency.PPC)))); 30 | addWithdrawal(new TransferMethod(Currency.QRK, TransferType.VIRTUAL, new ConstantFee(new CurrencyValue(0.50000000, Currency.QRK)))); 31 | 32 | addAsset(Currency.LTC, Currency.BTC); 33 | addAsset(Currency.NVC, Currency.BTC); 34 | addAsset(Currency.PPC, Currency.BTC); 35 | addAsset(Currency.QRK, Currency.BTC); 36 | 37 | addAsset(Currency.QRK, Currency.LTC); 38 | } 39 | 40 | @Override 41 | public ExchangeClient createClient() { 42 | return new CoinseApiClient(this); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/account/WalletTransaction.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.account; 2 | 3 | import at.outdated.bitcoin.exchange.api.OrderId; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Created with IntelliJ IDEA. 10 | * User: ebirn 11 | * Date: 10.05.13 12 | * Time: 20:23 13 | * To change this template use File | Settings | File Templates. 14 | */ 15 | public class WalletTransaction implements Comparable { 16 | 17 | 18 | 19 | private Date timestamp; 20 | 21 | private OrderId id; 22 | 23 | private String info; 24 | 25 | private TransactionType type; 26 | 27 | private CurrencyValue value; 28 | 29 | private CurrencyValue balance; 30 | 31 | 32 | public WalletTransaction() { 33 | 34 | } 35 | 36 | public WalletTransaction(TransactionType type, CurrencyValue volume) { 37 | this.type = type; 38 | this.value = volume; 39 | } 40 | 41 | public Date getTimestamp() { 42 | return timestamp; 43 | } 44 | 45 | public void setId(OrderId id) { 46 | this.id = id; 47 | } 48 | 49 | public OrderId getId() { 50 | return id; 51 | } 52 | 53 | public String getInfo() { 54 | return info; 55 | } 56 | 57 | public TransactionType getType() { 58 | return type; 59 | } 60 | 61 | public CurrencyValue getValue() { 62 | return value; 63 | } 64 | 65 | public CurrencyValue getBalance() { 66 | return balance; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return type + ": " + value; 72 | } 73 | 74 | public void setValue(CurrencyValue value) { 75 | this.value = value; 76 | } 77 | 78 | public void setBalance(CurrencyValue balance) { 79 | this.balance = balance; 80 | } 81 | 82 | public void setType(TransactionType type) { 83 | this.type = type; 84 | } 85 | 86 | public void setTimestamp(Date datestamp) { 87 | this.timestamp = datestamp; 88 | } 89 | 90 | public void setInfo(String info) { 91 | this.info = info; 92 | } 93 | 94 | @Override 95 | public int compareTo(WalletTransaction other) { 96 | return getTimestamp().compareTo(other.getTimestamp()); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /bitcurex/src/main/java/at/outdated/bitcoin/exchange/bitcurex/jaxb/BitcurexTickerValue.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitcurex.jaxb; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 6 | import at.outdated.bitcoin.exchange.api.market.TickerValue; 7 | 8 | import javax.xml.bind.annotation.XmlAccessType; 9 | import javax.xml.bind.annotation.XmlAccessorType; 10 | import javax.xml.bind.annotation.XmlElement; 11 | import javax.xml.bind.annotation.XmlRootElement; 12 | import java.math.BigDecimal; 13 | import java.util.Date; 14 | 15 | /** 16 | * Created with IntelliJ IDEA. 17 | * User: ebirn 18 | * Date: 30.05.13 19 | * Time: 12:50 20 | * To change this template use File | Settings | File Templates. 21 | */ 22 | @XmlRootElement 23 | @XmlAccessorType(XmlAccessType.FIELD) 24 | public class BitcurexTickerValue { 25 | 26 | 27 | //https://eur.bitcurex.com/data/ticker.json 28 | // {"high":99.98,"low":99.85,"avg":99.91499999,"vwap":99.96944474,"vol":2.68977951,"last":99.98,"buy":97.15,"sell":100.98,"time":1369911319} 29 | 30 | @XmlElement 31 | BigDecimal high; 32 | 33 | @XmlElement 34 | BigDecimal low; 35 | 36 | @XmlElement 37 | double avg; 38 | 39 | @XmlElement 40 | double vwap; 41 | 42 | @XmlElement 43 | BigDecimal vol; 44 | 45 | @XmlElement 46 | BigDecimal last; 47 | 48 | @XmlElement 49 | BigDecimal sell; 50 | 51 | @XmlElement 52 | BigDecimal buy; 53 | 54 | @XmlElement(name="time") 55 | //@XmlJavaTypeAdapter(UnixTimeDateAdapter.class) 56 | //Date time; 57 | long unixTime; 58 | 59 | 60 | public TickerValue getTickerValue(AssetPair asset) { 61 | 62 | Currency quote = asset.getQuote(); 63 | 64 | TickerValue ticker = new TickerValue(asset); 65 | 66 | ticker.setTimestamp(new Date(unixTime * 1000L)); 67 | ticker.setLast(new CurrencyValue(last, quote)); 68 | 69 | ticker.setHigh(new CurrencyValue(high, quote)); 70 | ticker.setLow(new CurrencyValue(low, quote)); 71 | 72 | ticker.setAsk(new CurrencyValue(sell, quote)); 73 | ticker.setBid(new CurrencyValue(buy, quote)); 74 | 75 | ticker.setVolume(new CurrencyValue(vol, asset.getBase())); 76 | 77 | return ticker; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /btc-e/src/main/java/at/outdated/bitcoin/exchange/btce/BtcETickerValue.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.btce; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 6 | import at.outdated.bitcoin.exchange.api.market.TickerValue; 7 | 8 | import javax.xml.bind.annotation.XmlAccessType; 9 | import javax.xml.bind.annotation.XmlAccessorType; 10 | import javax.xml.bind.annotation.XmlElement; 11 | import java.math.BigDecimal; 12 | import java.util.Date; 13 | 14 | /** 15 | * Created with IntelliJ IDEA. 16 | * User: ebirn 17 | * Date: 26.05.13 18 | * Time: 23:50 19 | * To change this template use File | Settings | File Templates. 20 | */ 21 | @XmlAccessorType(XmlAccessType.FIELD) 22 | public class BtcETickerValue { 23 | 24 | // {"ticker":{ 25 | // "high":130.96001, 26 | // "low":127.031, 27 | // "avg":128.995505, 28 | // "vol":363027.57475, 29 | // "vol_cur":2817.3477, 30 | // "last":130.4, 31 | // "buy":130.4, 32 | // "sell":130.07, 33 | // "server_time":1369604800}} 34 | 35 | 36 | @XmlElement 37 | BigDecimal last; 38 | 39 | @XmlElement 40 | BigDecimal buy; 41 | 42 | @XmlElement 43 | BigDecimal sell; 44 | 45 | @XmlElement 46 | double avg; 47 | 48 | @XmlElement 49 | BigDecimal high; 50 | 51 | @XmlElement 52 | BigDecimal low; 53 | 54 | @XmlElement 55 | double vol; 56 | 57 | @XmlElement 58 | BigDecimal vol_cur; 59 | 60 | @XmlElement(name="server_time") 61 | protected long timestamp; 62 | 63 | @XmlElement 64 | protected long updated; 65 | 66 | public TickerValue getTickerValue(AssetPair asset) { 67 | 68 | Currency quote = asset.getQuote(); 69 | 70 | TickerValue ticker = new TickerValue(asset); 71 | 72 | ticker.setTimestamp(new Date(updated*1000)); 73 | ticker.setLast(new CurrencyValue(last, quote)); 74 | 75 | ticker.setBid(new CurrencyValue(sell, quote)); 76 | ticker.setAsk(new CurrencyValue(buy, quote)); 77 | ticker.setHigh(new CurrencyValue(high, quote)); 78 | ticker.setLow(new CurrencyValue(low, quote)); 79 | 80 | ticker.setVolume(new CurrencyValue(vol_cur, asset.getBase())); 81 | 82 | return ticker; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /tests/src/test/java/at/outdated/bitcoin/exchange/AccountInfoTest.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange; 2 | 3 | import at.outdated.bitcoin.exchange.api.account.Balance; 4 | import at.outdated.bitcoin.exchange.api.account.WalletTransaction; 5 | import at.outdated.bitcoin.exchange.api.client.ExchangeClient; 6 | import at.outdated.bitcoin.exchange.api.client.TradeClient; 7 | import at.outdated.bitcoin.exchange.api.currency.Currency; 8 | import at.outdated.bitcoin.exchange.api.market.Market; 9 | import at.outdated.bitcoin.exchange.api.market.MarketOrder; 10 | import at.outdated.bitcoin.exchange.api.market.OrderType; 11 | import org.junit.Assert; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import org.junit.runners.Parameterized; 15 | 16 | import java.util.Collection; 17 | import java.util.List; 18 | 19 | /** 20 | * Created by ebirn on 25.01.14. 21 | */ 22 | @RunWith(value=Parameterized.class) 23 | public class AccountInfoTest extends BaseTest { 24 | 25 | 26 | public AccountInfoTest(String key, Market m, ExchangeClient client) { 27 | super(key, m, client); 28 | } 29 | 30 | @Parameterized.Parameters(name = "{0}AccountInfoTest") 31 | public static Collection getMarketParams() { 32 | return BaseTest.getMarketParams(); 33 | /* 34 | List params = new ArrayList<>(); 35 | params.add(marketParams(Markets.getMarket("coinse"))); 36 | return params; 37 | */ 38 | } 39 | 40 | 41 | @Test 42 | public void balanceTest() { 43 | 44 | Balance balance = client.getBalance(); 45 | 46 | Assert.assertNotNull("balance is null", balance); 47 | 48 | log.info("balance on {}: {}", market, balance); 49 | for(Currency c : market.getCurrencies()) { 50 | log.info(" available: {} | open {}", balance.getAvailable(c), balance.getOpen(c)); 51 | } 52 | 53 | } 54 | 55 | @Test 56 | public void listTransactions() { 57 | 58 | List transactions = client.getTransactions(); 59 | Assert.assertNotNull("transaction history", transactions); 60 | 61 | for(WalletTransaction wt : transactions) { 62 | log.info("transaction: {}", wt); 63 | } 64 | } 65 | 66 | @Test 67 | public void testOpenOrders() { 68 | List orders = client.getOpenOrders(); 69 | Assert.assertNotNull("open orders", orders); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/ExchangeRateCalculator.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | 6 | import java.math.BigDecimal; 7 | import java.util.Arrays; 8 | 9 | /** 10 | * Created with IntelliJ IDEA. 11 | * User: ebirn 12 | * Date: 16.05.13 13 | * Time: 23:48 14 | * To change this template use File | Settings | File Templates. 15 | */ 16 | public class ExchangeRateCalculator { 17 | 18 | BigDecimal[][] rates; 19 | 20 | public ExchangeRateCalculator() { 21 | int currencyCount = Currency.values().length; 22 | 23 | // init exchange rate matrix 24 | rates = new BigDecimal[currencyCount][currencyCount]; 25 | 26 | // set exchange rate for a currency with itself to 1 27 | BigDecimal selfRate = new BigDecimal(1, CurrencyValue.CURRENCY_MATH_CONTEXT); 28 | 29 | for(int i=0; i wallets = new CurrencyContainer<>(); 28 | 29 | abstract public Fee getTradeFee(OrderType trade); 30 | 31 | public CurrencyValue getTradeFee(OrderType trade, CurrencyValue volume) { 32 | return getTradeFee(trade).calculate(trade, volume); 33 | } 34 | 35 | public Wallet getWallet(Currency curr) { 36 | return wallets.get(curr); 37 | } 38 | 39 | public void addWallet(Wallet wallet) { 40 | wallets.set(wallet.getCurrency(), wallet); 41 | } 42 | 43 | public List getAllTransactions() { 44 | 45 | List transactionList = new ArrayList<>(); 46 | 47 | for(Wallet w : wallets) { 48 | transactionList.addAll(w.getTransactions()); 49 | } 50 | 51 | return transactionList; 52 | } 53 | 54 | 55 | public CurrencyValue getOverallBalance(Currency currency) { 56 | 57 | CurrencyValue totalBalance = new CurrencyValue(currency); 58 | 59 | for(Wallet w : wallets) { 60 | totalBalance.add(w.getBalance()); 61 | } 62 | 63 | return totalBalance; 64 | } 65 | 66 | 67 | public Performance getOverallPerformance(Currency inCurrency, ExchangeRateCalculator calculator) { 68 | CombinedPerformance perf = new CombinedPerformance(inCurrency, calculator); 69 | 70 | for(Wallet w : wallets) { 71 | perf.includeWallet(w); 72 | } 73 | 74 | return perf; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/AssetPair.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import org.apache.commons.lang3.builder.EqualsBuilder; 5 | import org.apache.commons.lang3.builder.HashCodeBuilder; 6 | 7 | /** 8 | * Created by ebirn on 20.10.13. 9 | */ 10 | public class AssetPair implements Comparable { 11 | 12 | Currency base; 13 | 14 | Currency quote; 15 | 16 | public AssetPair(Currency base, Currency quote) { 17 | this.base = base; 18 | this.quote = quote; 19 | } 20 | 21 | public Currency getBase() { 22 | return base; 23 | } 24 | 25 | public Currency getQuote() { 26 | return quote; 27 | } 28 | 29 | public Currency getOther(Currency one) { 30 | if(one == base) return quote; 31 | if(one == quote) return base; 32 | 33 | throw new IllegalArgumentException(one + " is not part of pair"); 34 | } 35 | 36 | public boolean isCrypto() { 37 | return (base.isCrypto() && quote.isCrypto()); 38 | } 39 | 40 | public boolean isMember(Currency one) { 41 | if(base == one || quote == one) return true; 42 | 43 | return false; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return base + ":" + quote; 49 | } 50 | 51 | @Override 52 | public boolean equals(Object obj) { 53 | 54 | boolean isEquals = false; 55 | 56 | if(this == obj) { 57 | isEquals = true; 58 | } 59 | else if(obj.getClass() != getClass()) { 60 | isEquals = false; 61 | } 62 | else { 63 | EqualsBuilder builder = new EqualsBuilder(); 64 | 65 | AssetPair other = (AssetPair) obj; 66 | 67 | builder.append(this.base, other.base); 68 | builder.append(this.quote, other.quote); 69 | 70 | isEquals = builder.isEquals(); 71 | } 72 | return isEquals; 73 | } 74 | 75 | @Override 76 | public int hashCode() { 77 | 78 | HashCodeBuilder builder = new HashCodeBuilder(); 79 | 80 | builder.append(base); 81 | builder.append(quote); 82 | 83 | return builder.toHashCode(); 84 | } 85 | 86 | @Override 87 | public int compareTo(AssetPair other) { 88 | 89 | int comp = this.getBase().compareTo(other.getBase()); 90 | if(comp == 0) { 91 | comp = this.getQuote().compareTo(other.getQuote()); 92 | } 93 | 94 | return comp; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /bitstamp/src/main/java/at/outdated/bitcoin/exchange/bitstamp/BitstampTickerValue.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitstamp; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | import at.outdated.bitcoin.exchange.api.jaxb.StringBigDecimalAdapter; 6 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 7 | import at.outdated.bitcoin.exchange.api.market.TickerValue; 8 | 9 | import javax.xml.bind.annotation.XmlAccessType; 10 | import javax.xml.bind.annotation.XmlAccessorType; 11 | import javax.xml.bind.annotation.XmlElement; 12 | import javax.xml.bind.annotation.XmlRootElement; 13 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 14 | import java.math.BigDecimal; 15 | import java.util.Date; 16 | 17 | /** 18 | * Created with IntelliJ IDEA. 19 | * User: ebirn 20 | * Date: 25.05.13 21 | * Time: 13:06 22 | * To change this template use File | Settings | File Templates. 23 | */ 24 | @XmlRootElement 25 | @XmlAccessorType(XmlAccessType.FIELD) 26 | public class BitstampTickerValue { 27 | 28 | // {"high": "129.94", "last": "128.48", "bid": "128.30", "volume": "12260.32110601", "low": "124.00", "ask": "128.48"} 29 | 30 | @XmlElement @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 31 | BigDecimal last; 32 | 33 | @XmlElement @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 34 | BigDecimal high; 35 | 36 | @XmlElement @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 37 | BigDecimal low; 38 | 39 | // what you need to pay for buying 40 | @XmlElement @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 41 | BigDecimal bid; 42 | 43 | // what you get for selling 44 | @XmlElement @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 45 | BigDecimal ask; 46 | 47 | @XmlElement @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 48 | BigDecimal volume; 49 | 50 | Date timeStamp = new Date(); 51 | 52 | public TickerValue getTickerValue(AssetPair asset) { 53 | 54 | Currency quote = asset.getQuote(); 55 | TickerValue ticker = new TickerValue(asset); 56 | ticker.setTimestamp(timeStamp); 57 | 58 | ticker.setLast(new CurrencyValue(last, quote)); 59 | ticker.setHigh(new CurrencyValue(high, quote)); 60 | ticker.setLow(new CurrencyValue(low, quote)); 61 | 62 | ticker.setAsk(new CurrencyValue(ask, quote)); 63 | ticker.setBid(new CurrencyValue(bid, quote)); 64 | 65 | ticker.setVolume(new CurrencyValue(volume, asset.getBase())); 66 | 67 | return ticker; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/transfer/TransferMethod.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market.transfer; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyAddress; 5 | import at.outdated.bitcoin.exchange.api.market.fee.Fee; 6 | import at.outdated.bitcoin.exchange.api.market.fee.ZeroFee; 7 | 8 | /** 9 | * Created by ebirn on 12.10.13. 10 | */ 11 | public class TransferMethod { 12 | 13 | protected Fee fee = new ZeroFee(); 14 | 15 | protected Currency currency = null; 16 | protected CurrencyAddress address = null; 17 | 18 | protected TransferType transfer = null; 19 | 20 | public TransferMethod() { 21 | } 22 | 23 | public TransferMethod(Currency currency, TransferType transfer, CurrencyAddress address) { 24 | setCurrency(currency); 25 | setTransfer(transfer); 26 | setAddress(address); 27 | } 28 | 29 | public TransferMethod(Currency currency, TransferType transfer, CurrencyAddress address, Fee fee) { 30 | setCurrency(currency); 31 | setTransfer(transfer); 32 | setAddress(address); 33 | setFee(fee); 34 | } 35 | 36 | public TransferMethod(Currency currency, TransferType transfer, Fee fee) { 37 | setCurrency(currency); 38 | setTransfer(transfer); 39 | setFee(fee); 40 | } 41 | 42 | public TransferMethod(Currency currency, TransferType transfer) { 43 | setCurrency(currency); 44 | setTransfer(transfer); 45 | } 46 | 47 | public Fee getFee() { 48 | return fee; 49 | } 50 | 51 | public Currency getCurrency() { 52 | return currency; 53 | } 54 | 55 | 56 | public void setFee(Fee fee) { 57 | this.fee = fee; 58 | } 59 | 60 | public void setCurrency(Currency currency) { 61 | this.currency = currency; 62 | } 63 | 64 | public TransferType getTransfer() { 65 | return transfer; 66 | } 67 | 68 | public void setTransfer(TransferType transfer) { 69 | this.transfer = transfer; 70 | } 71 | 72 | public CurrencyAddress getAddress() { 73 | return address; 74 | } 75 | 76 | public void setAddress(CurrencyAddress address) { 77 | 78 | if(address != null && address.getReference() != currency) { 79 | throw new IllegalArgumentException("currency address does not match currency"); 80 | } 81 | 82 | this.address = address; 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return transfer + ":" + currency; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /bitstamp/src/main/java/at/outdated/bitcoin/exchange/bitstamp/BitstampAccountBalance.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.bitstamp; 2 | 3 | import at.outdated.bitcoin.exchange.api.jaxb.StringBigDecimalAdapter; 4 | 5 | import javax.xml.bind.annotation.XmlAccessType; 6 | import javax.xml.bind.annotation.XmlAccessorType; 7 | import javax.xml.bind.annotation.XmlElement; 8 | import javax.xml.bind.annotation.XmlRootElement; 9 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 10 | import java.math.BigDecimal; 11 | 12 | /** 13 | * Created with IntelliJ IDEA. 14 | * User: ebirn 15 | * Date: 25.05.13 16 | * Time: 16:23 17 | * To change this template use File | Settings | File Templates. 18 | */ 19 | @XmlRootElement 20 | @XmlAccessorType(XmlAccessType.FIELD) 21 | public class BitstampAccountBalance { 22 | /* 23 | { 24 | "btc_reserved": "0", 25 | "usd_balance": "0.00", 26 | "fee": "0.5000", 27 | "usd_available": "0.00", 28 | "btc_balance": "0", 29 | "usd_reserved": "0", 30 | "btc_available": "0" 31 | } 32 | */ 33 | 34 | @XmlElement @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 35 | BigDecimal fee; 36 | 37 | @XmlElement(name="usd_balance") @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 38 | BigDecimal usdBalance; 39 | 40 | @XmlElement(name="usd_reserved") @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 41 | BigDecimal usdReserved; 42 | 43 | @XmlElement(name="usd_available") @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 44 | BigDecimal usdAvailable; 45 | 46 | 47 | 48 | @XmlElement(name="btc_balance") @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 49 | BigDecimal btcBalance; 50 | 51 | @XmlElement(name="btc_reserved") @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 52 | BigDecimal btcReserved; 53 | 54 | 55 | @XmlElement(name="btc_available") @XmlJavaTypeAdapter(StringBigDecimalAdapter.class) 56 | BigDecimal btcAvailable; 57 | 58 | 59 | public BigDecimal getBtcReserved() { 60 | return btcReserved; 61 | } 62 | 63 | public BigDecimal getUsdBalance() { 64 | return usdBalance; 65 | } 66 | 67 | public BigDecimal getFee() { 68 | return fee; 69 | } 70 | 71 | public BigDecimal getUsdAvailable() { 72 | return usdAvailable; 73 | } 74 | 75 | public BigDecimal getBtcBalance() { 76 | return btcBalance; 77 | } 78 | 79 | public BigDecimal getUsdReserved() { 80 | return usdReserved; 81 | } 82 | 83 | public BigDecimal getBtcAvailable() { 84 | return btcAvailable; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/market/MarketOrder.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.market; 2 | 3 | import at.outdated.bitcoin.exchange.api.OrderId; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | 6 | import java.math.BigDecimal; 7 | import java.util.Date; 8 | 9 | /** 10 | * Created by ebirn on 22.09.13. 11 | */ 12 | public class MarketOrder { 13 | 14 | OrderId id; 15 | 16 | AssetPair asset; 17 | 18 | protected CurrencyValue price; 19 | protected CurrencyValue volume; 20 | 21 | protected OrderType type; 22 | 23 | protected Date timestamp; 24 | 25 | public MarketOrder() { 26 | 27 | } 28 | 29 | public MarketOrder(OrderId id) { 30 | this.id = id; 31 | } 32 | 33 | public MarketOrder(OrderType type, CurrencyValue volume, CurrencyValue price) { 34 | this.type = type; 35 | this.volume = volume; 36 | this.price = price; 37 | } 38 | 39 | 40 | public CurrencyValue getPrice() { 41 | return price; 42 | } 43 | 44 | public void setPrice(CurrencyValue price) { 45 | this.price = price; 46 | } 47 | 48 | public void setPrice(BigDecimal price) { 49 | this.price = new CurrencyValue(price, asset.getQuote()); 50 | } 51 | 52 | public CurrencyValue getPriceVolume() { 53 | return new CurrencyValue(price).multiply(volume.getValue()); 54 | } 55 | 56 | public CurrencyValue getVolume() { 57 | return volume; 58 | } 59 | 60 | public void setVolume(CurrencyValue volume) { 61 | this.volume = volume; 62 | } 63 | 64 | public void setVolume(BigDecimal volume) { 65 | this.volume = new CurrencyValue(volume, asset.getBase()); 66 | } 67 | @Override 68 | public String toString() { 69 | return "Order: " + type + " " + volume + " @ " + price; 70 | } 71 | 72 | public OrderId getId() { 73 | return id; 74 | } 75 | 76 | public void setId(OrderId id) { 77 | this.id = id; 78 | } 79 | 80 | public AssetPair getAsset() { 81 | return asset; 82 | } 83 | 84 | public void setAsset(AssetPair asset) { 85 | this.asset = asset; 86 | } 87 | 88 | public OrderType getType() { 89 | return type; 90 | } 91 | 92 | public void setType(OrderType type) { 93 | this.type = type; 94 | } 95 | 96 | public Date getTimestamp() { 97 | return timestamp; 98 | } 99 | 100 | public void setTimestamp(Date timestamp) { 101 | this.timestamp = timestamp; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /kraken/src/main/java/at/outdated/bitcoin/exchange/kraken/jaxb/KrakenTickerValue.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.kraken.jaxb; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | import at.outdated.bitcoin.exchange.api.market.AssetPair; 6 | import at.outdated.bitcoin.exchange.api.market.TickerValue; 7 | 8 | import javax.xml.bind.annotation.XmlAccessType; 9 | import javax.xml.bind.annotation.XmlAccessorType; 10 | import javax.xml.bind.annotation.XmlElement; 11 | import javax.xml.bind.annotation.XmlRootElement; 12 | import java.math.BigDecimal; 13 | 14 | /** 15 | * Created with IntelliJ IDEA. 16 | * User: ebirn 17 | * Date: 17.09.13 18 | * Time: 18:37 19 | * To change this template use File | Settings | File Templates. 20 | */ 21 | @XmlRootElement 22 | @XmlAccessorType(XmlAccessType.FIELD) 23 | public class KrakenTickerValue { 24 | 25 | @XmlElement 26 | String a[]; 27 | 28 | @XmlElement 29 | String b[]; 30 | 31 | @XmlElement 32 | String c[]; 33 | 34 | 35 | @XmlElement 36 | String v[]; 37 | 38 | @XmlElement 39 | String p[]; 40 | 41 | @XmlElement 42 | int t[]; 43 | 44 | @XmlElement 45 | String l[]; 46 | 47 | @XmlElement 48 | String h[]; 49 | 50 | @XmlElement 51 | String o; 52 | 53 | 54 | public void setA(String[] a) { 55 | this.a = a; 56 | } 57 | 58 | public void setB(String[] b) { 59 | this.b = b; 60 | } 61 | 62 | public void setC(String[] c) { 63 | this.c = c; 64 | } 65 | 66 | public void setV(String[] v) { 67 | this.v = v; 68 | } 69 | 70 | public void setP(String[] p) { 71 | this.p = p; 72 | } 73 | 74 | public void setT(int[] t) { 75 | this.t = t; 76 | } 77 | 78 | public void setL(String[] l) { 79 | this.l = l; 80 | } 81 | 82 | public void setH(String[] h) { 83 | this.h = h; 84 | } 85 | 86 | public void setO(String o) { 87 | this.o = o; 88 | } 89 | 90 | public TickerValue getValue(AssetPair asset) { 91 | 92 | Currency quote = asset.getQuote(); 93 | 94 | TickerValue value = new TickerValue(asset); 95 | 96 | value.setLast(new CurrencyValue(l[0], quote)); 97 | 98 | value.setAsk(new CurrencyValue(a[0], quote)); 99 | value.setBid(new CurrencyValue(b[0], quote)); 100 | 101 | value.setVolume(new CurrencyValue(v[0], asset.getBase())); 102 | 103 | value.setHigh(new CurrencyValue(h[0], quote)); 104 | value.setLow(new CurrencyValue(l[0], quote)); 105 | 106 | return value; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /mtgox/src/main/java/at/outdated/bitcoin/exchange/mtgox/MtGoxOrder.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.mtgox; 2 | 3 | import at.outdated.bitcoin.exchange.api.currency.Currency; 4 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 5 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeDateAdapter; 6 | import at.outdated.bitcoin.exchange.api.jaxb.UnixTimeMicroDateAdapter; 7 | 8 | import javax.xml.bind.annotation.*; 9 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by ebirn on 14.01.14. 14 | */ 15 | @XmlRootElement 16 | @XmlAccessorType(XmlAccessType.FIELD) 17 | public class MtGoxOrder { 18 | 19 | public enum Type { 20 | @XmlEnumValue("bid") BUY, 21 | @XmlEnumValue("ask") SELL 22 | } 23 | 24 | public enum Status { 25 | // pending, executing, post-pending, open, stop, invalid, 26 | @XmlEnumValue("pending") PENDING, 27 | @XmlEnumValue("executing") EXECUTING, 28 | @XmlEnumValue("post-pending") POSTPENDING, 29 | @XmlEnumValue("open") OPEN, 30 | @XmlEnumValue("stop") STOP, 31 | @XmlEnumValue("invalid") INVALID 32 | } 33 | 34 | @XmlElement 35 | String oid; 36 | 37 | 38 | @XmlElement(name = "item") 39 | Currency base; 40 | 41 | 42 | @XmlElement(name = "currency") 43 | Currency quote; 44 | 45 | @XmlElement(name="date") 46 | @XmlJavaTypeAdapter(UnixTimeDateAdapter.class) 47 | Date timestamp; 48 | 49 | @XmlElement 50 | @XmlJavaTypeAdapter(UnixTimeMicroDateAdapter.class) 51 | Date priority; 52 | 53 | @XmlElement 54 | Type type; 55 | 56 | @XmlElement 57 | CurrencyValue amount; 58 | 59 | @XmlElement 60 | CurrencyValue price; 61 | 62 | @XmlElement(name="effective_amount") 63 | CurrencyValue effectiveAmount; 64 | 65 | @XmlElement 66 | Status status; 67 | 68 | 69 | public String getOid() { 70 | return oid; 71 | } 72 | 73 | public Currency getBase() { 74 | return base; 75 | } 76 | 77 | public Currency getQuote() { 78 | return quote; 79 | } 80 | 81 | public Date getTimestamp() { 82 | return timestamp; 83 | } 84 | 85 | public Date getPriority() { 86 | return priority; 87 | } 88 | 89 | public Type getType() { 90 | return type; 91 | } 92 | 93 | public CurrencyValue getAmount() { 94 | return amount; 95 | } 96 | 97 | public CurrencyValue getPrice() { 98 | return price; 99 | } 100 | 101 | public CurrencyValue getEffectiveAmount() { 102 | return effectiveAmount; 103 | } 104 | 105 | public Status getStatus() { 106 | return status; 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/track/ValueTrack.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.track; 2 | 3 | 4 | import at.outdated.bitcoin.exchange.api.container.CircularStore; 5 | import at.outdated.bitcoin.exchange.api.market.TimedValue; 6 | import org.apache.commons.math3.stat.regression.MillerUpdatingRegression; 7 | import org.apache.commons.math3.stat.regression.RegressionResults; 8 | 9 | import java.util.Collection; 10 | import java.util.Iterator; 11 | 12 | /** 13 | * Created with IntelliJ IDEA. 14 | * User: ebirn 15 | * Date: 02.05.13 16 | * Time: 21:16 17 | * To change this template use File | Settings | File Templates. 18 | */ 19 | public class ValueTrack implements Iterable { 20 | 21 | // assuming values every minute: track 1 hours 22 | private static final int LENGTH = 60; 23 | 24 | CircularStore valueBuffer; //, diffBuffer, diff2Buffer; 25 | 26 | private long inserts = 0L; 27 | 28 | public ValueTrack() { 29 | init(LENGTH); 30 | } 31 | 32 | public ValueTrack(int length) { 33 | init(length); 34 | } 35 | 36 | public ValueTrack(Collection collection) { 37 | init(collection.size()); 38 | valueBuffer.addAll(collection); 39 | } 40 | 41 | protected void init(int length) { 42 | valueBuffer = new CircularStore<>(length); 43 | } 44 | 45 | 46 | public void insert(D value) { 47 | valueBuffer.add(value); 48 | inserts++; 49 | } 50 | 51 | private D getLatestBufferValue(CircularStore buffer) { 52 | 53 | 54 | if(buffer.get() == null) return null; 55 | 56 | return ((D) buffer.get()); 57 | } 58 | 59 | public D getLatest() { 60 | return getLatestBufferValue(valueBuffer); 61 | } 62 | 63 | 64 | 65 | public D getOldest() { 66 | return this.valueBuffer.getTail(); 67 | } 68 | 69 | public RegressionResults getRegression() { 70 | int numberOfVariables = 8; // TODO: this sould not be hardcoded 71 | boolean includeConstant = true; // enables intercept 72 | double errorTolerance = 1.0; 73 | 74 | MillerUpdatingRegression regression = new MillerUpdatingRegression(numberOfVariables, includeConstant, errorTolerance); 75 | // maybe also check this: http://openforecast.sourceforge.net 76 | 77 | Iterator> valueIt = valueBuffer.iterator(); 78 | while(valueIt.hasNext()) { 79 | TimedValue data = valueIt.next(); 80 | regression.addObservation(data.getValue(), data.getTimestamp().getTime()); 81 | } 82 | 83 | return regression.regress(); 84 | } 85 | 86 | 87 | 88 | public int getTrackLength() { 89 | return valueBuffer.size(); 90 | } 91 | 92 | 93 | public Iterator iterator() { 94 | return valueBuffer.iterator(); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /api/src/main/java/at/outdated/bitcoin/exchange/api/performance/CurrencyPerformance.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.api.performance; 2 | 3 | import at.outdated.bitcoin.exchange.api.account.TransactionType; 4 | import at.outdated.bitcoin.exchange.api.account.WalletTransaction; 5 | import at.outdated.bitcoin.exchange.api.currency.Currency; 6 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created with IntelliJ IDEA. 14 | * User: ebirn 15 | * Date: 11.05.13 16 | * Time: 15:23 17 | * To change this template use File | Settings | File Templates. 18 | */ 19 | public class CurrencyPerformance extends Performance { 20 | 21 | protected CurrencyValue startBalance = null; 22 | protected CurrencyValue endBalance = null; 23 | 24 | Currency currency; 25 | 26 | boolean started = false; 27 | 28 | private List transactions = new ArrayList<>(); 29 | 30 | //private Set ignoredTransactions = new HashSet<>(); 31 | 32 | public CurrencyPerformance(Currency currency) { 33 | this.currency = currency; 34 | this.startBalance = new CurrencyValue(currency); 35 | this.endBalance = new CurrencyValue(currency); 36 | } 37 | 38 | @Override 39 | public boolean includeTransaction(WalletTransaction transaction) { 40 | 41 | if(transaction.getValue().getCurrency() == currency) { 42 | 43 | 44 | transactions.add(transaction); 45 | 46 | TransactionType type = transaction.getType(); 47 | CurrencyValue balance = transaction.getBalance(); 48 | 49 | if(!started) { 50 | startBalance = balance; 51 | started = true; 52 | } 53 | 54 | if(balance != null) { 55 | endBalance = balance; 56 | } 57 | return true; 58 | } 59 | 60 | return false; 61 | } 62 | 63 | @Override 64 | public BigDecimal getPercent() { 65 | 66 | // special case if we started at 0.0 67 | if(startBalance.getValue().signum() == 0 && endBalance.getValue().signum() == 0) { 68 | return BigDecimal.ZERO; 69 | } 70 | else if(startBalance.getValue().signum() == 0 && endBalance.getValue().signum() == 1) { 71 | return BigDecimal.ONE; 72 | } 73 | 74 | return new CurrencyValue(getTotalDifference()).divide(startBalance).getValue(); 75 | } 76 | 77 | @Override 78 | public CurrencyValue getTotalDifference() { 79 | return new CurrencyValue(endBalance).subtract(startBalance); 80 | } 81 | 82 | @Override 83 | public CurrencyValue getEndBalance() { 84 | return endBalance; 85 | } 86 | 87 | @Override 88 | public CurrencyValue getStartBalance() { 89 | return startBalance; 90 | } 91 | 92 | @Override 93 | public Currency getCurrency() { 94 | return currency; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /kraken/src/main/java/at/outdated/bitcoin/exchange/kraken/KrakenMarket.java: -------------------------------------------------------------------------------- 1 | package at.outdated.bitcoin.exchange.kraken; 2 | 3 | import at.outdated.bitcoin.exchange.api.client.ExchangeClient; 4 | import at.outdated.bitcoin.exchange.api.currency.Currency; 5 | import at.outdated.bitcoin.exchange.api.currency.CurrencyValue; 6 | import at.outdated.bitcoin.exchange.api.market.Market; 7 | import at.outdated.bitcoin.exchange.api.market.fee.ConstantFee; 8 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferMethod; 9 | import at.outdated.bitcoin.exchange.api.market.transfer.TransferType; 10 | 11 | /** 12 | * Created with IntelliJ IDEA. 13 | * User: ebirn 14 | * Date: 17.09.13 15 | * Time: 18:28 16 | * To change this template use File | Settings | File Templates. 17 | */ 18 | public class KrakenMarket extends Market { 19 | 20 | public KrakenMarket() { 21 | super("kraken", "http://www.kraken.com", "Kraken"); 22 | 23 | addWithdrawal(new TransferMethod(Currency.BTC, TransferType.VIRTUAL, new ConstantFee(new CurrencyValue("0.0005", Currency.BTC)))); 24 | addWithdrawal(new TransferMethod(Currency.LTC, TransferType.VIRTUAL, new ConstantFee(new CurrencyValue("0.02", Currency.LTC)))); 25 | addWithdrawal(new TransferMethod(Currency.XRP, TransferType.VIRTUAL, new ConstantFee(new CurrencyValue("0.00002", Currency.XRP)))); 26 | 27 | addWithdrawal(new TransferMethod(Currency.NMC, TransferType.VIRTUAL, new ConstantFee(new CurrencyValue("0.005", Currency.NMC)))); 28 | 29 | addWithdrawal(new TransferMethod(Currency.EUR, TransferType.BANK, new ConstantFee(new CurrencyValue("0.09", Currency.EUR)))); 30 | addWithdrawal(new TransferMethod(Currency.USD, TransferType.BANK, new ConstantFee(new CurrencyValue("30.0", Currency.USD)))); 31 | 32 | 33 | addDeposit(new TransferMethod(Currency.BTC, TransferType.VIRTUAL)); 34 | addDeposit(new TransferMethod(Currency.LTC, TransferType.VIRTUAL)); 35 | addDeposit(new TransferMethod(Currency.XRP, TransferType.VIRTUAL)); 36 | addDeposit(new TransferMethod(Currency.NMC, TransferType.VIRTUAL)); 37 | 38 | addDeposit(new TransferMethod(Currency.EUR, TransferType.BANK)); 39 | addDeposit(new TransferMethod(Currency.USD, TransferType.BANK)); 40 | 41 | addAsset(Currency.BTC, Currency.EUR); 42 | addAsset(Currency.BTC, Currency.USD); 43 | addAsset(Currency.BTC, Currency.XRP); 44 | addAsset(Currency.USD, Currency.XRP); 45 | addAsset(Currency.EUR, Currency.XRP); 46 | addAsset(Currency.BTC, Currency.LTC); 47 | addAsset(Currency.LTC, Currency.USD); 48 | addAsset(Currency.LTC, Currency.EUR); 49 | addAsset(Currency.LTC, Currency.XRP); 50 | 51 | addAsset(Currency.BTC, Currency.NMC); 52 | addAsset(Currency.NMC, Currency.USD); 53 | addAsset(Currency.NMC, Currency.EUR); 54 | addAsset(Currency.NMC, Currency.XRP); 55 | } 56 | 57 | @Override 58 | public ExchangeClient createClient() { 59 | return new KrakenClient(this); 60 | } 61 | 62 | } 63 | --------------------------------------------------------------------------------