From 97c0c752715b07c996c7b4220183805c913e1ab4 Mon Sep 17 00:00:00 2001 From: Dmitri Karpovich Date: Wed, 8 Jan 2025 13:54:36 +0100 Subject: [PATCH] [lgo] Delete non-existing exchange --- pom.xml | 2 - xchange-examples/pom.xml | 5 - .../examples/lgo/LgoExamplesUtils.java | 17 - .../org/knowm/xchange/examples/lgo/README | 5 - .../lgo/trade/LgoTradeHistoryDemo.java | 32 -- xchange-lgo/.gitignore | 1 - xchange-lgo/README.md | 65 --- xchange-lgo/pom.xml | 40 -- .../xchange/lgo/CertificateAuthority.java | 21 - .../main/java/org/knowm/xchange/lgo/Lgo.java | 112 ----- .../org/knowm/xchange/lgo/LgoAdapters.java | 229 ---------- .../java/org/knowm/xchange/lgo/LgoEnv.java | 66 --- .../knowm/xchange/lgo/LgoErrorAdapter.java | 29 -- .../org/knowm/xchange/lgo/LgoExchange.java | 66 --- .../knowm/xchange/lgo/dto/LgoException.java | 5 - .../org/knowm/xchange/lgo/dto/WithCursor.java | 22 - .../lgo/dto/currency/LgoCurrencies.java | 17 - .../xchange/lgo/dto/currency/LgoCurrency.java | 31 -- .../org/knowm/xchange/lgo/dto/key/LgoKey.java | 37 -- .../lgo/dto/marketdata/LgoCandlestick.java | 78 ---- .../lgo/dto/marketdata/LgoGranularity.java | 20 - .../lgo/dto/marketdata/LgoOrderbook.java | 34 -- .../lgo/dto/marketdata/LgoPriceHistory.java | 22 - .../lgo/dto/order/LgoEncryptedOrder.java | 37 -- .../lgo/dto/order/LgoOrderSignature.java | 19 - .../lgo/dto/order/LgoPlaceCancelOrder.java | 26 -- .../lgo/dto/order/LgoPlaceLimitOrder.java | 55 --- .../lgo/dto/order/LgoPlaceMarketOrder.java | 44 -- .../xchange/lgo/dto/order/LgoPlaceOrder.java | 24 - .../lgo/dto/order/LgoPlaceOrderResponse.java | 12 - .../lgo/dto/order/LgoUnencryptedOrder.java | 25 - .../xchange/lgo/dto/product/LgoLimit.java | 23 - .../xchange/lgo/dto/product/LgoProduct.java | 38 -- .../lgo/dto/product/LgoProductCurrency.java | 32 -- .../lgo/dto/product/LgoProductTotal.java | 16 - .../xchange/lgo/dto/product/LgoProducts.java | 18 - .../xchange/lgo/dto/trade/LgoUserTrade.java | 78 ---- .../xchange/lgo/dto/trade/LgoUserTrades.java | 17 - .../xchange/lgo/service/CryptoUtils.java | 59 --- .../xchange/lgo/service/LgoBaseService.java | 19 - .../xchange/lgo/service/LgoKeyService.java | 53 --- .../lgo/service/LgoMarketDataService.java | 28 -- .../lgo/service/LgoMarketDataServiceRaw.java | 55 --- .../lgo/service/LgoSignatureService.java | 53 --- .../service/LgoSignatureServiceLocalRsa.java | 81 ---- .../LgoSignatureServicePassthroughs.java | 31 -- .../lgo/service/LgoTradeHistoryParams.java | 61 --- .../xchange/lgo/service/LgoTradeService.java | 232 ---------- .../lgo/service/LgoTradeServiceRaw.java | 56 --- xchange-lgo/src/main/resources/lgo.json | 19 - .../knowm/xchange/lgo/LgoAdaptersTest.java | 340 -------------- .../lgo/LgoExchangeMarketDataIntegration.java | 80 ---- .../lgo/LgoExchangeMetadataIntegration.java | 46 -- .../lgo/LgoExchangeTradeIntegration.java | 134 ------ .../lgo/dto/currency/LgoCurrenciesTest.java | 28 -- .../lgo/dto/marketdata/LgoOrderbookTest.java | 35 -- .../dto/marketdata/LgoPriceHistoryTest.java | 45 -- .../lgo/dto/order/LgoPlaceOrderTest.java | 42 -- .../lgo/dto/product/LgoProductsTest.java | 42 -- .../lgo/service/LgoKeyServiceIntegration.java | 45 -- .../LgoSignatureServiceLocalRsaTest.java | 51 --- .../LgoSignatureServicePassthroughsTest.java | 33 -- .../lgo/service/LgoTradeServiceTest.java | 228 ---------- xchange-lgo/src/test/resources/logback.xml | 24 - .../lgo/currency/example-currencies-data.json | 14 - .../org/knowm/xchange/lgo/key/index.txt | 1 - .../marketdata/example-orderbook-data.json | 24 - .../marketdata/example-pricehistory-data.json | 6 - .../lgo/product/example-products-data.json | 28 -- .../lgo/trade/example-trades-data.json | 29 -- .../src/test/resources/private_key.pem | 28 -- xchange-stream-lgo/.gitignore | 1 - xchange-stream-lgo/pom.xml | 36 -- .../bitrich/xchangestream/lgo/LgoAdapter.java | 150 ------ .../lgo/LgoLevel2BatchSubscription.java | 73 --- .../lgo/LgoStreamingAccountService.java | 62 --- .../lgo/LgoStreamingExchange.java | 88 ---- .../lgo/LgoStreamingMarketDataService.java | 44 -- .../lgo/LgoStreamingService.java | 52 --- .../lgo/LgoStreamingTradeService.java | 198 -------- .../lgo/LgoTradeBatchSubscription.java | 72 --- .../lgo/LgoUserBatchSubscription.java | 103 ----- .../lgo/domain/LgoAckOrderEvent.java | 10 - .../lgo/domain/LgoBatchOrderEvent.java | 34 -- .../lgo/domain/LgoDoneOrderEvent.java | 63 --- .../lgo/domain/LgoFailedOrderEvent.java | 39 -- .../lgo/domain/LgoGroupedBalanceUpdate.java | 32 -- .../lgo/domain/LgoGroupedLevel2Update.java | 71 --- .../lgo/domain/LgoGroupedTradeUpdate.java | 36 -- .../lgo/domain/LgoGroupedUserUpdate.java | 57 --- .../lgo/domain/LgoInvalidOrderEvent.java | 45 -- .../lgo/domain/LgoMatchOrderEvent.java | 118 ----- .../lgo/domain/LgoOpenOrderEvent.java | 36 -- .../lgo/domain/LgoOrderEvent.java | 45 -- .../lgo/domain/LgoPendingOrderEvent.java | 82 ---- .../lgo/domain/LgoReceivedOrderEvent.java | 26 -- .../xchangestream/lgo/dto/LgoAckUpdate.java | 33 -- .../lgo/dto/LgoBalanceUpdate.java | 38 -- .../xchangestream/lgo/dto/LgoLevel2Data.java | 25 - .../lgo/dto/LgoLevel2Update.java | 45 -- .../lgo/dto/LgoSocketPlaceOrder.java | 20 - .../lgo/dto/LgoSubscription.java | 43 -- .../xchangestream/lgo/dto/LgoTrade.java | 50 -- .../lgo/dto/LgoTradesUpdate.java | 46 -- .../xchangestream/lgo/dto/LgoUserMessage.java | 40 -- .../lgo/dto/LgoUserSnapshot.java | 23 - .../lgo/dto/LgoUserSnapshotData.java | 64 --- .../xchangestream/lgo/dto/LgoUserUpdate.java | 24 - .../lgo/LgoStreamingAccountServiceTest.java | 111 ----- .../lgo/LgoStreamingExchangeExample.java | 155 ------- .../LgoStreamingMarketDataServiceTest.java | 118 ----- .../lgo/LgoStreamingServiceTest.java | 93 ---- .../lgo/LgoStreamingTradeServiceTest.java | 428 ------------------ .../bitrich/xchangestream/lgo/TestUtils.java | 20 - .../resources/account/balance-snapshot.json | 17 - .../resources/account/balance-update.json | 12 - .../src/test/resources/logback.xml | 23 - .../resources/marketdata/level2-snapshot.json | 24 - .../resources/marketdata/level2-update.json | 24 - .../resources/marketdata/trades-update.json | 22 - .../src/test/resources/private_key.pem | 28 -- .../src/test/resources/public.pem | 6 - .../subscribe/balance-subscribe.json | 8 - .../resources/subscribe/level2-subscribe.json | 9 - .../resources/subscribe/trades-subscribe.json | 9 - .../test/resources/trade/afr-snapshot.json | 5 - .../src/test/resources/trade/afr-update1.json | 12 - .../src/test/resources/trade/afr-update2.json | 13 - .../resources/trade/all-afr-snapshot.json | 5 - .../test/resources/trade/all-afr-update.json | 12 - .../resources/trade/all-orders-snapshot.json | 7 - .../resources/trade/all-orders-update.json | 22 - .../trade/order-changes-snapshot.json | 26 -- .../resources/trade/order-changes-update.json | 50 -- .../trade/order-events-snapshot.json | 26 -- .../resources/trade/order-events-update.json | 43 -- .../test/resources/trade/orders-snapshot.json | 26 -- .../test/resources/trade/orders-update.json | 28 -- .../resources/trade/user-trades-snapshot.json | 7 - .../resources/trade/user-trades-update.json | 33 -- 140 files changed, 6916 deletions(-) delete mode 100644 xchange-examples/src/main/java/org/knowm/xchange/examples/lgo/LgoExamplesUtils.java delete mode 100644 xchange-examples/src/main/java/org/knowm/xchange/examples/lgo/README delete mode 100644 xchange-examples/src/main/java/org/knowm/xchange/examples/lgo/trade/LgoTradeHistoryDemo.java delete mode 100644 xchange-lgo/.gitignore delete mode 100644 xchange-lgo/README.md delete mode 100644 xchange-lgo/pom.xml delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/CertificateAuthority.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/Lgo.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoAdapters.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoEnv.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoErrorAdapter.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoExchange.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/LgoException.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/WithCursor.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/currency/LgoCurrencies.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/currency/LgoCurrency.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/key/LgoKey.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoCandlestick.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoGranularity.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoOrderbook.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoPriceHistory.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoEncryptedOrder.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoOrderSignature.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceCancelOrder.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceLimitOrder.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceMarketOrder.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceOrder.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceOrderResponse.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoUnencryptedOrder.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoLimit.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProduct.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProductCurrency.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProductTotal.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProducts.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/trade/LgoUserTrade.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/trade/LgoUserTrades.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/CryptoUtils.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoBaseService.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoKeyService.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoMarketDataService.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoMarketDataServiceRaw.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoSignatureService.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoSignatureServiceLocalRsa.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoSignatureServicePassthroughs.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoTradeHistoryParams.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoTradeService.java delete mode 100644 xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoTradeServiceRaw.java delete mode 100644 xchange-lgo/src/main/resources/lgo.json delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoAdaptersTest.java delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoExchangeMarketDataIntegration.java delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoExchangeMetadataIntegration.java delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoExchangeTradeIntegration.java delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/currency/LgoCurrenciesTest.java delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/marketdata/LgoOrderbookTest.java delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/marketdata/LgoPriceHistoryTest.java delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/order/LgoPlaceOrderTest.java delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/product/LgoProductsTest.java delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoKeyServiceIntegration.java delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoSignatureServiceLocalRsaTest.java delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoSignatureServicePassthroughsTest.java delete mode 100644 xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoTradeServiceTest.java delete mode 100644 xchange-lgo/src/test/resources/logback.xml delete mode 100644 xchange-lgo/src/test/resources/org/knowm/xchange/lgo/currency/example-currencies-data.json delete mode 100644 xchange-lgo/src/test/resources/org/knowm/xchange/lgo/key/index.txt delete mode 100644 xchange-lgo/src/test/resources/org/knowm/xchange/lgo/marketdata/example-orderbook-data.json delete mode 100644 xchange-lgo/src/test/resources/org/knowm/xchange/lgo/marketdata/example-pricehistory-data.json delete mode 100644 xchange-lgo/src/test/resources/org/knowm/xchange/lgo/product/example-products-data.json delete mode 100644 xchange-lgo/src/test/resources/org/knowm/xchange/lgo/trade/example-trades-data.json delete mode 100644 xchange-lgo/src/test/resources/private_key.pem delete mode 100644 xchange-stream-lgo/.gitignore delete mode 100644 xchange-stream-lgo/pom.xml delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoAdapter.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoLevel2BatchSubscription.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingAccountService.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingExchange.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingMarketDataService.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingService.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingTradeService.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoTradeBatchSubscription.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoUserBatchSubscription.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoAckOrderEvent.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoBatchOrderEvent.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoDoneOrderEvent.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoFailedOrderEvent.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedBalanceUpdate.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedLevel2Update.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedTradeUpdate.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedUserUpdate.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoInvalidOrderEvent.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoMatchOrderEvent.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoOpenOrderEvent.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoOrderEvent.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoPendingOrderEvent.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoReceivedOrderEvent.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoAckUpdate.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoBalanceUpdate.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoLevel2Data.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoLevel2Update.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoSocketPlaceOrder.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoSubscription.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoTrade.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoTradesUpdate.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserMessage.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserSnapshot.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserSnapshotData.java delete mode 100644 xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserUpdate.java delete mode 100644 xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingAccountServiceTest.java delete mode 100644 xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingExchangeExample.java delete mode 100644 xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingMarketDataServiceTest.java delete mode 100644 xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingServiceTest.java delete mode 100644 xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingTradeServiceTest.java delete mode 100644 xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/TestUtils.java delete mode 100644 xchange-stream-lgo/src/test/resources/account/balance-snapshot.json delete mode 100644 xchange-stream-lgo/src/test/resources/account/balance-update.json delete mode 100644 xchange-stream-lgo/src/test/resources/logback.xml delete mode 100644 xchange-stream-lgo/src/test/resources/marketdata/level2-snapshot.json delete mode 100644 xchange-stream-lgo/src/test/resources/marketdata/level2-update.json delete mode 100644 xchange-stream-lgo/src/test/resources/marketdata/trades-update.json delete mode 100644 xchange-stream-lgo/src/test/resources/private_key.pem delete mode 100644 xchange-stream-lgo/src/test/resources/public.pem delete mode 100644 xchange-stream-lgo/src/test/resources/subscribe/balance-subscribe.json delete mode 100644 xchange-stream-lgo/src/test/resources/subscribe/level2-subscribe.json delete mode 100644 xchange-stream-lgo/src/test/resources/subscribe/trades-subscribe.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/afr-snapshot.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/afr-update1.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/afr-update2.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/all-afr-snapshot.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/all-afr-update.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/all-orders-snapshot.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/all-orders-update.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/order-changes-snapshot.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/order-changes-update.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/order-events-snapshot.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/order-events-update.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/orders-snapshot.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/orders-update.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/user-trades-snapshot.json delete mode 100644 xchange-stream-lgo/src/test/resources/trade/user-trades-update.json diff --git a/pom.xml b/pom.xml index 3ab5b436d01..25d473cc790 100644 --- a/pom.xml +++ b/pom.xml @@ -100,7 +100,6 @@ xchange-kucoin xchange-kuna xchange-latoken - xchange-lgo xchange-livecoin xchange-luno xchange-lykke @@ -140,7 +139,6 @@ xchange-stream-kraken xchange-stream-krakenfutures xchange-stream-kucoin - xchange-stream-lgo xchange-stream-okcoin xchange-stream-okex xchange-stream-poloniex2 diff --git a/xchange-examples/pom.xml b/xchange-examples/pom.xml index bff03ca4051..48ee1e57f04 100755 --- a/xchange-examples/pom.xml +++ b/xchange-examples/pom.xml @@ -333,11 +333,6 @@ xchange-enigma ${project.version} - - org.knowm.xchange - xchange-lgo - ${project.version} - org.knowm.xchart diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/lgo/LgoExamplesUtils.java b/xchange-examples/src/main/java/org/knowm/xchange/examples/lgo/LgoExamplesUtils.java deleted file mode 100644 index 480c109e6b0..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/lgo/LgoExamplesUtils.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.knowm.xchange.examples.lgo; - -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeFactory; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.lgo.LgoEnv; - -public class LgoExamplesUtils { - - public static Exchange getExchange() { - ExchangeSpecification spec = LgoEnv.sandbox(); - spec.setSecretKey("your private key"); - spec.setApiKey("your api key"); - - return ExchangeFactory.INSTANCE.createExchange(spec); - } -} diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/lgo/README b/xchange-examples/src/main/java/org/knowm/xchange/examples/lgo/README deleted file mode 100644 index 184ebb7f9d3..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/lgo/README +++ /dev/null @@ -1,5 +0,0 @@ -## LGO - -For now, only metadata, auth, trade history and order signature are supported, because the web socket should be favored for any trading activity (lowest possible latency). - -For web socket support, see [xchange-stream](https://github.com/bitrich-info/xchange-stream) diff --git a/xchange-examples/src/main/java/org/knowm/xchange/examples/lgo/trade/LgoTradeHistoryDemo.java b/xchange-examples/src/main/java/org/knowm/xchange/examples/lgo/trade/LgoTradeHistoryDemo.java deleted file mode 100644 index c5915a191cc..00000000000 --- a/xchange-examples/src/main/java/org/knowm/xchange/examples/lgo/trade/LgoTradeHistoryDemo.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.knowm.xchange.examples.lgo.trade; - -import java.io.IOException; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.dto.trade.UserTrade; -import org.knowm.xchange.dto.trade.UserTrades; -import org.knowm.xchange.examples.lgo.LgoExamplesUtils; -import org.knowm.xchange.lgo.service.LgoTradeHistoryParams; -import org.knowm.xchange.service.trade.TradeService; - -public class LgoTradeHistoryDemo { - - public static void main(String[] args) throws IOException { - Exchange lgoExchange = LgoExamplesUtils.getExchange(); - TradeService tradeService = lgoExchange.getTradeService(); - UserTrades tradeHistory = tradeService.getTradeHistory(tradeService.createTradeHistoryParams()); - System.out.println("Your last trades:"); - print(tradeHistory); - while (tradeHistory.getNextPageCursor() != null - && !tradeHistory.getNextPageCursor().isEmpty()) { - LgoTradeHistoryParams params = - (LgoTradeHistoryParams) tradeService.createTradeHistoryParams(); - params.setNextPageCursor(tradeHistory.getNextPageCursor()); - tradeHistory = tradeService.getTradeHistory(params); - print(tradeHistory); - } - } - - private static void print(UserTrades tradeHistory) { - tradeHistory.getUserTrades().stream().map(UserTrade::toString).forEach(System.out::println); - } -} diff --git a/xchange-lgo/.gitignore b/xchange-lgo/.gitignore deleted file mode 100644 index 0f1976fdef0..00000000000 --- a/xchange-lgo/.gitignore +++ /dev/null @@ -1 +0,0 @@ -src/test/resources/integration \ No newline at end of file diff --git a/xchange-lgo/README.md b/xchange-lgo/README.md deleted file mode 100644 index 6ebfc96824b..00000000000 --- a/xchange-lgo/README.md +++ /dev/null @@ -1,65 +0,0 @@ -## LGO - -Supports LGO HTTP API and authentication. - -For now, only metadata, auth, trade history, order book, order signature and placing orders/cancelling orders are supported. -The web socket API should be favored (lowest possible latency). - -For web socket support, see [xchange-stream](https://github.com/lgo-public/xchange-stream) - -### Documentation - -[LGO web site](https://lgo.group) - -[API Documentation](https://doc.exchange.lgo.markets) - -### Authentication methods - -LGO authenticates request using an api key, and a RSA key/pair. -This library supports several strategy do deal with that. - -You can choose between the two methods by setting the `LgoEnv.SIGNATURE_SERVICE` specific parameter to `SignatureService.PASSTHROUGHS` or `SignatureService.LOCAL_RSA`. -`LOCAL_RSA` is assumed by default. - - -#### PASSTHROUGHS - -This strategy is intended for people running this lib behind a proxy that will do the real authentication. -This is a good approach to secure your secrets, and even more so if you managed them with an HSM. - -This strategy will pass in the Authorization header whatever you gave as `User_Id` `Api_Key` - and `Secret_Key`, encoded in Base64, concatenated as so : `LGO ${User_Id}:${Api_Key}:${Secret_Key} - -Your proxy could then fetch the real key given this identifier, and do the authorization - -#### Local RSA - -This strategy uses directly your secrets to apply authentication. Bet very careful about how you store and secure your secrets. - -You should configure `ExchangeSpecification` by setting `setApiKey` with your accessKey, and `setApiSecret` with your private key in PKCS8 format. - -##### How to generate a proper private key for real usage or integration tests - -To generate a valid key pair : - -* `openssl genrsa -out private.pem 2048` (generates a 2048 RSA private key in PKCS1) -* `openssl rsa -in private.pem -pubout > key.pub` (deduce your pub key from private key) -* `openssl pkcs8 -topk8 -inform PEM -in private.pem -out private_key.pem -nocrypt` (converts your private key to PKCS8) - - -In LGO application, to generate an api key, copy the content of `key.pub`, and paste it when asked. -You should be given an api key. - -This library expect your private key in PKCS8 format (the second file you generated earlier). - -For integration tests, an integration directory should exist into src/test/resources, containing: -* `api_key.txt` : a file containing your api key in plain text -* `private_key.pem` : the private key in PKCS8 pem format generated earlier - -### Order encryption - -LGO includes an optional front-running protection. More informations are available [here](https://lgono.de/) -In practice, to prevent front-running, you can encrypt your orders with a key LGO doesn't know, and your order will be unencrypted only after LGO made several proofs that it won't -insert orders before yours. - -This behavior is controlled by the specific parameter `LgoEnv.SHOULD_ENCRYPT_ORDERS`, that can be set to `true` or `false`. \ No newline at end of file diff --git a/xchange-lgo/pom.xml b/xchange-lgo/pom.xml deleted file mode 100644 index 9d057217085..00000000000 --- a/xchange-lgo/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - 4.0.0 - - - org.knowm.xchange - xchange-parent - 5.2.2-SNAPSHOT - - - xchange-lgo - - XChange LGO - XChange implementation for LGO - - http://knowm.org/open-source/xchange/ - 2019 - - - Knowm Inc. - http://knowm.org/open-source/xchange/ - - - - - - - org.knowm.xchange - xchange-core - ${project.version} - - - org.mockito - mockito-core - test - - - - diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/CertificateAuthority.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/CertificateAuthority.java deleted file mode 100644 index 7dce1841eb7..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/CertificateAuthority.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.knowm.xchange.lgo; - -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.core.MediaType; - -@Path("/") -public interface CertificateAuthority { - - @Path("index.txt") - @Produces(MediaType.TEXT_PLAIN) - @GET - String fetchIndex(); - - @Path("{id}_public.pem") - @Produces(MediaType.TEXT_PLAIN) - @GET - String fetchKey(@PathParam("id") String keyId); -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/Lgo.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/Lgo.java deleted file mode 100644 index 38089880bb4..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/Lgo.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.knowm.xchange.lgo; - -import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.DELETE; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.HeaderParam; -import jakarta.ws.rs.POST; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.QueryParam; -import jakarta.ws.rs.core.MediaType; -import java.io.IOException; -import org.knowm.xchange.lgo.dto.LgoException; -import org.knowm.xchange.lgo.dto.WithCursor; -import org.knowm.xchange.lgo.dto.currency.LgoCurrencies; -import org.knowm.xchange.lgo.dto.marketdata.LgoOrderbook; -import org.knowm.xchange.lgo.dto.marketdata.LgoPriceHistory; -import org.knowm.xchange.lgo.dto.order.LgoEncryptedOrder; -import org.knowm.xchange.lgo.dto.order.LgoPlaceOrderResponse; -import org.knowm.xchange.lgo.dto.order.LgoUnencryptedOrder; -import org.knowm.xchange.lgo.dto.product.LgoProducts; -import org.knowm.xchange.lgo.dto.trade.LgoUserTrades; -import si.mazi.rescu.ParamsDigest; - -@Produces(MediaType.APPLICATION_JSON) -@Path("/v1") -public interface Lgo { - - String X_LGO_DATE = "X-LGO-DATE"; - String AUTHORIZATION = "Authorization"; - String PRODUCT_ID = "product_id"; - String MAX_RESULTS = "max_results"; - String PAGE = "page"; - String SORT = "sort"; - String ORDER_ID = "order_id"; - String GRANULARITY = "granularity"; - String END = "end"; - String START = "start"; - - @GET - @Path("/live/products") - LgoProducts getProducts( - @HeaderParam(X_LGO_DATE) long timestamp, @HeaderParam(AUTHORIZATION) ParamsDigest signature) - throws IOException, LgoException; - - @GET - @Path("/live/currencies") - LgoCurrencies getCurrencies( - @HeaderParam(X_LGO_DATE) long timestamp, @HeaderParam(AUTHORIZATION) ParamsDigest signature) - throws IOException, LgoException; - - @GET - @Path("/history/trades") - WithCursor getLastTrades( - @HeaderParam(X_LGO_DATE) long timestamp, - @HeaderParam(AUTHORIZATION) ParamsDigest signature, - @QueryParam(PRODUCT_ID) String productId, - @QueryParam(MAX_RESULTS) int maxResults, - @QueryParam(PAGE) String page, - @QueryParam(SORT) String sort) - throws IOException, LgoException; - - @GET - @Path("/live/products/{product_id}/book") - LgoOrderbook getOrderBook( - @HeaderParam(X_LGO_DATE) long timestamp, - @HeaderParam(AUTHORIZATION) ParamsDigest signature, - @PathParam(PRODUCT_ID) String productId) - throws IOException, LgoException; - - @POST - @Path("/live/orders/encrypted") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - LgoPlaceOrderResponse placeEncryptedOrder( - LgoEncryptedOrder placeOrder, - @HeaderParam(X_LGO_DATE) long timestamp, - @HeaderParam(AUTHORIZATION) ParamsDigest signature) - throws IOException, LgoException; - - @POST - @Path("/live/orders") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - LgoPlaceOrderResponse placeUnencryptedOrder( - LgoUnencryptedOrder placeOrder, - @HeaderParam(X_LGO_DATE) long timestamp, - @HeaderParam(AUTHORIZATION) ParamsDigest signature) - throws IOException, LgoException; - - @DELETE - @Path("/live/orders/{order_id}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - LgoPlaceOrderResponse placeUnencryptedCancelOrder( - @HeaderParam(X_LGO_DATE) long timestamp, - @HeaderParam(AUTHORIZATION) ParamsDigest signature, - @PathParam(ORDER_ID) String orderId) - throws IOException, LgoException; - - @GET - @Path("/history/products/{product_id}/candles") - LgoPriceHistory getPriceHistory( - @HeaderParam(X_LGO_DATE) long timestamp, - @HeaderParam(AUTHORIZATION) ParamsDigest signature, - @PathParam(PRODUCT_ID) String productId, - @QueryParam(START) String startTime, - @QueryParam(END) String endTime, - @QueryParam(GRANULARITY) int granularity) - throws IOException, LgoException; -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoAdapters.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoAdapters.java deleted file mode 100644 index 1a6950446ea..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoAdapters.java +++ /dev/null @@ -1,229 +0,0 @@ -package org.knowm.xchange.lgo; - -import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.time.Instant; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Spliterator; -import java.util.Spliterators; -import java.util.TimeZone; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; -import org.knowm.xchange.currency.Currency; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order.OrderType; -import org.knowm.xchange.dto.marketdata.OrderBook; -import org.knowm.xchange.dto.marketdata.Trades; -import org.knowm.xchange.dto.meta.CurrencyMetaData; -import org.knowm.xchange.dto.meta.ExchangeMetaData; -import org.knowm.xchange.dto.meta.FeeTier; -import org.knowm.xchange.dto.meta.InstrumentMetaData; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.MarketOrder; -import org.knowm.xchange.dto.trade.UserTrade; -import org.knowm.xchange.dto.trade.UserTrades; -import org.knowm.xchange.instrument.Instrument; -import org.knowm.xchange.lgo.dto.WithCursor; -import org.knowm.xchange.lgo.dto.currency.LgoCurrencies; -import org.knowm.xchange.lgo.dto.currency.LgoCurrency; -import org.knowm.xchange.lgo.dto.key.LgoKey; -import org.knowm.xchange.lgo.dto.marketdata.LgoOrderbook; -import org.knowm.xchange.lgo.dto.order.LgoPlaceCancelOrder; -import org.knowm.xchange.lgo.dto.order.LgoPlaceLimitOrder; -import org.knowm.xchange.lgo.dto.order.LgoPlaceMarketOrder; -import org.knowm.xchange.lgo.dto.order.LgoPlaceOrder; -import org.knowm.xchange.lgo.dto.order.LgoUnencryptedOrder; -import org.knowm.xchange.lgo.dto.product.LgoProduct; -import org.knowm.xchange.lgo.dto.product.LgoProducts; -import org.knowm.xchange.lgo.dto.trade.LgoUserTrade; -import org.knowm.xchange.lgo.dto.trade.LgoUserTrades; - -public final class LgoAdapters { - - private LgoAdapters() {} - - private static SimpleDateFormat ISO_DATE_FORMAT; - - static { - ISO_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - ISO_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC")); - } - - public static ExchangeMetaData adaptMetadata( - ExchangeMetaData metaData, LgoProducts products, LgoCurrencies currencies) { - Map currencyPairs = metaData.getInstruments(); - Map currency = metaData.getCurrencies(); - for (LgoCurrency lgoCurrency : currencies.getCurrencies()) { - currency.put( - Currency.getInstance(lgoCurrency.getCode()), - new CurrencyMetaData(lgoCurrency.getDecimals(), null)); - } - for (LgoProduct product : products.getProducts()) { - BigDecimal minAmount = product.getBase().getLimits().getMin(); - BigDecimal maxAmount = product.getBase().getLimits().getMax(); - Integer baseScale = currency.get(Currency.getInstance(product.getBase().getId())).getScale(); - BigDecimal increment = product.getQuote().getIncrement().stripTrailingZeros(); - currencyPairs.put( - toPair(product), - new InstrumentMetaData.Builder() - .minimumAmount(minAmount) - .maximumAmount(maxAmount) - .volumeScale(baseScale) - .priceScale(increment.scale()) - .amountStepSize(increment) - .feeTiers(new FeeTier[0]) - .tradingFeeCurrency(Currency.USD) - .marketOrderEnabled(true) - .build()); - } - return metaData; - } - - private static CurrencyPair toPair(LgoProduct product) { - return new CurrencyPair( - Currency.getInstance(product.getBase().getId()), - Currency.getInstance(product.getQuote().getId())); - } - - public static Stream adaptKeysIndex(String indexFile) { - String[] all = indexFile.split("(true|false)"); - Spliterator spliterator = - Spliterators.spliterator(all, Spliterator.IMMUTABLE | Spliterator.NONNULL); - return StreamSupport.stream(spliterator, true).map(LgoAdapters::parseSummary); - } - - private static LgoKey parseSummary(String rawSummary) { - String[] summary = rawSummary.split(" "); - return new LgoKey(summary[0], Instant.parse(summary[1]), Instant.parse(summary[2])); - } - - public static LgoPlaceOrder adaptLimitOrder(LimitOrder limitOrder) { - String product = adaptCurrencyPair(limitOrder.getCurrencyPair()); - String side = adaptOrderType(limitOrder.getType()); - return new LgoPlaceLimitOrder( - 0, - side, - product, - limitOrder.getOriginalAmount(), - limitOrder.getLimitPrice(), - limitOrder.getTimestamp().toInstant()); - } - - public static LgoPlaceOrder adaptEncryptedMarketOrder(MarketOrder marketOrder) { - String product = adaptCurrencyPair(marketOrder.getCurrencyPair()); - String side = adaptOrderType(marketOrder.getType()); - return new LgoPlaceMarketOrder( - 0, side, product, marketOrder.getOriginalAmount(), marketOrder.getTimestamp().toInstant()); - } - - public static LgoPlaceOrder adaptEncryptedCancelOrder(String orderId, Date date) { - return new LgoPlaceCancelOrder(0, orderId, date.toInstant()); - } - - public static LgoUnencryptedOrder adaptUnencryptedLimitOrder(LimitOrder limitOrder) { - String product = adaptCurrencyPair(limitOrder.getCurrencyPair()); - String side = adaptOrderType(limitOrder.getType()); - return new LgoUnencryptedOrder( - "L", - side, - product, - limitOrder.getOriginalAmount().toString(), - limitOrder.getLimitPrice().toString(), - limitOrder.getTimestamp().getTime()); - } - - public static LgoUnencryptedOrder adaptUnencryptedMarketOrder(MarketOrder marketOrder) { - String product = adaptCurrencyPair(marketOrder.getCurrencyPair()); - String side = adaptOrderType(marketOrder.getType()); - return new LgoUnencryptedOrder( - "M", - side, - product, - marketOrder.getOriginalAmount().toString(), - null, - marketOrder.getTimestamp().getTime()); - } - - private static String adaptOrderType(OrderType type) { - return type == OrderType.BID ? "B" : "S"; - } - - public static String adaptCurrencyPair(CurrencyPair currencyPair) { - return String.format( - "%s-%s", currencyPair.base.getCurrencyCode(), currencyPair.counter.getCurrencyCode()); - } - - private static UserTrade adaptUserTrade(LgoUserTrade lgoUserTrade) { - OrderType type = adaptUserTradeType(lgoUserTrade); - CurrencyPair currencyPair = adaptProductId(lgoUserTrade.getProductId()); - Date creationDate = lgoUserTrade.getCreationDate(); - return UserTrade.builder() - .type(type) - .originalAmount(lgoUserTrade.getQuantity()) - .currencyPair(currencyPair) - .price(lgoUserTrade.getPrice()) - .timestamp(creationDate) - .id(lgoUserTrade.getId()) - .orderId(lgoUserTrade.getOrderId()) - .feeAmount(lgoUserTrade.getFees()) - .feeCurrency(currencyPair.counter) - .build(); - } - - static CurrencyPair adaptProductId(String productId) { - String[] pair = productId.split("-"); - return new CurrencyPair(pair[0], pair[1]); - } - - static OrderType adaptUserTradeType(LgoUserTrade trade) { - boolean bidSide = buyerTaker(trade) || sellerMaker(trade); - return bidSide ? OrderType.BID : OrderType.ASK; - } - - private static boolean sellerMaker(LgoUserTrade trade) { - return trade.getSide().equals("S") && trade.getLiquidity().equals("M"); - } - - private static boolean buyerTaker(LgoUserTrade trade) { - return trade.getSide().equals("B") && trade.getLiquidity().equals("T"); - } - - public static UserTrades adaptUserTrades(WithCursor lastTrades) { - List trades = - lastTrades.getResult().getTrades().stream() - .map(LgoAdapters::adaptUserTrade) - .collect(Collectors.toList()); - return new UserTrades(trades, 0L, Trades.TradeSortType.SortByID, lastTrades.getNextPage()); - } - - public static OrderBook adaptOrderBook(LgoOrderbook ob, CurrencyPair pair) { - List bids = - ob.getBids().stream() - .map(e -> adaptEntryToLimitOrder(e, OrderType.BID, pair)) - .collect(Collectors.toList()); - List asks = - ob.getAsks().stream() - .map(e -> adaptEntryToLimitOrder(e, OrderType.ASK, pair)) - .collect(Collectors.toList()); - - return new OrderBook(null, asks, bids, true); - } - - public static LimitOrder adaptEntryToLimitOrder( - Object[] entry, OrderType bid, CurrencyPair pair) { - return new LimitOrder( - bid, - new BigDecimal(entry[1].toString()), - pair, - null, - null, - new BigDecimal(entry[0].toString())); - } - - public static String adaptDateParam(Date date) { - return ISO_DATE_FORMAT.format(date); - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoEnv.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoEnv.java deleted file mode 100644 index cd2a1c97ae3..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoEnv.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.knowm.xchange.lgo; - -import org.knowm.xchange.ExchangeSpecification; - -public final class LgoEnv { - - public static final String KEYS_URL = "Keys_Url"; - public static final String WS_URL = "Websocket_Url"; - public static final String SIGNATURE_SERVICE = "Signature_Service"; - public static final String SHOULD_ENCRYPT_ORDERS = "Encrypt_Orders"; - - private LgoEnv() {} - - public static ExchangeSpecification prod() { - ExchangeSpecification result = baseSpecification(); - result.setSslUri("https://exchange-api.exchange.lgo.markets"); - result.setHost("exchange-api.exchange.lgo.markets"); - result.setExchangeSpecificParametersItem( - KEYS_URL, "https://storage.googleapis.com/lgo-markets-keys"); - result.setExchangeSpecificParametersItem(WS_URL, "wss://ws.exchange.lgo.markets/"); - return result; - } - - public static ExchangeSpecification sandbox() { - ExchangeSpecification result = baseSpecification(); - result.setSslUri("https://exchange-api.sandbox.lgo.markets"); - result.setHost("exchange-api.sandbox.lgo.markets"); - result.setExchangeSpecificParametersItem( - KEYS_URL, "https://storage.googleapis.com/lgo-sandbox_batch_keys"); - result.setExchangeSpecificParametersItem(WS_URL, "wss://ws.sandbox.lgo.markets/"); - return result; - } - - public static ExchangeSpecification devel() { - ExchangeSpecification result = baseSpecification(); - result.setSslUri("https://exchange-api.devel.z.lgo.ninja"); - result.setHost("exchange-api.devel.z.lgo.ninja"); - result.setExchangeSpecificParametersItem( - KEYS_URL, "https://storage.googleapis.com/lgo-devel_batch_keys"); - result.setExchangeSpecificParametersItem(WS_URL, "wss://ws.devel.z.lgo.ninja/"); - return result; - } - - public static ExchangeSpecification local() { - ExchangeSpecification result = baseSpecification(); - result.setSslUri("http://localhost:8083"); - result.setHost("localhost"); - result.setExchangeSpecificParametersItem(KEYS_URL, "http://localhost:3001/keys"); - result.setExchangeSpecificParametersItem(WS_URL, "ws://localhost:8084/"); - return result; - } - - private static ExchangeSpecification baseSpecification() { - ExchangeSpecification result = new ExchangeSpecification(LgoExchange.class); - result.setExchangeName("LGO"); - result.setExchangeSpecificParametersItem(SHOULD_ENCRYPT_ORDERS, false); - result.setExchangeDescription( - "LGO is a fare and secure exchange for institutional and retail investors."); - return result; - } - - public enum SignatureService { - PASSTHROUGHS, - LOCAL_RSA - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoErrorAdapter.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoErrorAdapter.java deleted file mode 100644 index f0da1ad1be8..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoErrorAdapter.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.knowm.xchange.lgo; - -import org.apache.commons.lang3.StringUtils; -import org.knowm.xchange.exceptions.ExchangeException; -import org.knowm.xchange.exceptions.ExchangeSecurityException; -import org.knowm.xchange.exceptions.FrequencyLimitExceededException; -import org.knowm.xchange.exceptions.InternalServerException; -import org.knowm.xchange.lgo.dto.LgoException; - -public class LgoErrorAdapter { - - private LgoErrorAdapter() {} - - public static ExchangeException adapt(LgoException exception) { - String message = exception.getMessage(); - if (StringUtils.isEmpty(message)) { - message = "Operation failed without any error message"; - } - switch (exception.getHttpStatusCode()) { - case 401: - return new ExchangeSecurityException(message, exception); - case 429: - return new FrequencyLimitExceededException(message); - case 500: - return new InternalServerException(message, exception); - } - return new ExchangeException(message, exception); - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoExchange.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoExchange.java deleted file mode 100644 index 422829b5849..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/LgoExchange.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.knowm.xchange.lgo; - -import java.io.IOException; -import org.knowm.xchange.BaseExchange; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.lgo.dto.LgoException; -import org.knowm.xchange.lgo.dto.currency.LgoCurrencies; -import org.knowm.xchange.lgo.dto.product.LgoProducts; -import org.knowm.xchange.lgo.service.LgoKeyService; -import org.knowm.xchange.lgo.service.LgoMarketDataService; -import org.knowm.xchange.lgo.service.LgoSignatureService; -import org.knowm.xchange.lgo.service.LgoTradeService; -import org.knowm.xchange.service.account.AccountService; - -public class LgoExchange extends BaseExchange { - - private LgoSignatureService signatureService; - private LgoProducts products; - private LgoCurrencies currencies; - - @Override - protected void initServices() { - signatureService = LgoSignatureService.createInstance(getExchangeSpecification()); - this.marketDataService = new LgoMarketDataService(this); - this.tradeService = new LgoTradeService(this, new LgoKeyService(getExchangeSpecification())); - this.accountService = new AccountService() {}; - } - - @Override - public void remoteInit() throws IOException { - try { - products = getMarketDataService().getProducts(); - currencies = getMarketDataService().getCurrencies(); - } catch (LgoException e) { - throw LgoErrorAdapter.adapt(e); - } - LgoAdapters.adaptMetadata(getExchangeMetaData(), products, currencies); - } - - @Override - public ExchangeSpecification getDefaultExchangeSpecification() { - return LgoEnv.prod(); - } - - @Override - public LgoMarketDataService getMarketDataService() { - return (LgoMarketDataService) marketDataService; - } - - @Override - public LgoTradeService getTradeService() { - return (LgoTradeService) super.getTradeService(); - } - - public LgoProducts getProducts() { - return products; - } - - public LgoCurrencies getCurrencies() { - return currencies; - } - - public LgoSignatureService getSignatureService() { - return signatureService; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/LgoException.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/LgoException.java deleted file mode 100644 index f7d7e149bb9..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/LgoException.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.knowm.xchange.lgo.dto; - -import si.mazi.rescu.HttpStatusExceptionSupport; - -public class LgoException extends HttpStatusExceptionSupport {} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/WithCursor.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/WithCursor.java deleted file mode 100644 index 78be28bf253..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/WithCursor.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.knowm.xchange.lgo.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class WithCursor { - - private final T result; - private final String nextPage; - - public WithCursor(@JsonProperty("result") T result, @JsonProperty("next_page") String nextPage) { - this.result = result; - this.nextPage = nextPage; - } - - public T getResult() { - return result; - } - - public String getNextPage() { - return nextPage; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/currency/LgoCurrencies.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/currency/LgoCurrencies.java deleted file mode 100644 index d39b987d084..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/currency/LgoCurrencies.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.knowm.xchange.lgo.dto.currency; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public final class LgoCurrencies { - - private final List currencies; - - public LgoCurrencies(@JsonProperty("currencies") List currencies) { - this.currencies = currencies; - } - - public List getCurrencies() { - return currencies; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/currency/LgoCurrency.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/currency/LgoCurrency.java deleted file mode 100644 index 4e5a49e3b42..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/currency/LgoCurrency.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.knowm.xchange.lgo.dto.currency; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class LgoCurrency { - - private final String name; - private final String code; - private final int decimals; - - public LgoCurrency( - @JsonProperty("name") String name, - @JsonProperty("code") String code, - @JsonProperty("decimals") int decimals) { - this.name = name; - this.code = code; - this.decimals = decimals; - } - - public String getName() { - return name; - } - - public String getCode() { - return code; - } - - public int getDecimals() { - return decimals; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/key/LgoKey.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/key/LgoKey.java deleted file mode 100644 index dbccc8560c4..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/key/LgoKey.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.knowm.xchange.lgo.dto.key; - -import java.time.Instant; - -public final class LgoKey { - - private final String id; - private final Instant issuedAt; - private final Instant disabledAt; - private String value; - - public LgoKey(String id, Instant issuedAt, Instant disabledAt) { - this.id = id; - this.issuedAt = issuedAt; - this.disabledAt = disabledAt; - } - - public String getId() { - return id; - } - - public Instant getEnabledAt() { - return issuedAt; - } - - public Instant getDisabledAt() { - return disabledAt; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoCandlestick.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoCandlestick.java deleted file mode 100644 index e1d8c898f46..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoCandlestick.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.knowm.xchange.lgo.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import java.util.Date; - -@JsonFormat(shape = JsonFormat.Shape.ARRAY) -public class LgoCandlestick { - - private final Date time; - private final BigDecimal open; - private final BigDecimal high; - private final BigDecimal low; - private final BigDecimal close; - private final BigDecimal volume; - - @JsonCreator - public LgoCandlestick( - @JsonProperty("time") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'") - Date time, - @JsonProperty("low") BigDecimal low, - @JsonProperty("high") BigDecimal high, - @JsonProperty("open") BigDecimal open, - @JsonProperty("close") BigDecimal close, - @JsonProperty("volume") BigDecimal volume) { - this.time = time; - this.open = open; - this.close = close; - this.high = high; - this.low = low; - this.volume = volume; - } - - public Date getTime() { - return time; - } - - public BigDecimal getOpen() { - return open; - } - - public BigDecimal getHigh() { - return high; - } - - public BigDecimal getLow() { - return low; - } - - public BigDecimal getClose() { - return close; - } - - public BigDecimal getVolume() { - return volume; - } - - @Override - public String toString() { - return "LgoCandlestick{" - + "time=" - + time - + ", open=" - + open - + ", high=" - + high - + ", low=" - + low - + ", close=" - + close - + ", volume=" - + volume - + '}'; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoGranularity.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoGranularity.java deleted file mode 100644 index 19a969b2f3a..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoGranularity.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.knowm.xchange.lgo.dto.marketdata; - -public enum LgoGranularity { - ONE_MINUTE(60), - FIVE_MINUTES(300), - FIFTEEN_MINUTES(900), - ONE_HOUR(3600), - SIX_HOURS(21600), - ONE_DAY(86400); - - private final int seconds; - - LgoGranularity(int seconds) { - this.seconds = seconds; - } - - public int asSeconds() { - return seconds; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoOrderbook.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoOrderbook.java deleted file mode 100644 index 27413e66b16..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoOrderbook.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.knowm.xchange.lgo.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -@JsonIgnoreProperties(ignoreUnknown = true) -public final class LgoOrderbook { - - private final long lastBatchId; - private final List bids; - private final List asks; - - public LgoOrderbook( - @JsonProperty("batch_id") long lastBatchId, - @JsonProperty("bids") List bids, - @JsonProperty("asks") List asks) { - this.lastBatchId = lastBatchId; - this.bids = bids; - this.asks = asks; - } - - public long getLastBatchId() { - return lastBatchId; - } - - public List getBids() { - return bids; - } - - public List getAsks() { - return asks; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoPriceHistory.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoPriceHistory.java deleted file mode 100644 index fbeb04a0c60..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/marketdata/LgoPriceHistory.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.knowm.xchange.lgo.dto.marketdata; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class LgoPriceHistory { - - private final List prices; - - public LgoPriceHistory(@JsonProperty("prices") List prices) { - this.prices = prices; - } - - public List getPrices() { - return prices; - } - - @Override - public String toString() { - return "LgoPriceHistory{" + "prices=" + prices + '}'; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoEncryptedOrder.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoEncryptedOrder.java deleted file mode 100644 index 7b7eec44b00..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoEncryptedOrder.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.knowm.xchange.lgo.dto.order; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; - -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -public class LgoEncryptedOrder { - - private final String keyId; - private final String order; - private final LgoOrderSignature signature; - private final long reference; - - public LgoEncryptedOrder( - String keyId, String order, LgoOrderSignature signature, long reference) { - this.keyId = keyId; - this.order = order; - this.signature = signature; - this.reference = reference; - } - - public String getKeyId() { - return keyId; - } - - public String getOrder() { - return order; - } - - public LgoOrderSignature getSignature() { - return signature; - } - - public long getReference() { - return reference; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoOrderSignature.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoOrderSignature.java deleted file mode 100644 index 5c1a7706276..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoOrderSignature.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.knowm.xchange.lgo.dto.order; - -public class LgoOrderSignature { - - private final String value; - private final String source = "RSA"; - - public LgoOrderSignature(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - public String getSource() { - return source; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceCancelOrder.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceCancelOrder.java deleted file mode 100644 index bf06b872d50..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceCancelOrder.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.knowm.xchange.lgo.dto.order; - -import java.time.Instant; -import java.util.StringJoiner; - -public class LgoPlaceCancelOrder extends LgoPlaceOrder { - - private final String orderId; - - public LgoPlaceCancelOrder(long reference, String orderId, Instant timestamp) { - super(reference, timestamp); - this.orderId = orderId; - } - - public String toPayload() { - return new StringJoiner(",") - .add("C") - .add(orderId) - .add(String.valueOf(getTimestamp().toEpochMilli())) - .toString(); - } - - public String getOrderId() { - return orderId; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceLimitOrder.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceLimitOrder.java deleted file mode 100644 index eada2568ee4..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceLimitOrder.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.knowm.xchange.lgo.dto.order; - -import java.math.BigDecimal; -import java.time.Instant; -import java.util.StringJoiner; - -public class LgoPlaceLimitOrder extends LgoPlaceOrder { - - private final String side; - private final String productId; - private final BigDecimal quantity; - private final BigDecimal price; - - public LgoPlaceLimitOrder( - long reference, - String side, - String productId, - BigDecimal quantity, - BigDecimal price, - Instant timestamp) { - super(reference, timestamp); - this.side = side; - this.productId = productId; - this.quantity = quantity; - this.price = price; - } - - public String toPayload() { - return new StringJoiner(",") - .add("L") - .add(side) - .add(productId) - .add(quantity.toPlainString()) - .add(price == null ? "" : price.toPlainString()) - .add("gtc") - .add(String.valueOf(getTimestamp().toEpochMilli())) - .toString(); - } - - public String getSide() { - return side; - } - - public String getProductId() { - return productId; - } - - public BigDecimal getQuantity() { - return quantity; - } - - public BigDecimal getPrice() { - return price; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceMarketOrder.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceMarketOrder.java deleted file mode 100644 index dd0c625f86e..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceMarketOrder.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.knowm.xchange.lgo.dto.order; - -import java.math.BigDecimal; -import java.time.Instant; -import java.util.StringJoiner; - -public class LgoPlaceMarketOrder extends LgoPlaceOrder { - - private final String side; - private final String productId; - private final BigDecimal quantity; - - public LgoPlaceMarketOrder( - long reference, String side, String productId, BigDecimal quantity, Instant timestamp) { - super(reference, timestamp); - this.side = side; - this.productId = productId; - this.quantity = quantity; - } - - public String toPayload() { - return new StringJoiner(",") - .add("M") - .add(side) - .add(productId) - .add(quantity.toPlainString()) - .add("") - .add("") - .add(String.valueOf(getTimestamp().toEpochMilli())) - .toString(); - } - - public String getSide() { - return side; - } - - public String getProductId() { - return productId; - } - - public BigDecimal getQuantity() { - return quantity; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceOrder.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceOrder.java deleted file mode 100644 index c863cfabbc5..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceOrder.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.knowm.xchange.lgo.dto.order; - -import java.time.Instant; - -public abstract class LgoPlaceOrder { - - private final long reference; - private final Instant timestamp; - - public LgoPlaceOrder(long reference, Instant timestamp) { - this.reference = reference; - this.timestamp = timestamp; - } - - public abstract String toPayload(); - - public long getReference() { - return reference; - } - - public Instant getTimestamp() { - return timestamp; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceOrderResponse.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceOrderResponse.java deleted file mode 100644 index 43893b83186..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoPlaceOrderResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.knowm.xchange.lgo.dto.order; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class LgoPlaceOrderResponse { - - public final String orderId; - - public LgoPlaceOrderResponse(@JsonProperty("order_id") String orderId) { - this.orderId = orderId; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoUnencryptedOrder.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoUnencryptedOrder.java deleted file mode 100644 index 4486c551eaf..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/order/LgoUnencryptedOrder.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.knowm.xchange.lgo.dto.order; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; - -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -public class LgoUnencryptedOrder { - - public final String type; - public final String side; - public final String productId; - public final String quantity; - public final String price; - public final long timestamp; - - public LgoUnencryptedOrder( - String type, String side, String productId, String quantity, String price, long timestamp) { - this.type = type; - this.side = side; - this.productId = productId; - this.quantity = quantity; - this.price = price; - this.timestamp = timestamp; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoLimit.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoLimit.java deleted file mode 100644 index 12e77caeba1..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoLimit.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.knowm.xchange.lgo.dto.product; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; - -public final class LgoLimit { - - private final BigDecimal min; - private final BigDecimal max; - - public LgoLimit(@JsonProperty("min") BigDecimal min, @JsonProperty("max") BigDecimal max) { - this.min = min; - this.max = max; - } - - public BigDecimal getMin() { - return min; - } - - public BigDecimal getMax() { - return max; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProduct.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProduct.java deleted file mode 100644 index 94b3f53371e..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProduct.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.knowm.xchange.lgo.dto.product; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public final class LgoProduct { - - private final String id; - private final LgoProductTotal total; - private final LgoProductCurrency base; - private final LgoProductCurrency quote; - - public LgoProduct( - @JsonProperty("id") String id, - @JsonProperty("total") LgoProductTotal total, - @JsonProperty("base") LgoProductCurrency base, - @JsonProperty("quote") LgoProductCurrency quote) { - this.id = id; - this.total = total; - this.base = base; - this.quote = quote; - } - - public String getId() { - return id; - } - - public LgoProductCurrency getBase() { - return base; - } - - public LgoProductCurrency getQuote() { - return quote; - } - - public LgoProductTotal getTotal() { - return total; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProductCurrency.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProductCurrency.java deleted file mode 100644 index ebf64693ca8..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProductCurrency.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.knowm.xchange.lgo.dto.product; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; - -public final class LgoProductCurrency { - - private final String id; - private final BigDecimal increment; - private final LgoLimit limits; - - public LgoProductCurrency( - @JsonProperty("id") String id, - @JsonProperty("increment") BigDecimal increment, - @JsonProperty("limits") LgoLimit limits) { - this.id = id; - this.increment = increment; - this.limits = limits; - } - - public String getId() { - return id; - } - - public BigDecimal getIncrement() { - return increment; - } - - public LgoLimit getLimits() { - return limits; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProductTotal.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProductTotal.java deleted file mode 100644 index 623cb8e4248..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProductTotal.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.knowm.xchange.lgo.dto.product; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public final class LgoProductTotal { - - private final LgoLimit limits; - - public LgoProductTotal(@JsonProperty("limits") LgoLimit limits) { - this.limits = limits; - } - - public LgoLimit getLimits() { - return limits; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProducts.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProducts.java deleted file mode 100644 index 086a29cbe08..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/product/LgoProducts.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.knowm.xchange.lgo.dto.product; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Collections; -import java.util.List; - -public final class LgoProducts { - - private final List products; - - public LgoProducts(@JsonProperty("products") List products) { - this.products = Collections.unmodifiableList(products); - } - - public List getProducts() { - return products; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/trade/LgoUserTrade.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/trade/LgoUserTrade.java deleted file mode 100644 index 6b137a4e4ae..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/trade/LgoUserTrade.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.knowm.xchange.lgo.dto.trade; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import java.util.Date; - -public class LgoUserTrade { - - private final String id; - private final String orderId; - private final String productId; - private final BigDecimal price; - private final BigDecimal quantity; - private final Date creationDate; - private final BigDecimal fees; - private final String side; - private final String liquidity; - - public LgoUserTrade( - @JsonProperty("id") String id, - @JsonProperty("order_id") String orderId, - @JsonProperty("product_id") String productId, - @JsonProperty("price") BigDecimal price, - @JsonProperty("quantity") BigDecimal quantity, - @JsonProperty("creation_date") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - Date creationDate, - @JsonProperty("fees") BigDecimal fees, - @JsonProperty("side") String side, - @JsonProperty("liquidity") String liquidity) { - this.id = id; - this.orderId = orderId; - this.productId = productId; - this.price = price; - this.quantity = quantity; - this.creationDate = creationDate; - this.fees = fees; - this.side = side; - this.liquidity = liquidity; - } - - public String getId() { - return id; - } - - public String getOrderId() { - return orderId; - } - - public String getProductId() { - return productId; - } - - public BigDecimal getPrice() { - return price; - } - - public BigDecimal getQuantity() { - return quantity; - } - - public Date getCreationDate() { - return creationDate; - } - - public BigDecimal getFees() { - return fees; - } - - public String getSide() { - return side; - } - - public String getLiquidity() { - return liquidity; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/trade/LgoUserTrades.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/trade/LgoUserTrades.java deleted file mode 100644 index ccccad37b74..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/dto/trade/LgoUserTrades.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.knowm.xchange.lgo.dto.trade; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class LgoUserTrades { - - private final List trades; - - public LgoUserTrades(@JsonProperty("trades") List trades) { - this.trades = trades; - } - - public List getTrades() { - return trades; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/CryptoUtils.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/CryptoUtils.java deleted file mode 100644 index e00ca5ef3da..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/CryptoUtils.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import java.nio.charset.StandardCharsets; -import java.security.InvalidKeyException; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; -import java.security.interfaces.RSAPublicKey; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.X509EncodedKeySpec; -import java.util.Base64; -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import org.knowm.xchange.exceptions.ExchangeException; -import org.knowm.xchange.lgo.dto.key.LgoKey; -import org.knowm.xchange.lgo.dto.order.LgoPlaceOrder; - -public final class CryptoUtils { - - private CryptoUtils() {} - - public static String encryptOrder(LgoKey lgoKey, LgoPlaceOrder lgoPlaceOrder) { - try { - String pub = lgoKey.getValue(); - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); - byte[] keyBytes = Base64.getDecoder().decode(pub.getBytes(StandardCharsets.UTF_8)); - X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes); - RSAPublicKey publicKey = (RSAPublicKey) keyFactory.generatePublic(spec); - - Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding"); - cipher.init(Cipher.ENCRYPT_MODE, publicKey); - byte[] cipherData = - cipher.doFinal(lgoPlaceOrder.toPayload().getBytes(StandardCharsets.UTF_8)); - return Base64.getEncoder().encodeToString(cipherData); - } catch (NoSuchAlgorithmException e) { - throw new ExchangeException("Error encrypting order: algorithm instance not available", e); - } catch (NoSuchPaddingException e) { - throw new ExchangeException("Error encrypting order: padding instance not available", e); - } catch (IllegalBlockSizeException - | BadPaddingException - | InvalidKeySpecException - | InvalidKeyException e) { - throw new ExchangeException("Error encrypting order: provided data invalid", e); - } - } - - static String parsePrivateKey(String key) { - return key.replaceAll("-----END PRIVATE KEY-----", "") - .replaceAll("-----BEGIN PRIVATE KEY-----", "") - .replaceAll("\n", ""); - } - - static String parsePublicKey(String key) { - return key.replaceAll("-----END PUBLIC KEY-----", "") - .replaceAll("-----BEGIN PUBLIC KEY-----", "") - .replaceAll("\n", ""); - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoBaseService.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoBaseService.java deleted file mode 100644 index 8ac7b962e67..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoBaseService.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import org.knowm.xchange.client.ExchangeRestProxyBuilder; -import org.knowm.xchange.lgo.Lgo; -import org.knowm.xchange.lgo.LgoExchange; -import org.knowm.xchange.service.BaseExchangeService; -import org.knowm.xchange.service.BaseService; - -public class LgoBaseService extends BaseExchangeService implements BaseService { - - protected final Lgo proxy; - - protected LgoBaseService(LgoExchange exchange) { - super(exchange); - proxy = - ExchangeRestProxyBuilder.forInterface(Lgo.class, exchange.getExchangeSpecification()) - .build(); - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoKeyService.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoKeyService.java deleted file mode 100644 index 6c66dcbd6b3..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoKeyService.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.Comparator; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.client.ExchangeRestProxyBuilder; -import org.knowm.xchange.exceptions.ExchangeException; -import org.knowm.xchange.lgo.CertificateAuthority; -import org.knowm.xchange.lgo.LgoAdapters; -import org.knowm.xchange.lgo.LgoEnv; -import org.knowm.xchange.lgo.dto.key.LgoKey; - -public class LgoKeyService { - - private final CertificateAuthority proxy; - private LgoKey currentKey; - - public LgoKeyService(ExchangeSpecification exchangeSpecification) { - final String baseUrl = - exchangeSpecification.getExchangeSpecificParametersItem(LgoEnv.KEYS_URL).toString(); - proxy = - ExchangeRestProxyBuilder.forInterface(CertificateAuthority.class, exchangeSpecification) - .baseUrl(baseUrl) - .build(); - } - - public LgoKey selectKey() { - if (mustFetchNewKey()) { - fetchKey(); - } - return currentKey; - } - - private boolean mustFetchNewKey() { - return currentKey == null - || Instant.now().minus(10, ChronoUnit.MINUTES).isAfter(currentKey.getDisabledAt()); - } - - private void fetchKey() { - currentKey = - LgoAdapters.adaptKeysIndex(proxy.fetchIndex()) - .filter( - k -> { - Instant now = Instant.now(); - return now.isBefore(k.getDisabledAt()) && now.isAfter(k.getEnabledAt()); - }) - .max(Comparator.comparing(LgoKey::getDisabledAt)) - .orElseThrow(() -> new ExchangeException("Can't find a proper key")); - String value = proxy.fetchKey(currentKey.getId()); - currentKey.setValue(CryptoUtils.parsePublicKey(value)); - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoMarketDataService.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoMarketDataService.java deleted file mode 100644 index a058222f240..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoMarketDataService.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import java.io.IOException; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.marketdata.OrderBook; -import org.knowm.xchange.lgo.LgoAdapters; -import org.knowm.xchange.lgo.LgoErrorAdapter; -import org.knowm.xchange.lgo.LgoExchange; -import org.knowm.xchange.lgo.dto.LgoException; -import org.knowm.xchange.lgo.dto.marketdata.LgoOrderbook; -import org.knowm.xchange.service.marketdata.MarketDataService; - -public class LgoMarketDataService extends LgoMarketDataServiceRaw implements MarketDataService { - - public LgoMarketDataService(LgoExchange exchange) { - super(exchange); - } - - @Override - public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException { - try { - LgoOrderbook orderBook = super.getLgoOrderBook(currencyPair); - return LgoAdapters.adaptOrderBook(orderBook, currencyPair); - } catch (LgoException e) { - throw LgoErrorAdapter.adapt(e); - } - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoMarketDataServiceRaw.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoMarketDataServiceRaw.java deleted file mode 100644 index 9b9c8809841..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoMarketDataServiceRaw.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import java.io.IOException; -import java.util.Date; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.lgo.LgoAdapters; -import org.knowm.xchange.lgo.LgoExchange; -import org.knowm.xchange.lgo.dto.currency.LgoCurrencies; -import org.knowm.xchange.lgo.dto.marketdata.LgoGranularity; -import org.knowm.xchange.lgo.dto.marketdata.LgoOrderbook; -import org.knowm.xchange.lgo.dto.marketdata.LgoPriceHistory; -import org.knowm.xchange.lgo.dto.product.LgoProducts; - -public class LgoMarketDataServiceRaw extends LgoBaseService { - - public LgoMarketDataServiceRaw(LgoExchange exchange) { - super(exchange); - } - - public LgoProducts getProducts() throws IOException { - return this.proxy.getProducts( - exchange.getNonceFactory().createValue(), exchange.getSignatureService()); - } - - public LgoCurrencies getCurrencies() throws IOException { - return this.proxy.getCurrencies( - exchange.getNonceFactory().createValue(), exchange.getSignatureService()); - } - - public LgoOrderbook getLgoOrderBook(CurrencyPair product) throws IOException { - return this.proxy.getOrderBook( - exchange.getNonceFactory().createValue(), - exchange.getSignatureService(), - LgoAdapters.adaptCurrencyPair(product)); - } - - /** - * Price history (candlestick bars) for a pair and a period of time.
- * All parameters are required. - * - * @return the price history, null if some sort of error occurred. Implementers should log the - * error. - */ - public LgoPriceHistory getLgoPriceHistory( - CurrencyPair product, Date startTime, Date endTime, LgoGranularity granularity) - throws IOException { - return this.proxy.getPriceHistory( - exchange.getNonceFactory().createValue(), - exchange.getSignatureService(), - LgoAdapters.adaptCurrencyPair(product), - LgoAdapters.adaptDateParam(startTime), - LgoAdapters.adaptDateParam(endTime), - granularity.asSeconds()); - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoSignatureService.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoSignatureService.java deleted file mode 100644 index e8fb1bd1b78..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoSignatureService.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.exceptions.ExchangeException; -import org.knowm.xchange.lgo.Lgo; -import org.knowm.xchange.lgo.LgoEnv; -import org.knowm.xchange.lgo.LgoEnv.SignatureService; -import org.knowm.xchange.lgo.dto.order.LgoOrderSignature; -import si.mazi.rescu.HttpMethod; -import si.mazi.rescu.ParamsDigest; -import si.mazi.rescu.RestInvocation; - -public interface LgoSignatureService extends ParamsDigest { - - static LgoSignatureService createInstance(ExchangeSpecification specification) { - LgoEnv.SignatureService implementation = - (SignatureService) - specification - .getExchangeSpecificParameters() - .getOrDefault(LgoEnv.SIGNATURE_SERVICE, SignatureService.LOCAL_RSA); - switch (implementation) { - case LOCAL_RSA: - return new LgoSignatureServiceLocalRsa( - specification.getApiKey(), specification.getSecretKey()); - case PASSTHROUGHS: - return new LgoSignatureServicePassthroughs( - specification.getUserName(), specification.getApiKey(), specification.getSecretKey()); - default: - throw new ExchangeException("Unknown signature service implementation " + implementation); - } - } - - @Override - default String digestParams(RestInvocation restInvocation) { - String rawUrl = restInvocation.getInvocationUrl(); - String timestamp = restInvocation.getHttpHeadersFromParams().getOrDefault(Lgo.X_LGO_DATE, ""); - if (needsBodySignature(restInvocation)) { - return digestSignedUrlAndBodyHeader(rawUrl, timestamp, restInvocation.getRequestBody()); - } - return digestSignedUrlHeader(rawUrl, timestamp); - } - - default boolean needsBodySignature(RestInvocation restInvocation) { - return restInvocation.getPath().equals("/v1/live/orders") - && restInvocation.getHttpMethod().equals(HttpMethod.POST.name()); - } - - String digestSignedUrlHeader(String urlToSign, String timestamp); - - String digestSignedUrlAndBodyHeader(String urlToSign, String timestamp, String body); - - LgoOrderSignature signOrder(String encryptedOrder); -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoSignatureServiceLocalRsa.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoSignatureServiceLocalRsa.java deleted file mode 100644 index 1602d00a68e..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoSignatureServiceLocalRsa.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import java.nio.charset.StandardCharsets; -import java.security.KeyFactory; -import java.security.Signature; -import java.security.spec.PKCS8EncodedKeySpec; -import java.util.Base64; -import lombok.NonNull; -import org.knowm.xchange.lgo.dto.order.LgoOrderSignature; - -public class LgoSignatureServiceLocalRsa implements LgoSignatureService { - - private final String apiKey; - private final String privKey; - - LgoSignatureServiceLocalRsa(@NonNull String apiKey, @NonNull String privKey) { - this.apiKey = apiKey; - this.privKey = CryptoUtils.parsePrivateKey(privKey); - } - - private static String byteArrayToHex(byte[] a) { - StringBuilder sb = new StringBuilder(a.length * 2); - for (byte b : a) { - sb.append(String.format("%02x", b)); - } - return sb.toString(); - } - - @Override - public String digestSignedUrlAndBodyHeader(String url, String timestamp, String body) { - try { - String urlToSign = removeProtocol(url); - String signatureBaseString = String.format("%s\n%s\n%s", timestamp, urlToSign, body); - return buildHeader(signSHA256RSA(signatureBaseString)); - } catch (Exception e) { - throw new RuntimeException("Error signing request", e); - } - } - - @Override - public String digestSignedUrlHeader(String url, String timestamp) { - try { - String urlToSign = removeProtocol(url); - String signatureBaseString = String.format("%s\n%s", timestamp, urlToSign); - return buildHeader(signSHA256RSA(signatureBaseString)); - } catch (Exception e) { - throw new RuntimeException("Error signing request", e); - } - } - - private String buildHeader(String signed) { - return String.format("LGO %s:%s", apiKey, signed); - } - - private String removeProtocol(String urlToSign) { - return urlToSign - .replace("http://", "") - .replace("https://", "") - .replace("wss://", "") - .replace("ws://", ""); - } - - @Override - public LgoOrderSignature signOrder(String encryptedOrder) { - try { - return new LgoOrderSignature(signSHA256RSA(encryptedOrder)); - } catch (Exception e) { - throw new RuntimeException("Error signing order", e); - } - } - - private String signSHA256RSA(String input) throws Exception { - byte[] b1 = Base64.getDecoder().decode(privKey); - PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(b1); - KeyFactory kf = KeyFactory.getInstance("RSA"); - Signature privateSignature = Signature.getInstance("SHA256withRSA"); - privateSignature.initSign(kf.generatePrivate(spec)); - privateSignature.update(input.getBytes(StandardCharsets.UTF_8)); - return byteArrayToHex(privateSignature.sign()); - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoSignatureServicePassthroughs.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoSignatureServicePassthroughs.java deleted file mode 100644 index b27f2986743..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoSignatureServicePassthroughs.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import java.nio.charset.StandardCharsets; -import java.util.Base64; -import java.util.StringJoiner; -import org.knowm.xchange.lgo.dto.order.LgoOrderSignature; - -public class LgoSignatureServicePassthroughs implements LgoSignatureService { - - private final String value; - - public LgoSignatureServicePassthroughs(String userName, String apiKey, String secretKey) { - String concat = new StringJoiner(":").add(userName).add(apiKey).add(secretKey).toString(); - value = Base64.getEncoder().encodeToString(concat.getBytes(StandardCharsets.UTF_8)); - } - - @Override - public String digestSignedUrlHeader(String urlToSign, String timestamp) { - return value; - } - - @Override - public String digestSignedUrlAndBodyHeader(String urlToSign, String timestamp, String body) { - return value; - } - - @Override - public LgoOrderSignature signOrder(String encryptedOrder) { - return new LgoOrderSignature(value); - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoTradeHistoryParams.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoTradeHistoryParams.java deleted file mode 100644 index 1481856a99d..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoTradeHistoryParams.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair; -import org.knowm.xchange.service.trade.params.TradeHistoryParamLimit; -import org.knowm.xchange.service.trade.params.TradeHistoryParamNextPageCursor; -import org.knowm.xchange.service.trade.params.TradeHistoryParams; -import org.knowm.xchange.service.trade.params.TradeHistoryParamsSorted; - -public class LgoTradeHistoryParams - implements TradeHistoryParams, - TradeHistoryParamCurrencyPair, - TradeHistoryParamLimit, - TradeHistoryParamNextPageCursor, - TradeHistoryParamsSorted { - - private CurrencyPair currencyPair = CurrencyPair.BTC_USD; - private Integer limit = 100; - private String pageCursor = null; - private Order order = Order.desc; - - @Override - public CurrencyPair getCurrencyPair() { - return currencyPair; - } - - @Override - public void setCurrencyPair(CurrencyPair pair) { - this.currencyPair = pair; - } - - @Override - public Integer getLimit() { - return limit; - } - - @Override - public void setLimit(Integer limit) { - this.limit = limit; - } - - @Override - public String getNextPageCursor() { - return pageCursor; - } - - @Override - public void setNextPageCursor(String cursor) { - this.pageCursor = cursor; - } - - @Override - public Order getOrder() { - return order; - } - - @Override - public void setOrder(Order order) { - this.order = order; - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoTradeService.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoTradeService.java deleted file mode 100644 index 9e55171c696..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoTradeService.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.Date; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order.OrderType; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.MarketOrder; -import org.knowm.xchange.dto.trade.UserTrades; -import org.knowm.xchange.lgo.LgoAdapters; -import org.knowm.xchange.lgo.LgoEnv; -import org.knowm.xchange.lgo.LgoErrorAdapter; -import org.knowm.xchange.lgo.LgoExchange; -import org.knowm.xchange.lgo.dto.LgoException; -import org.knowm.xchange.lgo.dto.WithCursor; -import org.knowm.xchange.lgo.dto.key.LgoKey; -import org.knowm.xchange.lgo.dto.order.LgoEncryptedOrder; -import org.knowm.xchange.lgo.dto.order.LgoOrderSignature; -import org.knowm.xchange.lgo.dto.order.LgoPlaceOrder; -import org.knowm.xchange.lgo.dto.order.LgoUnencryptedOrder; -import org.knowm.xchange.lgo.dto.product.LgoProduct; -import org.knowm.xchange.lgo.dto.product.LgoProductCurrency; -import org.knowm.xchange.lgo.dto.trade.LgoUserTrades; -import org.knowm.xchange.service.trade.TradeService; -import org.knowm.xchange.service.trade.params.CancelOrderByIdParams; -import org.knowm.xchange.service.trade.params.CancelOrderParams; -import org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair; -import org.knowm.xchange.service.trade.params.TradeHistoryParamLimit; -import org.knowm.xchange.service.trade.params.TradeHistoryParamNextPageCursor; -import org.knowm.xchange.service.trade.params.TradeHistoryParams; -import org.knowm.xchange.service.trade.params.TradeHistoryParamsSorted; - -public class LgoTradeService extends LgoTradeServiceRaw implements TradeService { - - private final LgoKeyService keyService; - private final boolean shouldEncryptOrders; - - public LgoTradeService(LgoExchange exchange, LgoKeyService keyService) { - super(exchange); - this.keyService = keyService; - shouldEncryptOrders = - (boolean) - exchange - .getExchangeSpecification() - .getExchangeSpecificParameters() - .getOrDefault(LgoEnv.SHOULD_ENCRYPT_ORDERS, false); - } - - @Override - public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException { - CurrencyPair productId = getProductId(params); - Integer maxResults = getMaxResults(params); - String page = getPage(params); - TradeHistoryParamsSorted.Order sort = getSort(params); - try { - WithCursor lgoTrades = super.getLastTrades(productId, maxResults, page, sort); - return LgoAdapters.adaptUserTrades(lgoTrades); - } catch (LgoException e) { - throw LgoErrorAdapter.adapt(e); - } - } - - private TradeHistoryParamsSorted.Order getSort(TradeHistoryParams params) { - if (!(params instanceof TradeHistoryParamsSorted)) { - return TradeHistoryParamsSorted.Order.desc; - } - return ((TradeHistoryParamsSorted) params).getOrder(); - } - - private String getPage(TradeHistoryParams params) { - if (!(params instanceof TradeHistoryParamNextPageCursor)) { - return null; - } - return ((TradeHistoryParamNextPageCursor) params).getNextPageCursor(); - } - - private CurrencyPair getProductId(TradeHistoryParams params) { - if (!(params instanceof TradeHistoryParamCurrencyPair)) { - return null; - } - return ((TradeHistoryParamCurrencyPair) params).getCurrencyPair(); - } - - private int getMaxResults(TradeHistoryParams params) { - if (!(params instanceof TradeHistoryParamLimit)) { - return 100; - } - return ((TradeHistoryParamLimit) params).getLimit(); - } - - @Override - public TradeHistoryParams createTradeHistoryParams() { - return new LgoTradeHistoryParams(); - } - - @Override - public void verifyOrder(MarketOrder marketOrder) { - LgoProduct product = getProduct(marketOrder.getCurrencyPair()); - LgoProductCurrency currencyToCheck = - OrderType.BID.equals(marketOrder.getType()) ? product.getQuote() : product.getBase(); - if (currencyToCheck.getLimits().getMin().compareTo(marketOrder.getRemainingAmount()) > 0) { - throw new IllegalArgumentException("Quantity to low"); - } - if (currencyToCheck.getLimits().getMax().compareTo(marketOrder.getRemainingAmount()) < 0) { - throw new IllegalArgumentException("Quantity to high"); - } - } - - @Override - public void verifyOrder(LimitOrder limitOrder) { - super.verifyOrder(limitOrder); - LgoProduct product = getProduct(limitOrder.getCurrencyPair()); - if (product.getBase().getLimits().getMax().compareTo(limitOrder.getOriginalAmount()) < 0) { - throw new IllegalArgumentException("Order amount more than maximum"); - } - if (product.getQuote().getLimits().getMin().compareTo(limitOrder.getLimitPrice()) > 0) { - throw new IllegalArgumentException("Order price to low"); - } - if (product.getQuote().getLimits().getMax().compareTo(limitOrder.getLimitPrice()) < 0) { - throw new IllegalArgumentException("Order price to high"); - } - if (limitOrder - .getLimitPrice() - .remainder(product.getQuote().getIncrement()) - .compareTo(BigDecimal.ZERO) - != 0) { - throw new IllegalArgumentException("Invalid price increment"); - } - } - - private LgoProduct getProduct(CurrencyPair currencyPair) { - for (LgoProduct product : exchange.getProducts().getProducts()) { - if (product.getBase().getId().equalsIgnoreCase(currencyPair.base.getCurrencyCode()) - && product.getQuote().getId().equalsIgnoreCase(currencyPair.counter.getCurrencyCode())) { - return product; - } - } - throw new IllegalArgumentException("Product not supported " + currencyPair.toString()); - } - - @Override - public String placeLimitOrder(LimitOrder limitOrder) throws IOException { - if (shouldEncryptOrders) { - return placeEncryptedLimitOrder(limitOrder); - } - return placeUnencryptedLimitOrder(limitOrder); - } - - private String placeEncryptedLimitOrder(LimitOrder limitOrder) throws IOException { - LgoPlaceOrder lgoOrder = LgoAdapters.adaptLimitOrder(limitOrder); - return placeEncryptedOrder(lgoOrder); - } - - private String placeUnencryptedLimitOrder(LimitOrder limitOrder) throws IOException { - try { - LgoUnencryptedOrder lgoOrder = LgoAdapters.adaptUnencryptedLimitOrder(limitOrder); - return placeLgoUnencryptedOrder(lgoOrder); - } catch (LgoException e) { - throw LgoErrorAdapter.adapt(e); - } - } - - @Override - public String placeMarketOrder(MarketOrder marketOrder) throws IOException { - if (shouldEncryptOrders) { - return placeEncryptedMarketOrder(marketOrder); - } - return placeUnencryptedMarketOrder(marketOrder); - } - - private String placeEncryptedMarketOrder(MarketOrder marketOrder) throws IOException { - LgoPlaceOrder lgoOrder = LgoAdapters.adaptEncryptedMarketOrder(marketOrder); - return placeEncryptedOrder(lgoOrder); - } - - private String placeUnencryptedMarketOrder(MarketOrder marketOrder) throws IOException { - try { - LgoUnencryptedOrder lgoOrder = LgoAdapters.adaptUnencryptedMarketOrder(marketOrder); - return placeLgoUnencryptedOrder(lgoOrder); - } catch (LgoException e) { - throw LgoErrorAdapter.adapt(e); - } - } - - @Override - public boolean cancelOrder(CancelOrderParams orderParams) throws IOException { - if (!(orderParams instanceof CancelOrderByIdParams)) { - return false; - } - CancelOrderByIdParams cancelParams = (CancelOrderByIdParams) orderParams; - return cancelOrder(cancelParams.getOrderId()); - } - - @Override - public boolean cancelOrder(String orderId) throws IOException { - if (shouldEncryptOrders) { - placeEncryptedCancelOrder(orderId); - return true; - } - return placeUnencryptedCancelOrder(orderId); - } - - private boolean placeUnencryptedCancelOrder(String orderId) throws IOException { - try { - placeLgoUnencryptedCancelOrder(orderId); - return true; - } catch (LgoException e) { - throw LgoErrorAdapter.adapt(e); - } - } - - /** Place a cancellation order encrypting it's content. */ - private String placeEncryptedCancelOrder(String orderId) throws IOException { - LgoPlaceOrder lgoOrder = LgoAdapters.adaptEncryptedCancelOrder(orderId, new Date()); - return placeEncryptedOrder(lgoOrder); - } - - private String placeEncryptedOrder(LgoPlaceOrder lgoOrder) throws IOException { - try { - LgoKey lgoKey = keyService.selectKey(); - Long ref = exchange.getNonceFactory().createValue(); - String encryptedOrder = CryptoUtils.encryptOrder(lgoKey, lgoOrder); - LgoOrderSignature signature = exchange.getSignatureService().signOrder(encryptedOrder); - LgoEncryptedOrder lgoEncryptedOrder = - new LgoEncryptedOrder(lgoKey.getId(), encryptedOrder, signature, ref); - return placeLgoEncryptedOrder(lgoEncryptedOrder); - } catch (LgoException e) { - throw LgoErrorAdapter.adapt(e); - } - } -} diff --git a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoTradeServiceRaw.java b/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoTradeServiceRaw.java deleted file mode 100644 index ab7371d1881..00000000000 --- a/xchange-lgo/src/main/java/org/knowm/xchange/lgo/service/LgoTradeServiceRaw.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import java.io.IOException; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.lgo.LgoAdapters; -import org.knowm.xchange.lgo.LgoExchange; -import org.knowm.xchange.lgo.dto.LgoException; -import org.knowm.xchange.lgo.dto.WithCursor; -import org.knowm.xchange.lgo.dto.order.LgoEncryptedOrder; -import org.knowm.xchange.lgo.dto.order.LgoPlaceOrderResponse; -import org.knowm.xchange.lgo.dto.order.LgoUnencryptedOrder; -import org.knowm.xchange.lgo.dto.trade.LgoUserTrades; -import org.knowm.xchange.service.trade.params.TradeHistoryParamsSorted; - -public class LgoTradeServiceRaw extends LgoBaseService { - - protected LgoTradeServiceRaw(LgoExchange exchange) { - super(exchange); - } - - protected WithCursor getLastTrades( - CurrencyPair productId, Integer maxResults, String page, TradeHistoryParamsSorted.Order sort) - throws IOException, LgoException { - return proxy.getLastTrades( - exchange.getNonceFactory().createValue(), - exchange.getSignatureService(), - LgoAdapters.adaptCurrencyPair(productId), - maxResults, - page, - sort == null ? null : sort.name().toUpperCase()); - } - - protected String placeLgoEncryptedOrder(LgoEncryptedOrder lgoEncryptedOrder) - throws IOException, LgoException { - return proxy.placeEncryptedOrder( - lgoEncryptedOrder, - exchange.getNonceFactory().createValue(), - exchange.getSignatureService()) - .orderId; - } - - protected String placeLgoUnencryptedOrder(LgoUnencryptedOrder order) - throws IOException, LgoException { - LgoPlaceOrderResponse lgoPlaceOrderResponse = - proxy.placeUnencryptedOrder( - order, exchange.getNonceFactory().createValue(), exchange.getSignatureService()); - return lgoPlaceOrderResponse.orderId; - } - - protected String placeLgoUnencryptedCancelOrder(String orderId) throws IOException, LgoException { - LgoPlaceOrderResponse lgoPlaceOrderResponse = - proxy.placeUnencryptedCancelOrder( - exchange.getNonceFactory().createValue(), exchange.getSignatureService(), orderId); - return lgoPlaceOrderResponse.orderId; - } -} diff --git a/xchange-lgo/src/main/resources/lgo.json b/xchange-lgo/src/main/resources/lgo.json deleted file mode 100644 index e24a78b806e..00000000000 --- a/xchange-lgo/src/main/resources/lgo.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "currency_pairs": {}, - "currencies": {}, - "private_rate_limits": [ - { - "calls": 600, - "time_span": 1, - "time_unit": "minutes" - } - ], - "public_rate_limits": [ - { - "calls": 600, - "time_span": 1, - "time_unit": "minutes" - } - ], - "share_rate_limits": true -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoAdaptersTest.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoAdaptersTest.java deleted file mode 100644 index b1759322b2d..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoAdaptersTest.java +++ /dev/null @@ -1,340 +0,0 @@ -package org.knowm.xchange.lgo; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.Instant; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.TimeZone; -import java.util.stream.Collectors; -import org.assertj.core.util.Lists; -import org.junit.Before; -import org.junit.Test; -import org.knowm.xchange.currency.Currency; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order.OrderType; -import org.knowm.xchange.dto.marketdata.OrderBook; -import org.knowm.xchange.dto.meta.CurrencyMetaData; -import org.knowm.xchange.dto.meta.ExchangeMetaData; -import org.knowm.xchange.dto.meta.RateLimit; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.MarketOrder; -import org.knowm.xchange.dto.trade.UserTrade; -import org.knowm.xchange.dto.trade.UserTrades; -import org.knowm.xchange.lgo.dto.WithCursor; -import org.knowm.xchange.lgo.dto.currency.LgoCurrencies; -import org.knowm.xchange.lgo.dto.currency.LgoCurrency; -import org.knowm.xchange.lgo.dto.key.LgoKey; -import org.knowm.xchange.lgo.dto.marketdata.LgoOrderbook; -import org.knowm.xchange.lgo.dto.order.LgoPlaceLimitOrder; -import org.knowm.xchange.lgo.dto.order.LgoPlaceMarketOrder; -import org.knowm.xchange.lgo.dto.order.LgoPlaceOrder; -import org.knowm.xchange.lgo.dto.order.LgoUnencryptedOrder; -import org.knowm.xchange.lgo.dto.product.LgoLimit; -import org.knowm.xchange.lgo.dto.product.LgoProduct; -import org.knowm.xchange.lgo.dto.product.LgoProductCurrency; -import org.knowm.xchange.lgo.dto.product.LgoProductTotal; -import org.knowm.xchange.lgo.dto.product.LgoProducts; -import org.knowm.xchange.lgo.dto.product.LgoProductsTest; -import org.knowm.xchange.lgo.dto.trade.LgoUserTrade; -import org.knowm.xchange.lgo.dto.trade.LgoUserTrades; - -public class LgoAdaptersTest { - - private SimpleDateFormat dateFormat; - - @Before - public void setUp() { - dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - } - - @Test - public void adaptsMetadata() { - ExchangeMetaData metaData = LgoAdapters.adaptMetadata(emptyMeta(), products(), currencies()); - - assertThat(metaData).isNotNull(); - assertThat(metaData.getCurrencies()).hasSize(2).containsKeys(Currency.BTC, Currency.USD); - assertThat(metaData.getCurrencies().get(Currency.BTC)) - .isEqualToComparingFieldByField(new CurrencyMetaData(8, null)); - assertThat(metaData.getCurrencies().get(Currency.USD)) - .isEqualToComparingFieldByField(new CurrencyMetaData(4, null)); - assertThat(metaData.getInstruments()).hasSize(1).containsKeys(CurrencyPair.BTC_USD); - } - - @Test - public void adaptsKeysIndex() throws IOException, URISyntaxException { - String indexFile = - new String( - Files.readAllBytes( - Paths.get(getClass().getResource("/org/knowm/xchange/lgo/key/index.txt").toURI())), - StandardCharsets.US_ASCII); - - List keys = LgoAdapters.adaptKeysIndex(indexFile).collect(Collectors.toList()); - - assertThat(keys).hasSize(2); - assertThat(keys.get(0)) - .isEqualToComparingFieldByField( - new LgoKey( - "7b5dd30f-47cc-4c72-938b-199b13bc6f72", - Instant.parse("2019-07-16T09:13:54Z"), - Instant.parse("2019-07-16T10:13:54Z"))); - assertThat(keys.get(1)) - .isEqualToComparingFieldByField( - new LgoKey( - "684700ae-8bc7-4315-8aec-b69ca778339a", - Instant.parse("2019-07-16T10:03:54Z"), - Instant.parse("2019-07-16T11:03:54Z"))); - } - - @Test - public void adaptsBidLimitOrder() { - Date now = new Date(); - LimitOrder limitOrder = - new LimitOrder( - OrderType.BID, - new BigDecimal("1"), - CurrencyPair.BTC_USD, - null, - now, - new BigDecimal("6000")); - - LgoPlaceOrder bidOrder = LgoAdapters.adaptLimitOrder(limitOrder); - - assertThat(bidOrder) - .isEqualToComparingFieldByField( - new LgoPlaceLimitOrder( - 0, "B", "BTC-USD", new BigDecimal("1"), new BigDecimal("6000"), now.toInstant())); - } - - @Test - public void adaptsAskLimitOrder() { - Date timestamp = new Date(); - LimitOrder limitOrder = - new LimitOrder( - OrderType.ASK, - new BigDecimal("1"), - CurrencyPair.BTC_USD, - null, - timestamp, - new BigDecimal("6000")); - - LgoPlaceOrder bidOrder = LgoAdapters.adaptLimitOrder(limitOrder); - - assertThat(bidOrder) - .isEqualToComparingFieldByField( - new LgoPlaceLimitOrder( - 0, - "S", - "BTC-USD", - new BigDecimal("1"), - new BigDecimal("6000"), - timestamp.toInstant())); - } - - @Test - public void adaptsBidMarketOrder() { - Date now = new Date(); - MarketOrder marketOrder = - new MarketOrder(OrderType.BID, new BigDecimal("1"), CurrencyPair.BTC_USD, null, now); - - LgoPlaceOrder bidOrder = LgoAdapters.adaptEncryptedMarketOrder(marketOrder); - - assertThat(bidOrder) - .isEqualToComparingFieldByField( - new LgoPlaceMarketOrder(0, "B", "BTC-USD", new BigDecimal("1"), now.toInstant())); - } - - @Test - public void adaptsAskMarketOrder() { - Date timestamp = new Date(); - MarketOrder marketOrder = - new MarketOrder(OrderType.ASK, new BigDecimal("1"), CurrencyPair.BTC_USD, null, timestamp); - - LgoPlaceOrder bidOrder = LgoAdapters.adaptEncryptedMarketOrder(marketOrder); - - assertThat(bidOrder) - .isEqualToComparingFieldByField( - new LgoPlaceMarketOrder(0, "S", "BTC-USD", new BigDecimal("1"), timestamp.toInstant())); - } - - @Test - public void adaptsUnencryptedOrder() { - Date timestamp = new Date(); - LimitOrder limitOrder = - new LimitOrder( - OrderType.ASK, - new BigDecimal("1"), - CurrencyPair.BTC_USD, - null, - timestamp, - new BigDecimal("6000")); - - LgoUnencryptedOrder lgoUnencryptedOrder = LgoAdapters.adaptUnencryptedLimitOrder(limitOrder); - - assertThat(lgoUnencryptedOrder.price).isEqualTo("6000"); - assertThat(lgoUnencryptedOrder.quantity).isEqualTo("1"); - assertThat(lgoUnencryptedOrder.productId).isEqualTo("BTC-USD"); - assertThat(lgoUnencryptedOrder.side).isEqualTo("S"); - assertThat(lgoUnencryptedOrder.timestamp).isEqualTo(timestamp.getTime()); - assertThat(lgoUnencryptedOrder.type).isEqualTo("L"); - } - - @Test - public void adaptsTradeType() { - assertThat(LgoAdapters.adaptUserTradeType(lgoTrade("B", "T"))).isEqualTo(OrderType.BID); - assertThat(LgoAdapters.adaptUserTradeType(lgoTrade("B", "M"))).isEqualTo(OrderType.ASK); - assertThat(LgoAdapters.adaptUserTradeType(lgoTrade("S", "T"))).isEqualTo(OrderType.ASK); - assertThat(LgoAdapters.adaptUserTradeType(lgoTrade("S", "M"))).isEqualTo(OrderType.BID); - } - - @Test - public void adaptsProductId() { - assertThat(LgoAdapters.adaptProductId("BTC-USD")).isEqualTo(CurrencyPair.BTC_USD); - } - - @Test - public void adaptsUserTrades() throws IOException, ParseException { - WithCursor lastTrades = - readResourceAs( - "/org/knowm/xchange/lgo/trade/example-trades-data.json", - new TypeReference>() {}); - - UserTrades userTrades = LgoAdapters.adaptUserTrades(lastTrades); - - assertThat(userTrades.getNextPageCursor()).isEqualTo("aGVsbG8="); - assertThat(userTrades.getUserTrades()).hasSize(2); - assertThat(userTrades.getUserTrades().get(0)) - .isEqualToComparingFieldByField( - UserTrade.builder() - .type(OrderType.ASK) - .originalAmount(new BigDecimal("0.00500000")) - .currencyPair(CurrencyPair.BTC_USD) - .price(new BigDecimal("3854.0000")) - .timestamp(dateFormat.parse("2019-03-05T16:37:17.220Z")) - .id("2") - .orderId("155180383648300001") - .feeAmount(new BigDecimal("0.0096")) - .feeCurrency(Currency.USD) - .build()); - assertThat(userTrades.getUserTrades().get(1)) - .isEqualToComparingFieldByField( - UserTrade.builder() - .type(OrderType.BID) - .originalAmount(new BigDecimal("0.00829566")) - .currencyPair(CurrencyPair.BTC_USD) - .price(new BigDecimal("2410.9000")) - .timestamp(dateFormat.parse("2019-06-20T15:37:21.855Z")) - .id("2477363") - .orderId("156104504046400001") - .feeAmount(new BigDecimal("0.0100")) - .feeCurrency(Currency.USD) - .build()); - } - - @Test - public void adaptsOrderBook() throws IOException { - LgoOrderbook lgoOrderbook = - readResourceAs( - "/org/knowm/xchange/lgo/marketdata/example-orderbook-data.json", - new TypeReference() {}); - - OrderBook orderBook = LgoAdapters.adaptOrderBook(lgoOrderbook, CurrencyPair.BTC_USD); - - assertThat(orderBook).isNotNull(); - assertThat(orderBook.getAsks()).hasSize(2); - assertThat(orderBook.getBids()).hasSize(2); - assertThat(orderBook.getAsks().get(0)) - .isEqualTo( - new LimitOrder( - OrderType.ASK, - new BigDecimal("4.44440000"), - CurrencyPair.BTC_USD, - null, - null, - new BigDecimal("2921.9000"))); - assertThat(orderBook.getAsks().get(1)) - .isEqualTo( - new LimitOrder( - OrderType.ASK, - new BigDecimal("8.38460000"), - CurrencyPair.BTC_USD, - null, - null, - new BigDecimal("2926.5000"))); - assertThat(orderBook.getBids().get(0)) - .isEqualTo( - new LimitOrder( - OrderType.BID, - new BigDecimal("8.35030000"), - CurrencyPair.BTC_USD, - null, - null, - new BigDecimal("2896.6000"))); - assertThat(orderBook.getBids().get(1)) - .isEqualTo( - new LimitOrder( - OrderType.BID, - new BigDecimal("931.83050000"), - CurrencyPair.BTC_USD, - null, - null, - new BigDecimal("1850.0000"))); - } - - private T readResourceAs(String path, TypeReference type) throws IOException { - InputStream is = LgoProductsTest.class.getResourceAsStream(path); - ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(is, type); - } - - private LgoUserTrade lgoTrade(String side, String liquidity) { - return new LgoUserTrade( - "1", - "2", - "BTC-USD", - new BigDecimal("1"), - new BigDecimal("1"), - null, - new BigDecimal("1"), - side, - liquidity); - } - - private ExchangeMetaData emptyMeta() { - return new ExchangeMetaData( - new HashMap<>(), new HashMap<>(), new RateLimit[0], new RateLimit[0], true); - } - - private LgoCurrencies currencies() { - return new LgoCurrencies( - Lists.newArrayList( - new LgoCurrency("Bitcoin", "BTC", 8), new LgoCurrency("Dollar", "USD", 4))); - } - - private LgoProducts products() { - return new LgoProducts( - Lists.newArrayList( - new LgoProduct( - "BTC-USD", - new LgoProductTotal(limit("10", "50000000")), - new LgoProductCurrency("BTC", null, limit("0.001", "1000")), - new LgoProductCurrency("USD", new BigDecimal("0.10"), limit("10", "1000000"))))); - } - - private LgoLimit limit(String min, String max) { - return new LgoLimit(new BigDecimal(min), new BigDecimal(max)); - } -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoExchangeMarketDataIntegration.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoExchangeMarketDataIntegration.java deleted file mode 100644 index 32389a1aeaf..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoExchangeMarketDataIntegration.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.knowm.xchange.lgo; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.TimeZone; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.knowm.xchange.ExchangeFactory; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.marketdata.OrderBook; -import org.knowm.xchange.lgo.dto.marketdata.LgoGranularity; -import org.knowm.xchange.lgo.dto.marketdata.LgoPriceHistory; -import org.knowm.xchange.lgo.service.LgoMarketDataService; - -@Ignore -public class LgoExchangeMarketDataIntegration { - - private SimpleDateFormat dateFormat; - - @Before - public void setUp() { - dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - } - - @Test - public void fetchOrderBook() throws IOException { - LgoExchange lgoExchange = exchangeWithCredentials(); - LgoMarketDataService tradeService = lgoExchange.getMarketDataService(); - OrderBook ob = tradeService.getOrderBook(CurrencyPair.BTC_USD, ""); - // assertThat(ob.getBids()).isNotEmpty(); - // assertThat(ob.getAsks()).isNotEmpty(); - ob.getBids().forEach(l -> System.out.println(l.toString())); - ob.getAsks().forEach(l -> System.out.println(l.toString())); - } - - @Test - public void fetchPriceHistory() throws IOException, ParseException { - LgoExchange lgoExchange = exchangeWithCredentials(); - LgoMarketDataService tradeService = lgoExchange.getMarketDataService(); - LgoPriceHistory history = - tradeService.getLgoPriceHistory( - CurrencyPair.BTC_USD, - dateFormat.parse("2019-12-20T15:00:00.000Z"), - dateFormat.parse("2019-12-21T15:00:00.000Z"), - LgoGranularity.ONE_HOUR); - assertThat(history.getPrices()).hasSize(24); - System.out.println(history); - } - - // api key and secret key are expected to be in test resources under - // integration directory - // this directory is added to .gitignore to avoid committing a real usable key - private LgoExchange exchangeWithCredentials() throws IOException { - ExchangeSpecification spec = LgoEnv.sandbox(); - spec.setSecretKey(readResource("/integration/private_key.pem")); - spec.setApiKey(readResource("/integration/api_key.txt")); - - return (LgoExchange) ExchangeFactory.INSTANCE.createExchange(spec); - } - - private String readResource(String path) throws IOException { - try { - return new String( - Files.readAllBytes(Paths.get(getClass().getResource(path).toURI())), - StandardCharsets.UTF_8); - } catch (URISyntaxException e) { - return null; - } - } -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoExchangeMetadataIntegration.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoExchangeMetadataIntegration.java deleted file mode 100644 index 938516ff575..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoExchangeMetadataIntegration.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.knowm.xchange.lgo; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import org.junit.Ignore; -import org.junit.Test; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeFactory; -import org.knowm.xchange.ExchangeSpecification; - -@Ignore -public class LgoExchangeMetadataIntegration { - - @Test - public void fetchRemoteMetadata() throws IOException { - Exchange exchange = exchangeWithCredentials(); - - assertThat(exchange.getExchangeMetaData().getInstruments()).hasSize(1); - } - - // api key and secret key are expected to be in test resources under - // integration directory - // this directory is added to .gitignore to avoid committing a real usable key - protected LgoExchange exchangeWithCredentials() throws IOException { - ExchangeSpecification spec = LgoEnv.sandbox(); - spec.setSecretKey(readResource("/integration/private_key.pem")); - spec.setApiKey(readResource("/integration/api_key.txt")); - - return (LgoExchange) ExchangeFactory.INSTANCE.createExchange(spec); - } - - private String readResource(String path) throws IOException { - try { - return new String( - Files.readAllBytes(Paths.get(getClass().getResource(path).toURI())), - StandardCharsets.UTF_8); - } catch (URISyntaxException e) { - return null; - } - } -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoExchangeTradeIntegration.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoExchangeTradeIntegration.java deleted file mode 100644 index 935542e3893..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/LgoExchangeTradeIntegration.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.knowm.xchange.lgo; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import java.math.BigDecimal; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Date; -import org.junit.Ignore; -import org.junit.Test; -import org.knowm.xchange.ExchangeFactory; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order.OrderType; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.MarketOrder; -import org.knowm.xchange.dto.trade.UserTrades; -import org.knowm.xchange.lgo.service.LgoTradeService; - -@Ignore -public class LgoExchangeTradeIntegration { - - @Test - public void fetchLastTrades() throws IOException { - LgoExchange lgoExchange = exchangeWithCredentials(false); - LgoTradeService tradeService = lgoExchange.getTradeService(); - UserTrades tradeHistory = tradeService.getTradeHistory(tradeService.createTradeHistoryParams()); - assertThat(tradeHistory.getUserTrades()).isNotEmpty(); - System.out.println(tradeHistory.getUserTrades().size()); - } - - @Test - public void placeLimitOrder() throws IOException { - LgoExchange lgoExchange = exchangeWithCredentials(false); - LgoTradeService tradeService = lgoExchange.getTradeService(); - - String orderId = - tradeService.placeLimitOrder( - new LimitOrder( - OrderType.ASK, - new BigDecimal("2"), - CurrencyPair.BTC_USD, - null, - new Date(), - new BigDecimal("6000"))); - - System.out.println(orderId); - } - - @Test - public void placeMarketOrder() throws IOException { - LgoExchange lgoExchange = exchangeWithCredentials(false); - LgoTradeService tradeService = lgoExchange.getTradeService(); - - String orderId = - tradeService.placeMarketOrder( - new MarketOrder( - OrderType.ASK, new BigDecimal("2"), CurrencyPair.BTC_USD, null, new Date())); - - System.out.println(orderId); - } - - @Test - public void cancelOrder() throws IOException { - LgoExchange lgoExchange = exchangeWithCredentials(false); - LgoTradeService tradeService = lgoExchange.getTradeService(); - - tradeService.cancelOrder("156941460160700001"); - } - - @Test - public void placeEncryptedLimitOrder() throws IOException { - LgoExchange lgoExchange = exchangeWithCredentials(true); - LgoTradeService tradeService = lgoExchange.getTradeService(); - - String orderId = - tradeService.placeLimitOrder( - new LimitOrder( - OrderType.ASK, - new BigDecimal("2"), - CurrencyPair.BTC_USD, - null, - new Date(), - new BigDecimal("6000"))); - - System.out.println(orderId); - } - - @Test - public void placeEncryptedMarketOrder() throws IOException { - LgoExchange lgoExchange = exchangeWithCredentials(true); - LgoTradeService tradeService = lgoExchange.getTradeService(); - - String orderId = - tradeService.placeMarketOrder( - new MarketOrder( - OrderType.ASK, new BigDecimal("2"), CurrencyPair.BTC_USD, null, new Date())); - - System.out.println(orderId); - } - - @Test - public void placeEncryptedCancelOrder() throws IOException { - LgoExchange lgoExchange = exchangeWithCredentials(true); - LgoTradeService tradeService = lgoExchange.getTradeService(); - - tradeService.cancelOrder("157771427343700001"); - } - - // api key and secret key are expected to be in test resources under - // integration directory - // this directory is added to .gitignore to avoid committing a real usable key - protected LgoExchange exchangeWithCredentials(boolean shouldEncryptOrders) throws IOException { - ExchangeSpecification spec = LgoEnv.sandbox(); - spec.setSecretKey(readResource("/integration/private_key.pem")); - spec.setApiKey(readResource("/integration/api_key.txt")); - spec.setExchangeSpecificParametersItem(LgoEnv.SHOULD_ENCRYPT_ORDERS, shouldEncryptOrders); - - return (LgoExchange) ExchangeFactory.INSTANCE.createExchange(spec); - } - - private String readResource(String path) throws IOException { - try { - return new String( - Files.readAllBytes(Paths.get(getClass().getResource(path).toURI())), - StandardCharsets.UTF_8); - } catch (URISyntaxException e) { - return null; - } - } -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/currency/LgoCurrenciesTest.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/currency/LgoCurrenciesTest.java deleted file mode 100644 index 9086d1c2da9..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/currency/LgoCurrenciesTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.knowm.xchange.lgo.dto.currency; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.io.InputStream; -import org.junit.Test; -import org.knowm.xchange.lgo.dto.product.LgoProductsTest; - -public class LgoCurrenciesTest { - - @Test - public void itCanReadJson() throws IOException { - InputStream is = - LgoProductsTest.class.getResourceAsStream( - "/org/knowm/xchange/lgo/currency/example-currencies-data.json"); - ObjectMapper mapper = new ObjectMapper(); - - LgoCurrencies currencies = mapper.readValue(is, LgoCurrencies.class); - - assertThat(currencies.getCurrencies()).hasSize(2); - assertThat(currencies.getCurrencies().get(0)) - .isEqualToComparingFieldByField(new LgoCurrency("Bitcoin", "BTC", 8)); - assertThat(currencies.getCurrencies().get(1)) - .isEqualToComparingFieldByField(new LgoCurrency("United States Dollar", "USD", 4)); - } -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/marketdata/LgoOrderbookTest.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/marketdata/LgoOrderbookTest.java deleted file mode 100644 index af8d5c2e7f8..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/marketdata/LgoOrderbookTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.knowm.xchange.lgo.dto.marketdata; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.io.InputStream; -import org.junit.Test; -import org.knowm.xchange.lgo.dto.product.LgoProductsTest; - -public class LgoOrderbookTest { - - @Test - public void itCanReadJson() throws IOException { - InputStream is = - LgoProductsTest.class.getResourceAsStream( - "/org/knowm/xchange/lgo/marketdata/example-orderbook-data.json"); - ObjectMapper mapper = new ObjectMapper(); - - LgoOrderbook lgoOrderbook = mapper.readValue(is, LgoOrderbook.class); - - assertThat(lgoOrderbook).isNotNull(); - assertThat(lgoOrderbook.getLastBatchId()).isEqualTo(10); - assertThat(lgoOrderbook.getAsks()).hasSize(2); - assertThat(lgoOrderbook.getAsks().get(0)) - .containsExactly(new String[] {"2921.9000", "4.44440000"}); - assertThat(lgoOrderbook.getAsks().get(1)) - .containsExactly(new String[] {"2926.5000", "8.38460000"}); - assertThat(lgoOrderbook.getBids()).hasSize(2); - assertThat(lgoOrderbook.getBids().get(0)) - .containsExactly(new String[] {"2896.6000", "8.35030000"}); - assertThat(lgoOrderbook.getBids().get(1)) - .containsExactly(new String[] {"1850.0000", "931.83050000"}); - } -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/marketdata/LgoPriceHistoryTest.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/marketdata/LgoPriceHistoryTest.java deleted file mode 100644 index 824932aeac1..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/marketdata/LgoPriceHistoryTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.knowm.xchange.lgo.dto.marketdata; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.TimeZone; -import org.junit.Before; -import org.junit.Test; -import org.knowm.xchange.lgo.dto.product.LgoProductsTest; - -public class LgoPriceHistoryTest { - - private SimpleDateFormat dateFormat; - - @Before - public void setUp() { - dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - } - - @Test - public void itCanReadJson() throws IOException, ParseException { - InputStream is = - LgoProductsTest.class.getResourceAsStream( - "/org/knowm/xchange/lgo/marketdata/example-pricehistory-data.json"); - ObjectMapper mapper = new ObjectMapper(); - - LgoPriceHistory response = mapper.readValue(is, LgoPriceHistory.class); - - assertThat(response).isNotNull(); - assertThat(response.getPrices()).hasSize(2); - LgoCandlestick candlestick = response.getPrices().get(0); - assertThat(candlestick.getTime()).isEqualTo(dateFormat.parse("2019-12-20T15:00:00Z")); - assertThat(candlestick.getLow()).isEqualTo(new BigDecimal("4396.7000")); - assertThat(candlestick.getHigh()).isEqualTo(new BigDecimal("4654.4000")); - assertThat(candlestick.getOpen()).isEqualTo(new BigDecimal("4592.6000")); - assertThat(candlestick.getClose()).isEqualTo(new BigDecimal("4531.6000")); - assertThat(candlestick.getVolume()).isEqualTo(new BigDecimal("485.35050000")); - } -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/order/LgoPlaceOrderTest.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/order/LgoPlaceOrderTest.java deleted file mode 100644 index 08421025851..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/order/LgoPlaceOrderTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.knowm.xchange.lgo.dto.order; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.math.BigDecimal; -import java.time.Instant; -import org.junit.Test; - -public class LgoPlaceOrderTest { - - @Test - public void serializesToLgoLimitOrderPayload() { - Instant now = Instant.now(); - LgoPlaceOrder order = - new LgoPlaceLimitOrder( - 1, "B", "BTC-USD", new BigDecimal("10.5"), new BigDecimal("6001.50"), now); - - String payload = order.toPayload(); - - assertThat(payload).isEqualTo("L,B,BTC-USD,10.5,6001.50,gtc," + now.toEpochMilli()); - } - - @Test - public void serializesToLgoMarketOrderPayload() { - Instant now = Instant.now(); - LgoPlaceOrder order = new LgoPlaceMarketOrder(1, "S", "BTC-USD", new BigDecimal("10.5"), now); - - String payload = order.toPayload(); - - assertThat(payload).isEqualTo("M,S,BTC-USD,10.5,,," + now.toEpochMilli()); - } - - @Test - public void serializesToLgoCancelOrderPayload() { - Instant now = Instant.now(); - LgoPlaceCancelOrder order = new LgoPlaceCancelOrder(1, "orderId", now); - - String payload = order.toPayload(); - - assertThat(payload).isEqualTo("C,orderId," + now.toEpochMilli()); - } -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/product/LgoProductsTest.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/product/LgoProductsTest.java deleted file mode 100644 index 2b278491eab..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/dto/product/LgoProductsTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.knowm.xchange.lgo.dto.product; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import org.junit.Test; - -public class LgoProductsTest { - - @Test - public void itCanReadJson() throws IOException { - InputStream is = - LgoProductsTest.class.getResourceAsStream( - "/org/knowm/xchange/lgo/product/example-products-data.json"); - ObjectMapper mapper = new ObjectMapper(); - - LgoProducts products = mapper.readValue(is, LgoProducts.class); - - assertThat(products.getProducts()).hasSize(1); - LgoProduct product = products.getProducts().get(0); - assertThat(product.getId()).isEqualTo("BTC-USD"); - assertThat(product.getBase()) - .usingRecursiveComparison() - .isEqualTo( - new LgoProductCurrency( - "BTC", null, new LgoLimit(new BigDecimal("0.001"), new BigDecimal("1000")))); - assertThat(product.getQuote()) - .usingRecursiveComparison() - .isEqualTo( - new LgoProductCurrency( - "USD", - new BigDecimal("0.10"), - new LgoLimit(new BigDecimal("10"), new BigDecimal("1000000")))); - assertThat(product.getTotal()) - .usingRecursiveComparison() - .isEqualTo( - new LgoProductTotal(new LgoLimit(new BigDecimal("10"), new BigDecimal("50000000")))); - } -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoKeyServiceIntegration.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoKeyServiceIntegration.java deleted file mode 100644 index 966e4d3ab03..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoKeyServiceIntegration.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.time.Instant; -import org.junit.Before; -import org.junit.Test; -import org.knowm.xchange.Exchange; -import org.knowm.xchange.ExchangeFactory; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.lgo.LgoEnv; -import org.knowm.xchange.lgo.LgoEnv.SignatureService; -import org.knowm.xchange.lgo.dto.key.LgoKey; - -public class LgoKeyServiceIntegration { - - private LgoKeyService lgoKeyService; - - @Before - public void setUp() { - ExchangeSpecification spec = LgoEnv.sandbox(); - spec.setShouldLoadRemoteMetaData(false); - spec.getExchangeSpecificParameters() - .put(LgoEnv.SIGNATURE_SERVICE, SignatureService.PASSTHROUGHS); - Exchange exchange = ExchangeFactory.INSTANCE.createExchange(spec); - - lgoKeyService = new LgoKeyService(exchange.getExchangeSpecification()); - } - - @Test - public void fetchAValidKey() { - LgoKey key = lgoKeyService.selectKey(); - - assertThat(key).isNotNull(); - assertThat(key.getDisabledAt()).isAfter(Instant.now()); - } - - @Test - public void returnsTheSameKeyIfValid() { - LgoKey firstKey = lgoKeyService.selectKey(); - LgoKey secondKey = lgoKeyService.selectKey(); - - assertThat(firstKey).isEqualTo(secondKey); - } -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoSignatureServiceLocalRsaTest.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoSignatureServiceLocalRsaTest.java deleted file mode 100644 index 8a5a49b559e..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoSignatureServiceLocalRsaTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import org.junit.Before; -import org.junit.Test; - -public class LgoSignatureServiceLocalRsaTest { - - private final String apiKey = "b34edb11-eb03-4da5-af84-496e42d8a92c"; - private LgoSignatureServiceLocalRsa signatureService; - - @Before - public void setUp() throws Exception { - String pKeyAsString = - new String( - Files.readAllBytes(Paths.get(getClass().getResource("/private_key.pem").toURI())), - StandardCharsets.UTF_8); - signatureService = new LgoSignatureServiceLocalRsa(apiKey, pKeyAsString); - } - - @Test - public void digestHeader() { - String digest = signatureService.digestSignedUrlHeader("wss://echo.test", "3"); - - assertThat(digest) - .isEqualTo( - String.format( - "LGO %s:49fc528952ac62c7fd18524df714c7929900e8da66532cd99f4e7bda74eb22913120f85902afe7d48b1a50639f8a0748b9ffb2c1736189c5a01d9de4c79131dd3911feeb4a5c91290d754bb78700a9b12377059611b21b8853b5ae684d065d1e024a8d0d928bf6e44312620ca586173d838523b4cfd829d3b212a9013064424d832bca63303841def4a922ea777d52e3e1e0ad871278c44a60dfc827dacb25355028a6ef92c449b0ab779ae481c6f7247c0d07707989ac922d7151736c38ab4fe728e36a148851da5b9226ce9ed03cd7ffe66292c79109817a66fff03e1cb71c0f5ab88cb631d0cb776d96727e7d7938cd0c1f4095fc8949960da212e319ec1e", - apiKey)); - } - - @Test - public void digestHeaderWithBody() { - String timestamp = "123456789"; - String urlToSign = "http://localhost:8083/v1/live/orders"; - String payload = - "{\"type\":\"L\",\"side\":\"S\",\"product_id\":\"BTC-USD\",\"quantity\":\"0.5\",\"price\":\"1000\",\"reference\":2468}"; - - String digest = signatureService.digestSignedUrlAndBodyHeader(urlToSign, timestamp, payload); - - assertThat(digest) - .isEqualTo( - String.format( - "LGO %s:58590721eccabb3cfd0bf68658bd69cd3bece50332dfbd5e55ccb695fdc5a8cf9f71257c910a1d1c425c0e3e5b591d3cc480ec29032a642512d71592f236b72ccbca1ba53695e3d28002cdb67b22875de9a4ca57b431b25719ad51fedbc961f00b979077126e76a67f5bf8baaef2109133c06aa358d3e0df21ef818db3d9a0d0770f695be4c9f5123815e184534cef8606e64e4117b81bc9dda83c4793bc4d823f66d1d2f152548e0595f031d0a5caa49407a2fdf31f6f8710133abd14cabd5ad9af7893d8360a65438946bedc377c694fd84c260d30ff6916f61a0c0492966c1cf662c3a8b523111e8ecc36b3acf65241d2e6d71ce2085d0e29a8d88655a03e", - apiKey)); - } -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoSignatureServicePassthroughsTest.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoSignatureServicePassthroughsTest.java deleted file mode 100644 index e83101e2f1c..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoSignatureServicePassthroughsTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Before; -import org.junit.Test; -import org.knowm.xchange.lgo.dto.order.LgoOrderSignature; - -public class LgoSignatureServicePassthroughsTest { - - private LgoSignatureServicePassthroughs signatureService; - - @Before - public void setUp() { - signatureService = new LgoSignatureServicePassthroughs("user", "key", "secret"); - } - - @Test - public void itEncodesUserInformations() { - String result = signatureService.digestSignedUrlHeader("url", "1234"); - - assertThat(result).isEqualTo("dXNlcjprZXk6c2VjcmV0"); - } - - @Test - public void putsIdentifierInOrderSignature() { - LgoOrderSignature encryptedOrder = signatureService.signOrder("encryptedOrder"); - - assertThat(encryptedOrder).isNotNull(); - assertThat(encryptedOrder.getSource()).isEqualTo("RSA"); - assertThat(encryptedOrder.getValue()).isEqualTo("dXNlcjprZXk6c2VjcmV0"); - } -} diff --git a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoTradeServiceTest.java b/xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoTradeServiceTest.java deleted file mode 100644 index eb81c5b1240..00000000000 --- a/xchange-lgo/src/test/java/org/knowm/xchange/lgo/service/LgoTradeServiceTest.java +++ /dev/null @@ -1,228 +0,0 @@ -package org.knowm.xchange.lgo.service; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.InputStream; -import java.math.BigDecimal; -import java.util.Date; -import org.assertj.core.api.ThrowableAssert.ThrowingCallable; -import org.junit.Before; -import org.junit.Test; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order.OrderType; -import org.knowm.xchange.dto.meta.ExchangeMetaData; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.MarketOrder; -import org.knowm.xchange.lgo.LgoAdapters; -import org.knowm.xchange.lgo.LgoEnv; -import org.knowm.xchange.lgo.LgoExchange; -import org.knowm.xchange.lgo.dto.currency.LgoCurrencies; -import org.knowm.xchange.lgo.dto.product.LgoProducts; -import org.knowm.xchange.lgo.dto.product.LgoProductsTest; - -public class LgoTradeServiceTest { - - private LgoTradeService tradeService; - private LgoExchange exchange; - - @Before - public void setUp() throws Exception { - exchange = mock(LgoExchange.class); - LgoProducts products = - load("/org/knowm/xchange/lgo/product/example-products-data.json", LgoProducts.class); - LgoCurrencies currencies = - load("/org/knowm/xchange/lgo/currency/example-currencies-data.json", LgoCurrencies.class); - ExchangeMetaData metaData = load("/lgo.json", ExchangeMetaData.class); - when(exchange.getProducts()).thenReturn(products); - when(exchange.getCurrencies()).thenReturn(currencies); - when(exchange.getExchangeSpecification()).thenReturn(LgoEnv.sandbox()); - when(exchange.getExchangeMetaData()) - .thenReturn(LgoAdapters.adaptMetadata(metaData, products, currencies)); - tradeService = new LgoTradeService(exchange, mock(LgoKeyService.class)); - } - - private T load(String resource, Class clazz) throws java.io.IOException { - InputStream is = LgoProductsTest.class.getResourceAsStream(resource); - ObjectMapper mapper = new ObjectMapper(); - - return mapper.readValue(is, clazz); - } - - @Test - public void acceptsCorrectLimitOrder() { - tradeService.verifyOrder( - new LimitOrder( - OrderType.ASK, - new BigDecimal("3"), - CurrencyPair.BTC_USD, - "", - new Date(), - new BigDecimal(7000))); - } - - @Test - public void acceptsCorrectMarketOrder() { - tradeService.verifyOrder( - new MarketOrder(OrderType.BID, new BigDecimal("1000"), CurrencyPair.BTC_USD, new Date())); - } - - @Test - public void cannotPlaceLimitOrderWithToLowBaseAmount() { - ThrowingCallable check = - () -> - tradeService.verifyOrder( - new LimitOrder( - OrderType.ASK, - new BigDecimal("0.00000001"), - CurrencyPair.BTC_USD, - "", - new Date(), - new BigDecimal(7000))); - - assertThatThrownBy(check) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Unsupported amount scale 8"); - } - - @Test - public void cannotPlaceLimitOrderWithToHighBaseAmount() { - ThrowingCallable check = - () -> - tradeService.verifyOrder( - new LimitOrder( - OrderType.ASK, - new BigDecimal("1001"), - CurrencyPair.BTC_USD, - "", - new Date(), - new BigDecimal(7000))); - - assertThatThrownBy(check) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Order amount more than maximum"); - } - - @Test - public void cannotPlaceLimitOrderWithToLowPrice() { - ThrowingCallable check = - () -> - tradeService.verifyOrder( - new LimitOrder( - OrderType.ASK, - new BigDecimal("10"), - CurrencyPair.BTC_USD, - "", - new Date(), - new BigDecimal(9))); - - assertThatThrownBy(check) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Order price to low"); - } - - @Test - public void cannotPlaceLimitOrderWithToHighPrice() { - ThrowingCallable check = - () -> - tradeService.verifyOrder( - new LimitOrder( - OrderType.ASK, - new BigDecimal("10"), - CurrencyPair.BTC_USD, - "", - new Date(), - new BigDecimal(1000001))); - - assertThatThrownBy(check) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Order price to high"); - } - - @Test - public void cannotPlaceLimitOrderWithInvalidPriceIncrement() { - ThrowingCallable check = - () -> - tradeService.verifyOrder( - new LimitOrder( - OrderType.ASK, - new BigDecimal("10"), - CurrencyPair.BTC_USD, - "", - new Date(), - new BigDecimal("100.05"))); - - assertThatThrownBy(check) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Unsupported price scale 2"); - } - - @Test - public void canPlaceLimitOrderWithValidPriceIncrementAndScaleGreaterThan0() { - tradeService.verifyOrder( - new LimitOrder( - OrderType.ASK, - new BigDecimal("10"), - CurrencyPair.BTC_USD, - "", - new Date(), - new BigDecimal("100.1"))); - - assertThat(true).describedAs("No exception thrown").isTrue(); - } - - @Test - public void cannotPlaceBidMarketOrderWithAmountToLow() { - ThrowingCallable check = - () -> - tradeService.verifyOrder( - new MarketOrder( - OrderType.BID, new BigDecimal("0.00001"), CurrencyPair.BTC_USD, new Date())); - - assertThatThrownBy(check) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Quantity to low"); - } - - @Test - public void cannotPlaceBidMarketOrderWithAmountToHigh() { - ThrowingCallable check = - () -> - tradeService.verifyOrder( - new MarketOrder( - OrderType.BID, new BigDecimal("1000001"), CurrencyPair.BTC_USD, new Date())); - - assertThatThrownBy(check) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Quantity to high"); - } - - @Test - public void cannotPlaceAskMarketOrderWithAmountToLow() { - ThrowingCallable check = - () -> - tradeService.verifyOrder( - new MarketOrder( - OrderType.ASK, new BigDecimal("0.00001"), CurrencyPair.BTC_USD, new Date())); - - assertThatThrownBy(check) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Quantity to low"); - } - - @Test - public void cannotPlaceAskMarketOrderWithAmountToHigh() { - ThrowingCallable check = - () -> - tradeService.verifyOrder( - new MarketOrder( - OrderType.ASK, new BigDecimal("1001"), CurrencyPair.BTC_USD, new Date())); - - assertThatThrownBy(check) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Quantity to high"); - } -} diff --git a/xchange-lgo/src/test/resources/logback.xml b/xchange-lgo/src/test/resources/logback.xml deleted file mode 100644 index a3416282901..00000000000 --- a/xchange-lgo/src/test/resources/logback.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - %d{HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{36} - %msg %xEx%n - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/currency/example-currencies-data.json b/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/currency/example-currencies-data.json deleted file mode 100644 index b3146918a4b..00000000000 --- a/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/currency/example-currencies-data.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "currencies": [ - { - "name": "Bitcoin", - "code": "BTC", - "decimals": 8 - }, - { - "name": "United States Dollar", - "code": "USD", - "decimals": 4 - } - ] -} \ No newline at end of file diff --git a/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/key/index.txt b/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/key/index.txt deleted file mode 100644 index 043da5400f5..00000000000 --- a/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/key/index.txt +++ /dev/null @@ -1 +0,0 @@ -7b5dd30f-47cc-4c72-938b-199b13bc6f72 2019-07-16T09:13:54Z 2019-07-16T10:13:54Z true684700ae-8bc7-4315-8aec-b69ca778339a 2019-07-16T10:03:54Z 2019-07-16T11:03:54Z false \ No newline at end of file diff --git a/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/marketdata/example-orderbook-data.json b/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/marketdata/example-orderbook-data.json deleted file mode 100644 index 2135a8aea63..00000000000 --- a/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/marketdata/example-orderbook-data.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "batch_id": 10, - "product_id": "BTC-USD", - "bids": [ - [ - "2896.6000", - "8.35030000" - ], - [ - "1850.0000", - "931.83050000" - ] - ], - "asks": [ - [ - "2921.9000", - "4.44440000" - ], - [ - "2926.5000", - "8.38460000" - ] - ] -} \ No newline at end of file diff --git a/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/marketdata/example-pricehistory-data.json b/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/marketdata/example-pricehistory-data.json deleted file mode 100644 index 1010ae43c26..00000000000 --- a/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/marketdata/example-pricehistory-data.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "prices": [ - ["2019-12-20T15:00:00Z", "4396.7000", "4654.4000", "4592.6000", "4531.6000", "485.35050000"], - ["2019-12-20T16:00:00Z", "4114.1000", "4526.5000", "4486.2000", "4192.1000", "518.80760000"] - ] -} \ No newline at end of file diff --git a/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/product/example-products-data.json b/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/product/example-products-data.json deleted file mode 100644 index 80416bc9a6c..00000000000 --- a/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/product/example-products-data.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "products": [ - { - "id": "BTC-USD", - "total": { - "limits": { - "min": "10", - "max": "50000000" - } - }, - "base": { - "id": "BTC", - "limits": { - "min": "0.001", - "max": "1000" - } - }, - "quote": { - "id": "USD", - "increment": "0.10", - "limits": { - "min": "10", - "max": "1000000" - } - } - } - ] -} \ No newline at end of file diff --git a/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/trade/example-trades-data.json b/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/trade/example-trades-data.json deleted file mode 100644 index bcccf7cc04d..00000000000 --- a/xchange-lgo/src/test/resources/org/knowm/xchange/lgo/trade/example-trades-data.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "result": { - "trades": [ - { - "id": "2477363", - "order_id": "156104504046400001", - "product_id": "BTC-USD", - "price": "2410.9000", - "quantity": "0.00829566", - "creation_date": "2019-06-20T15:37:21.855Z", - "fees": "0.0100", - "side": "B", - "liquidity": "T" - }, - { - "id": "2", - "order_id": "155180383648300001", - "product_id": "BTC-USD", - "price": "3854.0000", - "quantity": "0.00500000", - "creation_date": "2019-03-05T16:37:17.220Z", - "fees": "0.0096", - "side": "S", - "liquidity": "T" - } - ] - }, - "next_page": "aGVsbG8=" -} diff --git a/xchange-lgo/src/test/resources/private_key.pem b/xchange-lgo/src/test/resources/private_key.pem deleted file mode 100644 index 371aadee11a..00000000000 --- a/xchange-lgo/src/test/resources/private_key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC6Ucf/BAiT+Wg4 -tiPaSrLK57HDrMJeP6t7BqXWRxfxYG6Cvtq6RvYO9bX1THcjk0gR6N6iCU26cAFM -O1FRs6r3RPe47lh+4FipH7HSmT5UqjsPr0xrfczt8qbGMa1Ywn4VKz1MqsMU4EfK -5YOA7ddzibICAN1QYObJB14DoZeeFqErXjSnBVQZ7lfUIaESED4oV/0NLXbePKfv -QnSk1AVPMLzJxmkmOWw2lu1Mc176YJZOiEN2xDEjZMvyIkT2m+2bJKtKiQ5Rvlu7 -iOI9orSM5QMFCFNdz4wq0SoJEGjrumVRvEAzlXpEnZfmrt3ze86ZUJA/J6pKPULN -eqkshc+tAgMBAAECgf9nWPWWfqZDbhRhYKaCbuy9n8b6wtkNbkOv+gAC22xsdxDV -dQfeS34wzhof9kofcZKIXKMhPgffYkFWB5ETwJUUkyzVZ1+vAMItDWeVaWspi0M3 -cATzmtQRKIdZaDS/ByLomxNlc1LCQaWQ5b4LxeG8NKSId/JKo3VgDLYZTYjMJs1I -dbpwwyTz0EVXDZjIqz6UNV5E7UoMTVqU2l6xNa86YsqYt7w1vY/IwvPjbFL2Ba8x -7bcUBLdOSXfCDEisN1rtvTMat02dMnYmowhzxnpgJrqjAIEEhJ+8pDHL9tK9Hqnn -hQgeSqMgFzR6v08MtjAySIFxn1q2WejCcsdkb4kCgYEA9anWi5UU503W7a77VXe3 -8F+F/Fq21Owx+rEuKuwySvmHoroyAgY9J7018mk0J/48xBrVvtZoRQ9dTTjarhUU -zC3UvUB2aO6fpj9KHtA9srdGSJqHrgvP6D227R0DwLbHJ/gta0SOrwbutF4VzbP0 -0ALtOrNtf+4MLiFbi1BCusMCgYEAwii4UOlkjcMnPMw6PXlqR+3c6jO774MA8CgS -kqdciqwRoU3CrZC0kQygjYwIv05x+0ZsXsFKQ9Ts3GOeDJFNY964Qw3UnZSyZ1Y1 -au29eIxfcOH5LkyM5/k+awFlriahYypaqlGZQ0cwGJcbP3zJRRAhKsUvtmBUBD9O -0m3nRM8CgYEAvK/LYwCJwrNNztekodvHQvALuG1wmpAkPzoRjNRIOL/6BuneeSGT -nU89/UgC0Gj9AV7fJ6oFAm4vqp1tkWINzFmzWf0GNch6hTV9V7d4fCk66Y8PgYX/ -FZE5TFwJwt5gj3mWYRqSQSsg8xaExq9e7NoingCsrSMI5fGnH5Tw/AMCgYEAntPG -q1GxUxJAh8idH+qxmXOoUuHNLEnjO5HcV6GW302RAn3k8iy8uSc2M3RJN43JSf86 -6Wx+/uwwcrz+7lLylu77lsa6lcmtA0GPYxBl/TX/YQ1J1KkEX0MR32D+N68cOE3O -ayNjF5klbAg4XwAKeXePWjiCJlO4htzu8s668BsCgYAX3fiZW3mgMdOS39iyn+tB -0mPBNv9jqt14hegHc5c8Euco8UkawdYp8NToMRusBl4cm02fzCvbY3mCO6lbP0rA -xhr5KrKh4j6rdAlr4ysRgntch6rmkSm6tBiOwKgwgmXgA1UjV6IzS097pnhvt+Y+ -E+i//AKDfWhBlxhoslETDg== ------END PRIVATE KEY----- diff --git a/xchange-stream-lgo/.gitignore b/xchange-stream-lgo/.gitignore deleted file mode 100644 index 8412f3d0539..00000000000 --- a/xchange-stream-lgo/.gitignore +++ /dev/null @@ -1 +0,0 @@ -src/test/resources/example \ No newline at end of file diff --git a/xchange-stream-lgo/pom.xml b/xchange-stream-lgo/pom.xml deleted file mode 100644 index 219b3af756c..00000000000 --- a/xchange-stream-lgo/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - 4.0.0 - - - org.knowm.xchange - xchange-parent - 5.2.2-SNAPSHOT - - xchange-stream-lgo - - XChange LGO Stream - - - - org.knowm.xchange - xchange-lgo - ${project.parent.version} - - - org.knowm.xchange - xchange-stream-core - ${project.parent.version} - - - org.knowm.xchange - xchange-stream-service-netty - ${project.parent.version} - - - org.mockito - mockito-core - - - diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoAdapter.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoAdapter.java deleted file mode 100644 index eec1244bbd1..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoAdapter.java +++ /dev/null @@ -1,150 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import static java.util.stream.Collectors.toList; - -import info.bitrich.xchangestream.lgo.domain.LgoBatchOrderEvent; -import info.bitrich.xchangestream.lgo.domain.LgoMatchOrderEvent; -import info.bitrich.xchangestream.lgo.domain.LgoPendingOrderEvent; -import info.bitrich.xchangestream.lgo.dto.LgoTrade; -import info.bitrich.xchangestream.lgo.dto.LgoUserSnapshotData; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import org.knowm.xchange.currency.Currency; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; -import org.knowm.xchange.dto.account.Balance; -import org.knowm.xchange.dto.marketdata.Trade; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.MarketOrder; -import org.knowm.xchange.dto.trade.UserTrade; - -public class LgoAdapter { - - static String channelName(String name, CurrencyPair currencyPair) { - return name + "-" + currencyPair.base.toString() + "-" + currencyPair.counter.toString(); - } - - public static Trade adaptTrade(CurrencyPair currencyPair, LgoTrade lgoTrade) { - return new Trade.Builder() - .type(parseTradeType(lgoTrade)) - .originalAmount(lgoTrade.getQuantity()) - .currencyPair(currencyPair) - .price(lgoTrade.getPrice()) - .timestamp(lgoTrade.getCreationTime()) - .id(lgoTrade.getId()) - .build(); - } - - static List adaptBalances(List> data) { - return data.stream() - .map( - balance -> { - Currency currency = Currency.getInstance(balance.get(0)); - BigDecimal available = new BigDecimal(balance.get(1)); - BigDecimal escrow = new BigDecimal(balance.get(2)); - BigDecimal total = available.add(escrow); - return new Balance.Builder() - .currency(currency) - .total(total) - .available(available) - .frozen(escrow) - .build(); - }) - .collect(toList()); - } - - private static Order.OrderType parseTradeType(LgoTrade lgoTrade) { - // the XChange API requires the taker order type whereas the LGO API gives the maker order type - return lgoTrade.getSide().equals("B") ? Order.OrderType.ASK : Order.OrderType.BID; - } - - private static Order.OrderType parseOrderType(String side) { - return side.equals("B") ? Order.OrderType.BID : Order.OrderType.ASK; - } - - static Collection adaptOrdersSnapshot( - List orderEvents, CurrencyPair currencyPair) { - return orderEvents.stream() - .map( - orderEvent -> { - Order.OrderStatus status = - orderEvent.getQuantity().equals(orderEvent.getRemainingQuantity()) - ? Order.OrderStatus.NEW - : Order.OrderStatus.PARTIALLY_FILLED; - return new LimitOrder.Builder(parseOrderType(orderEvent.getSide()), currencyPair) - .id(orderEvent.getOrderId()) - .userReference(null) - .originalAmount(orderEvent.getQuantity()) - .remainingAmount(orderEvent.getRemainingQuantity()) - .limitPrice(orderEvent.getPrice()) - .orderStatus(status) - .timestamp(orderEvent.getOrderCreationTime()) - .build(); - }) - .collect(toList()); - } - - public static Order adaptPendingOrder( - LgoPendingOrderEvent orderEvent, CurrencyPair currencyPair) { - if (orderEvent.getOrderType().equals("L")) { - return adaptPendingLimitOrder(orderEvent, currencyPair); - } - return adaptPendingMarketOrder(orderEvent, currencyPair); - } - - private static LimitOrder adaptPendingLimitOrder( - LgoPendingOrderEvent orderEvent, CurrencyPair currencyPair) { - return new LimitOrder.Builder(orderEvent.getSide(), currencyPair) - .id(orderEvent.getOrderId()) - .originalAmount(orderEvent.getInitialAmount()) - .remainingAmount(orderEvent.getInitialAmount()) - .limitPrice(orderEvent.getLimitPrice()) - .orderStatus(Order.OrderStatus.PENDING_NEW) - .timestamp(orderEvent.getTime()) - .build(); - } - - private static MarketOrder adaptPendingMarketOrder( - LgoPendingOrderEvent orderEvent, CurrencyPair currencyPair) { - return new MarketOrder.Builder(orderEvent.getSide(), currencyPair) - .id(orderEvent.getOrderId()) - .originalAmount(orderEvent.getInitialAmount()) - .cumulativeAmount(BigDecimal.ZERO) - .orderStatus(Order.OrderStatus.PENDING_NEW) - .timestamp(orderEvent.getTime()) - .build(); - } - - static List adaptOrderEvent( - List data, Long batchId, List openOrders) { - data.forEach( - e -> { - e.setBatchId(batchId); - if ("match".equals(e.getType())) { - LgoMatchOrderEvent matchEvent = (LgoMatchOrderEvent) e; - Optional matchedOrder = - openOrders.stream() - .filter(order -> order.getId().equals(e.getOrderId())) - .findFirst(); - matchEvent.setOrderType(matchedOrder.map(Order::getType).orElse(null)); - } - }); - return data; - } - - static UserTrade adaptUserTrade(CurrencyPair currencyPair, LgoMatchOrderEvent event) { - return UserTrade.builder() - .type(event.getOrderType()) - .originalAmount(event.getFilledQuantity()) - .currencyPair(currencyPair) - .price(event.getTradePrice()) - .timestamp(event.getTime()) - .id(event.getTradeId()) - .orderId(event.getOrderId()) - .feeAmount(event.getFees()) - .feeCurrency(currencyPair.counter) - .build(); - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoLevel2BatchSubscription.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoLevel2BatchSubscription.java deleted file mode 100644 index 4db4157e7d6..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoLevel2BatchSubscription.java +++ /dev/null @@ -1,73 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import com.fasterxml.jackson.databind.ObjectMapper; -import info.bitrich.xchangestream.lgo.domain.LgoGroupedLevel2Update; -import info.bitrich.xchangestream.lgo.dto.LgoLevel2Update; -import info.bitrich.xchangestream.service.netty.StreamingObjectMapperHelper; -import io.reactivex.rxjava3.core.Observable; -import java.io.IOException; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.marketdata.OrderBook; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -class LgoLevel2BatchSubscription { - - private final LgoStreamingService service; - private final Observable subscription; - private static final Logger LOGGER = LoggerFactory.getLogger(LgoLevel2BatchSubscription.class); - private CurrencyPair currencyPair; - - static LgoLevel2BatchSubscription create(LgoStreamingService service, CurrencyPair currencyPair) { - return new LgoLevel2BatchSubscription(service, currencyPair); - } - - private LgoLevel2BatchSubscription(LgoStreamingService service, CurrencyPair currencyPair) { - this.service = service; - this.currencyPair = currencyPair; - subscription = createSubscription(); - } - - Observable getSubscription() { - return subscription; - } - - private Observable createSubscription() { - final ObjectMapper mapper = StreamingObjectMapperHelper.getObjectMapper(); - return service - .subscribeChannel(LgoAdapter.channelName("level2", currencyPair)) - .map(s -> mapper.treeToValue(s, LgoLevel2Update.class)) - .scan( - new LgoGroupedLevel2Update(), - (acc, s) -> { - if (s.getType().equals("snapshot")) { - acc.applySnapshot(s.getBatchId(), currencyPair, s.getData()); - return acc; - } - if (acc.getLastBatchId() + 1 != s.getBatchId()) { - LOGGER.warn( - "Wrong batch id. Expected {} got {}.", - acc.getLastBatchId() + 1, - s.getBatchId()); - acc.markDirty(); - resubscribe(); - return acc; - } - acc.applyUpdate(s.getBatchId(), currencyPair, s.getData()); - return acc; - }) - .filter(LgoGroupedLevel2Update::isValid) - .map(LgoGroupedLevel2Update::orderBook) - .share(); - } - - private void resubscribe() { - try { - String channelName = LgoAdapter.channelName("level2", currencyPair); - service.sendMessage(service.getUnsubscribeMessage(channelName)); - service.sendMessage(service.getSubscribeMessage(channelName)); - } catch (IOException e) { - LOGGER.warn("Error resubscribing", e); - } - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingAccountService.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingAccountService.java deleted file mode 100644 index 2c9fce22467..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingAccountService.java +++ /dev/null @@ -1,62 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import com.fasterxml.jackson.databind.ObjectMapper; -import info.bitrich.xchangestream.core.StreamingAccountService; -import info.bitrich.xchangestream.lgo.domain.LgoGroupedBalanceUpdate; -import info.bitrich.xchangestream.lgo.dto.LgoBalanceUpdate; -import info.bitrich.xchangestream.service.netty.StreamingObjectMapperHelper; -import io.reactivex.rxjava3.core.Observable; -import java.util.List; -import org.knowm.xchange.currency.Currency; -import org.knowm.xchange.dto.account.Balance; -import org.knowm.xchange.dto.account.Wallet; - -public class LgoStreamingAccountService implements StreamingAccountService { - - private static final String CHANNEL_NAME = "balance"; - private final LgoStreamingService service; - private volatile Observable subscription = null; - - public LgoStreamingAccountService(LgoStreamingService lgoStreamingService) { - service = lgoStreamingService; - } - - @Override - public Observable getBalanceChanges(Currency currency, Object... args) { - ensureSubscription(); - return subscription.map(u -> u.getWallet().get(currency)); - } - - public Observable getWallet() { - ensureSubscription(); - return subscription.map(u -> Wallet.Builder.from(u.getWallet().values()).build()); - } - - private void ensureSubscription() { - if (subscription == null) { - createSubscription(); - } - } - - private synchronized void createSubscription() { - if (subscription != null) { - return; - } - final ObjectMapper mapper = StreamingObjectMapperHelper.getObjectMapper(); - subscription = - service - .subscribeChannel(CHANNEL_NAME) - .map(s -> mapper.treeToValue(s, LgoBalanceUpdate.class)) - .scan( - new LgoGroupedBalanceUpdate(), - (acc, s) -> { - List updatedBalances = LgoAdapter.adaptBalances(s.getData()); - if (s.getType().equals("snapshot")) { - return acc.applySnapshot(s.getSeq(), updatedBalances); - } - return acc.applyUpdate(s.getSeq(), updatedBalances); - }) - .skip(1) // skips first element for it's just the empty initial accumulator - .share(); - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingExchange.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingExchange.java deleted file mode 100644 index ccd34bc5636..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingExchange.java +++ /dev/null @@ -1,88 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import info.bitrich.xchangestream.core.ProductSubscription; -import info.bitrich.xchangestream.core.StreamingExchange; -import info.bitrich.xchangestream.core.StreamingMarketDataService; -import info.bitrich.xchangestream.service.netty.ConnectionStateModel.State; -import io.reactivex.rxjava3.core.Completable; -import io.reactivex.rxjava3.core.Observable; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.lgo.LgoEnv; -import org.knowm.xchange.lgo.LgoExchange; -import org.knowm.xchange.lgo.service.LgoKeyService; -import org.knowm.xchange.lgo.service.LgoSignatureService; - -public class LgoStreamingExchange extends LgoExchange implements StreamingExchange { - - private LgoStreamingService streamingService; - private LgoStreamingMarketDataService marketDataService; - private LgoStreamingAccountService accountService; - private LgoStreamingTradeService tradeService; - - @Override - protected void initServices() { - super.initServices(); - streamingService = createStreamingService(); - marketDataService = new LgoStreamingMarketDataService(streamingService); - accountService = new LgoStreamingAccountService(streamingService); - tradeService = - new LgoStreamingTradeService( - streamingService, - new LgoKeyService(getExchangeSpecification()), - LgoSignatureService.createInstance(getExchangeSpecification()), - getNonceFactory()); - } - - private LgoStreamingService createStreamingService() { - String apiUrl = - getExchangeSpecification().getExchangeSpecificParameters().get(LgoEnv.WS_URL).toString(); - LgoStreamingService streamingService = - new LgoStreamingService(this.getSignatureService(), apiUrl); - applyStreamingSpecification(getExchangeSpecification(), streamingService); - return streamingService; - } - - @Override - public void applySpecification(ExchangeSpecification exchangeSpecification) { - super.applySpecification(exchangeSpecification); - initServices(); - } - - @Override - public Completable connect(ProductSubscription... args) { - return streamingService.connect(); - } - - @Override - public Completable disconnect() { - return streamingService.disconnect(); - } - - @Override - public boolean isAlive() { - return streamingService.isSocketOpen(); - } - - @Override - public StreamingMarketDataService getStreamingMarketDataService() { - return marketDataService; - } - - @Override - public LgoStreamingAccountService getStreamingAccountService() { - return accountService; - } - - @Override - public LgoStreamingTradeService getStreamingTradeService() { - return tradeService; - } - - @Override - public Observable connectionStateObservable() { - return streamingService.subscribeConnectionState(); - } - - @Override - public void useCompressedMessages(boolean compressedMessages) {} -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingMarketDataService.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingMarketDataService.java deleted file mode 100644 index 21940e39779..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingMarketDataService.java +++ /dev/null @@ -1,44 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import info.bitrich.xchangestream.core.StreamingMarketDataService; -import io.reactivex.rxjava3.core.Observable; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.marketdata.OrderBook; -import org.knowm.xchange.dto.marketdata.Trade; - -public class LgoStreamingMarketDataService implements StreamingMarketDataService { - - private final LgoStreamingService service; - private final Map level2Subscriptions = - new ConcurrentHashMap<>(); - private final Map tradeSubscriptions = - new ConcurrentHashMap<>(); - - LgoStreamingMarketDataService(LgoStreamingService lgoStreamingService) { - service = lgoStreamingService; - } - - @Override - public Observable getOrderBook(CurrencyPair currencyPair, Object... args) { - return level2Subscriptions - .computeIfAbsent(currencyPair, this::createLevel2Subscription) - .getSubscription(); - } - - private LgoLevel2BatchSubscription createLevel2Subscription(CurrencyPair currencyPair) { - return LgoLevel2BatchSubscription.create(service, currencyPair); - } - - @Override - public Observable getTrades(CurrencyPair currencyPair, Object... args) { - return tradeSubscriptions - .computeIfAbsent(currencyPair, this::createTradeSubscription) - .getSubscription(); - } - - private LgoTradeBatchSubscription createTradeSubscription(CurrencyPair currencyPair) { - return LgoTradeBatchSubscription.create(service, currencyPair); - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingService.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingService.java deleted file mode 100644 index c5892074dba..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingService.java +++ /dev/null @@ -1,52 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import static info.bitrich.xchangestream.service.netty.StreamingObjectMapperHelper.getObjectMapper; - -import com.fasterxml.jackson.databind.JsonNode; -import info.bitrich.xchangestream.lgo.dto.LgoSubscription; -import info.bitrich.xchangestream.service.netty.JsonNettyStreamingService; -import io.netty.handler.codec.http.DefaultHttpHeaders; -import java.io.IOException; -import java.time.Duration; -import org.knowm.xchange.lgo.service.LgoSignatureService; - -public class LgoStreamingService extends JsonNettyStreamingService { - - private final LgoSignatureService signatureService; - private final String apiUrl; - - LgoStreamingService(LgoSignatureService signatureService, String apiUrl) { - super(apiUrl, Integer.MAX_VALUE, Duration.ofSeconds(10), Duration.ofSeconds(15), 1); - this.apiUrl = apiUrl; - this.signatureService = signatureService; - } - - @Override - protected String getChannelNameFromMessage(JsonNode message) { - String channel = message.get("channel").asText(); - if (channel.equals("trades") || channel.equals("level2") || channel.equals("user")) { - return channel + "-" + message.get("product_id").textValue(); - } - return channel; - } - - @Override - public String getSubscribeMessage(String channelName, Object... args) throws IOException { - return getObjectMapper().writeValueAsString(LgoSubscription.subscribe(channelName)); - } - - @Override - public String getUnsubscribeMessage(String channelName, Object... args) throws IOException { - return getObjectMapper().writeValueAsString(LgoSubscription.unsubscribe(channelName)); - } - - @Override - protected DefaultHttpHeaders getCustomHeaders() { - DefaultHttpHeaders headers = super.getCustomHeaders(); - String timestamp = String.valueOf(System.currentTimeMillis()); - headers.add("X-LGO-DATE", timestamp); - String auth = signatureService.digestSignedUrlHeader(this.apiUrl, timestamp); - headers.add("Authorization", auth); - return headers; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingTradeService.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingTradeService.java deleted file mode 100644 index 0db78aa8d1c..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoStreamingTradeService.java +++ /dev/null @@ -1,198 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import info.bitrich.xchangestream.core.StreamingTradeService; -import info.bitrich.xchangestream.lgo.domain.LgoGroupedUserUpdate; -import info.bitrich.xchangestream.lgo.domain.LgoMatchOrderEvent; -import info.bitrich.xchangestream.lgo.domain.LgoOrderEvent; -import info.bitrich.xchangestream.lgo.dto.LgoAckUpdate; -import info.bitrich.xchangestream.lgo.dto.LgoSocketPlaceOrder; -import info.bitrich.xchangestream.service.netty.StreamingObjectMapperHelper; -import io.reactivex.rxjava3.core.Observable; -import java.io.IOException; -import java.util.Collection; -import java.util.Date; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.MarketOrder; -import org.knowm.xchange.dto.trade.OpenOrders; -import org.knowm.xchange.dto.trade.UserTrade; -import org.knowm.xchange.lgo.LgoAdapters; -import org.knowm.xchange.lgo.dto.key.LgoKey; -import org.knowm.xchange.lgo.dto.order.LgoEncryptedOrder; -import org.knowm.xchange.lgo.dto.order.LgoOrderSignature; -import org.knowm.xchange.lgo.dto.order.LgoPlaceCancelOrder; -import org.knowm.xchange.lgo.dto.order.LgoPlaceOrder; -import org.knowm.xchange.lgo.service.CryptoUtils; -import org.knowm.xchange.lgo.service.LgoKeyService; -import org.knowm.xchange.lgo.service.LgoSignatureService; -import si.mazi.rescu.SynchronizedValueFactory; - -public class LgoStreamingTradeService implements StreamingTradeService { - - private final LgoStreamingService streamingService; - private final LgoKeyService keyService; - private final LgoSignatureService signatureService; - private final SynchronizedValueFactory nonceFactory; - private final Map batchSubscriptions = - new ConcurrentHashMap<>(); - private Observable afrSubscription; - - LgoStreamingTradeService( - LgoStreamingService streamingService, - LgoKeyService keyService, - LgoSignatureService signatureService, - SynchronizedValueFactory nonceFactory) { - this.streamingService = streamingService; - this.keyService = keyService; - this.signatureService = signatureService; - this.nonceFactory = nonceFactory; - } - - /** {@inheritDoc} First sent orders will be current open orders. */ - @Override - public Observable getOrderChanges(CurrencyPair currencyPair, Object... args) { - return getOrderBatchChanges(currencyPair).flatMap(Observable::fromIterable); - } - - /** - * Get an up-to-date view of all your open orders after each LGO batch execution. First sending - * will be the actual open orders list. - */ - public Observable getOpenOrders(CurrencyPair currencyPair) { - return getOrderUpdates(currencyPair) - .map( - u -> - u.getAllOpenOrders().values().stream() - .filter(order -> order instanceof LimitOrder) - .map(order -> (LimitOrder) order) - .collect(Collectors.toList())) - .map(OpenOrders::new); - } - - /** - * Receive all updated orders, for each LGO batches. First sending will be the actual open orders - * list. - */ - public Observable> getOrderBatchChanges(CurrencyPair currencyPair) { - return getOrderUpdates(currencyPair).map(LgoGroupedUserUpdate::getUpdatedOrders); - } - - private Observable getOrderUpdates(CurrencyPair currencyPair) { - return batchSubscriptions - .computeIfAbsent(currencyPair, this::createBatchSubscription) - .getPublisher(); - } - - private LgoUserBatchSubscription createBatchSubscription(CurrencyPair currencyPair) { - return LgoUserBatchSubscription.create(streamingService, currencyPair); - } - - @Override - public Observable getUserTrades(CurrencyPair currencyPair, Object... args) { - return getRawBatchOrderEvents(currencyPair) - .filter(lgoOrderEvent -> "match".equals(lgoOrderEvent.getType())) - .map( - matchEvent -> LgoAdapter.adaptUserTrade(currencyPair, (LgoMatchOrderEvent) matchEvent)); - } - - /** - * Receive all events for the selected currency pairs. Merges batch order events and ack (AFR) - * events. - */ - public Observable getRawAllOrderEvents(Collection currencyPairs) { - Observable ackObservable = getRawReceivedOrderEvents(); - return currencyPairs.stream() - .map(this::getRawBatchOrderEvents) - .reduce(Observable::mergeWith) - .map(ackObservable::mergeWith) - .orElse(ackObservable); - } - - /** - * Get ack for your placed orders. "received" events indicate the orderId associated to your - * order, if you set a reference on order placement you will have it in the event. "failed" events - * indicate that the order could not be read or was invalid and not added to a batch. - */ - public Observable getRawReceivedOrderEvents() { - if (afrSubscription == null) { - createAfrSubscription(); - } - return afrSubscription; - } - - private void createAfrSubscription() { - final ObjectMapper mapper = StreamingObjectMapperHelper.getObjectMapper(); - afrSubscription = - streamingService - .subscribeChannel("afr") - .map(s -> mapper.treeToValue(s, LgoAckUpdate.class)) - .map(LgoAckUpdate::getData) - .flatMap(Observable::fromIterable) - .share(); - } - - /** - * Get all events of your orders happened during batch execution, for a currency pair. "pending" - * events indicate that the order was added to a batch and received by the execution engine. - * "invalid" events indicate that the order was not suitable for execution. "match" events - * indicate that the order did match against another order. "open" events indicate that the order - * entered the order book. "done" events indicate that the order was filled, canceled or rejected. - */ - public Observable getRawBatchOrderEvents(CurrencyPair currencyPair) { - return getOrderUpdates(currencyPair) - .map(LgoGroupedUserUpdate::getEvents) - .flatMap(Observable::fromIterable); - } - - /** - * Place a market order - * - * @return the order reference - */ - public String placeMarketOrder(MarketOrder marketOrder) throws IOException { - Long ref = nonceFactory.createValue(); - LgoPlaceOrder lgoOrder = LgoAdapters.adaptEncryptedMarketOrder(marketOrder); - return placeOrder(ref, lgoOrder); - } - - /** - * Place a limit order - * - * @return the order reference - */ - public String placeLimitOrder(LimitOrder limitOrder) throws IOException { - Long ref = nonceFactory.createValue(); - LgoPlaceOrder lgoOrder = LgoAdapters.adaptLimitOrder(limitOrder); - return placeOrder(ref, lgoOrder); - } - - /** - * Place a cancel order - * - * @return true - */ - public boolean cancelOrder(String orderId) throws IOException { - Long ref = nonceFactory.createValue(); - LgoPlaceCancelOrder lgoOrder = new LgoPlaceCancelOrder(ref, orderId, new Date().toInstant()); - placeOrder(ref, lgoOrder); - return true; - } - - private String placeOrder(Long ref, LgoPlaceOrder lgoOrder) throws JsonProcessingException { - LgoKey lgoKey = keyService.selectKey(); - String encryptedOrder = CryptoUtils.encryptOrder(lgoKey, lgoOrder); - LgoOrderSignature signature = signatureService.signOrder(encryptedOrder); - LgoSocketPlaceOrder placeOrder = - new LgoSocketPlaceOrder( - new LgoEncryptedOrder(lgoKey.getId(), encryptedOrder, signature, ref)); - String payload = StreamingObjectMapperHelper.getObjectMapper().writeValueAsString(placeOrder); - streamingService.sendMessage(payload); - return ref.toString(); - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoTradeBatchSubscription.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoTradeBatchSubscription.java deleted file mode 100644 index 15a99e5044e..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoTradeBatchSubscription.java +++ /dev/null @@ -1,72 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import com.fasterxml.jackson.databind.ObjectMapper; -import info.bitrich.xchangestream.lgo.domain.LgoGroupedTradeUpdate; -import info.bitrich.xchangestream.lgo.dto.LgoTradesUpdate; -import info.bitrich.xchangestream.service.netty.StreamingObjectMapperHelper; -import io.reactivex.rxjava3.core.Observable; -import java.io.IOException; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.marketdata.Trade; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -class LgoTradeBatchSubscription { - - private final LgoStreamingService service; - private final CurrencyPair currencyPair; - private final Observable subscription; - private static final Logger LOGGER = LoggerFactory.getLogger(LgoTradeBatchSubscription.class); - - static LgoTradeBatchSubscription create(LgoStreamingService service, CurrencyPair currencyPair) { - return new LgoTradeBatchSubscription(service, currencyPair); - } - - private LgoTradeBatchSubscription(LgoStreamingService service, CurrencyPair currencyPair) { - this.service = service; - this.currencyPair = currencyPair; - subscription = createTradeSubscription(); - } - - private Observable createTradeSubscription() { - final ObjectMapper mapper = StreamingObjectMapperHelper.getObjectMapper(); - Observable observable = - service - .subscribeChannel(LgoAdapter.channelName("trades", currencyPair)) - .map(s -> mapper.treeToValue(s, LgoTradesUpdate.class)) - .scan( - new LgoGroupedTradeUpdate(currencyPair), - (acc, s) -> { - if ("snapshot".equals(s.getType())) { - acc.apply(s.getBatchId(), s.getTrades()); - return acc; - } - if (acc.getLastBatchId() + 1 != s.getBatchId()) { - LOGGER.warn( - "Wrong batchId. Expected {} got {}.", - acc.getLastBatchId() + 1, - s.getBatchId()); - resubscribe(); - } - acc.apply(s.getBatchId(), s.getTrades()); - return acc; - }) - .skip(1) - .flatMap(acc -> Observable.fromIterable(acc.getTrades())); - return observable; - } - - private void resubscribe() { - String channelName = LgoAdapter.channelName("trades", currencyPair); - try { - service.sendMessage(service.getUnsubscribeMessage(channelName)); - service.sendMessage(service.getSubscribeMessage(channelName)); - } catch (IOException e) { - LOGGER.error("Error resubscribing", e); - } - } - - Observable getSubscription() { - return subscription; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoUserBatchSubscription.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoUserBatchSubscription.java deleted file mode 100644 index 98fbfb0afaa..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/LgoUserBatchSubscription.java +++ /dev/null @@ -1,103 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import static java.util.stream.Collectors.toConcurrentMap; - -import com.fasterxml.jackson.databind.ObjectMapper; -import info.bitrich.xchangestream.lgo.domain.LgoBatchOrderEvent; -import info.bitrich.xchangestream.lgo.domain.LgoGroupedUserUpdate; -import info.bitrich.xchangestream.lgo.dto.LgoUserMessage; -import info.bitrich.xchangestream.lgo.dto.LgoUserSnapshot; -import info.bitrich.xchangestream.lgo.dto.LgoUserUpdate; -import info.bitrich.xchangestream.service.netty.StreamingObjectMapperHelper; -import io.reactivex.rxjava3.core.Observable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentMap; -import java.util.stream.Collectors; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.MarketOrder; - -class LgoUserBatchSubscription { - - private final Observable downstream; - private final LgoStreamingService streamingService; - private final CurrencyPair currencyPair; - - static LgoUserBatchSubscription create( - LgoStreamingService streamingService, CurrencyPair currencyPair) { - return new LgoUserBatchSubscription(streamingService, currencyPair); - } - - private LgoUserBatchSubscription( - LgoStreamingService streamingService, CurrencyPair currencyPair) { - this.streamingService = streamingService; - this.currencyPair = currencyPair; - downstream = createSubscription(); - } - - Observable getPublisher() { - return downstream; - } - - private Observable createSubscription() { - final ObjectMapper mapper = StreamingObjectMapperHelper.getObjectMapper(); - return streamingService - .subscribeChannel(LgoAdapter.channelName("user", currencyPair)) - .map(s -> mapper.treeToValue(s, LgoUserMessage.class)) - .scan( - new LgoGroupedUserUpdate(), - (acc, s) -> { - List events = new ArrayList<>(); - if (s.getType().equals("update")) { - LgoUserUpdate userUpdate = (LgoUserUpdate) s; - List updates = - updateAllOrders( - currencyPair, userUpdate.getOrderEvents(), acc.getAllOpenOrders()); - events.addAll( - LgoAdapter.adaptOrderEvent( - userUpdate.getOrderEvents(), s.getBatchId(), updates)); - return new LgoGroupedUserUpdate( - acc.getAllOpenOrders(), updates, events, s.getBatchId(), s.getType()); - } else { - Collection allOrders = - handleUserSnapshot(currencyPair, (LgoUserSnapshot) s); - ConcurrentMap ordersById = - allOrders.stream().collect(toConcurrentMap(LimitOrder::getId, this::copyOrder)); - return new LgoGroupedUserUpdate( - ordersById, new ArrayList<>(allOrders), events, s.getBatchId(), s.getType()); - } - }) - .skip(1) // skips the first element, for this is the empty accumulator - .share(); - } - - private List updateAllOrders( - CurrencyPair currencyPair, - List orderEvents, - Map allOpenOrders) { - return orderEvents.stream() - .map(orderEvent -> orderEvent.applyOnOrders(currencyPair, allOpenOrders)) - .map(this::copyOrder) - .collect(Collectors.toList()); - } - - private Collection handleUserSnapshot(CurrencyPair currencyPair, LgoUserSnapshot s) { - return LgoAdapter.adaptOrdersSnapshot(s.getSnapshotData(), currencyPair); - } - - private Order copyOrder(Order order) { - Order copy = - order instanceof LimitOrder - ? LimitOrder.Builder.from(order).build() - : MarketOrder.Builder.from(order).build(); - // because actual released version of xchange-core has buggy Builder.from methods - copy.setFee(order.getFee()); - copy.setCumulativeAmount(order.getCumulativeAmount()); - // https://github.com/knowm/XChange/pull/3163 - return copy; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoAckOrderEvent.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoAckOrderEvent.java deleted file mode 100644 index 006e21e36f1..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoAckOrderEvent.java +++ /dev/null @@ -1,10 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import java.util.Date; - -public class LgoAckOrderEvent extends LgoOrderEvent { - - protected LgoAckOrderEvent(String type, String orderId, Date time) { - super(type, orderId, time); - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoBatchOrderEvent.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoBatchOrderEvent.java deleted file mode 100644 index ff7f3af5537..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoBatchOrderEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import java.util.Date; -import java.util.Map; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; - -public abstract class LgoBatchOrderEvent extends LgoOrderEvent { - - /** - * Identifier of the batch where the event happened. Null in the case of a type=received event. - * Not null otherwise - */ - private Long batchId; - - protected LgoBatchOrderEvent(String type, String orderId, Date time) { - super(type, orderId, time); - } - - public LgoBatchOrderEvent(Long batchId, String type, String orderId, Date time) { - super(type, orderId, time); - this.batchId = batchId; - } - - public Long getBatchId() { - return batchId; - } - - public void setBatchId(long batchId) { - this.batchId = batchId; - } - - public abstract Order applyOnOrders(CurrencyPair currencyPair, Map allOrders); -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoDoneOrderEvent.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoDoneOrderEvent.java deleted file mode 100644 index 22d558aeb95..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoDoneOrderEvent.java +++ /dev/null @@ -1,63 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import java.util.Date; -import java.util.Map; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; - -/** Order left orderbook */ -public class LgoDoneOrderEvent extends LgoBatchOrderEvent { - - /** Reason of done status (rejected, canceled, canceledBySelfTradePrevention, filled) */ - private final String reason; - - /** Amount canceled (base currency) when reason=canceledBySelfTradePrevention */ - private final BigDecimal canceled; - - public LgoDoneOrderEvent( - Long batchId, String type, String orderId, Date time, String reason, BigDecimal canceled) { - super(batchId, type, orderId, time); - this.reason = reason; - this.canceled = canceled; - } - - public LgoDoneOrderEvent( - @JsonProperty("type") String type, - @JsonProperty("order_id") String orderId, - @JsonProperty("time") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - Date time, - @JsonProperty("reason") String reason, - @JsonProperty("canceled") BigDecimal canceled) { - super(type, orderId, time); - this.reason = reason; - this.canceled = canceled; - } - - public String getReason() { - return reason; - } - - public BigDecimal getCanceled() { - return canceled; - } - - @Override - public Order applyOnOrders(CurrencyPair currencyPair, Map allOrders) { - Order doneOrder = allOrders.remove(getOrderId()); - if ("canceledBySelfTradePrevention".equals(reason) || "canceled".equals(reason)) { - doneOrder.setOrderStatus( - doneOrder.getStatus() == Order.OrderStatus.PARTIALLY_FILLED - ? Order.OrderStatus.PARTIALLY_CANCELED - : Order.OrderStatus.CANCELED); - } else if ("filled".equals(reason)) { - doneOrder.setOrderStatus(Order.OrderStatus.FILLED); - } else { - doneOrder.setOrderStatus(Order.OrderStatus.REJECTED); - } - return doneOrder; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoFailedOrderEvent.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoFailedOrderEvent.java deleted file mode 100644 index f6f3e9b4360..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoFailedOrderEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Date; - -/** Order could not be added to a batch. No batchId for this event. */ -public class LgoFailedOrderEvent extends LgoAckOrderEvent { - - /** Reference set by the trader */ - private final String reference; - - /** - * Reason of failure (InvalidQuantity, InvalidPrice, InvalidAmount, InvalidPriceIncrement, - * InvalidProduct, InsufficientFunds) - */ - private final String reason; - - public LgoFailedOrderEvent( - @JsonProperty("order_id") String orderId, - @JsonProperty("reference") String reference, - @JsonProperty("type") String type, - @JsonProperty("time") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - Date time, - @JsonProperty("reason") String reason) { - super(type, orderId, time); - this.reference = reference; - this.reason = reason; - } - - public String getReference() { - return reference; - } - - public String getReason() { - return reason; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedBalanceUpdate.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedBalanceUpdate.java deleted file mode 100644 index e7f5958b1d8..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedBalanceUpdate.java +++ /dev/null @@ -1,32 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import org.knowm.xchange.currency.Currency; -import org.knowm.xchange.dto.account.Balance; - -public class LgoGroupedBalanceUpdate { - - private final Map wallet = new ConcurrentHashMap<>(); - private long seq; - - public LgoGroupedBalanceUpdate applySnapshot(long seq, List updatedBalances) { - wallet.clear(); - return applyUpdate(seq, updatedBalances); - } - - public LgoGroupedBalanceUpdate applyUpdate(long seq, List updatedBalances) { - this.seq = seq; - updatedBalances.forEach(b -> wallet.put(b.getCurrency(), b)); - return this; - } - - public long getSeq() { - return seq; - } - - public Map getWallet() { - return wallet; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedLevel2Update.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedLevel2Update.java deleted file mode 100644 index c7106f8afc7..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedLevel2Update.java +++ /dev/null @@ -1,71 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import info.bitrich.xchangestream.lgo.dto.LgoLevel2Data; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; -import org.knowm.xchange.dto.marketdata.OrderBook; -import org.knowm.xchange.dto.marketdata.OrderBookUpdate; - -public class LgoGroupedLevel2Update { - - private final OrderBook orderBook = new OrderBook(null, new ArrayList<>(), new ArrayList<>()); - private long lastBatchId; - private boolean dirty = true; - - public void applySnapshot(long batchId, CurrencyPair currencyPair, LgoLevel2Data data) { - dirty = false; - applyUpdate(batchId, currencyPair, data); - } - - public void applyUpdate(long batchId, CurrencyPair currencyPair, LgoLevel2Data data) { - lastBatchId = batchId; - updateL2Book(currencyPair, data); - } - - private void updateL2Book(CurrencyPair currencyPair, LgoLevel2Data data) { - Stream asksUpdates = - adaptLevel2Update(data, Order.OrderType.ASK, currencyPair); - Stream bidsUpdate = adaptLevel2Update(data, Order.OrderType.BID, currencyPair); - asksUpdates.forEach(orderBook::update); - bidsUpdate.forEach(orderBook::update); - } - - private Stream adaptLevel2Update( - LgoLevel2Data data, Order.OrderType type, CurrencyPair currencyPair) { - switch (type) { - case BID: - return data.getBids().stream().map(value -> toBookUpdate(type, currencyPair, value)); - case ASK: - return data.getAsks().stream().map(value -> toBookUpdate(type, currencyPair, value)); - default: - return Stream.empty(); - } - } - - private OrderBookUpdate toBookUpdate( - Order.OrderType type, CurrencyPair currencyPair, List value) { - BigDecimal price = new BigDecimal(value.get(0)); - BigDecimal quantity = new BigDecimal(value.get(1)); - return new OrderBookUpdate(type, null, currencyPair, price, null, quantity); - } - - public void markDirty() { - dirty = true; - } - - public boolean isValid() { - return !dirty; - } - - public long getLastBatchId() { - return lastBatchId; - } - - public OrderBook orderBook() { - return orderBook; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedTradeUpdate.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedTradeUpdate.java deleted file mode 100644 index c31ad8da613..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedTradeUpdate.java +++ /dev/null @@ -1,36 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import static java.util.stream.Collectors.toList; - -import info.bitrich.xchangestream.lgo.LgoAdapter; -import info.bitrich.xchangestream.lgo.dto.LgoTrade; -import java.util.List; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.marketdata.Trade; - -public class LgoGroupedTradeUpdate { - - private long lastBatchId; - private CurrencyPair currencyPair; - private List trades; - - public LgoGroupedTradeUpdate(CurrencyPair currencyPair) { - this.currencyPair = currencyPair; - } - - public void apply(long batchId, List trades) { - this.lastBatchId = batchId; - this.trades = - trades.stream() - .map(lgoTrade -> LgoAdapter.adaptTrade(currencyPair, lgoTrade)) - .collect(toList()); - } - - public long getLastBatchId() { - return lastBatchId; - } - - public List getTrades() { - return trades; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedUserUpdate.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedUserUpdate.java deleted file mode 100644 index c2b916c3f69..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoGroupedUserUpdate.java +++ /dev/null @@ -1,57 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import org.knowm.xchange.dto.Order; - -public class LgoGroupedUserUpdate { - - private final Map allOpenOrders; - private final List updatedOrders; - private final List events; - private final long batchId; - private final String type; - - public LgoGroupedUserUpdate() { - updatedOrders = Collections.emptyList(); - events = Collections.emptyList(); - batchId = 0; - type = ""; - allOpenOrders = new ConcurrentHashMap<>(); - } - - public LgoGroupedUserUpdate( - Map allOpenOrders, - List updatedOrders, - List events, - long batchId, - String type) { - this.allOpenOrders = allOpenOrders; - this.updatedOrders = updatedOrders; - this.events = events; - this.batchId = batchId; - this.type = type; - } - - public List getUpdatedOrders() { - return updatedOrders; - } - - public Map getAllOpenOrders() { - return allOpenOrders; - } - - public List getEvents() { - return events; - } - - public long getBatchId() { - return batchId; - } - - public String getType() { - return type; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoInvalidOrderEvent.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoInvalidOrderEvent.java deleted file mode 100644 index 700f1cbacdb..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoInvalidOrderEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Date; -import java.util.Map; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; - -/** Order was invalid */ -public class LgoInvalidOrderEvent extends LgoBatchOrderEvent { - - /** - * Reason of invalidity (InvalidQuantity, InvalidPrice, InvalidAmount, InvalidPriceIncrement, - * InvalidProduct, InsufficientFunds) - */ - private final String reason; - - public LgoInvalidOrderEvent(Long batchId, String type, String orderId, Date time, String reason) { - super(batchId, type, orderId, time); - this.reason = reason; - } - - public LgoInvalidOrderEvent( - @JsonProperty("type") String type, - @JsonProperty("order_id") String orderId, - @JsonProperty("time") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - Date time, - @JsonProperty("reason") String reason) { - super(type, orderId, time); - this.reason = reason; - } - - public String getReason() { - return reason; - } - - @Override - public Order applyOnOrders(CurrencyPair currencyPair, Map allOrders) { - Order doneOrder = allOrders.remove(getOrderId()); - doneOrder.setOrderStatus(Order.OrderStatus.REJECTED); - return doneOrder; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoMatchOrderEvent.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoMatchOrderEvent.java deleted file mode 100644 index 7a670bb3647..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoMatchOrderEvent.java +++ /dev/null @@ -1,118 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import java.util.Date; -import java.util.Map; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; - -/** Order matched against another order */ -public class LgoMatchOrderEvent extends LgoBatchOrderEvent { - /** Trade identifier */ - private final String tradeId; - - /** Trade price (quote currency) */ - private final BigDecimal tradePrice; - - /** Trade quantity (base currency) */ - private final BigDecimal filledQuantity; - - /** Remaining amount (base currency) */ - private final BigDecimal remainingQuantity; - - /** Fees (quote currency) */ - private final BigDecimal fees; - - /** Trade liquidity (T for taker, M for maker) */ - private final String liquidity; - - /** Trade type (BID/ASK): taker order type */ - private Order.OrderType orderType; - - public LgoMatchOrderEvent( - @JsonProperty("type") String type, - @JsonProperty("order_id") String orderId, - @JsonProperty("time") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - Date time, - @JsonProperty("trade_id") String tradeId, - @JsonProperty("price") BigDecimal price, - @JsonProperty("filled_quantity") BigDecimal filledQuantity, - @JsonProperty("remaining_quantity") BigDecimal remainingQuantity, - @JsonProperty("fees") BigDecimal fees, - @JsonProperty("liquidity") String liquidity) { - super(type, orderId, time); - this.tradeId = tradeId; - this.tradePrice = price; - this.filledQuantity = filledQuantity; - this.remainingQuantity = remainingQuantity; - this.fees = fees; - this.liquidity = liquidity; - } - - public LgoMatchOrderEvent( - Long batchId, - String type, - String orderId, - Date time, - String tradeId, - BigDecimal tradePrice, - BigDecimal filledQuantity, - BigDecimal remainingQuantity, - BigDecimal fees, - String liquidity, - Order.OrderType orderType) { - super(batchId, type, orderId, time); - this.tradeId = tradeId; - this.tradePrice = tradePrice; - this.filledQuantity = filledQuantity; - this.remainingQuantity = remainingQuantity; - this.fees = fees; - this.liquidity = liquidity; - this.orderType = orderType; - } - - public String getTradeId() { - return tradeId; - } - - public BigDecimal getTradePrice() { - return tradePrice; - } - - public BigDecimal getFilledQuantity() { - return filledQuantity; - } - - public BigDecimal getRemainingQuantity() { - return remainingQuantity; - } - - public BigDecimal getFees() { - return fees; - } - - public String getLiquidity() { - return liquidity; - } - - public Order.OrderType getOrderType() { - return orderType; - } - - public void setOrderType(Order.OrderType orderType) { - this.orderType = orderType; - } - - @Override - public Order applyOnOrders(CurrencyPair currencyPair, Map allOrders) { - Order matchedOrder = allOrders.get(getOrderId()); - matchedOrder.setOrderStatus(Order.OrderStatus.PARTIALLY_FILLED); - matchedOrder.setCumulativeAmount(matchedOrder.getOriginalAmount().subtract(remainingQuantity)); - BigDecimal fee = matchedOrder.getFee() == null ? fees : matchedOrder.getFee().add(fees); - matchedOrder.setFee(fee); - return matchedOrder; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoOpenOrderEvent.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoOpenOrderEvent.java deleted file mode 100644 index c033eae80ad..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoOpenOrderEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Date; -import java.util.Map; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; - -/** Order entered order book */ -public class LgoOpenOrderEvent extends LgoBatchOrderEvent { - - public LgoOpenOrderEvent(Long batchId, String type, String orderId, Date time) { - super(batchId, type, orderId, time); - } - - public LgoOpenOrderEvent( - @JsonProperty("type") String type, - @JsonProperty("order_id") String orderId, - @JsonProperty("time") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - Date time) { - super(type, orderId, time); - } - - @Override - public Order applyOnOrders(CurrencyPair currencyPair, Map allOrders) { - Order pendingOrder = allOrders.get(getOrderId()); - Order.OrderStatus status = - pendingOrder.getStatus().equals(Order.OrderStatus.PARTIALLY_FILLED) - ? pendingOrder.getStatus() - : Order.OrderStatus.NEW; - pendingOrder.setOrderStatus(status); - return pendingOrder; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoOrderEvent.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoOrderEvent.java deleted file mode 100644 index abe7a9ef3a6..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoOrderEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import java.util.Date; - -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true) -@JsonSubTypes({ - @JsonSubTypes.Type(value = LgoPendingOrderEvent.class, name = "pending"), - @JsonSubTypes.Type(value = LgoOpenOrderEvent.class, name = "open"), - @JsonSubTypes.Type(value = LgoMatchOrderEvent.class, name = "match"), - @JsonSubTypes.Type(value = LgoInvalidOrderEvent.class, name = "invalid"), - @JsonSubTypes.Type(value = LgoDoneOrderEvent.class, name = "done"), - @JsonSubTypes.Type(value = LgoReceivedOrderEvent.class, name = "received"), - @JsonSubTypes.Type(value = LgoFailedOrderEvent.class, name = "failed") -}) -public abstract class LgoOrderEvent { - - /** Type of the event (all events). */ - private final String type; - - /** Identifier of the order concerned by the event (all events) */ - private final String orderId; - - /** Date when the event happend, UTC (all events) */ - private final Date time; - - protected LgoOrderEvent(String type, String orderId, Date time) { - this.type = type; - this.orderId = orderId; - this.time = time; - } - - public String getType() { - return type; - } - - public String getOrderId() { - return orderId; - } - - public Date getTime() { - return time; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoPendingOrderEvent.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoPendingOrderEvent.java deleted file mode 100644 index 912fcbe121c..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoPendingOrderEvent.java +++ /dev/null @@ -1,82 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import info.bitrich.xchangestream.lgo.LgoAdapter; -import java.math.BigDecimal; -import java.util.Date; -import java.util.Map; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; - -/** Order was received by LGO execution engine in a batch */ -public class LgoPendingOrderEvent extends LgoBatchOrderEvent { - - /** Type of Order (L for LimitOrder, M for MarketOrder) when type=pending */ - private final String orderType; - - /** Limit price (quote currency) when type=pending and orderType=L */ - private final BigDecimal limitPrice; - - /** Side of the order: BID/ASK when type=pending */ - private final Order.OrderType side; - - /** Initial amount (base currency) when type=pending */ - private final BigDecimal initialAmount; - - public LgoPendingOrderEvent( - @JsonProperty("type") String type, - @JsonProperty("order_id") String orderId, - @JsonProperty("time") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - Date time, - @JsonProperty("order_type") String orderType, - @JsonProperty("price") BigDecimal price, - @JsonProperty("side") String side, - @JsonProperty("quantity") BigDecimal quantity) { - super(type, orderId, time); - this.orderType = orderType; - this.limitPrice = price; - this.side = side.equals("B") ? Order.OrderType.BID : Order.OrderType.ASK; - this.initialAmount = quantity; - } - - public LgoPendingOrderEvent( - Long batchId, - String type, - String orderId, - Date time, - String orderType, - BigDecimal limitPrice, - Order.OrderType side, - BigDecimal initialAmount) { - super(batchId, type, orderId, time); - this.orderType = orderType; - this.limitPrice = limitPrice; - this.side = side; - this.initialAmount = initialAmount; - } - - @Override - public Order applyOnOrders(CurrencyPair currencyPair, Map allOrders) { - Order order = LgoAdapter.adaptPendingOrder(this, currencyPair); - allOrders.put(order.getId(), order); - return order; - } - - public String getOrderType() { - return orderType; - } - - public BigDecimal getLimitPrice() { - return limitPrice; - } - - public Order.OrderType getSide() { - return side; - } - - public BigDecimal getInitialAmount() { - return initialAmount; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoReceivedOrderEvent.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoReceivedOrderEvent.java deleted file mode 100644 index b6a01c8fb69..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/domain/LgoReceivedOrderEvent.java +++ /dev/null @@ -1,26 +0,0 @@ -package info.bitrich.xchangestream.lgo.domain; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Date; - -/** Order was received by LGO platform. No batchId for this event. */ -public class LgoReceivedOrderEvent extends LgoAckOrderEvent { - - private final String reference; - - public LgoReceivedOrderEvent( - @JsonProperty("order_id") String orderId, - @JsonProperty("reference") String reference, - @JsonProperty("type") String type, - @JsonProperty("time") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - Date time) { - super(type, orderId, time); - this.reference = reference; - } - - public String getReference() { - return reference; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoAckUpdate.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoAckUpdate.java deleted file mode 100644 index 78facad8e00..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoAckUpdate.java +++ /dev/null @@ -1,33 +0,0 @@ -package info.bitrich.xchangestream.lgo.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import info.bitrich.xchangestream.lgo.domain.LgoAckOrderEvent; -import java.util.List; - -public class LgoAckUpdate { - - private final String type; - private final String channel; - private final List data; - - public LgoAckUpdate( - @JsonProperty("type") String type, - @JsonProperty("channel") String channel, - @JsonProperty("payload") List data) { - this.type = type; - this.channel = channel; - this.data = data; - } - - public String getType() { - return type; - } - - public String getChannel() { - return channel; - } - - public List getData() { - return data; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoBalanceUpdate.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoBalanceUpdate.java deleted file mode 100644 index 0392180c92c..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoBalanceUpdate.java +++ /dev/null @@ -1,38 +0,0 @@ -package info.bitrich.xchangestream.lgo.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class LgoBalanceUpdate { - private final long seq; - private final String type; - private final String channel; - private final List> data; - - public LgoBalanceUpdate( - @JsonProperty("seq") long seq, - @JsonProperty("type") String type, - @JsonProperty("channel") String channel, - @JsonProperty("payload") List> data) { - this.seq = seq; - this.type = type; - this.channel = channel; - this.data = data; - } - - public long getSeq() { - return seq; - } - - public String getType() { - return type; - } - - public String getChannel() { - return channel; - } - - public List> getData() { - return data; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoLevel2Data.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoLevel2Data.java deleted file mode 100644 index 283f5e5cc25..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoLevel2Data.java +++ /dev/null @@ -1,25 +0,0 @@ -package info.bitrich.xchangestream.lgo.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class LgoLevel2Data { - - private final List> bids; - private final List> asks; - - public LgoLevel2Data( - @JsonProperty("bids") List> bids, - @JsonProperty("asks") List> asks) { - this.bids = bids; - this.asks = asks; - } - - public List> getBids() { - return bids; - } - - public List> getAsks() { - return asks; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoLevel2Update.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoLevel2Update.java deleted file mode 100644 index 6729a6a98ce..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoLevel2Update.java +++ /dev/null @@ -1,45 +0,0 @@ -package info.bitrich.xchangestream.lgo.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class LgoLevel2Update { - - private final long batchId; - private final String type; - private final String channel; - private final String productId; - private final LgoLevel2Data data; - - public LgoLevel2Update( - @JsonProperty("batch_id") long batchId, - @JsonProperty("type") String type, - @JsonProperty("channel") String channel, - @JsonProperty("product_id") String productId, - @JsonProperty("payload") LgoLevel2Data data) { - this.batchId = batchId; - this.type = type; - this.channel = channel; - this.productId = productId; - this.data = data; - } - - public long getBatchId() { - return batchId; - } - - public String getType() { - return type; - } - - public String getChannel() { - return channel; - } - - public String getProductId() { - return productId; - } - - public LgoLevel2Data getData() { - return data; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoSocketPlaceOrder.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoSocketPlaceOrder.java deleted file mode 100644 index 0eacce5ea6c..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoSocketPlaceOrder.java +++ /dev/null @@ -1,20 +0,0 @@ -package info.bitrich.xchangestream.lgo.dto; - -import org.knowm.xchange.lgo.dto.order.LgoEncryptedOrder; - -public class LgoSocketPlaceOrder { - - private final LgoEncryptedOrder order; - - public LgoSocketPlaceOrder(LgoEncryptedOrder encryptedOrder) { - this.order = encryptedOrder; - } - - public String getType() { - return "placeorder"; - } - - public LgoEncryptedOrder getOrder() { - return order; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoSubscription.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoSubscription.java deleted file mode 100644 index 09888703805..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoSubscription.java +++ /dev/null @@ -1,43 +0,0 @@ -package info.bitrich.xchangestream.lgo.dto; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Collections; -import java.util.List; - -public class LgoSubscription { - public final String type; - public final List channels; - - public LgoSubscription(String type, Channel channels) { - this.type = type; - this.channels = Collections.singletonList(channels); - } - - public static LgoSubscription subscribe(String channelName) { - return new LgoSubscription("subscribe", new LgoSubscription.Channel(channelName)); - } - - public static LgoSubscription unsubscribe(String channelName) { - return new LgoSubscription("unsubscribe", new LgoSubscription.Channel(channelName)); - } - - @JsonInclude(JsonInclude.Include.NON_NULL) - public static class Channel { - public final String name; - - @JsonProperty("product_id") - public final String productId; - - public Channel(String channelName) { - if (channelName.contains("-")) { - String[] strings = channelName.split("-"); - this.name = strings[0]; - this.productId = strings[1] + "-" + strings[2]; - } else { - this.name = channelName; - this.productId = null; - } - } - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoTrade.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoTrade.java deleted file mode 100644 index 4a0b850a9c8..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoTrade.java +++ /dev/null @@ -1,50 +0,0 @@ -package info.bitrich.xchangestream.lgo.dto; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import java.util.Date; - -public class LgoTrade { - - private final String id; - private final String side; - private final BigDecimal price; - private final BigDecimal quantity; - private final Date creationTime; - - public LgoTrade( - @JsonProperty("trade_id") String id, - @JsonProperty("side") String side, - @JsonProperty("price") BigDecimal price, - @JsonProperty("quantity") BigDecimal quantity, - @JsonProperty("trade_creation_time") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - Date creationTime) { - this.id = id; - this.side = side; - this.price = price; - this.quantity = quantity; - this.creationTime = creationTime; - } - - public String getId() { - return id; - } - - public String getSide() { - return side; - } - - public BigDecimal getPrice() { - return price; - } - - public BigDecimal getQuantity() { - return quantity; - } - - public Date getCreationTime() { - return creationTime; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoTradesUpdate.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoTradesUpdate.java deleted file mode 100644 index 396a72b04bb..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoTradesUpdate.java +++ /dev/null @@ -1,46 +0,0 @@ -package info.bitrich.xchangestream.lgo.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class LgoTradesUpdate { - - private final long batchId; - private final String type; - private final String channel; - private final String productId; - private final List trades; - - public LgoTradesUpdate( - @JsonProperty("batch_id") long batchId, - @JsonProperty("type") String type, - @JsonProperty("channel") String channel, - @JsonProperty("product_id") String productId, - @JsonProperty("payload") List trades) { - this.batchId = batchId; - this.type = type; - this.channel = channel; - this.productId = productId; - this.trades = trades; - } - - public long getBatchId() { - return batchId; - } - - public String getType() { - return type; - } - - public String getChannel() { - return channel; - } - - public String getProductId() { - return productId; - } - - public List getTrades() { - return trades; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserMessage.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserMessage.java deleted file mode 100644 index 83ad016dc6f..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserMessage.java +++ /dev/null @@ -1,40 +0,0 @@ -package info.bitrich.xchangestream.lgo.dto; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true) -@JsonSubTypes({ - @JsonSubTypes.Type(value = LgoUserUpdate.class, name = "update"), - @JsonSubTypes.Type(value = LgoUserSnapshot.class, name = "snapshot") -}) -public class LgoUserMessage { - - private final long batchId; - private final String type; - private final String channel; - private final String productId; - - public LgoUserMessage(long batchId, String type, String channel, String productId) { - this.batchId = batchId; - this.type = type; - this.channel = channel; - this.productId = productId; - } - - public long getBatchId() { - return batchId; - } - - public String getType() { - return type; - } - - public String getChannel() { - return channel; - } - - public String getProductId() { - return productId; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserSnapshot.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserSnapshot.java deleted file mode 100644 index 8ffb3712955..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserSnapshot.java +++ /dev/null @@ -1,23 +0,0 @@ -package info.bitrich.xchangestream.lgo.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class LgoUserSnapshot extends LgoUserMessage { - - private final List snapshotData; - - public LgoUserSnapshot( - @JsonProperty("batch_id") long batchId, - @JsonProperty("type") String type, - @JsonProperty("channel") String channel, - @JsonProperty("product_id") String productId, - @JsonProperty("payload") List snapshotData) { - super(batchId, type, channel, productId); - this.snapshotData = snapshotData; - } - - public List getSnapshotData() { - return snapshotData; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserSnapshotData.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserSnapshotData.java deleted file mode 100644 index fa5fd7304f8..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserSnapshotData.java +++ /dev/null @@ -1,64 +0,0 @@ -package info.bitrich.xchangestream.lgo.dto; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import java.util.Date; - -public class LgoUserSnapshotData { - - private final String orderId; - private final String orderType; - private final BigDecimal price; - private final String side; - private final BigDecimal quantity; - private final BigDecimal remainingQuantity; - private final Date orderCreationTime; - - public LgoUserSnapshotData( - @JsonProperty("quantity") BigDecimal quantity, - @JsonProperty("price") BigDecimal price, - @JsonProperty("side") String side, - @JsonProperty("remaining_quantity") BigDecimal remainingQuantity, - @JsonProperty("order_id") String orderId, - @JsonProperty("order_type") String orderType, - @JsonProperty("order_creation_time") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - Date orderCreationTime) { - this.orderId = orderId; - this.orderType = orderType; - this.price = price; - this.side = side; - this.quantity = quantity; - this.remainingQuantity = remainingQuantity; - this.orderCreationTime = orderCreationTime; - } - - public String getOrderId() { - return orderId; - } - - public String getOrderType() { - return orderType; - } - - public BigDecimal getPrice() { - return price; - } - - public String getSide() { - return side; - } - - public BigDecimal getQuantity() { - return quantity; - } - - public BigDecimal getRemainingQuantity() { - return remainingQuantity; - } - - public Date getOrderCreationTime() { - return orderCreationTime; - } -} diff --git a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserUpdate.java b/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserUpdate.java deleted file mode 100644 index ad66816237d..00000000000 --- a/xchange-stream-lgo/src/main/java/info/bitrich/xchangestream/lgo/dto/LgoUserUpdate.java +++ /dev/null @@ -1,24 +0,0 @@ -package info.bitrich.xchangestream.lgo.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import info.bitrich.xchangestream.lgo.domain.LgoBatchOrderEvent; -import java.util.List; - -public class LgoUserUpdate extends LgoUserMessage { - - private final List orderEvents; - - public LgoUserUpdate( - @JsonProperty("batch_id") long batchId, - @JsonProperty("type") String type, - @JsonProperty("channel") String channel, - @JsonProperty("product_id") String productId, - @JsonProperty("payload") List orderEvents) { - super(batchId, type, channel, productId); - this.orderEvents = orderEvents; - } - - public List getOrderEvents() { - return orderEvents; - } -} diff --git a/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingAccountServiceTest.java b/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingAccountServiceTest.java deleted file mode 100644 index 99b3f9f32f6..00000000000 --- a/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingAccountServiceTest.java +++ /dev/null @@ -1,111 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.fasterxml.jackson.databind.JsonNode; -import io.reactivex.rxjava3.core.Observable; -import io.reactivex.rxjava3.observers.TestObserver; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.Arrays; -import org.junit.Test; -import org.knowm.xchange.currency.Currency; -import org.knowm.xchange.dto.account.Balance; -import org.knowm.xchange.dto.account.Wallet; - -public class LgoStreamingAccountServiceTest { - - @Test - public void it_gives_initial_wallet_snapshot() throws IOException { - JsonNode snapshot = TestUtils.getJsonContent("/account/balance-snapshot.json"); - LgoStreamingService streamingService = mock(LgoStreamingService.class); - LgoStreamingAccountService service = new LgoStreamingAccountService(streamingService); - Observable source = Observable.just(snapshot); - when(streamingService.subscribeChannel(anyString())).thenReturn(source); - - TestObserver wallet = service.getWallet().test(); - - verify(streamingService).subscribeChannel("balance"); - wallet.assertNoErrors(); - wallet.assertValueCount(1); - wallet - .values() - .contains( - buildWallet( - new Balance( - Currency.BTC, - new BigDecimal("2301.01329566"), - new BigDecimal("2297.01329566"), - new BigDecimal("4.00000000")), - new Balance( - Currency.USD, - new BigDecimal("453616.3125"), - new BigDecimal("453616.3125"), - new BigDecimal("0.0000")))); - } - - @Test - public void it_handles_update() throws IOException { - JsonNode snapshot = TestUtils.getJsonContent("/account/balance-snapshot.json"); - JsonNode update = TestUtils.getJsonContent("/account/balance-update.json"); - LgoStreamingService streamingService = mock(LgoStreamingService.class); - LgoStreamingAccountService service = new LgoStreamingAccountService(streamingService); - Observable source = Observable.just(snapshot, update); - when(streamingService.subscribeChannel(anyString())).thenReturn(source); - - service.getWallet().subscribe(); - - TestObserver wallet = service.getWallet().test(); - wallet.assertValueAt( - 1, - buildWallet( - new Balance( - Currency.BTC, - new BigDecimal("2299.01329566"), - new BigDecimal("2295.01329566"), - new BigDecimal("4.00000000")), - new Balance( - Currency.USD, - new BigDecimal("453616.3125"), - new BigDecimal("453616.3125"), - new BigDecimal("0.0000")))); - verify(streamingService).subscribeChannel("balance"); - } - - private Wallet buildWallet(Balance... balances) { - return Wallet.Builder.from(Arrays.asList(balances)).build(); - } - - @Test - public void it_connects_one_time_and_filters_by_currency() throws IOException { - JsonNode snapshot = TestUtils.getJsonContent("/account/balance-snapshot.json"); - JsonNode update = TestUtils.getJsonContent("/account/balance-update.json"); - LgoStreamingService streamingService = mock(LgoStreamingService.class); - LgoStreamingAccountService service = new LgoStreamingAccountService(streamingService); - when(streamingService.subscribeChannel(anyString())) - .thenReturn(Observable.just(snapshot, update)); - - TestObserver btcChanges = service.getBalanceChanges(Currency.BTC).test(); - TestObserver usdChanges = service.getBalanceChanges(Currency.USD).test(); - - verify(streamingService, times(1)).subscribeChannel("balance"); - btcChanges.assertValueAt( - 1, - new Balance( - Currency.BTC, - new BigDecimal("2299.01329566"), - new BigDecimal("2295.01329566"), - new BigDecimal("4.00000000"))); - usdChanges.assertValueAt( - 1, - new Balance( - Currency.USD, - new BigDecimal("453616.3125"), - new BigDecimal("453616.3125"), - new BigDecimal("0.0000"))); - } -} diff --git a/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingExchangeExample.java b/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingExchangeExample.java deleted file mode 100644 index 79a5b4afed0..00000000000 --- a/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingExchangeExample.java +++ /dev/null @@ -1,155 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import java.io.IOException; -import java.math.BigDecimal; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Collections; -import java.util.Date; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.currency.Currency; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.MarketOrder; -import org.knowm.xchange.lgo.LgoEnv; - -@Ignore -public class LgoStreamingExchangeExample { - - private LgoStreamingExchange exchange; - - // api key and secret key are expected to be in test resources under - // example directory - // this directory is added to .gitignore to avoid committing a real usable key - @Before - public void setUp() throws Exception { - exchange = new LgoStreamingExchange(); - ExchangeSpecification spec = LgoEnv.sandbox(); - spec.setSecretKey(readResource("/example/private_key.pem")); - spec.setApiKey(readResource("/example/api_key.txt")); - spec.setShouldLoadRemoteMetaData(false); - exchange.applySpecification(spec); - exchange.connect().blockingAwait(); - } - - private String readResource(String path) throws IOException { - try { - return new String( - Files.readAllBytes(Paths.get(getClass().getResource(path).toURI())), - StandardCharsets.UTF_8); - } catch (URISyntaxException e) { - return null; - } - } - - @Test - public void connectToMarketData() { - exchange - .getStreamingMarketDataService() - .getOrderBook(CurrencyPair.BTC_USD) - .blockingForEach(System.out::println); - } - - @Test - public void connectToTrades() { - exchange - .getStreamingMarketDataService() - .getTrades(CurrencyPair.BTC_USD) - .blockingForEach(System.out::println); - } - - @Test - public void connectToBalances() { - exchange.getStreamingAccountService().getWallet().blockingForEach(System.out::println); - } - - @Test - public void connectToBalance() { - exchange - .getStreamingAccountService() - .getBalanceChanges(Currency.BTC) - .blockingForEach(System.out::println); - } - - @Test - public void connectToUserTrades() { - exchange - .getStreamingTradeService() - .getUserTrades(CurrencyPair.BTC_USD) - .blockingSubscribe(System.out::println); - } - - @Test - public void connectToOpenOrders() { - exchange - .getStreamingTradeService() - .getOpenOrders(CurrencyPair.BTC_USD) - .blockingForEach(System.out::println); - } - - @Test - public void connectToOrderChanges() { - exchange - .getStreamingTradeService() - .getOrderChanges(CurrencyPair.BTC_USD) - .blockingForEach(System.out::println); - } - - @Test - public void connectToOrderBatchChanges() { - exchange - .getStreamingTradeService() - .getOrderBatchChanges(CurrencyPair.BTC_USD) - .blockingForEach(System.out::println); - } - - @Test - public void connectToOrderEvents() { - exchange - .getStreamingTradeService() - .getRawAllOrderEvents(Collections.singletonList(CurrencyPair.BTC_USD)) - .blockingForEach(System.out::println); - } - - @Test - public void placeLimitOrder() throws IOException { - String ref = - exchange - .getStreamingTradeService() - .placeLimitOrder( - new LimitOrder( - Order.OrderType.ASK, - new BigDecimal("0.5"), - CurrencyPair.BTC_USD, - null, - new Date(), - new BigDecimal("12000"))); - // System.out.println("Order was placed with reference: " + ref); - } - - @Test - public void placeMarketOrder() throws IOException { - String ref = - exchange - .getStreamingTradeService() - .placeMarketOrder( - new MarketOrder( - Order.OrderType.ASK, - new BigDecimal("0.5"), - CurrencyPair.BTC_USD, - null, - new Date())); - // System.out.println("Order was placed with reference: " + ref); - } - - @Test - public void cancelOrder() throws IOException { - exchange.getStreamingTradeService().cancelOrder("156406068135700001"); - } -} diff --git a/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingMarketDataServiceTest.java b/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingMarketDataServiceTest.java deleted file mode 100644 index 8ddb821406b..00000000000 --- a/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingMarketDataServiceTest.java +++ /dev/null @@ -1,118 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.fasterxml.jackson.databind.JsonNode; -import io.reactivex.rxjava3.core.Observable; -import java.io.IOException; -import java.math.BigDecimal; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.TimeZone; -import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration; -import org.junit.Before; -import org.junit.Test; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; -import org.knowm.xchange.dto.marketdata.OrderBook; -import org.knowm.xchange.dto.marketdata.Trade; -import org.knowm.xchange.dto.trade.LimitOrder; - -public class LgoStreamingMarketDataServiceTest { - - private final RecursiveComparisonConfiguration orderComparator = - new RecursiveComparisonConfiguration(); - private SimpleDateFormat dateFormat; - - @Before - public void setUp() { - dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - orderComparator.ignoreFields("userReference", "id"); - dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - } - - @Test - public void it_reads_trades() throws IOException, ParseException { - LgoStreamingService streamingService = mock(LgoStreamingService.class); - LgoStreamingMarketDataService service = new LgoStreamingMarketDataService(streamingService); - JsonNode message = TestUtils.getJsonContent("/marketdata/trades-update.json"); - when(streamingService.subscribeChannel(anyString())).thenReturn(Observable.just(message)); - - Observable trades = service.getTrades(CurrencyPair.BTC_USD); - - verify(streamingService).subscribeChannel("trades-BTC-USD"); - assertThat(trades.blockingFirst()) - .isEqualToComparingFieldByField( - new Trade.Builder() - .type(Order.OrderType.ASK) - .originalAmount(new BigDecimal("4.36920000")) - .currencyPair(CurrencyPair.BTC_USD) - .price(new BigDecimal("428.5000")) - .timestamp(dateFormat.parse("2019-07-19T12:25:01.596Z")) - .id("3128770") - .build()); - assertThat(trades.blockingLast()) - .isEqualToComparingFieldByField( - new Trade.Builder() - .type(Order.OrderType.BID) - .originalAmount(new BigDecimal("1.85390000")) - .currencyPair(CurrencyPair.BTC_USD) - .price(new BigDecimal("420.3000")) - .timestamp(dateFormat.parse("2019-07-19T12:25:05.860Z")) - .id("3128771") - .build()); - } - - @Test - public void it_reads_level2() throws IOException { - LgoStreamingService streamingService = mock(LgoStreamingService.class); - LgoStreamingMarketDataService service = new LgoStreamingMarketDataService(streamingService); - JsonNode snapshot = TestUtils.getJsonContent("/marketdata/level2-snapshot.json"); - JsonNode update = TestUtils.getJsonContent("/marketdata/level2-update.json"); - when(streamingService.subscribeChannel(anyString())) - .thenReturn(Observable.just(snapshot, update)); - - Observable orderBook = service.getOrderBook(CurrencyPair.BTC_USD); - - verify(streamingService).subscribeChannel("level2-BTC-USD"); - OrderBook firstBook = orderBook.blockingFirst(); - assertThat(firstBook.getAsks()) - .usingElementComparatorIgnoringFields("id", "userReference") - .contains(sellOrder("1111.1000", "9.39370000"), sellOrder("1115.9000", "0.88420000")); - assertThat(firstBook.getBids()) - .usingElementComparatorIgnoringFields("id", "userReference") - .contains(buyOrder("1089.1000", "0.10000000")); - OrderBook lastBook = orderBook.blockingLast(); - assertThat(lastBook.getBids()).isEmpty(); - assertThat(lastBook.getAsks()) - .usingElementComparatorIgnoringFields("id", "userReference") - .contains( - sellOrder("1111.1000", "0.10000000"), - sellOrder("1115.9000", "0.88420000"), - sellOrder("1116.9000", "0.20000000")); - } - - private LimitOrder sellOrder(String price, String quantity) { - return new LimitOrder( - Order.OrderType.ASK, - new BigDecimal(quantity), - CurrencyPair.BTC_USD, - null, - null, - new BigDecimal(price)); - } - - private LimitOrder buyOrder(String price, String quantity) { - return new LimitOrder( - Order.OrderType.BID, - new BigDecimal(quantity), - CurrencyPair.BTC_USD, - "0", - null, - new BigDecimal(price)); - } -} diff --git a/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingServiceTest.java b/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingServiceTest.java deleted file mode 100644 index 70008bad7ec..00000000000 --- a/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingServiceTest.java +++ /dev/null @@ -1,93 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import static info.bitrich.xchangestream.lgo.TestUtils.asJsonNode; -import static info.bitrich.xchangestream.lgo.TestUtils.getJsonContent; -import static org.assertj.core.api.Assertions.assertThat; - -import com.fasterxml.jackson.databind.JsonNode; -import java.io.IOException; -import org.junit.Before; -import org.junit.Test; -import org.knowm.xchange.ExchangeSpecification; -import org.knowm.xchange.lgo.LgoEnv; -import org.knowm.xchange.lgo.LgoEnv.SignatureService; -import org.knowm.xchange.lgo.service.LgoSignatureService; - -public class LgoStreamingServiceTest { - - private LgoStreamingService service; - - @Before - public void setUp() { - ExchangeSpecification env = LgoEnv.sandbox(); - env.getExchangeSpecificParameters() - .put(LgoEnv.SIGNATURE_SERVICE, SignatureService.PASSTHROUGHS); - service = new LgoStreamingService(LgoSignatureService.createInstance(env), "apiUrl"); - } - - @Test - public void it_returns_the_trades_subscribe_message() throws IOException { - String channelName = "trades-BTC-USD"; - - String subscribeMessage = service.getSubscribeMessage(channelName); - - assertThat(asJsonNode(subscribeMessage)) - .isEqualTo(getJsonContent("/subscribe/trades-subscribe.json")); - } - - @Test - public void it_returns_the_level2_subscribe_message() throws IOException { - String channelName = "level2-BTC-USD"; - - String subscribeMessage = service.getSubscribeMessage(channelName); - - assertThat(asJsonNode(subscribeMessage)) - .isEqualTo(getJsonContent("/subscribe/level2-subscribe.json")); - } - - @Test - public void it_returns_the_balance_subscribe_message() throws IOException { - String channelName = "balance"; - - String subscribeMessage = service.getSubscribeMessage(channelName); - - assertThat(asJsonNode(subscribeMessage)) - .isEqualTo(getJsonContent("/subscribe/balance-subscribe.json")); - } - - @Test - public void it_returns_the_right_channel_name_for_trades() throws IOException { - JsonNode message = getJsonContent("/marketdata/trades-update.json"); - - String name = service.getChannelNameFromMessage(message); - - assertThat(name).isEqualTo("trades-BTC-USD"); - } - - @Test - public void it_returns_the_right_channel_name_for_level2() throws IOException { - JsonNode message = getJsonContent("/marketdata/level2-snapshot.json"); - - String name = service.getChannelNameFromMessage(message); - - assertThat(name).isEqualTo("level2-BTC-USD"); - } - - @Test - public void it_returns_the_right_channel_name_for_balances() throws IOException { - JsonNode message = getJsonContent("/account/balance-snapshot.json"); - - String name = service.getChannelNameFromMessage(message); - - assertThat(name).isEqualTo("balance"); - } - - @Test - public void it_returns_the_right_channel_name_for_user() throws IOException { - JsonNode message = getJsonContent("/trade/orders-snapshot.json"); - - String name = service.getChannelNameFromMessage(message); - - assertThat(name).isEqualTo("user-BTC-USD"); - } -} diff --git a/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingTradeServiceTest.java b/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingTradeServiceTest.java deleted file mode 100644 index b090a6c00e9..00000000000 --- a/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/LgoStreamingTradeServiceTest.java +++ /dev/null @@ -1,428 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.fasterxml.jackson.databind.JsonNode; -import info.bitrich.xchangestream.lgo.domain.LgoDoneOrderEvent; -import info.bitrich.xchangestream.lgo.domain.LgoFailedOrderEvent; -import info.bitrich.xchangestream.lgo.domain.LgoInvalidOrderEvent; -import info.bitrich.xchangestream.lgo.domain.LgoOpenOrderEvent; -import info.bitrich.xchangestream.lgo.domain.LgoOrderEvent; -import info.bitrich.xchangestream.lgo.domain.LgoPendingOrderEvent; -import info.bitrich.xchangestream.lgo.domain.LgoReceivedOrderEvent; -import io.reactivex.rxjava3.core.Observable; -import java.io.IOException; -import java.math.BigDecimal; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.TimeZone; -import org.assertj.core.util.Lists; -import org.junit.Before; -import org.junit.Test; -import org.knowm.xchange.currency.Currency; -import org.knowm.xchange.currency.CurrencyPair; -import org.knowm.xchange.dto.Order; -import org.knowm.xchange.dto.trade.LimitOrder; -import org.knowm.xchange.dto.trade.OpenOrders; -import org.knowm.xchange.dto.trade.UserTrade; -import org.knowm.xchange.lgo.dto.key.LgoKey; -import org.knowm.xchange.lgo.dto.order.LgoOrderSignature; -import org.knowm.xchange.lgo.service.LgoKeyService; -import org.knowm.xchange.lgo.service.LgoSignatureService; -import org.mockito.ArgumentCaptor; -import si.mazi.rescu.SynchronizedValueFactory; - -public class LgoStreamingTradeServiceTest { - - private SimpleDateFormat dateFormat; - private LgoKeyService keyService; - private LgoSignatureService signatureService; - private LgoStreamingTradeService service; - private LgoStreamingService streamingService; - private SynchronizedValueFactory nonceFactory; - - @Before - public void setUp() { - dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - keyService = mock(LgoKeyService.class); - signatureService = mock(LgoSignatureService.class); - nonceFactory = mock(SynchronizedValueFactory.class); - streamingService = mock(LgoStreamingService.class); - service = - new LgoStreamingTradeService(streamingService, keyService, signatureService, nonceFactory); - } - - @Test - public void it_handles_open_orders_updates() throws IOException, ParseException { - JsonNode snapshot = TestUtils.getJsonContent("/trade/orders-snapshot.json"); - JsonNode update = TestUtils.getJsonContent("/trade/orders-update.json"); - when(streamingService.subscribeChannel(anyString())) - .thenReturn(Observable.just(snapshot, update)); - - Observable openOrders = service.getOpenOrders(CurrencyPair.BTC_USD); - - verify(streamingService).subscribeChannel("user-BTC-USD"); - Date date1 = dateFormat.parse("2019-07-23T15:36:14.304Z"); - Date date2 = dateFormat.parse("2019-07-18T12:24:21.891Z"); - Date date3 = dateFormat.parse("2019-07-24T08:37:19.116Z"); - LimitOrder order1 = - new LimitOrder( - Order.OrderType.ASK, - BigDecimal.ONE, - BigDecimal.ZERO, - CurrencyPair.BTC_USD, - "156389617430400001", - date1, - new BigDecimal(6000)); - order1.setOrderStatus(Order.OrderStatus.NEW); - LimitOrder order2 = - new LimitOrder( - Order.OrderType.ASK, - BigDecimal.ONE, - BigDecimal.ZERO, - CurrencyPair.BTC_USD, - "156345266189100001", - date2, - new BigDecimal(6000)); - order2.setOrderStatus(Order.OrderStatus.NEW); - LimitOrder order3 = - new LimitOrder( - Order.OrderType.BID, - new BigDecimal(2), - BigDecimal.ZERO, - CurrencyPair.BTC_USD, - "156395743911600001", - date3, - new BigDecimal(8000)); - order3.setOrderStatus(Order.OrderStatus.NEW); - // TODO fix this. - // assertThat(openOrders.blockingFirst()) - // .usingRecursiveComparison() - // .isEqualTo(new OpenOrders(Arrays.asList(order2, order1))); - // assertThat(openOrders.blockingLast()) - // .usingRecursiveComparison() - // .isEqualTo(new OpenOrders(Arrays.asList(order3, order1))); - } - - @Test - public void it_handles_order_changes() throws IOException, ParseException { - JsonNode snapshot = TestUtils.getJsonContent("/trade/order-changes-snapshot.json"); - JsonNode update = TestUtils.getJsonContent("/trade/order-changes-update.json"); - when(streamingService.subscribeChannel(anyString())) - .thenReturn(Observable.just(snapshot, update)); - - Observable observable = service.getOrderChanges(CurrencyPair.BTC_USD); - - verify(streamingService).subscribeChannel("user-BTC-USD"); - Date date1 = dateFormat.parse("2019-07-23T15:36:14.304Z"); - Date date2 = dateFormat.parse("2019-07-18T12:24:21.891Z"); - Date date3 = dateFormat.parse("2019-07-24T08:37:19.116Z"); - LimitOrder order1 = - createOrder( - Order.OrderType.ASK, - new BigDecimal("1.00000000"), - new BigDecimal("0.00000000"), - CurrencyPair.BTC_USD, - "156389617430400001", - date1, - new BigDecimal("6000.0000"), - Order.OrderStatus.NEW); - LimitOrder order2 = - createOrder( - Order.OrderType.ASK, - new BigDecimal("1.00000000"), - new BigDecimal("0.00000000"), - CurrencyPair.BTC_USD, - "156345266189100001", - date2, - new BigDecimal("6000.0000"), - Order.OrderStatus.NEW); - LimitOrder order2Matched = - createOrder( - Order.OrderType.ASK, - new BigDecimal("1.00000000"), - new BigDecimal("0.40000000"), - CurrencyPair.BTC_USD, - "156345266189100001", - date2, - new BigDecimal("6000.0000"), - Order.OrderStatus.PARTIALLY_FILLED); - order2Matched.setFee(new BigDecimal("0.2388")); - LimitOrder order2Matched2 = - createOrder( - Order.OrderType.ASK, - new BigDecimal("1.00000000"), - new BigDecimal("1.00000000"), - CurrencyPair.BTC_USD, - "156345266189100001", - date2, - new BigDecimal("6000.0000"), - Order.OrderStatus.PARTIALLY_FILLED); - order2Matched2.setFee(new BigDecimal("0.6988")); - LimitOrder order2Filled = - createOrder( - Order.OrderType.ASK, - new BigDecimal("1.00000000"), - new BigDecimal("1.00000000"), - CurrencyPair.BTC_USD, - "156345266189100001", - date2, - new BigDecimal("6000.0000"), - Order.OrderStatus.FILLED); - order2Filled.setFee(new BigDecimal("0.6988")); - LimitOrder order3Pending = - createOrder( - Order.OrderType.BID, - new BigDecimal("2.00000000"), - new BigDecimal("0.00000000"), - CurrencyPair.BTC_USD, - "156395743911600001", - date3, - new BigDecimal("8000.0000"), - Order.OrderStatus.PENDING_NEW); - LimitOrder order3Open = - createOrder( - Order.OrderType.BID, - new BigDecimal("2.00000000"), - new BigDecimal("0.00000000"), - CurrencyPair.BTC_USD, - "156395743911600001", - date3, - new BigDecimal("8000.0000"), - Order.OrderStatus.NEW); - - ArrayList orderChanges = Lists.newArrayList(observable.blockingIterable()); - assertThat(orderChanges).hasSize(7); - assertThat(orderChanges.get(0)).usingRecursiveComparison().isEqualTo(order1); - assertThat(orderChanges.get(1)).usingRecursiveComparison().isEqualTo(order2); - assertThat(orderChanges.get(2)).usingRecursiveComparison().isEqualTo(order3Pending); - assertThat(orderChanges.get(3)).usingRecursiveComparison().isEqualTo(order3Open); - assertThat(orderChanges.get(4)).usingRecursiveComparison().isEqualTo(order2Matched); - assertThat(orderChanges.get(5)).usingRecursiveComparison().isEqualTo(order2Matched2); - assertThat(orderChanges.get(6)).usingRecursiveComparison().isEqualTo(order2Filled); - } - - private LimitOrder createOrder( - Order.OrderType type, - BigDecimal originalAmount, - BigDecimal cumulativeAmount, - CurrencyPair pair, - String id, - Date timestamp, - BigDecimal limitPrice, - Order.OrderStatus status) { - return new LimitOrder.Builder(type, pair) - .id(id) - .userReference(null) - .originalAmount(originalAmount) - .cumulativeAmount(cumulativeAmount) - .limitPrice(limitPrice) - .orderStatus(status) - .averagePrice(null) - .timestamp(timestamp) - .fee(null) - .build(); - } - - @Test - public void it_handles_trades() throws IOException, ParseException { - JsonNode snapshot = TestUtils.getJsonContent("/trade/user-trades-snapshot.json"); - JsonNode update = TestUtils.getJsonContent("/trade/user-trades-update.json"); - when(streamingService.subscribeChannel(anyString())) - .thenReturn(Observable.just(snapshot, update)); - - Observable userTrades = service.getUserTrades(CurrencyPair.BTC_USD); - - verify(streamingService).subscribeChannel("user-BTC-USD"); - Date date = dateFormat.parse("2019-08-06T10:00:05.658Z"); - ArrayList trades = Lists.newArrayList(userTrades.blockingIterable()); - assertThat(trades).hasSize(1); - assertThat(trades.get(0)) - .usingRecursiveComparison() - .isEqualTo( - UserTrade.builder() - .type(Order.OrderType.ASK) - .originalAmount(new BigDecimal("0.50000000")) - .currencyPair(CurrencyPair.BTC_USD) - .price(new BigDecimal("955.3000")) - .timestamp(date) - .id("4441691") - .orderId("156508560418400001") - .feeAmount(new BigDecimal("0.2388")) - .feeCurrency(Currency.USD) - .build()); - } - - @Test - public void it_handles_orders_events() throws IOException, ParseException { - JsonNode snapshot = TestUtils.getJsonContent("/trade/order-events-snapshot.json"); - JsonNode update = TestUtils.getJsonContent("/trade/order-events-update.json"); - when(streamingService.subscribeChannel(anyString())) - .thenReturn(Observable.just(snapshot, update)); - - Observable events = service.getRawBatchOrderEvents(CurrencyPair.BTC_USD); - - verify(streamingService).subscribeChannel("user-BTC-USD"); - Date date1 = dateFormat.parse("2019-07-24T08:37:19.116Z"); - Date date2 = dateFormat.parse("2019-07-24T08:37:19.849Z"); - Date date3 = dateFormat.parse("2019-07-24T08:37:19.922Z"); - ArrayList lgoOrderEvents = Lists.newArrayList(events.blockingIterable()); - assertThat(lgoOrderEvents.get(0)) - .isEqualToComparingFieldByField( - new LgoPendingOrderEvent( - 6317543L, - "pending", - "156395743911600001", - date1, - "L", - new BigDecimal("8000.0000"), - Order.OrderType.BID, - new BigDecimal("2.00000000"))); - assertThat(lgoOrderEvents.get(1)) - .isEqualToComparingFieldByField( - new LgoOpenOrderEvent(6317543L, "open", "156395743911600001", date2)); - assertThat(lgoOrderEvents.get(2)) - .isEqualToComparingFieldByField( - new LgoPendingOrderEvent( - 6317543L, - "pending", - "156395743912700001", - date2, - "L", - new BigDecimal("8000.0001"), - Order.OrderType.BID, - new BigDecimal("2.00000000"))); - assertThat(lgoOrderEvents.get(3)) - .isEqualToComparingFieldByField( - new LgoInvalidOrderEvent( - 6317543L, "invalid", "156395743912700001", date2, "InvalidAmount")); - assertThat(lgoOrderEvents.get(4)) - .isEqualToComparingFieldByField( - new LgoDoneOrderEvent(6317543L, "done", "156345266189100001", date3, "canceled", null)); - } - - @Test - public void it_handles_orders_ack() throws IOException, ParseException { - JsonNode snapshot = TestUtils.getJsonContent("/trade/afr-snapshot.json"); - JsonNode update1 = TestUtils.getJsonContent("/trade/afr-update1.json"); - JsonNode update2 = TestUtils.getJsonContent("/trade/afr-update2.json"); - when(streamingService.subscribeChannel(anyString())) - .thenReturn(Observable.just(snapshot, update1, update2)); - - Observable events = service.getRawReceivedOrderEvents(); - - verify(streamingService).subscribeChannel("afr"); - Date date1 = dateFormat.parse("2019-07-24T13:42:34.970Z"); - Date date2 = dateFormat.parse("2019-07-24T13:42:35.698Z"); - ArrayList lgoOrderEvents = Lists.newArrayList(events.blockingIterable()); - assertThat(lgoOrderEvents.get(0)) - .isEqualToComparingFieldByField( - new LgoReceivedOrderEvent("156397575497000001", "plop", "received", date1)); - assertThat(lgoOrderEvents.get(1)) - .isEqualToComparingFieldByField( - new LgoFailedOrderEvent( - "156397575497000001", "plop", "failed", date2, "INVALID_PAYLOAD")); - } - - @Test - public void it_handles_all_order_events() throws IOException, ParseException { - JsonNode snapshotOrders = TestUtils.getJsonContent("/trade/all-orders-snapshot.json"); - JsonNode snapshotAFR = TestUtils.getJsonContent("/trade/all-afr-snapshot.json"); - JsonNode update1 = TestUtils.getJsonContent("/trade/all-afr-update.json"); - JsonNode update2 = TestUtils.getJsonContent("/trade/all-orders-update.json"); - when(streamingService.subscribeChannel("afr")) - .thenReturn(Observable.just(snapshotAFR, update1)); - when(streamingService.subscribeChannel("user-BTC-USD")) - .thenReturn(Observable.just(snapshotOrders, update2)); - - Observable events = - service.getRawAllOrderEvents(Collections.singletonList(CurrencyPair.BTC_USD)); - - verify(streamingService).subscribeChannel("afr"); - verify(streamingService).subscribeChannel("user-BTC-USD"); - Date date1 = dateFormat.parse("2019-07-25T07:16:21.600Z"); - Date date2 = dateFormat.parse("2019-07-25T07:16:22.959Z"); - ArrayList lgoOrderEvents = Lists.newArrayList(events.blockingIterable()); - assertThat(lgoOrderEvents.get(0)) - .isEqualToComparingFieldByField( - new LgoReceivedOrderEvent("156403898160000001", "0", "received", date1)); - assertThat(lgoOrderEvents.get(1)) - .isEqualToComparingFieldByField( - new LgoPendingOrderEvent( - 6393996L, - "pending", - "156403898160000001", - date1, - "L", - new BigDecimal("7000.0000"), - Order.OrderType.ASK, - new BigDecimal("3.00000000"))); - assertThat(lgoOrderEvents.get(2)) - .isEqualToComparingFieldByField( - new LgoOpenOrderEvent(6393996L, "open", "156403898160000001", date2)); - } - - @Test - public void it_places_a_limit_order() throws IOException, ParseException, URISyntaxException { - Date date = dateFormat.parse("2019-07-25T07:16:21.600Z"); - LimitOrder limitOrder = - new LimitOrder( - Order.OrderType.ASK, - new BigDecimal("0.5"), - CurrencyPair.BTC_USD, - null, - date, - new BigDecimal("12000")); - when(nonceFactory.createValue()).thenReturn(22L); - LgoKey key = - new LgoKey( - "abcdefg", - new Date().toInstant().minus(1, ChronoUnit.HOURS), - new Date().toInstant().plus(1, ChronoUnit.HOURS)); - - String utf8 = - new String( - Files.readAllBytes(Paths.get(getClass().getResource("/public.pem").toURI())), - StandardCharsets.UTF_8); - - key.setValue(parsePublicKey(utf8)); - when(keyService.selectKey()).thenReturn(key); - when(signatureService.signOrder(anyString())).thenReturn(new LgoOrderSignature("signed")); - doNothing().when(streamingService).sendMessage(anyString()); - - String ref = service.placeLimitOrder(limitOrder); - - verify(nonceFactory).createValue(); - verify(keyService).selectKey(); - ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); - verify(streamingService).sendMessage(captor.capture()); - assertThat(captor.getValue().contains("\"reference\":22")); - assertThat( - captor - .getValue() - .contains( - "\"signature\":{\"value\":\"signed\",\"source\":\"RSA\"},\"key_id\":\"abcdefg\"},\"type\":\"placeorder\"")); - assertThat(ref).isEqualTo("22"); - } - - private static String parsePublicKey(String key) { - return key.replaceAll("-----END PUBLIC KEY-----", "") - .replaceAll("-----BEGIN PUBLIC KEY-----", "") - .replaceAll("\n", "") - .replaceAll("\r", ""); - } -} diff --git a/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/TestUtils.java b/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/TestUtils.java deleted file mode 100644 index e560be744ad..00000000000 --- a/xchange-stream-lgo/src/test/java/info/bitrich/xchangestream/lgo/TestUtils.java +++ /dev/null @@ -1,20 +0,0 @@ -package info.bitrich.xchangestream.lgo; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; - -public class TestUtils { - - private static final ObjectMapper mapper = new ObjectMapper(); - - private TestUtils() {} - - public static JsonNode getJsonContent(String path) throws IOException { - return mapper.readTree(LgoStreamingAccountServiceTest.class.getResourceAsStream(path)); - } - - public static JsonNode asJsonNode(String jsonString) throws IOException { - return mapper.readTree(jsonString); - } -} diff --git a/xchange-stream-lgo/src/test/resources/account/balance-snapshot.json b/xchange-stream-lgo/src/test/resources/account/balance-snapshot.json deleted file mode 100644 index 910ac7b7181..00000000000 --- a/xchange-stream-lgo/src/test/resources/account/balance-snapshot.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "seq": 0, - "payload": [ - [ - "BTC", - "2297.01329566", - "4.00000000" - ], - [ - "USD", - "453616.3125", - "0.0000" - ] - ], - "type": "snapshot", - "channel": "balance" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/account/balance-update.json b/xchange-stream-lgo/src/test/resources/account/balance-update.json deleted file mode 100644 index faee53d5f1d..00000000000 --- a/xchange-stream-lgo/src/test/resources/account/balance-update.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "seq": 1, - "payload": [ - [ - "BTC", - "2295.01329566", - "4.00000000" - ] - ], - "type": "update", - "channel": "balance" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/logback.xml b/xchange-stream-lgo/src/test/resources/logback.xml deleted file mode 100644 index 5809b573500..00000000000 --- a/xchange-stream-lgo/src/test/resources/logback.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - %d{HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{36} - %msg %xEx%n - - - - - - - - - - - - - - diff --git a/xchange-stream-lgo/src/test/resources/marketdata/level2-snapshot.json b/xchange-stream-lgo/src/test/resources/marketdata/level2-snapshot.json deleted file mode 100644 index 00ea569aa66..00000000000 --- a/xchange-stream-lgo/src/test/resources/marketdata/level2-snapshot.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "payload": { - "asks": [ - [ - "1115.9000", - "0.88420000" - ], - [ - "1111.1000", - "9.39370000" - ] - ], - "bids": [ - [ - "1089.1000", - "0.10000000" - ] - ] - }, - "batch_id": 5898979, - "type": "snapshot", - "channel": "level2", - "product_id": "BTC-USD" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/marketdata/level2-update.json b/xchange-stream-lgo/src/test/resources/marketdata/level2-update.json deleted file mode 100644 index ff49cce709d..00000000000 --- a/xchange-stream-lgo/src/test/resources/marketdata/level2-update.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "payload": { - "asks": [ - [ - "1116.9000", - "0.20000000" - ], - [ - "1111.1000", - "0.10000000" - ] - ], - "bids": [ - [ - "1089.1000", - "0.00000000" - ] - ] - }, - "batch_id": 5898980, - "type": "update", - "channel": "level2", - "product_id": "BTC-USD" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/marketdata/trades-update.json b/xchange-stream-lgo/src/test/resources/marketdata/trades-update.json deleted file mode 100644 index 5fdc10b8481..00000000000 --- a/xchange-stream-lgo/src/test/resources/marketdata/trades-update.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "payload": [ - { - "quantity": "4.36920000", - "side": "B", - "trade_creation_time": "2019-07-19T12:25:01.596Z", - "price": "428.5000", - "trade_id": "3128770" - }, - { - "side": "S", - "quantity": "1.85390000", - "trade_id": "3128771", - "price": "420.3000", - "trade_creation_time": "2019-07-19T12:25:05.860Z" - } - ], - "batch_id": 5891632, - "type": "update", - "channel": "trades", - "product_id": "BTC-USD" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/private_key.pem b/xchange-stream-lgo/src/test/resources/private_key.pem deleted file mode 100644 index 371aadee11a..00000000000 --- a/xchange-stream-lgo/src/test/resources/private_key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC6Ucf/BAiT+Wg4 -tiPaSrLK57HDrMJeP6t7BqXWRxfxYG6Cvtq6RvYO9bX1THcjk0gR6N6iCU26cAFM -O1FRs6r3RPe47lh+4FipH7HSmT5UqjsPr0xrfczt8qbGMa1Ywn4VKz1MqsMU4EfK -5YOA7ddzibICAN1QYObJB14DoZeeFqErXjSnBVQZ7lfUIaESED4oV/0NLXbePKfv -QnSk1AVPMLzJxmkmOWw2lu1Mc176YJZOiEN2xDEjZMvyIkT2m+2bJKtKiQ5Rvlu7 -iOI9orSM5QMFCFNdz4wq0SoJEGjrumVRvEAzlXpEnZfmrt3ze86ZUJA/J6pKPULN -eqkshc+tAgMBAAECgf9nWPWWfqZDbhRhYKaCbuy9n8b6wtkNbkOv+gAC22xsdxDV -dQfeS34wzhof9kofcZKIXKMhPgffYkFWB5ETwJUUkyzVZ1+vAMItDWeVaWspi0M3 -cATzmtQRKIdZaDS/ByLomxNlc1LCQaWQ5b4LxeG8NKSId/JKo3VgDLYZTYjMJs1I -dbpwwyTz0EVXDZjIqz6UNV5E7UoMTVqU2l6xNa86YsqYt7w1vY/IwvPjbFL2Ba8x -7bcUBLdOSXfCDEisN1rtvTMat02dMnYmowhzxnpgJrqjAIEEhJ+8pDHL9tK9Hqnn -hQgeSqMgFzR6v08MtjAySIFxn1q2WejCcsdkb4kCgYEA9anWi5UU503W7a77VXe3 -8F+F/Fq21Owx+rEuKuwySvmHoroyAgY9J7018mk0J/48xBrVvtZoRQ9dTTjarhUU -zC3UvUB2aO6fpj9KHtA9srdGSJqHrgvP6D227R0DwLbHJ/gta0SOrwbutF4VzbP0 -0ALtOrNtf+4MLiFbi1BCusMCgYEAwii4UOlkjcMnPMw6PXlqR+3c6jO774MA8CgS -kqdciqwRoU3CrZC0kQygjYwIv05x+0ZsXsFKQ9Ts3GOeDJFNY964Qw3UnZSyZ1Y1 -au29eIxfcOH5LkyM5/k+awFlriahYypaqlGZQ0cwGJcbP3zJRRAhKsUvtmBUBD9O -0m3nRM8CgYEAvK/LYwCJwrNNztekodvHQvALuG1wmpAkPzoRjNRIOL/6BuneeSGT -nU89/UgC0Gj9AV7fJ6oFAm4vqp1tkWINzFmzWf0GNch6hTV9V7d4fCk66Y8PgYX/ -FZE5TFwJwt5gj3mWYRqSQSsg8xaExq9e7NoingCsrSMI5fGnH5Tw/AMCgYEAntPG -q1GxUxJAh8idH+qxmXOoUuHNLEnjO5HcV6GW302RAn3k8iy8uSc2M3RJN43JSf86 -6Wx+/uwwcrz+7lLylu77lsa6lcmtA0GPYxBl/TX/YQ1J1KkEX0MR32D+N68cOE3O -ayNjF5klbAg4XwAKeXePWjiCJlO4htzu8s668BsCgYAX3fiZW3mgMdOS39iyn+tB -0mPBNv9jqt14hegHc5c8Euco8UkawdYp8NToMRusBl4cm02fzCvbY3mCO6lbP0rA -xhr5KrKh4j6rdAlr4ysRgntch6rmkSm6tBiOwKgwgmXgA1UjV6IzS097pnhvt+Y+ -E+i//AKDfWhBlxhoslETDg== ------END PRIVATE KEY----- diff --git a/xchange-stream-lgo/src/test/resources/public.pem b/xchange-stream-lgo/src/test/resources/public.pem deleted file mode 100644 index 3eb2981def7..00000000000 --- a/xchange-stream-lgo/src/test/resources/public.pem +++ /dev/null @@ -1,6 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCe/x4rZs3IqEnNu7tgOZf2LcVO -Ki6PuWRkWn8J4E3LIzRVc+BEa4wSH+SeVwDfDCrAoemvLQuOsyJ1ArdMB1qpm18e -NucJQbPhIfgQtmJOPoqMuVSXYZ57+RpdpkZUV4w2OF45Esuv5xz0olSR6hjYf3Ne -eaeidIt74L9tV/pHEwIDAQAB ------END PUBLIC KEY----- diff --git a/xchange-stream-lgo/src/test/resources/subscribe/balance-subscribe.json b/xchange-stream-lgo/src/test/resources/subscribe/balance-subscribe.json deleted file mode 100644 index a43aabda2b2..00000000000 --- a/xchange-stream-lgo/src/test/resources/subscribe/balance-subscribe.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "subscribe", - "channels": [ - { - "name": "balance" - } - ] -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/subscribe/level2-subscribe.json b/xchange-stream-lgo/src/test/resources/subscribe/level2-subscribe.json deleted file mode 100644 index c7a676bbdf9..00000000000 --- a/xchange-stream-lgo/src/test/resources/subscribe/level2-subscribe.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "subscribe", - "channels": [ - { - "name": "level2", - "product_id": "BTC-USD" - } - ] -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/subscribe/trades-subscribe.json b/xchange-stream-lgo/src/test/resources/subscribe/trades-subscribe.json deleted file mode 100644 index 3e00d679883..00000000000 --- a/xchange-stream-lgo/src/test/resources/subscribe/trades-subscribe.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "subscribe", - "channels": [ - { - "name": "trades", - "product_id": "BTC-USD" - } - ] -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/afr-snapshot.json b/xchange-stream-lgo/src/test/resources/trade/afr-snapshot.json deleted file mode 100644 index 16e33be4954..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/afr-snapshot.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "payload": [], - "type": "snapshot", - "channel": "afr" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/afr-update1.json b/xchange-stream-lgo/src/test/resources/trade/afr-update1.json deleted file mode 100644 index 343c33aede5..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/afr-update1.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "payload": [ - { - "reference": "plop", - "time": "2019-07-24T13:42:34.970Z", - "type": "received", - "order_id": "156397575497000001" - } - ], - "type": "update", - "channel": "afr" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/afr-update2.json b/xchange-stream-lgo/src/test/resources/trade/afr-update2.json deleted file mode 100644 index d7e1c7c3a1d..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/afr-update2.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "payload": [ - { - "type": "failed", - "time": "2019-07-24T13:42:35.698Z", - "reference": "plop", - "reason": "INVALID_PAYLOAD", - "order_id": "156397575497000001" - } - ], - "type": "update", - "channel": "afr" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/all-afr-snapshot.json b/xchange-stream-lgo/src/test/resources/trade/all-afr-snapshot.json deleted file mode 100644 index 16e33be4954..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/all-afr-snapshot.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "payload": [], - "type": "snapshot", - "channel": "afr" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/all-afr-update.json b/xchange-stream-lgo/src/test/resources/trade/all-afr-update.json deleted file mode 100644 index 27a106b9ba1..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/all-afr-update.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "payload": [ - { - "time": "2019-07-25T07:16:21.600Z", - "reference": "0", - "type": "received", - "order_id": "156403898160000001" - } - ], - "type": "update", - "channel": "afr" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/all-orders-snapshot.json b/xchange-stream-lgo/src/test/resources/trade/all-orders-snapshot.json deleted file mode 100644 index 608d8ef4549..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/all-orders-snapshot.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "payload": [], - "batch_id": 6393995, - "type": "snapshot", - "channel": "user", - "product_id": "BTC-USD" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/all-orders-update.json b/xchange-stream-lgo/src/test/resources/trade/all-orders-update.json deleted file mode 100644 index fb324331388..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/all-orders-update.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "payload": [ - { - "time": "2019-07-25T07:16:21.600Z", - "side": "S", - "order_id": "156403898160000001", - "quantity": "3.00000000", - "type": "pending", - "order_type": "L", - "price": "7000.0000" - }, - { - "time": "2019-07-25T07:16:22.959Z", - "type": "open", - "order_id": "156403898160000001" - } - ], - "batch_id": 6393996, - "type": "update", - "channel": "user", - "product_id": "BTC-USD" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/order-changes-snapshot.json b/xchange-stream-lgo/src/test/resources/trade/order-changes-snapshot.json deleted file mode 100644 index 686e7a569bb..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/order-changes-snapshot.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "payload": [ - { - "quantity": "1.00000000", - "price": "6000.0000", - "side": "S", - "remaining_quantity": "1.00000000", - "order_id": "156389617430400001", - "order_creation_time": "2019-07-23T15:36:14.304Z", - "order_type": "L" - }, - { - "quantity": "1.00000000", - "order_creation_time": "2019-07-18T12:24:21.891Z", - "price": "6000.0000", - "side": "S", - "remaining_quantity": "1.00000000", - "order_id": "156345266189100001", - "order_type": "L" - } - ], - "batch_id": 6317542, - "type": "snapshot", - "channel": "user", - "product_id": "BTC-USD" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/order-changes-update.json b/xchange-stream-lgo/src/test/resources/trade/order-changes-update.json deleted file mode 100644 index 7c5a83ce725..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/order-changes-update.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "payload": [ - { - "quantity": "2.00000000", - "time": "2019-07-24T08:37:19.116Z", - "side": "B", - "price": "8000.0000", - "type": "pending", - "order_type": "L", - "order_id": "156395743911600001" - }, - { - "time": "2019-07-24T08:37:19.849Z", - "type": "open", - "order_id": "156395743911600001" - }, - { - "liquidity": "T", - "time": "2019-07-24T08:37:19.849Z", - "order_id": "156345266189100001", - "remaining_quantity": "0.60000000", - "filled_quantity": "0.40000000", - "type": "match", - "price": "955.3000", - "trade_id": "4441691", - "fees": "0.2388" - }, - { - "liquidity": "T", - "time": "2019-07-24T08:37:19.849Z", - "order_id": "156345266189100001", - "remaining_quantity": "0.00000000", - "filled_quantity": "0.60000000", - "type": "match", - "price": "955.4000", - "trade_id": "4441692", - "fees": "0.4600" - }, - { - "reason": "filled", - "type": "done", - "time": "2019-07-24T08:37:19.849Z", - "order_id": "156345266189100001" - } - ], - "batch_id": 6317543, - "type": "update", - "channel": "user", - "product_id": "BTC-USD" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/order-events-snapshot.json b/xchange-stream-lgo/src/test/resources/trade/order-events-snapshot.json deleted file mode 100644 index 686e7a569bb..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/order-events-snapshot.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "payload": [ - { - "quantity": "1.00000000", - "price": "6000.0000", - "side": "S", - "remaining_quantity": "1.00000000", - "order_id": "156389617430400001", - "order_creation_time": "2019-07-23T15:36:14.304Z", - "order_type": "L" - }, - { - "quantity": "1.00000000", - "order_creation_time": "2019-07-18T12:24:21.891Z", - "price": "6000.0000", - "side": "S", - "remaining_quantity": "1.00000000", - "order_id": "156345266189100001", - "order_type": "L" - } - ], - "batch_id": 6317542, - "type": "snapshot", - "channel": "user", - "product_id": "BTC-USD" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/order-events-update.json b/xchange-stream-lgo/src/test/resources/trade/order-events-update.json deleted file mode 100644 index 9694a2ebf3c..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/order-events-update.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "payload": [ - { - "quantity": "2.00000000", - "time": "2019-07-24T08:37:19.116Z", - "side": "B", - "price": "8000.0000", - "type": "pending", - "order_type": "L", - "order_id": "156395743911600001" - }, - { - "time": "2019-07-24T08:37:19.849Z", - "type": "open", - "order_id": "156395743911600001" - }, - { - "quantity": "2.00000000", - "time": "2019-07-24T08:37:19.849Z", - "side": "B", - "price": "8000.0001", - "type": "pending", - "order_type": "L", - "order_id": "156395743912700001" - }, - { - "time": "2019-07-24T08:37:19.849Z", - "type": "invalid", - "reason": "InvalidAmount", - "order_id": "156395743912700001" - }, - { - "time": "2019-07-24T08:37:19.922Z", - "type": "done", - "reason": "canceled", - "order_id": "156345266189100001" - } - ], - "batch_id": 6317543, - "type": "update", - "channel": "user", - "product_id": "BTC-USD" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/orders-snapshot.json b/xchange-stream-lgo/src/test/resources/trade/orders-snapshot.json deleted file mode 100644 index 686e7a569bb..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/orders-snapshot.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "payload": [ - { - "quantity": "1.00000000", - "price": "6000.0000", - "side": "S", - "remaining_quantity": "1.00000000", - "order_id": "156389617430400001", - "order_creation_time": "2019-07-23T15:36:14.304Z", - "order_type": "L" - }, - { - "quantity": "1.00000000", - "order_creation_time": "2019-07-18T12:24:21.891Z", - "price": "6000.0000", - "side": "S", - "remaining_quantity": "1.00000000", - "order_id": "156345266189100001", - "order_type": "L" - } - ], - "batch_id": 6317542, - "type": "snapshot", - "channel": "user", - "product_id": "BTC-USD" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/orders-update.json b/xchange-stream-lgo/src/test/resources/trade/orders-update.json deleted file mode 100644 index 24510c00731..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/orders-update.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "payload": [ - { - "quantity": "2.00000000", - "time": "2019-07-24T08:37:19.116Z", - "side": "B", - "price": "8000.0000", - "type": "pending", - "order_type": "L", - "order_id": "156395743911600001" - }, - { - "time": "2019-07-24T08:37:19.849Z", - "type": "open", - "order_id": "156395743911600001" - }, - { - "time": "2019-07-24T08:37:19.849Z", - "type": "done", - "reason": "canceled", - "order_id": "156345266189100001" - } - ], - "batch_id": 6317543, - "type": "update", - "channel": "user", - "product_id": "BTC-USD" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/user-trades-snapshot.json b/xchange-stream-lgo/src/test/resources/trade/user-trades-snapshot.json deleted file mode 100644 index b35204d00ea..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/user-trades-snapshot.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "payload": [], - "batch_id": 7632136, - "type": "snapshot", - "channel": "user", - "product_id": "BTC-USD" -} \ No newline at end of file diff --git a/xchange-stream-lgo/src/test/resources/trade/user-trades-update.json b/xchange-stream-lgo/src/test/resources/trade/user-trades-update.json deleted file mode 100644 index fd63422588d..00000000000 --- a/xchange-stream-lgo/src/test/resources/trade/user-trades-update.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "payload": [ - { - "time": "2019-08-06T10:00:04.184Z", - "side": "S", - "type": "pending", - "order_type": "M", - "order_id": "156508560418400001", - "quantity": "0.50000000" - }, - { - "liquidity": "M", - "time": "2019-08-06T10:00:05.658Z", - "order_id": "156508560418400001", - "remaining_quantity": "0.00000000", - "filled_quantity": "0.50000000", - "type": "match", - "price": "955.3000", - "trade_id": "4441691", - "fees": "0.2388" - }, - { - "reason": "filled", - "type": "done", - "time": "2019-08-06T10:00:05.658Z", - "order_id": "156508560418400001" - } - ], - "batch_id": 7632137, - "type": "update", - "channel": "user", - "product_id": "BTC-USD" -} \ No newline at end of file