├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ ├── build.yml │ └── release.yml ├── .gitignore ├── .lycheeignore ├── LICENSE ├── README.md ├── allowed-lic.json ├── bin └── runner.sh ├── build.gradle ├── config └── checkstyle │ └── checkstyle.xml ├── docs ├── configuration.md ├── developer.md ├── docker-compose.yml ├── img │ ├── L3OrderBook.png │ ├── OrderBook.png │ ├── Scheme.png │ ├── TradeEventFlowchart.png │ ├── TradeMessageFlowchart.png │ ├── TradeRequestFlowchart.png │ ├── ValidationSchemeL1.png │ ├── ValidationSchemeL2.png │ ├── ValidationSchemeL3.png │ ├── flowchart2.png │ ├── quotes.png │ ├── raw.png │ ├── snapshots.png │ ├── tb-book.png │ ├── tb-ce-connectors1.png │ ├── tb-ce-connectors2.png │ ├── tb-ce-connectors3.png │ ├── tb-ce-connectors4.png │ ├── tb-l2.png │ └── tb-raw.png ├── uniswap.md └── universal.md ├── gradle.properties ├── gradle ├── DockerSupport.gradle ├── License.gradle ├── Release.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── img └── stream-monitor.png ├── java ├── build.gradle ├── commons │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── commons │ │ │ ├── AsciiByteCharSequence.java │ │ │ ├── CloseableMessageOutput.java │ │ │ ├── CloseableMessageOutputFactory.java │ │ │ ├── DataConnector.java │ │ │ ├── DataConnectorSettings.java │ │ │ ├── ErrorListener.java │ │ │ ├── Factory.java │ │ │ ├── GraphQlPagination.java │ │ │ ├── GraphQlQuery.java │ │ │ ├── HttpFeed.java │ │ │ ├── HttpPoller.java │ │ │ ├── Iso8601DateTimeParser.java │ │ │ ├── JsonObjectsListener.java │ │ │ ├── JulLogger.java │ │ │ ├── L1Producer.java │ │ │ ├── Logger.java │ │ │ ├── MdFeed.java │ │ │ ├── MdModel.java │ │ │ ├── MdModelEnum.java │ │ │ ├── MdProcessor.java │ │ │ ├── MdSingleWsFeed.java │ │ │ ├── MdSingleWsRestFeed.java │ │ │ ├── MessageOutput.java │ │ │ ├── ObjectPool.java │ │ │ ├── PeriodicalJsonTask.java │ │ │ ├── QuoteSequenceProcessor.java │ │ │ ├── RetriableFactory.java │ │ │ ├── Retrier.java │ │ │ ├── SingleWsFeed.java │ │ │ ├── SingleWsRestFeed.java │ │ │ ├── SymbolMapper.java │ │ │ ├── TbMessageOutputFactory.java │ │ │ ├── TradeProducer.java │ │ │ ├── Util.java │ │ │ ├── WsJsonFrameSender.java │ │ │ ├── ZlibAsciiTextDecompressor.java │ │ │ ├── annotations │ │ │ ├── Connector.java │ │ │ └── ConnectorSettings.java │ │ │ ├── json │ │ │ ├── JsonArray.java │ │ │ ├── JsonObject.java │ │ │ ├── JsonValue.java │ │ │ ├── JsonValueParser.java │ │ │ ├── JsonWriter.java │ │ │ └── JsonWriterToGenerator.java │ │ │ └── l2 │ │ │ ├── BestBidOfferProducer.java │ │ │ ├── Book.java │ │ │ ├── BookAction.java │ │ │ ├── BookEvent.java │ │ │ ├── BookItem.java │ │ │ ├── BookListener.java │ │ │ ├── ChainedL2Listener.java │ │ │ ├── DefaultEvent.java │ │ │ ├── DefaultItem.java │ │ │ ├── InstrumentBooks.java │ │ │ ├── L2Listener.java │ │ │ ├── L2ListenerAdapter.java │ │ │ ├── L2Processor.java │ │ │ ├── L2Producer.java │ │ │ └── PriceBook.java │ │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── commons │ │ │ └── SymbolMapperTest.java │ │ └── testFixtures │ │ └── java │ │ └── com │ │ └── epam │ │ └── deltix │ │ └── data │ │ └── connectors │ │ └── test │ │ └── fixtures │ │ └── integration │ │ └── TbIntTestPreparation.java ├── connectors │ ├── ascendex │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── ascendex │ │ │ ├── AscendexConnectorSettings.java │ │ │ ├── AscendexDataConnector.java │ │ │ └── AscendexFeed.java │ ├── binance-futures │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── binance │ │ │ └── futures │ │ │ ├── BinanceFuturesConnectorSettings.java │ │ │ ├── BinanceFuturesDataConnector.java │ │ │ └── BinanceFuturesFeed.java │ ├── binance-spot │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── binance │ │ │ └── spot │ │ │ ├── BinanceSpotConnectorSettings.java │ │ │ ├── BinanceSpotDataConnector.java │ │ │ └── BinanceSpotFeed.java │ ├── bitfinex │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── bitfinex │ │ │ ├── BitfinexSpotConnectorSettings.java │ │ │ ├── BitfinexSpotDataConnector.java │ │ │ └── BitfinexSpotFeed.java │ ├── bitmart │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── bitmart │ │ │ ├── BitmartSpotConnectorSettings.java │ │ │ ├── BitmartSpotDataConnector.java │ │ │ └── BitmartSpotFeed.java │ ├── bitmex │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── bitmex │ │ │ ├── BitmexConnectorSettings.java │ │ │ ├── BitmexDataConnector.java │ │ │ └── BitmexFeed.java │ ├── build.gradle │ ├── bybit │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── bybit │ │ │ ├── BybitConnectorSettings.java │ │ │ ├── BybitDataConnector.java │ │ │ ├── BybitEndpoint.java │ │ │ └── BybitFeed.java │ ├── coinbase │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── coinbase │ │ │ ├── CoinbaseConnectorSettings.java │ │ │ ├── CoinbaseDataConnector.java │ │ │ └── CoinbaseFeed.java │ ├── cryptofacilities │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── cryptofacilities │ │ │ ├── CryptofacilitiesConnectorSettings.java │ │ │ ├── CryptofacilitiesDataConnector.java │ │ │ └── CryptofacilitiesFeed.java │ ├── deribit │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── deribit │ │ │ ├── DeribitConnectorSettings.java │ │ │ ├── DeribitDataConnector.java │ │ │ └── DeribitFeed.java │ ├── hitbtc │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── hitbtc │ │ │ ├── HitbtcConnectorSettings.java │ │ │ ├── HitbtcDataConnector.java │ │ │ └── HitbtcFeed.java │ ├── huobi-futures │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── huobi │ │ │ ├── HuobiFuturesConnectorSettings.java │ │ │ ├── HuobiFuturesDataConnector.java │ │ │ └── HuobiFuturesFeed.java │ ├── huobi-spot │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── huobi │ │ │ ├── HuobiSpotConnectorSettings.java │ │ │ ├── HuobiSpotDataConnector.java │ │ │ └── HuobiSpotFeed.java │ ├── kraken-futures │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── kraken │ │ │ ├── KrakenFuturesConnectorSettings.java │ │ │ ├── KrakenFuturesDataConnector.java │ │ │ └── KrakenFuturesFeed.java │ ├── kraken-spot │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── kraken │ │ │ ├── KrakenSpotConnectorSettings.java │ │ │ ├── KrakenSpotDataConnector.java │ │ │ ├── KrakenSpotFeed.java │ │ │ └── Util.java │ ├── kucoin │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── kucoin │ │ │ ├── KucoinConnectorSettings.java │ │ │ ├── KucoinDataConnector.java │ │ │ └── KucoinFeed.java │ ├── okcoin │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── okcoin │ │ │ ├── OkcoinSpotConnectorSettings.java │ │ │ ├── OkcoinSpotDataConnector.java │ │ │ └── OkcoinSpotFeed.java │ ├── okx │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── okx │ │ │ ├── OkxSpotConnectorSettings.java │ │ │ ├── OkxSpotDataConnector.java │ │ │ └── OkxSpotFeed.java │ ├── onetrading │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── onetrading │ │ │ ├── OneTradingSpotConnectorSettings.java │ │ │ ├── OneTradingSpotDataConnector.java │ │ │ └── OneTradingSpotFeed.java │ ├── poloniex │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── poloniex │ │ │ ├── PoloniexConnectorSettings.java │ │ │ ├── PoloniexDataConnector.java │ │ │ └── PoloniexFeed.java │ ├── polygon-io │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ └── polygon │ │ │ ├── PolygonIoConnectorSettings.java │ │ │ ├── PolygonIoCryptoFeed.java │ │ │ ├── PolygonIoDataConnector.java │ │ │ ├── PolygonIoEndpoint.java │ │ │ ├── PolygonIoFeed.java │ │ │ ├── PolygonIoForexFeed.java │ │ │ ├── PolygonIoIndicesFeed.java │ │ │ └── PolygonIoStocksFeed.java │ └── uniswap │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── epam │ │ └── deltix │ │ └── data │ │ ├── connectors │ │ └── uniswap │ │ │ ├── ConstantListener.java │ │ │ ├── PaginatingUniswapHttpPoller.java │ │ │ ├── ReadUniswapData.java │ │ │ ├── UniswapCollectionPoller.java │ │ │ ├── UniswapConnectorSettings.java │ │ │ ├── UniswapDataConnector.java │ │ │ ├── UniswapFeed.java │ │ │ ├── UniswapHttpPoller.java │ │ │ ├── UniswapPricePoller.java │ │ │ ├── UpdatableListener.java │ │ │ └── subscriptions │ │ │ ├── BundleSubscription.java │ │ │ ├── BurnSubscription.java │ │ │ ├── CollectSubscription.java │ │ │ ├── FactorySubscription.java │ │ │ ├── FlashSubscription.java │ │ │ ├── IdentifiedUniswapSymbol.java │ │ │ ├── MintSubscription.java │ │ │ ├── PoolSubscription.java │ │ │ ├── PositionSnapshotSubscription.java │ │ │ ├── PositionSubscription.java │ │ │ ├── PriceSubscription.java │ │ │ ├── Subscription.java │ │ │ ├── SwapSubscription.java │ │ │ ├── TickSubscription.java │ │ │ ├── TokenDayDataSubscription.java │ │ │ ├── TokenHourDataSubscription.java │ │ │ ├── TokenIdentifier.java │ │ │ ├── TokenSubscription.java │ │ │ ├── TransactionSubscription.java │ │ │ ├── UniswapDayDataSubscription.java │ │ │ └── UniswapSymbol.java │ │ └── uniswap │ │ ├── Action.java │ │ ├── Bundle.java │ │ ├── BundleAction.java │ │ ├── Burn.java │ │ ├── BurnAction.java │ │ ├── Collect.java │ │ ├── CollectAction.java │ │ ├── Factory.java │ │ ├── FactoryAction.java │ │ ├── Flash.java │ │ ├── FlashAction.java │ │ ├── Mint.java │ │ ├── MintAction.java │ │ ├── Pool.java │ │ ├── PoolAction.java │ │ ├── Position.java │ │ ├── PositionAction.java │ │ ├── PositionSnapshot.java │ │ ├── PositionSnapshotAction.java │ │ ├── Swap.java │ │ ├── SwapAction.java │ │ ├── Tick.java │ │ ├── TickAction.java │ │ ├── Token.java │ │ ├── TokenAction.java │ │ ├── TokenDayData.java │ │ ├── TokenDayDataAction.java │ │ ├── TokenHourData.java │ │ ├── TokenHourDataAction.java │ │ ├── Transaction.java │ │ ├── TransactionAction.java │ │ ├── UniswapDayData.java │ │ ├── UniswapDayDataAction.java │ │ ├── Updatable.java │ │ └── UpdatableAction.java └── runner │ ├── build.gradle │ └── src │ ├── intTest │ ├── java │ │ └── com │ │ │ └── epam │ │ │ └── deltix │ │ │ └── data │ │ │ └── connectors │ │ │ ├── IntegrationTest.java │ │ │ ├── reports │ │ │ ├── ReportGenerator.java │ │ │ ├── TestConnectorReports.java │ │ │ ├── TestReport.java │ │ │ └── TestStatus.java │ │ │ └── validator │ │ │ ├── DataValidator.java │ │ │ ├── DataValidatorImpl.java │ │ │ ├── L1DataValidator.java │ │ │ └── L2DataValidator.java │ └── resources │ │ └── logback.xml │ └── main │ ├── docker │ └── Dockerfile │ ├── java │ └── com │ │ └── epam │ │ └── deltix │ │ └── data │ │ └── connectors │ │ ├── Application.java │ │ └── runner │ │ ├── ConnectorImplementation.java │ │ ├── ConnectorsRunner.java │ │ ├── controllers │ │ └── DataConnectorsController.java │ │ ├── model │ │ └── DataConnectorDto.java │ │ └── settings │ │ ├── ConnectorsSettingsProvider.java │ │ ├── RunnerSettings.java │ │ └── TimebaseSettings.java │ └── resources │ ├── application.yaml │ └── logback.xml ├── lgtm.yml ├── settings.gradle └── spotbugs-excludes.xml /.gitattributes: -------------------------------------------------------------------------------- 1 | *.doc filter=lfs diff=lfs merge=lfs -text 2 | *.docx filter=lfs diff=lfs merge=lfs -text 3 | *.xls filter=lfs diff=lfs merge=lfs -text 4 | *.xlsx filter=lfs diff=lfs merge=lfs -text 5 | *.chm filter=lfs diff=lfs merge=lfs -text 6 | *.pdf filter=lfs diff=lfs merge=lfs -text 7 | *.exe filter=lfs diff=lfs merge=lfs -text 8 | *.jar filter=lfs diff=lfs merge=lfs -text 9 | *.gz filter=lfs diff=lfs merge=lfs -text 10 | *.zip filter=lfs diff=lfs merge=lfs -text 11 | *.dat filter=lfs diff=lfs merge=lfs -text 12 | *.lib filter=lfs diff=lfs merge=lfs -text 13 | *.dll filter=lfs diff=lfs merge=lfs -text 14 | *.a filter=lfs diff=lfs merge=lfs -text 15 | *.pdb filter=lfs diff=lfs merge=lfs -text 16 | *.so filter=lfs diff=lfs merge=lfs -text 17 | *.hnd filter=lfs diff=lfs merge=lfs -text 18 | *.pyd filter=lfs diff=lfs merge=lfs -text 19 | *.png filter=lfs diff=lfs merge=lfs -text 20 | *.jpg filter=lfs diff=lfs merge=lfs -text 21 | 22 | bin/runner.sh text eol=lf -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" # See documentation for possible values 9 | directory: "/services/uniswap" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | *.vc.db 3 | *.user 4 | .idea 5 | .gradle 6 | 7 | /**/bin/ 8 | /**/obj/ 9 | /**/build/ 10 | /**/out/ 11 | /lib/ 12 | /bin/ 13 | /logs/ -------------------------------------------------------------------------------- /.lycheeignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epam/TimebaseCryptoConnectors/1e67c292bf8d16a92ba74e35dc24dbd2dc076601/.lycheeignore -------------------------------------------------------------------------------- /docs/configuration.md: -------------------------------------------------------------------------------- 1 | # Configuration 2 | 3 | ## Default 4 | 5 | By default, we launch with [default](https://raw.githubusercontent.com/epam/TimebaseCryptoConnectors/main/java/runner/src/main/resources/application.yaml) configuration to start all the available connectors. 6 | 7 | ## Custom 8 | 9 | You can override the [default](https://raw.githubusercontent.com/epam/TimebaseCryptoConnectors/main/java/runner/src/main/resources/application.yaml) configuration by your custom config. 10 | 11 | The default `application.yaml` is located in Docker in the [/runner/config](https://github.com/epam/TimebaseCryptoConnectors/blob/76ee7a34e1eaa0b68f36227d0ae19ff428ff6436/java/runner/src/main/docker/Dockerfile#L40) directory. To override this, you can mount the directory with your custom `application.yaml` config on the `/runner/config` directory as shown in the below example. 12 | 13 | > For the convenience purposes, we recommend creating a `config` folder to store your custom configs in the directory, where you keep your docker-compose.yml. 14 | 15 | ```yaml 16 | # docker-compose configuration 17 | version: "3" 18 | services: 19 | crypto-connectors: 20 | image: "epam/timebase-crypto-connectors:0.1.7" 21 | ports: 22 | - 8055:8055 23 | volumes: 24 | - "./config:/runner/config" 25 | ``` 26 | 27 | For example, you can create a custom config to start just the selected data connector as shown in the below example: 28 | 29 | ```yaml 30 | #application.yaml configuration 31 | server: 32 | port: 8055 33 | 34 | timebase: 35 | url: dxtick://timebase:8011 36 | 37 | connectors: 38 | bitfinex: 39 | stream: bitfinex 40 | wsUrl: wss://api.bitfinex.com/ws/2 41 | depth: 20 42 | model: 43 | - "L1" 44 | - "L2" 45 | - "TRADES" 46 | instruments: "tBTCUSD=BTC/USD,tBTCEUR=BTC/EUR,tETCUSD=ETC/USD,tBTCF0:USTF0=BTCPC" 47 | ``` 48 | 49 | ## Multiple Containers 50 | 51 | In the previous example, we started one docker container with either all the available or a specific marker data connector. If it is necessary, you can also start more than one docker container concurrently, each with a specific application.yaml config. In the example below, we run two containers crypto-connectors1 and crypto-connectors2, each on a dedicated port and with a specific config. 52 | 53 | ```yaml 54 | # docker-compose configuration 55 | version: "3" 56 | services: 57 | crypto-connectors1: 58 | image: "epam/timebase-crypto-connectors:0.1.7" 59 | ports: 60 | - 8055:8055 61 | volumes: 62 | - "./config1:/runner/config" 63 | crypto-connectors2: 64 | image: "epam/timebase-crypto-connectors:0.1.7" 65 | ports: 66 | - 8056:8055 67 | volumes: 68 | - "./config2:/runner/config" 69 | ``` 70 | -------------------------------------------------------------------------------- /docs/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | timebase: 4 | image: "finos/timebase-ce-server:6.1.14" 5 | stop_grace_period: 5m 6 | ulimits: 7 | nofile: 8 | soft: 65536 9 | hard: 65536 10 | environment: 11 | - JAVA_OPTS= 12 | -Xms8g 13 | -Xmx8g 14 | -XX:+HeapDumpOnOutOfMemoryError 15 | -XX:HeapDumpPath=/timebase-home/timebase.hprof 16 | -Xlog:gc=debug:file=/timebase-home/GClog-TimeBase.log:time,uptime,level,tags:filecount=5,filesize=100m 17 | ports: 18 | - 8011:8011 19 | volumes: 20 | - "./timebase-home:/timebase-home" 21 | 22 | timebase-admin: 23 | image: "epam/timebase-ws-server:1.0.4" 24 | environment: 25 | - JAVA_OPTS= 26 | -Xmx1g 27 | -Dserver.port=8099 28 | -Dtimebase.url=dxtick://timebase:8011 29 | -Dserver.compression.enabled=true 30 | -Dserver.compression.mime-types=text/html,text/css,application/javascript,application/json 31 | ports: 32 | - 8099:8099 33 | depends_on: 34 | - timebase 35 | 36 | crypto-connectors: 37 | image: "epam/timebase-crypto-connectors:0.1.13" 38 | environment: 39 | - JAVA_OPTS= 40 | -Xmx1g 41 | -Dserver.port=8055 42 | -Dtimebase.url=dxtick://timebase:8011 43 | -Dserver.compression.enabled=true 44 | -Dserver.compression.mime-types=text/html,text/css,application/javascript,application/json 45 | -Dspring.confid=config/application.yml 46 | ports: 47 | - 8055:8055 48 | depends_on: 49 | - timebase 50 | 51 | grafana: 52 | image: grafana/grafana:8.3.5 53 | volumes: 54 | - grafana-volume:/var/lib/grafana 55 | environment: 56 | - GF_INSTALL_PLUGINS=https://github.com/ilgizar/ilgizar-candlestick-panel/raw/master/pack/ilgizar-candlestick-panel.zip;ilgizar-candlestick-panel,https://github.com/epam/TimeBaseGrafanaPlugin/releases/download/1.0.10/epam-timebase-datasource.zip;epam-timebase-datasource 57 | - GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=ilgizar-candlestick-panel,epam-timebase-datasource 58 | ports: 59 | - "3000:3000" 60 | depends_on: 61 | - timebase-admin 62 | 63 | # jupyter-demo: 64 | # image: jupyter-test:1.0 65 | # ports: 66 | # - "8888:8888" 67 | 68 | volumes: 69 | grafana-volume: 70 | -------------------------------------------------------------------------------- /docs/img/L3OrderBook.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:956cffff2ef5b6d9497b3c4d092703bc9e385d5e15efc296b3b08d08bb9fab68 3 | size 11030 4 | -------------------------------------------------------------------------------- /docs/img/OrderBook.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1a9d4de8d9da08d6cd3978878833041d3cc8cae2be78d1915cb5044c58e556d9 3 | size 8827 4 | -------------------------------------------------------------------------------- /docs/img/Scheme.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:02ddfad60a14c1bbec63cbb8fe04dbe35d90b6ed45cd2e6b898c5c0eead53cd1 3 | size 39830 4 | -------------------------------------------------------------------------------- /docs/img/TradeEventFlowchart.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:734f44925a20712e766b1c60fb1d1d8ba51f4f2e87032af8a070e0db15e1d925 3 | size 20646 4 | -------------------------------------------------------------------------------- /docs/img/TradeMessageFlowchart.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fb14e19365b947a665d9ad3a783d4ebd79be66267a3011c5c4f66f31b166a8a5 3 | size 103601 4 | -------------------------------------------------------------------------------- /docs/img/TradeRequestFlowchart.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c856370ea38e160dd6136b9d4d1e6c96d94cb885abe18a7d7cbbbd56f998a2a6 3 | size 7952 4 | -------------------------------------------------------------------------------- /docs/img/ValidationSchemeL1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d86fa3017555450dea94de14635166b944d6447c3c592f6ef2a4f39a5a06aea3 3 | size 122836 4 | -------------------------------------------------------------------------------- /docs/img/ValidationSchemeL2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:489d969cc4c86adc1b736d5492ca56442801bc4443fe3f4d519e9cab1edd4699 3 | size 237499 4 | -------------------------------------------------------------------------------- /docs/img/ValidationSchemeL3.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cbfae8acfce08ce111ecd59a57e118e4fe674d87785c5c83688fac51c00abe4a 3 | size 206728 4 | -------------------------------------------------------------------------------- /docs/img/flowchart2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2f339af5ffefe47664a03c40b7b41cbd557a6e4472d8fefc04959588f63f816f 3 | size 25526 4 | -------------------------------------------------------------------------------- /docs/img/quotes.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2b609cf2f151fe82f27db1834521bd7a5b90752f37dd7184379da6af7d808675 3 | size 5841 4 | -------------------------------------------------------------------------------- /docs/img/raw.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f58acc717f7e77b5f92245a5543a9ea39409d93f1427b718a412fd21fcc82c3b 3 | size 5199 4 | -------------------------------------------------------------------------------- /docs/img/snapshots.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0413df2834d1a4dcca1d3d62db47dcef172c5acdc9e5a19f663234a2d6f3bab3 3 | size 18629 4 | -------------------------------------------------------------------------------- /docs/img/tb-book.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0f475142e32efa5df272fb934b6a6c36bfbf5f30fb9bf2707e1c76955e51ac4d 3 | size 212293 4 | -------------------------------------------------------------------------------- /docs/img/tb-ce-connectors1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:998abbb24537c5da95da359a6c222d4bc21bc8c39d1d30ddaffe0c1684dbf42f 3 | size 8522 4 | -------------------------------------------------------------------------------- /docs/img/tb-ce-connectors2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fc974250bc744f6c56e5fb051bb5a72e40b1a9dae899688013b6518d4c3f1000 3 | size 25496 4 | -------------------------------------------------------------------------------- /docs/img/tb-ce-connectors3.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e9f4d2fdb37f4549e914c40b750b46b3671dfb0fc75258473c133654c316c81c 3 | size 19904 4 | -------------------------------------------------------------------------------- /docs/img/tb-ce-connectors4.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3ba54bfc6a2df33e0f6819ae029f7701bb789f7f39d2e9225a19595d93e7874b 3 | size 59950 4 | -------------------------------------------------------------------------------- /docs/img/tb-l2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9b74c1b2d77f2acb06f94adef230d9f4facf2b0c2e49efa3aa614abf6d060c61 3 | size 174728 4 | -------------------------------------------------------------------------------- /docs/img/tb-raw.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:61ded32d263d409760f4a1c03686f6deb4d98aa92755d1ba7ce5e040633c8f6c 3 | size 135563 4 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | projectGroup=com.epam.deltix.data.connectors 2 | 3 | version=0.1.11-SNAPSHOT 4 | gflogVersion=3.0.3 5 | timebaseVersion=6.1.14 6 | timebaseCommonsVersion=6.0.65 7 | dfpVersion=0.12.8 8 | springBootVersion=2.7.18 9 | springVersion=5.3.31 10 | junitJupiterVersion=5.8.1 11 | testcontainersVersion=1.16.3 12 | docker.dockerCommonPath=epam/ 13 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e996d452d2645e70c01c11143ca2d3742734a28da2bf61f25c82bdc288c9e637 3 | size 59203 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /img/stream-monitor.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ef487fb98bb4fee58c93b81244aaf4522f09f0afb115d28edcf189edd7432eb3 3 | size 110644 4 | -------------------------------------------------------------------------------- /java/commons/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-test-fixtures' 2 | 3 | dependencies { 4 | implementation 'io.github.green4j:green-jelly' 5 | implementation 'com.epam.deltix:dfp' 6 | 7 | implementation 'org.finos.timebase-ce:timebase-api' 8 | implementation 'org.finos.timebase-ce:timebase-client' 9 | implementation 'com.epam.deltix:timebase-messages' 10 | 11 | testImplementation 'org.junit.jupiter:junit-jupiter-api' 12 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' 13 | 14 | testFixturesImplementation "org.testcontainers:testcontainers" 15 | testFixturesImplementation "org.testcontainers:junit-jupiter" 16 | } 17 | 18 | tasks.withType(JavaCompile) { 19 | options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" 20 | } 21 | 22 | test { 23 | useJUnitPlatform() 24 | testLogging { 25 | showStandardStreams = true 26 | exceptionFormat = 'full' 27 | } 28 | } 29 | 30 | tasks.test { enabled = true } 31 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/AsciiByteCharSequence.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | public class AsciiByteCharSequence implements CharSequence { 4 | private byte[] bytes; 5 | private int length; 6 | 7 | public AsciiByteCharSequence() { 8 | this(128); 9 | } 10 | 11 | public AsciiByteCharSequence(final int size) { 12 | this(new byte[size]); 13 | } 14 | 15 | public AsciiByteCharSequence(final byte[] bytes) { 16 | this.bytes = bytes; 17 | } 18 | 19 | public void set(final byte[] bytes, final int length) { 20 | this.bytes = bytes; 21 | this.length = length; 22 | } 23 | 24 | public byte[] bytes() { 25 | return bytes; 26 | } 27 | 28 | public void setLength(final int length) { 29 | this.length = length; 30 | } 31 | 32 | @Override 33 | public int length() { 34 | return length; 35 | } 36 | 37 | public void clear() { 38 | length = 0; 39 | } 40 | 41 | @Override 42 | public char charAt(final int index) { 43 | return (char) bytes[index]; 44 | } 45 | 46 | @Override 47 | public CharSequence subSequence(final int start, final int end) { 48 | return new String(bytes, start, end); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/CloseableMessageOutput.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | import java.io.Closeable; 4 | 5 | public interface CloseableMessageOutput extends MessageOutput, Closeable { 6 | 7 | @Override 8 | void close(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/CloseableMessageOutputFactory.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | public interface CloseableMessageOutputFactory extends Factory { 4 | } 5 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/DataConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | public class DataConnectorSettings { 4 | 5 | private String type; 6 | private String name; 7 | private String tbUrl = "dxtick://localhost:8011"; 8 | private String tbUser; 9 | private String tbPassword; 10 | private String stream; 11 | private int depth = 20; 12 | 13 | private boolean disabled; 14 | 15 | public DataConnectorSettings() { 16 | } 17 | 18 | public DataConnectorSettings(String tbUrl, String stream) { 19 | this.tbUrl = tbUrl; 20 | this.stream = stream; 21 | } 22 | 23 | public String getType() { 24 | return type; 25 | } 26 | 27 | public void setType(String type) { 28 | this.type = type; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public String getTbUrl() { 40 | return tbUrl; 41 | } 42 | 43 | public void setTbUrl(String tbUrl) { 44 | this.tbUrl = tbUrl; 45 | } 46 | 47 | public String getTbUser() { 48 | return tbUser; 49 | } 50 | 51 | public void setTbUser(String tbUser) { 52 | this.tbUser = tbUser; 53 | } 54 | 55 | public String getTbPassword() { 56 | return tbPassword; 57 | } 58 | 59 | public void setTbPassword(String tbPassword) { 60 | this.tbPassword = tbPassword; 61 | } 62 | 63 | public String getStream() { 64 | return stream; 65 | } 66 | 67 | public void setStream(String stream) { 68 | this.stream = stream; 69 | } 70 | 71 | public int getDepth() { 72 | return depth; 73 | } 74 | 75 | public void setDepth(int depth) { 76 | this.depth = depth; 77 | } 78 | 79 | public boolean isDisabled() { 80 | return disabled; 81 | } 82 | 83 | public void setDisabled(boolean disabled) { 84 | this.disabled = disabled; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/ErrorListener.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | public interface ErrorListener { 4 | 5 | void onError(Throwable error); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/Factory.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | public interface Factory { 4 | 5 | T create(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/GraphQlPagination.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | public class GraphQlPagination { 4 | private final GraphQlQuery.Query query; 5 | private final int pageSize; 6 | 7 | private int skip; 8 | 9 | public GraphQlPagination( 10 | final GraphQlQuery.Query template, 11 | final int pageSize) { 12 | this.query = template.copy(); // we make a copy to mutate the query in next() 13 | this.pageSize = pageSize; 14 | 15 | query.arguments().withFirst(pageSize); 16 | } 17 | 18 | public void reset() { 19 | skip = 0; 20 | query.arguments().withNoSkip(); 21 | } 22 | 23 | public GraphQlQuery.Query next() { 24 | if (skip > 0) { 25 | query.arguments().withSkip(skip); 26 | } 27 | 28 | skip += pageSize; 29 | 30 | return query; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/HttpPoller.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | import java.net.http.HttpClient; 4 | 5 | public interface HttpPoller { 6 | 7 | void poll(HttpClient client, Runnable continuator, ErrorListener errorListener); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/JsonObjectsListener.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | import com.epam.deltix.data.connectors.commons.json.JsonObject; 4 | 5 | public interface JsonObjectsListener { 6 | 7 | void onObjectsStarted(); 8 | 9 | void onObject(JsonObject object); 10 | 11 | void onObjectsFinished(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/JulLogger.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | import java.util.function.Supplier; 4 | import java.util.logging.Level; 5 | 6 | public class JulLogger implements Logger { 7 | public static Logger forConnector(final String connector) { 8 | return new JulLogger("com.epam.deltix.data.connectors", connector); 9 | } 10 | 11 | private final java.util.logging.Logger jul; 12 | private final String prefix; 13 | 14 | public JulLogger(final String julPrefix, final String id) { 15 | this(java.util.logging.Logger.getLogger(julPrefix + '.' + id), id); 16 | } 17 | 18 | public JulLogger(final java.util.logging.Logger jul, final String id) { 19 | this.jul = jul; 20 | this.prefix = '[' + id + "] "; 21 | } 22 | 23 | @Override 24 | public void warning(String msg) { 25 | jul.log(Level.WARNING, prefix + msg); 26 | } 27 | 28 | @Override 29 | public void warning(String msg, Throwable t) { 30 | jul.log(Level.WARNING, prefix + msg, t); 31 | } 32 | 33 | @Override 34 | public void warning(final Supplier msgSupplier) { 35 | if (!jul.isLoggable(Level.WARNING)) { 36 | return; 37 | } 38 | 39 | jul.log(Level.WARNING, prefix + msgSupplier.get()); 40 | } 41 | 42 | @Override 43 | public void warning(final Supplier msgSupplier, final Throwable t) { 44 | if (!jul.isLoggable(Level.WARNING)) { 45 | return; 46 | } 47 | 48 | jul.log(Level.WARNING,prefix + msgSupplier.get(), t); 49 | } 50 | 51 | @Override 52 | public void info(final Supplier msgSupplier) { 53 | if (!jul.isLoggable(Level.INFO)) { 54 | return; 55 | } 56 | 57 | jul.log(Level.INFO, prefix + msgSupplier.get()); 58 | } 59 | 60 | public boolean isDebugEnabled() { 61 | return jul.isLoggable(Level.FINE); 62 | } 63 | 64 | public void debug(final String msg) { 65 | jul.log(Level.FINE, prefix + msg); 66 | } 67 | 68 | @Override 69 | public void debug(final Supplier msgSupplier) { 70 | if (!isDebugEnabled()) { 71 | return; 72 | } 73 | jul.log(Level.FINE, prefix + msgSupplier.get()); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/Logger.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | import java.util.function.Supplier; 4 | 5 | public interface Logger { 6 | 7 | void warning(String msg); 8 | 9 | void warning(String msg, Throwable t); 10 | 11 | void warning(Supplier msgSupplier); 12 | 13 | void warning(Supplier msgSupplier, Throwable t); 14 | 15 | void info(Supplier msgSupplier); 16 | 17 | boolean isDebugEnabled(); 18 | 19 | void debug(final String msg); 20 | 21 | void debug(Supplier msgSupplier); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/MdFeed.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | import com.epam.deltix.timebase.messages.InstrumentMessage; 4 | 5 | public abstract class MdFeed implements CloseableMessageOutput, ErrorListener { 6 | private final MdModel.Options selected; 7 | private final CloseableMessageOutput output; 8 | private final ErrorListener errorListener; 9 | private final Logger logger; 10 | 11 | private volatile Throwable error; 12 | private boolean closed; // guarded by this 13 | 14 | protected MdFeed( 15 | final MdModel.Options selected, 16 | final CloseableMessageOutput output, 17 | final ErrorListener errorListener, 18 | final Logger logger) { 19 | this.selected = selected; 20 | this.output = output; 21 | this.errorListener = errorListener; 22 | this.logger = logger; 23 | } 24 | 25 | Throwable error() { 26 | return error; 27 | } 28 | 29 | public MdModel.Options selected() { 30 | return selected; 31 | } 32 | 33 | public Logger logger() { 34 | return logger; 35 | } 36 | 37 | @Override 38 | public final void close() { 39 | synchronized (this) { 40 | if (closed) { 41 | return; 42 | } 43 | closed = true; 44 | } 45 | try { 46 | doClose(); 47 | } finally { 48 | Util.closeQuiet(output); 49 | } 50 | } 51 | 52 | public final void send(final InstrumentMessage message) { 53 | try { 54 | output.send(message); 55 | } catch (final Throwable t) { 56 | onError(t); 57 | } 58 | } 59 | 60 | @Override 61 | public final void onError(final Throwable error) { 62 | this.error = error; 63 | errorListener.onError(error); 64 | } 65 | 66 | protected abstract void doClose(); 67 | } 68 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/MdModelEnum.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | public enum MdModelEnum { 4 | TRADES, 5 | L1, 6 | L2, 7 | CUSTOM; 8 | 9 | public static void with(MdModel.ModifiableOptions options, String enumValue) { 10 | with(options, MdModelEnum.valueOf(enumValue)); 11 | } 12 | 13 | public static void with(MdModel.ModifiableOptions options, MdModelEnum enumValue) { 14 | switch (enumValue) { 15 | case TRADES: 16 | options.withTrades(); 17 | return; 18 | case L1: 19 | options.withLevel1(); 20 | return; 21 | case L2: 22 | options.withLevel2(); 23 | return; 24 | } 25 | } 26 | 27 | public static void withCustom(MdModel.ModifiableOptions options, MdModel model, Class ... customTypes) { 28 | if (customTypes != null && customTypes.length > 0) { 29 | options.withCustom(customTypes); 30 | } else { 31 | MdModel.Availability available = model.available(); 32 | if (available.custom()) { 33 | options.withCustom(available.customTypes()); 34 | } 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/MessageOutput.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | import com.epam.deltix.timebase.messages.InstrumentMessage; 4 | 5 | public interface MessageOutput { 6 | 7 | void send(InstrumentMessage message); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/PeriodicalJsonTask.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | import com.epam.deltix.data.connectors.commons.json.JsonWriter; 4 | 5 | public interface PeriodicalJsonTask { 6 | 7 | long delayMillis(); 8 | 9 | void execute(JsonWriter jsonWriter); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/QuoteSequenceProcessor.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | import com.epam.deltix.data.connectors.commons.l2.DefaultEvent; 4 | import com.epam.deltix.data.connectors.commons.l2.DefaultItem; 5 | import com.epam.deltix.data.connectors.commons.l2.L2Processor; 6 | import com.epam.deltix.data.connectors.commons.l2.PriceBook; 7 | import com.epam.deltix.dfp.Decimal; 8 | import com.epam.deltix.qsrv.hf.tickdb.pub.TimeConstants; 9 | 10 | public class QuoteSequenceProcessor { 11 | 12 | private final L2Processor, DefaultEvent>, DefaultItem, DefaultEvent> 13 | l2Processor; 14 | 15 | private final DefaultEvent priceBookEvent = new DefaultEvent(); 16 | 17 | private boolean packageStarted = false; 18 | 19 | public QuoteSequenceProcessor( 20 | L2Processor, DefaultEvent>, DefaultItem, DefaultEvent> l2Processor) { 21 | 22 | this.l2Processor = l2Processor; 23 | } 24 | 25 | void packageStarted(boolean snapshot, long timestamp) { 26 | checkPackageNotStarted(); 27 | 28 | if (snapshot) { 29 | l2Processor.onSnapshotPackageStarted(TimeConstants.TIMESTAMP_UNKNOWN, timestamp); 30 | } else { 31 | l2Processor.onIncrementalPackageStarted(timestamp); 32 | } 33 | 34 | packageStarted = true; 35 | } 36 | 37 | public void onQuote(@Decimal long price, @Decimal long size, boolean isAsk) { 38 | checkPackageStarted(); 39 | 40 | priceBookEvent.reset(); 41 | priceBookEvent.set(isAsk, price, size); 42 | l2Processor.onEvent(priceBookEvent); 43 | } 44 | 45 | public void onFinish() { 46 | checkPackageStarted(); 47 | packageStarted = false; 48 | 49 | l2Processor.onPackageFinished(); 50 | } 51 | 52 | private void checkPackageNotStarted() { 53 | if (packageStarted) { 54 | throw new IllegalStateException( 55 | "Previous package is not finished. Please call 'onFinish()' before starting new package" 56 | ); 57 | } 58 | } 59 | 60 | private void checkPackageStarted() { 61 | if (!packageStarted) { 62 | throw new IllegalStateException( 63 | "Package is not started. Please use 'onBookSnapshot()' or 'onBookUpdate()' to start new package." 64 | ); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/RetriableFactory.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | import java.io.Closeable; 4 | 5 | public interface RetriableFactory { 6 | 7 | C create(final ErrorListener errorListener) throws Exception; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/Util.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | import java.io.IOException; 4 | import java.util.regex.Pattern; 5 | 6 | public abstract class Util { 7 | public static final String NATIVE_LINE_BREAK = System.getProperty("line.separator"); 8 | 9 | public static final String INSTRUMENTS_SEPARATOR = ","; 10 | 11 | private static final String[] TABS_BY_2 = new String[] { 12 | "", 13 | " ", 14 | " ", 15 | " ", 16 | " ", 17 | " " 18 | }; 19 | 20 | public static T closeQuiet(final T resource) { 21 | if (resource == null) { 22 | return null; 23 | } 24 | try { 25 | resource.close(); 26 | } catch (final Throwable t) { 27 | } 28 | return null; 29 | } 30 | 31 | public static String[] splitInstruments(String instruments) { 32 | return instruments.split("(? unzippedData.length) { 49 | final byte[] newData = new byte[(total + count) << 1]; 50 | System.arraycopy(unzippedData, 0, newData, 0, unzippedData.length); 51 | unzippedData = newData; 52 | } 53 | 54 | System.arraycopy(unzippedDataPortion, 0, unzippedData, total, count); 55 | total += count; 56 | } 57 | return total; 58 | } finally { 59 | inflater.reset(); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/annotations/Connector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons.annotations; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * Indicates that an annotated class is a "Data Connector" implementation. 7 | * The implementation can be automatically discovered, instantiated and configured by Data Connectors Runner. 8 | */ 9 | @Target(ElementType.TYPE) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | public @interface Connector { 12 | 13 | /** 14 | * Data Connector name. 15 | * 16 | * @return name of the Data Connector 17 | */ 18 | String value() default ""; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/annotations/ConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Indicates that an annotated class is a "Data Connector Settings" implementation. 10 | */ 11 | @Target(ElementType.TYPE) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface ConnectorSettings { 14 | 15 | /** 16 | * Data Connector name. 17 | * @return name of the Data Connector 18 | */ 19 | String value() default ""; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/json/JsonWriter.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons.json; 2 | 3 | import io.github.green4j.jelly.JsonNumber; 4 | 5 | public interface JsonWriter { 6 | 7 | void startObject(); 8 | 9 | void objectMember(CharSequence name); 10 | 11 | void objectMember(CharSequence name, int start, int len); 12 | 13 | void endObject(); 14 | 15 | void startArray(); 16 | 17 | void endArray(); 18 | 19 | void stringValue(final CharSequence value, final boolean escaping); 20 | 21 | void stringValue(final CharSequence value); 22 | 23 | void stringValue(final CharSequence name, final int start, final int len, final boolean escaping); 24 | 25 | void stringValue(final CharSequence name, final int start, final int len); 26 | 27 | void numberValueAsString(final JsonNumber value); 28 | 29 | void numberValueAsString(final long value); 30 | 31 | void numberValueAsString(final long mantissa, final int exp); 32 | 33 | void numberValue(final long value); 34 | 35 | void numberValue(final JsonNumber value); 36 | 37 | void numberValue(final long mantissa, final int exp); 38 | 39 | void trueValue(); 40 | 41 | void falseValue(); 42 | 43 | void nullValue(); 44 | 45 | void eoj(); 46 | } 47 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/l2/BookAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons.l2; 2 | 3 | /** 4 | *

Represents actions that can be applied to a book.
5 | * All actions are named according FIX.

6 | */ 7 | public enum BookAction { 8 | 9 | New('0'), 10 | Change('1'), 11 | Delete('2'), 12 | DeleteThru('3'), 13 | DeleteFrom('4'), 14 | Overlay('5'); 15 | 16 | private final char code; 17 | 18 | /** 19 | *

Constructs new object with specified code

20 | * 21 | * @param code code of action for new object 22 | */ 23 | BookAction(final char code) { 24 | this.code = code; 25 | } 26 | 27 | /** 28 | *

Returns enum value of book action. 29 | * Use this method to decode action from it's number.

30 | * 31 | * @param c number of action in this enum 32 | * @return enum value witch matches specified number 33 | * @throws IllegalArgumentException if specified action number was not found 34 | */ 35 | public static BookAction decode(final char c) { 36 | switch (c) { 37 | case '0': 38 | return New; 39 | case '1': 40 | return Change; 41 | case '2': 42 | return Delete; 43 | case '3': 44 | return DeleteThru; 45 | case '4': 46 | return DeleteFrom; 47 | case '5': 48 | return Overlay; 49 | } 50 | 51 | throw new IllegalArgumentException("Unknown action code: " + c); 52 | } 53 | 54 | /** 55 | *

Returns code of this enum

56 | * 57 | * @return code of this enum 58 | */ 59 | public char getCode() { 60 | return this.code; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/l2/BookEvent.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons.l2; 2 | 3 | import com.epam.deltix.dfp.Decimal; 4 | 5 | /** 6 | *

Represents event, which can be processed with book.
7 | * Usually book can change it's state in response of getting event object.
8 | * This interface gives access to such event fields as side, price and size, 9 | * that are used by book to change it's items state.

10 | * 11 | * @see Book 12 | * @see BookItem 13 | */ 14 | public interface BookEvent { 15 | 16 | /** 17 | * Checks whether this event is an offer. 18 | * 19 | * @return true if this event has type offer, else - false. 20 | */ 21 | boolean isOffer(); 22 | 23 | /** 24 | * Returns the price of this event. This price can be used to update price property of book item. 25 | * 26 | * @return price value of this event. Returned long value should be treated as decimal. 27 | */ 28 | @Decimal 29 | long getPrice(); 30 | 31 | /** 32 | * Returns the size of this event. This size can be used to update size property of book item. 33 | * 34 | * @return size value of this event. Returned long value should be treated as decimal. 35 | */ 36 | @Decimal 37 | long getSize(); 38 | } 39 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/l2/BookItem.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons.l2; 2 | 3 | import com.epam.deltix.dfp.Decimal; 4 | 5 | import java.io.IOException; 6 | 7 | /** 8 | * Represents item which is stored in a Book. 9 | * 10 | * @param type of the event, which can be applied to this item. 11 | * @see BookEvent 12 | * @see Book 13 | */ 14 | public interface BookItem { 15 | 16 | /** 17 | * Returns the price of this item. 18 | * 19 | * @return price of this item. Returned long value should be treated as decimal. 20 | */ 21 | @Decimal 22 | long getPrice(); 23 | 24 | /** 25 | * Returns the size of this item. 26 | * 27 | * @return size of this item. Returned value should be treated as decimal. 28 | */ 29 | @Decimal 30 | long getSize(); 31 | 32 | /** 33 | * Sets the fields of this item according to information in given event. 34 | * 35 | * @param event event object with information to update the state of this item. 36 | */ 37 | void set(E event); 38 | 39 | /** 40 | * Creates dump of this item's internal state. Dump is written into the given appendable storage. 41 | * 42 | * @param to object which dump should be written to. 43 | * @param type of appendable object for saving internal state of this item. 44 | * @return storage object of type T filled with this item's internal state. 45 | * @throws IOException an exception if happened 46 | */ 47 | T dump(T to) throws IOException; 48 | } 49 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/l2/BookListener.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons.l2; 2 | 3 | /** 4 | *

Represents listener entity, which can be subscribed on a book.
5 | * Listener gets notifications any time book changes its state.

6 | * 7 | *

If you use this listener with no subscription on any book, 8 | * than you should care about calling methods of listener by yourself.

9 | * 10 | * @param type of item, which is stored in the book, that notifies this listener. 11 | * @param type of event, which can be applied to the book, that notifies this listener. 12 | * @see BookEvent 13 | * @see BookItem 14 | */ 15 | public interface BookListener, E extends BookEvent> { 16 | 17 | boolean beforeInsert(Book book, int depth, E event); 18 | 19 | /** 20 | *

Performs some actions when notifier gets an insert event.
21 | * This method is usually called by notifier. If you use listener object without notifier, 22 | * than you should take care of calling this method yourself.

23 | * 24 | * @param book book to which insert action was applied. 25 | * @param depth value of inserted into book item's depth. 26 | * @param item object which was inserted into book. 27 | */ 28 | void onInsert(Book book, int depth, I item); 29 | 30 | boolean beforeUpdate(Book book, int depth, E event); 31 | 32 | /** 33 | *

Performs some actions when notifier gets an update event.
34 | * This method is usually called by notifier. If you use listener object without notifier, 35 | * than you should take care of calling this method yourself.

36 | * 37 | * @param book book to which update action was applied. 38 | * @param depth value of updated in book item's depth. 39 | * @param item object which was updated in book side. 40 | */ 41 | void onUpdate(Book book, int depth, I item); 42 | 43 | boolean beforeDelete(Book book, int depth); 44 | 45 | /** 46 | *

Performs some actions when notifier gets an delete event.
47 | * This method is usually called by notifier. If you use listener object without notifier, 48 | * than you should take care of calling this method yourself.

49 | * 50 | * @param book book to which delete action was applied. 51 | * @param depth value of deleted in book item's depth. 52 | * @param item object which was updated in book side. 53 | */ 54 | void onDelete(Book book, int depth, I item); 55 | 56 | boolean beforeReset(Book book); 57 | 58 | /** 59 | *

Performs some actions when notifier gets and reset event.
60 | * This method is usually called by notifier. If you use listener object without notifier, 61 | * than you should take care of calling this method yourself.

62 | * 63 | * @param book book to which reset action was applied. 64 | */ 65 | void onReset(Book book); 66 | } 67 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/l2/DefaultEvent.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons.l2; 2 | 3 | import com.epam.deltix.dfp.Decimal; 4 | import com.epam.deltix.dfp.Decimal64Utils; 5 | 6 | /** 7 | *

Represents event, which can be processed with any book that stores default items.
8 | * Usually book can change it's state in response of getting event object.
9 | * This class aggregates such event fields as side, price and size, 10 | * that are used by book to change it's items state.

11 | * 12 | * @see Book 13 | * @see PriceBook 14 | * @see DefaultItem 15 | */ 16 | public class DefaultEvent implements BookEvent { 17 | 18 | /** 19 | * Price of this event. This long value must be treated as decimal. 20 | */ 21 | @Decimal 22 | protected long price = Decimal64Utils.NULL; 23 | 24 | /** 25 | * Size of this event. This long value must be treated as decimal. 26 | */ 27 | @Decimal 28 | protected long size = Decimal64Utils.NULL; 29 | 30 | /** 31 | * Side of this event. True if side is offers, else - false. 32 | */ 33 | protected boolean isOffer; 34 | 35 | @Override 36 | public @Decimal long getSize() { 37 | return size; 38 | } 39 | 40 | @Override 41 | public boolean isOffer() { 42 | return isOffer; 43 | } 44 | 45 | @Override 46 | public @Decimal long getPrice() { 47 | return price; 48 | } 49 | 50 | /** 51 | *

Sets fields of this event. This method is required to reuse event objects, that are stored in a pool.
52 | * Should be called to fill event with data any time event is going to be reused.

53 | * 54 | * @param isOffer side of this event. Must be true for offers, else - false. 55 | * @param price price of this event 56 | * @param size size of this event. 57 | * @see Pool 58 | */ 59 | public void set(final boolean isOffer, final @Decimal long price, final @Decimal long size) { 60 | this.isOffer = isOffer; 61 | this.price = price; 62 | this.size = size; 63 | } 64 | 65 | /** 66 | *

Resets fields of this event. 67 | * All fields will be equal to the default value after this method is called.

68 | */ 69 | public void reset() { 70 | isOffer = false; 71 | price = Decimal64Utils.NULL; 72 | size = Decimal64Utils.NULL; 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | return (isOffer ? 78 | "O" : 79 | "B") + "/" + Decimal64Utils.toString(price) + "/" + Decimal64Utils.toString(size); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/l2/DefaultItem.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons.l2; 2 | 3 | import com.epam.deltix.dfp.Decimal; 4 | import com.epam.deltix.dfp.Decimal64Utils; 5 | 6 | import java.io.IOException; 7 | 8 | /** 9 | *

Represents default item which can be stored in a book.

10 | * 11 | * @param type of event which can be applied to this item 12 | * @see Book 13 | * @see BookEvent 14 | */ 15 | public class DefaultItem implements BookItem { 16 | @Decimal 17 | private long price; 18 | @Decimal 19 | private long size; 20 | 21 | @Override 22 | public @Decimal long getPrice() { 23 | return price; 24 | } 25 | 26 | @Override 27 | public @Decimal long getSize() { 28 | return size; 29 | } 30 | 31 | @Override 32 | public void set(final E event) { 33 | price = event.getPrice(); 34 | size = event.getSize(); 35 | } 36 | 37 | @Override 38 | public T dump(final T to) throws IOException { 39 | to.append(Decimal64Utils.toString(price)) 40 | .append('/') 41 | .append(Decimal64Utils.toString(size)); 42 | 43 | return to; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | try { 49 | return dump(new StringBuilder()).toString(); 50 | } catch (final IOException e) { 51 | return null; 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/l2/InstrumentBooks.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons.l2; 2 | 3 | /** 4 | *

Represents book which has two sides (bids and offers) and handles events for specific withInstrument.
5 | * This interface provides access to served withInstrument and two sides of the book.

6 | * 7 | * @param type of items that are stored in this book 8 | * @param type of event which can be applied to items of this book 9 | * @see L2Listener 10 | */ 11 | public interface InstrumentBooks, E extends BookEvent> { 12 | 13 | /** 14 | * Returns encoded Id of source (see {@link com.epam.deltix.qsrv.hf.pub.ExchangeCodec}) 15 | * @return Id of the source 16 | */ 17 | long source(); 18 | 19 | /** 20 | * Returns withInstrument which is served by this book. 21 | * 22 | * @return withInstrument which is served by this book 23 | */ 24 | String symbol(); 25 | 26 | /** 27 | * Returns bids side of this withInstrument book. 28 | * 29 | * @return Returns bids side of this withInstrument book 30 | */ 31 | Book bids(); 32 | 33 | /** 34 | * Returns offers side of this withInstrument book 35 | * 36 | * @return offers side of this withInstrument book 37 | */ 38 | Book offers(); 39 | } -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/l2/L2ListenerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons.l2; 2 | 3 | public class L2ListenerAdapter, E extends BookEvent> 4 | implements L2Listener { 5 | @Override 6 | public void onSnapshotStarted(final InstrumentBooks instrumentBook, final long timestamp, final long originalTimestamp) { 7 | 8 | } 9 | 10 | @Override 11 | public void onIncrementStarted(final InstrumentBooks instrumentBook, final long timestamp, final long originalTimestamp) { 12 | 13 | } 14 | 15 | @Override 16 | public void onNew(final Book book, final int depth, final I item) { 17 | 18 | } 19 | 20 | @Override 21 | public void onUpdate(final Book book, final int depth, final I item) { 22 | 23 | } 24 | 25 | @Override 26 | public void onDelete(final Book book, final int depth, final I item) { 27 | 28 | } 29 | 30 | @Override 31 | public void onReset(final Book book) { 32 | 33 | } 34 | 35 | @Override 36 | public void onTopBidUpdated(final Book book) { 37 | 38 | } 39 | 40 | @Override 41 | public void onTopAskUpdated(final Book book) { 42 | 43 | } 44 | 45 | @Override 46 | public void onFinished(final InstrumentBooks instrumentBook) { 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /java/commons/src/main/java/com/epam/deltix/data/connectors/commons/l2/PriceBook.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons.l2; 2 | 3 | import com.epam.deltix.dfp.Decimal; 4 | import com.epam.deltix.dfp.Decimal64Utils; 5 | import com.epam.deltix.timebase.messages.TypeConstants; 6 | 7 | /** 8 | *

Represents type of book which stores items based on price.
9 | * This book stores all items sorted, according to side of the book.
10 | * When event is processed this book uses binary search to find item to be changed.

11 | * 12 | *

This class is not thread-safe. If multiple threads access instance of this class concurrently, it must be 13 | * synchronized externally.

14 | * 15 | * @param type of item which can be stored in this book 16 | * @param type of event which can be applied to items in this book 17 | */ 18 | public class PriceBook, E extends BookEvent> extends Book { 19 | 20 | /** 21 | * Constructs new PriceBook object with specified side. 22 | * 23 | * @param isOffer side of new book. Must be true if the side is offers, else - false. 24 | */ 25 | PriceBook(final boolean isOffer) { 26 | super(isOffer); 27 | } 28 | 29 | @Override 30 | protected void onEvent(final E event) { 31 | final int n = binarySearchPrice(event.getPrice()); 32 | 33 | final boolean delete = event.getSize() == TypeConstants.DECIMAL_NULL; 34 | 35 | if (n < 0) { 36 | if (!delete) { // skip delete for unknown price level 37 | insert(-n - 1, event); 38 | } 39 | } else { 40 | if (delete) { 41 | delete(n); 42 | } else { 43 | update(n, event); 44 | } 45 | } 46 | } 47 | 48 | /** 49 | *

Finds and returns item by it's price. 50 | * This method is based on binary search.

51 | * 52 | * @param price price of the item to be found 53 | * @return positive index of the item if it is found, else - negative value 54 | */ 55 | protected int binarySearchPrice(@Decimal final long price) { 56 | int low = 0; 57 | int high = currentSize - 1; 58 | 59 | while (low <= high) { 60 | final int mid = (low + high) >>> 1; 61 | final long midVal = items[mid].getPrice(); 62 | final int cmp = (isOffer ? 63 | 1 : 64 | -1) * Decimal64Utils.compareTo(midVal, price); // isOffer ? midVal - price : price - midVal; 65 | 66 | if (cmp < 0) { 67 | low = mid + 1; 68 | } else if (cmp > 0) { 69 | high = mid - 1; 70 | } else { 71 | return mid; // price found 72 | } 73 | } 74 | 75 | return -(low + 1); // price not found 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /java/commons/src/test/java/com/epam/deltix/data/connectors/commons/SymbolMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.commons; 2 | 3 | import com.epam.deltix.timebase.messages.InstrumentMessage; 4 | import com.epam.deltix.timebase.messages.universal.PackageHeader; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Arrays; 10 | import java.util.List; 11 | 12 | class SymbolMapperTest { 13 | 14 | @Test 15 | void renaming() throws Exception { 16 | final String[] symbols = new String[] {"SYM1", "SYM2=2MYS", "S\\=M3=S\\\\M3"}; 17 | final String[] expectedNormalizedSymbols = new String[] {"SYM1", "SYM2", "S=M3"}; 18 | final String[] expectedReceivedSymbols = new String[] {"SYM1", "2MYS", "S\\M3"}; 19 | 20 | final List receivedSymbols = new ArrayList<>(); 21 | 22 | final SymbolMapper mapper = new SymbolMapper(() -> new CloseableMessageOutput() { 23 | @Override 24 | public void close() { 25 | } 26 | 27 | @Override 28 | public void send(final InstrumentMessage message) { 29 | receivedSymbols.add(message.getSymbol().toString()); 30 | } 31 | }, symbols); 32 | 33 | Assertions.assertArrayEquals(expectedNormalizedSymbols, mapper.normalized()); 34 | 35 | final MessageOutput output = mapper.create(); 36 | 37 | final PackageHeader message = new PackageHeader(); 38 | Arrays.stream(mapper.normalized()).forEach(s -> { message.setSymbol(s); output.send(message); }); 39 | 40 | Assertions.assertArrayEquals(expectedReceivedSymbols, receivedSymbols.toArray()); 41 | } 42 | } -------------------------------------------------------------------------------- /java/commons/src/testFixtures/java/com/epam/deltix/data/connectors/test/fixtures/integration/TbIntTestPreparation.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.test.fixtures.integration; 2 | 3 | import org.testcontainers.containers.GenericContainer; 4 | import org.testcontainers.containers.Network; 5 | import org.testcontainers.utility.DockerImageName; 6 | 7 | import java.time.Duration; 8 | 9 | public class TbIntTestPreparation { 10 | public static final String TIMEBASE_SERVER_VERSION = System.getProperty("timebaseServerVersion", "6.1"); 11 | 12 | public static final Network NETWORK = Network.newNetwork(); 13 | 14 | public static final GenericContainer TIMEBASE_CONTAINER = new GenericContainer( 15 | DockerImageName.parse("finos/timebase-ce-server:" + TIMEBASE_SERVER_VERSION)). 16 | withReuse(true). 17 | withNetwork(NETWORK). 18 | withNetworkAliases("timebase"). 19 | withExposedPorts(8011). 20 | withStartupTimeout(Duration.ofMinutes(5)); 21 | } 22 | -------------------------------------------------------------------------------- /java/connectors/ascendex/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } 8 | -------------------------------------------------------------------------------- /java/connectors/ascendex/src/main/java/com/epam/deltix/data/connectors/ascendex/AscendexConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.ascendex; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Ascendex") 7 | public class AscendexConnectorSettings extends DataConnectorSettings { 8 | private String wsUrl = "wss://ascendex.com/api/pro/v1/stream"; 9 | 10 | AscendexConnectorSettings() { 11 | super(); 12 | } 13 | 14 | public AscendexConnectorSettings(String name, String wsUrl, String tbUrl, String stream) { 15 | super(tbUrl, stream); 16 | setName(name); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /java/connectors/ascendex/src/main/java/com/epam/deltix/data/connectors/ascendex/AscendexDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.ascendex; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Ascendex") 7 | public class AscendexDataConnector extends DataConnector { 8 | public AscendexDataConnector(AscendexConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final AscendexFeed result = new AscendexFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/binance-futures/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/binance-futures/src/main/java/com/epam/deltix/data/connectors/binance/futures/BinanceFuturesConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.binance.futures; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Binance-Futures") 7 | public class BinanceFuturesConnectorSettings extends DataConnectorSettings { 8 | private String wsUrl = "wss://fstream.binance.com/stream"; 9 | 10 | private String restUrl = "https://fapi.binance.com/fapi/v1"; 11 | 12 | public BinanceFuturesConnectorSettings() { 13 | super(); 14 | } 15 | 16 | public BinanceFuturesConnectorSettings(String tbUrl, String stream, String wsUrl, String restUrl) { 17 | super(tbUrl, stream); 18 | this.wsUrl = wsUrl; 19 | this.restUrl = restUrl; 20 | } 21 | 22 | public String getWsUrl() { 23 | return wsUrl; 24 | } 25 | 26 | public void setWsUrl(String wsUrl) { 27 | this.wsUrl = wsUrl; 28 | } 29 | 30 | public String getRestUrl() { 31 | return restUrl; 32 | } 33 | 34 | public void setRestUrl(String restUrl) { 35 | this.restUrl = restUrl; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /java/connectors/binance-futures/src/main/java/com/epam/deltix/data/connectors/binance/futures/BinanceFuturesDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.binance.futures; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Binance-Futures") 7 | public class BinanceFuturesDataConnector extends DataConnector { 8 | public BinanceFuturesDataConnector(BinanceFuturesConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final BinanceFuturesFeed result = new BinanceFuturesFeed( 24 | settings().getWsUrl(), 25 | settings().getRestUrl(), 26 | settings().getDepth(), 27 | selected, 28 | outputFactory.create(), 29 | errorListener, 30 | logger(), 31 | false, 32 | symbols); 33 | result.start(); 34 | return result; 35 | }; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /java/connectors/binance-spot/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/binance-spot/src/main/java/com/epam/deltix/data/connectors/binance/spot/BinanceSpotConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.binance.spot; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Binance-Spot") 7 | public class BinanceSpotConnectorSettings extends DataConnectorSettings { 8 | private String wsUrl = "wss://stream.binance.com:9443/ws"; 9 | 10 | private String restUrl = "https://api.binance.com/api/v3"; 11 | 12 | public BinanceSpotConnectorSettings() { 13 | super(); 14 | } 15 | 16 | public BinanceSpotConnectorSettings(String tbUrl, String stream, String wsUrl) { 17 | super(tbUrl, stream); 18 | this.wsUrl = wsUrl; 19 | } 20 | 21 | public String getWsUrl() { 22 | return wsUrl; 23 | } 24 | 25 | public void setWsUrl(String wsUrl) { 26 | this.wsUrl = wsUrl; 27 | } 28 | 29 | public String getRestUrl() { 30 | return restUrl; 31 | } 32 | 33 | public void setRestUrl(String restUrl) { 34 | this.restUrl = restUrl; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /java/connectors/binance-spot/src/main/java/com/epam/deltix/data/connectors/binance/spot/BinanceSpotDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.binance.spot; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Binance-Spot") 7 | public class BinanceSpotDataConnector extends DataConnector { 8 | public BinanceSpotDataConnector(BinanceSpotConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final BinanceSpotFeed result = new BinanceSpotFeed( 24 | settings().getWsUrl(), 25 | settings().getRestUrl(), 26 | settings().getDepth(), 27 | selected, 28 | outputFactory.create(), 29 | errorListener, 30 | logger(), 31 | false, 32 | symbols); 33 | result.start(); 34 | return result; 35 | }; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /java/connectors/bitfinex/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/bitfinex/src/main/java/com/epam/deltix/data/connectors/bitfinex/BitfinexSpotConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.bitfinex; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("BITFINEX") 7 | public class BitfinexSpotConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://api.bitfinex.com/ws/2"; 10 | 11 | public BitfinexSpotConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public BitfinexSpotConnectorSettings(String tbUrl, String stream, String wsUrl) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/bitfinex/src/main/java/com/epam/deltix/data/connectors/bitfinex/BitfinexSpotDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.bitfinex; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("BITFINEX") 7 | public class BitfinexSpotDataConnector extends DataConnector { 8 | public BitfinexSpotDataConnector(BitfinexSpotConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final BitfinexSpotFeed result = new BitfinexSpotFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/bitmart/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/bitmart/src/main/java/com/epam/deltix/data/connectors/bitmart/BitmartSpotConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.bitmart; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("BITMART") 7 | public class BitmartSpotConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://ws-manager-compress.bitmart.com/api?protocol=1.1"; 10 | 11 | public BitmartSpotConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public BitmartSpotConnectorSettings(String tbUrl, String stream, String wsUrl) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/bitmart/src/main/java/com/epam/deltix/data/connectors/bitmart/BitmartSpotDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.bitmart; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("BITMART") 7 | public class BitmartSpotDataConnector extends DataConnector { 8 | public BitmartSpotDataConnector(BitmartSpotConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final BitmartSpotFeed result = new BitmartSpotFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/bitmex/README.md: -------------------------------------------------------------------------------- 1 | # BitMEX Data Connector -------------------------------------------------------------------------------- /java/connectors/bitmex/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/bitmex/src/main/java/com/epam/deltix/data/connectors/bitmex/BitmexConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.bitmex; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Bitmex") 7 | public class BitmexConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://ws.bitmex.com/realtime"; 10 | 11 | public BitmexConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public BitmexConnectorSettings(String tbUrl, String stream, String wsUrl) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/bitmex/src/main/java/com/epam/deltix/data/connectors/bitmex/BitmexDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.bitmex; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Bitmex") 7 | public class BitmexDataConnector extends DataConnector { 8 | public BitmexDataConnector(BitmexConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final BitmexFeed result = new BitmexFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/build.gradle: -------------------------------------------------------------------------------- 1 | defaultTasks 'clean', 'build' 2 | 3 | ext.nowTimestamp = new Date().format('yyyy/MM/dd HH:mm:ss z', TimeZone.getTimeZone('GMT')) 4 | 5 | def leafProjects = subprojects.findAll { subproject -> 6 | subproject.subprojects.empty 7 | } 8 | 9 | /****** For all java connectors subprojects ******/ 10 | configure(leafProjects) { 11 | 12 | dependencies { 13 | implementation project(':java:commons') 14 | implementation 'io.github.green4j:green-jelly' 15 | 16 | implementation 'org.finos.timebase-ce:timebase-client' 17 | implementation 'com.epam.deltix:dfp' 18 | 19 | testImplementation 'org.junit.jupiter:junit-jupiter-api' 20 | testImplementation(testFixtures(project(':java:commons'))) 21 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' 22 | } 23 | 24 | tasks.withType(JavaCompile) { 25 | options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" 26 | } 27 | 28 | test { 29 | useJUnitPlatform() 30 | testLogging { 31 | showStandardStreams = true 32 | exceptionFormat = 'full' 33 | } 34 | } 35 | 36 | / ** 37 | * All commons projects' classes should be included into the result jar 38 | * / 39 | project.afterEvaluate { 40 | project.configurations.collectMany { it.allDependencies }. 41 | findAll { it instanceof ProjectDependency }. 42 | forEach { jar.from project(it.getDependencyProject().path).sourceSets.main.output } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /java/connectors/bybit/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/bybit/src/main/java/com/epam/deltix/data/connectors/bybit/BybitConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.bybit; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Bybit") 7 | public class BybitConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://stream.bybit.com/spot/quote/ws/v1"; 10 | 11 | public BybitConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public BybitConnectorSettings(String tbUrl, String stream, String wsUrl) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/bybit/src/main/java/com/epam/deltix/data/connectors/bybit/BybitDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.bybit; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Bybit") 7 | public class BybitDataConnector extends DataConnector { 8 | public BybitDataConnector(BybitConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final BybitFeed result = new BybitFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/bybit/src/main/java/com/epam/deltix/data/connectors/bybit/BybitEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.bybit; 2 | 3 | public enum BybitEndpoint { 4 | Spot, 5 | Linear, 6 | Inverse, 7 | Option; 8 | 9 | public static BybitEndpoint typeFromAddress(String wsEndpoint) { 10 | if (wsEndpoint == null || wsEndpoint.length() == 0) { 11 | return null; 12 | } 13 | 14 | wsEndpoint = wsEndpoint.toLowerCase(); 15 | 16 | if (wsEndpoint.contains("/spot")) { 17 | return Spot; 18 | } 19 | else if (wsEndpoint.contains("/linear")) { 20 | return Linear; 21 | } 22 | else if (wsEndpoint.contains("/inverse")) { 23 | return Inverse; 24 | } 25 | else if (wsEndpoint.contains("/option")) { 26 | return Option; 27 | } 28 | 29 | return null; 30 | } 31 | 32 | public static String getEndpoint(BybitEndpoint endpoint) { 33 | String result = null; 34 | 35 | switch (endpoint) { 36 | case Spot: 37 | result = "spot"; 38 | break; 39 | 40 | case Linear: 41 | result = "linear"; 42 | break; 43 | 44 | case Inverse: 45 | result = "inverse"; 46 | break; 47 | 48 | case Option: 49 | result = "option"; 50 | break; 51 | } 52 | 53 | return result; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /java/connectors/coinbase/README.md: -------------------------------------------------------------------------------- 1 | # Coinbase Data Connector -------------------------------------------------------------------------------- /java/connectors/coinbase/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/coinbase/src/main/java/com/epam/deltix/data/connectors/coinbase/CoinbaseConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.coinbase; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Coinbase") 7 | public class CoinbaseConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://ws-feed.pro.coinbase.com"; 10 | 11 | private String apiKey; 12 | 13 | private String apiSecret; 14 | 15 | private String passphrase; 16 | 17 | public CoinbaseConnectorSettings() { 18 | super(); 19 | } 20 | 21 | public CoinbaseConnectorSettings(String name, String wsUrl, String tbUrl, String stream) { 22 | super(tbUrl, stream); 23 | setName(name); 24 | this.wsUrl = wsUrl; 25 | } 26 | 27 | public String getWsUrl() { 28 | return wsUrl; 29 | } 30 | 31 | public void setWsUrl(String wsUrl) { 32 | this.wsUrl = wsUrl; 33 | } 34 | 35 | public String getApiKey() { 36 | return apiKey; 37 | } 38 | 39 | public void setApiKey(String apiKey) { 40 | this.apiKey = apiKey; 41 | } 42 | 43 | public String getApiSecret() { 44 | return apiSecret; 45 | } 46 | 47 | public void setApiSecret(String apiSecret) { 48 | this.apiSecret = apiSecret; 49 | } 50 | 51 | public String getPassphrase() { 52 | return passphrase; 53 | } 54 | 55 | public void setPassphrase(String passphrase) { 56 | this.passphrase = passphrase; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /java/connectors/coinbase/src/main/java/com/epam/deltix/data/connectors/coinbase/CoinbaseDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.coinbase; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Coinbase") 7 | public class CoinbaseDataConnector extends DataConnector { 8 | public CoinbaseDataConnector(CoinbaseConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final CoinbaseFeed result = new CoinbaseFeed( 24 | settings(), 25 | selected, 26 | outputFactory.create(), 27 | errorListener, 28 | logger(), 29 | symbols); 30 | result.start(); 31 | return result; 32 | }; 33 | } 34 | 35 | public static void main(String[] args) throws Exception { 36 | final CoinbaseDataConnector dataConnector = new CoinbaseDataConnector( 37 | new CoinbaseConnectorSettings( 38 | "coinbase", 39 | "wss://ws-feed.pro.coinbase.com", 40 | "dxtick://localhost:8011", 41 | "coinbase" 42 | ) 43 | ); 44 | 45 | final MdModel model = dataConnector.model(); 46 | 47 | final MdModel.Availability availability = model.available(); 48 | dataConnector.logger().info(() -> availability.toString()); 49 | 50 | dataConnector.subscribe( 51 | model.select(). 52 | withTrades(). 53 | withLevel1(). 54 | withLevel2(). 55 | build(), 56 | "ETH-USD=ETH/USD"/*, "ETH-EUR"*/ 57 | ); 58 | 59 | System.in.read(); 60 | 61 | dataConnector.close(); 62 | 63 | dataConnector.logger().info(() -> "CLOSED"); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /java/connectors/cryptofacilities/README.md: -------------------------------------------------------------------------------- 1 | # Coinbase Data Connector -------------------------------------------------------------------------------- /java/connectors/cryptofacilities/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/cryptofacilities/src/main/java/com/epam/deltix/data/connectors/cryptofacilities/CryptofacilitiesConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.cryptofacilities; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Cryptofacilities") 7 | public class CryptofacilitiesConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://www.cryptofacilities.com/ws/v1"; 10 | 11 | public CryptofacilitiesConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public CryptofacilitiesConnectorSettings(String wsUrl, String tbUrl, String stream) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /java/connectors/cryptofacilities/src/main/java/com/epam/deltix/data/connectors/cryptofacilities/CryptofacilitiesDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.cryptofacilities; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Cryptofacilities") 7 | public class CryptofacilitiesDataConnector extends DataConnector { 8 | public CryptofacilitiesDataConnector(CryptofacilitiesConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final CryptofacilitiesFeed result = new CryptofacilitiesFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/deribit/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } 8 | -------------------------------------------------------------------------------- /java/connectors/deribit/src/main/java/com/epam/deltix/data/connectors/deribit/DeribitConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.deribit; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Deribit") 7 | public class DeribitConnectorSettings extends DataConnectorSettings { 8 | private String wsUrl = "wss://deribit.com/ws/api/v2"; 9 | 10 | DeribitConnectorSettings() { 11 | super(); 12 | } 13 | 14 | public DeribitConnectorSettings(String name, String wsUrl, String tbUrl, String stream) { 15 | super(tbUrl, stream); 16 | setName(name); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /java/connectors/deribit/src/main/java/com/epam/deltix/data/connectors/deribit/DeribitDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.deribit; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Deribit") 7 | public class DeribitDataConnector extends DataConnector { 8 | public DeribitDataConnector(DeribitConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final DeribitFeed result = new DeribitFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /java/connectors/hitbtc/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/hitbtc/src/main/java/com/epam/deltix/data/connectors/hitbtc/HitbtcConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.hitbtc; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("HITBTC") 7 | public class HitbtcConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://api.hitbtc.com/api/3/ws/public"; 10 | 11 | public HitbtcConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public HitbtcConnectorSettings(String tbUrl, String stream, String wsUrl) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/hitbtc/src/main/java/com/epam/deltix/data/connectors/hitbtc/HitbtcDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.hitbtc; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("HITBTC") 7 | public class HitbtcDataConnector extends DataConnector { 8 | public HitbtcDataConnector(HitbtcConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final HitbtcFeed result = new HitbtcFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/huobi-futures/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/huobi-futures/src/main/java/com/epam/deltix/data/connectors/huobi/HuobiFuturesConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.huobi; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Huobi-Futures") 7 | public class HuobiFuturesConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://api.hbdm.com/ws"; 10 | 11 | public HuobiFuturesConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public HuobiFuturesConnectorSettings(String tbUrl, String stream, String wsUrl) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/huobi-futures/src/main/java/com/epam/deltix/data/connectors/huobi/HuobiFuturesDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.huobi; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Huobi-Futures") 7 | public class HuobiFuturesDataConnector extends DataConnector { 8 | public HuobiFuturesDataConnector(HuobiFuturesConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final HuobiFuturesFeed result = new HuobiFuturesFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/huobi-spot/README.md: -------------------------------------------------------------------------------- 1 | # Huobi Spot Data Connector -------------------------------------------------------------------------------- /java/connectors/huobi-spot/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/huobi-spot/src/main/java/com/epam/deltix/data/connectors/huobi/HuobiSpotConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.huobi; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Huobi-Spot") 7 | public class HuobiSpotConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://api.huobi.pro/ws"; 10 | 11 | public HuobiSpotConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public HuobiSpotConnectorSettings(String tbUrl, String stream, String wsUrl) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/huobi-spot/src/main/java/com/epam/deltix/data/connectors/huobi/HuobiSpotDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.huobi; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Huobi-Spot") 7 | public class HuobiSpotDataConnector extends DataConnector { 8 | public HuobiSpotDataConnector(HuobiSpotConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final HuobiSpotFeed result = new HuobiSpotFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/kraken-futures/README.md: -------------------------------------------------------------------------------- 1 | # Kraken Data Connector -------------------------------------------------------------------------------- /java/connectors/kraken-futures/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/kraken-futures/src/main/java/com/epam/deltix/data/connectors/kraken/KrakenFuturesConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.kraken; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Kraken-Futures") 7 | public class KrakenFuturesConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://futures.kraken.com/ws/v1"; 10 | 11 | public KrakenFuturesConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public KrakenFuturesConnectorSettings(String tbUrl, String stream, String wsUrl) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/kraken-futures/src/main/java/com/epam/deltix/data/connectors/kraken/KrakenFuturesDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.kraken; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Kraken-Futures") 7 | public class KrakenFuturesDataConnector extends DataConnector { 8 | public KrakenFuturesDataConnector(KrakenFuturesConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final KrakenFuturesFeed result = new KrakenFuturesFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/kraken-spot/README.md: -------------------------------------------------------------------------------- 1 | # Kraken Data Connector -------------------------------------------------------------------------------- /java/connectors/kraken-spot/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/kraken-spot/src/main/java/com/epam/deltix/data/connectors/kraken/KrakenSpotConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.kraken; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Kraken-Spot") 7 | public class KrakenSpotConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://ws.kraken.com"; 10 | 11 | public KrakenSpotConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public KrakenSpotConnectorSettings(String tbUrl, String stream, String wsUrl) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/kraken-spot/src/main/java/com/epam/deltix/data/connectors/kraken/KrakenSpotDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.kraken; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Kraken-Spot") 7 | public class KrakenSpotDataConnector extends DataConnector { 8 | public KrakenSpotDataConnector(KrakenSpotConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final KrakenSpotFeed result = new KrakenSpotFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/kucoin/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/kucoin/src/main/java/com/epam/deltix/data/connectors/kucoin/KucoinConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.kucoin; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Kucoin") 7 | public class KucoinConnectorSettings extends DataConnectorSettings { 8 | private String wsUrl = "wss://ws-api.kucoin.com/endpoint"; 9 | 10 | private String restUrl = "https://api.kucoin.com/api/v1"; 11 | 12 | public KucoinConnectorSettings() { 13 | super(); 14 | } 15 | 16 | public KucoinConnectorSettings(String tbUrl, String stream, String wsUrl) { 17 | super(tbUrl, stream); 18 | this.wsUrl = wsUrl; 19 | } 20 | 21 | public String getWsUrl() { 22 | return wsUrl; 23 | } 24 | 25 | public void setWsUrl(String wsUrl) { 26 | this.wsUrl = wsUrl; 27 | } 28 | 29 | public String getRestUrl() { 30 | return restUrl; 31 | } 32 | 33 | public void setRestUrl(String restUrl) { 34 | this.restUrl = restUrl; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /java/connectors/kucoin/src/main/java/com/epam/deltix/data/connectors/kucoin/KucoinDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.kucoin; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Kucoin") 7 | public class KucoinDataConnector extends DataConnector { 8 | public KucoinDataConnector(KucoinConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final KucoinFeed result = new KucoinFeed( 24 | settings().getWsUrl(), 25 | settings().getRestUrl(), 26 | settings().getDepth(), 27 | selected, 28 | outputFactory.create(), 29 | errorListener, 30 | logger(), 31 | true, 32 | symbols); 33 | result.start(); 34 | return result; 35 | }; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /java/connectors/okcoin/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/okcoin/src/main/java/com/epam/deltix/data/connectors/okcoin/OkcoinSpotConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.okcoin; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("OKCOIN") 7 | public class OkcoinSpotConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://real.okcoin.com:8443/ws/v5/public"; 10 | 11 | public OkcoinSpotConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public OkcoinSpotConnectorSettings(String tbUrl, String stream, String wsUrl) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/okcoin/src/main/java/com/epam/deltix/data/connectors/okcoin/OkcoinSpotDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.okcoin; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Okcoin") 7 | public class OkcoinSpotDataConnector extends DataConnector { 8 | public OkcoinSpotDataConnector(OkcoinSpotConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final OkcoinSpotFeed result = new OkcoinSpotFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/okx/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/okx/src/main/java/com/epam/deltix/data/connectors/okx/OkxSpotConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.okx; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("OKX") 7 | public class OkxSpotConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://ws.okex.com:8443/ws/v5/public"; 10 | 11 | public OkxSpotConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public OkxSpotConnectorSettings(String tbUrl, String stream, String wsUrl) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/okx/src/main/java/com/epam/deltix/data/connectors/okx/OkxSpotDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.okx; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("OKX") 7 | public class OkxSpotDataConnector extends DataConnector { 8 | public OkxSpotDataConnector(OkxSpotConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final OkxSpotFeed result = new OkxSpotFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/onetrading/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/onetrading/src/main/java/com/epam/deltix/data/connectors/onetrading/OneTradingSpotConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.onetrading; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("ONETRADING") 7 | public class OneTradingSpotConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://streams.fast.onetrading.com?x-version=3"; 10 | 11 | public OneTradingSpotConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public OneTradingSpotConnectorSettings(String tbUrl, String stream, String wsUrl) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/onetrading/src/main/java/com/epam/deltix/data/connectors/onetrading/OneTradingSpotDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.onetrading; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("ONETRADING") 7 | public class OneTradingSpotDataConnector extends DataConnector { 8 | public OneTradingSpotDataConnector(OneTradingSpotConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final OneTradingSpotFeed result = new OneTradingSpotFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/poloniex/README.md: -------------------------------------------------------------------------------- 1 | # Coinbase Data Connector -------------------------------------------------------------------------------- /java/connectors/poloniex/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/poloniex/src/main/java/com/epam/deltix/data/connectors/poloniex/PoloniexConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.poloniex; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("Poloniex") 7 | public class PoloniexConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://ws.poloniex.com/ws/public"; 10 | 11 | public PoloniexConnectorSettings() { 12 | super(); 13 | } 14 | 15 | public PoloniexConnectorSettings(String wsUrl, String tbUrl, String stream) { 16 | super(tbUrl, stream); 17 | this.wsUrl = wsUrl; 18 | } 19 | 20 | public String getWsUrl() { 21 | return wsUrl; 22 | } 23 | 24 | public void setWsUrl(String wsUrl) { 25 | this.wsUrl = wsUrl; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /java/connectors/poloniex/src/main/java/com/epam/deltix/data/connectors/poloniex/PoloniexDataConnector.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.poloniex; 2 | 3 | import com.epam.deltix.data.connectors.commons.*; 4 | import com.epam.deltix.data.connectors.commons.annotations.Connector; 5 | 6 | @Connector("Poloniex") 7 | public class PoloniexDataConnector extends DataConnector { 8 | public PoloniexDataConnector(PoloniexConnectorSettings settings) { 9 | super(settings, MdModel.availability() 10 | .withTrades() 11 | .withLevel1() 12 | .withLevel2().build() 13 | ); 14 | } 15 | 16 | @Override 17 | protected RetriableFactory doSubscribe( 18 | final MdModel.Options selected, 19 | final CloseableMessageOutputFactory outputFactory, 20 | final String... symbols) { 21 | 22 | return errorListener -> { 23 | final PoloniexFeed result = new PoloniexFeed( 24 | settings().getWsUrl(), 25 | settings().getDepth(), 26 | selected, 27 | outputFactory.create(), 28 | errorListener, 29 | logger(), 30 | symbols); 31 | result.start(); 32 | return result; 33 | }; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /java/connectors/polygon-io/README.md: -------------------------------------------------------------------------------- 1 | ## Polygon.io Data Connector 2 | 3 | **Important**: This connector writes data for exchanges and conditions using their numeric identifiers as received. 4 | To interpret these numeric identifiers, please use the following resources from Polygon.io: 5 | 6 | - For Exchange IDs: consult the [Exchanges](https://polygon.io/docs/crypto/get_v3_reference_exchanges) endpoint documentation. 7 | - For Condition IDs: reference the [Conditions and Indicators](https://polygon.io/glossary/conditions-indicators) glossary page. 8 | -------------------------------------------------------------------------------- /java/connectors/polygon-io/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":java:commons") 3 | 4 | implementation "org.finos.timebase-ce:timebase-pub" 5 | implementation "com.epam.deltix:timebase-messages" 6 | implementation "com.epam.deltix:timebase-collections" 7 | } -------------------------------------------------------------------------------- /java/connectors/polygon-io/src/main/java/com/epam/deltix/data/connectors/polygon/PolygonIoConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.polygon; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("POLYGON-IO") 7 | public class PolygonIoConnectorSettings extends DataConnectorSettings { 8 | 9 | private String wsUrl = "wss://socket.polygon.io/stocks"; 10 | 11 | private String apiKey; 12 | 13 | public PolygonIoConnectorSettings() { 14 | super(); 15 | } 16 | 17 | public PolygonIoConnectorSettings(String tbUrl, String stream, String wsUrl) { 18 | super(tbUrl, stream); 19 | this.wsUrl = wsUrl; 20 | } 21 | 22 | public String getWsUrl() { 23 | return wsUrl; 24 | } 25 | 26 | public void setWsUrl(String wsUrl) { 27 | this.wsUrl = wsUrl; 28 | } 29 | 30 | public String getApiKey() { 31 | return apiKey; 32 | } 33 | 34 | public void setApiKey(String apiKey) { 35 | this.apiKey = apiKey; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /java/connectors/polygon-io/src/main/java/com/epam/deltix/data/connectors/polygon/PolygonIoEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.polygon; 2 | 3 | public enum PolygonIoEndpoint { 4 | Stocks, 5 | Options, 6 | Indices, 7 | Forex, 8 | Crypto; 9 | 10 | public static PolygonIoEndpoint typeFromAddress(String wsEndpoint) { 11 | if (wsEndpoint == null || wsEndpoint.isEmpty()) { 12 | return null; 13 | } 14 | 15 | wsEndpoint = wsEndpoint.toLowerCase(); 16 | if (wsEndpoint.contains("/stocks")) { 17 | return Stocks; 18 | } else if (wsEndpoint.contains("/options")) { 19 | return Options; 20 | } else if (wsEndpoint.contains("/indices")) { 21 | return Indices; 22 | } else if (wsEndpoint.contains("/forex")) { 23 | return Forex; 24 | } else if (wsEndpoint.contains("/crypto")) { 25 | return Crypto; 26 | } 27 | 28 | return null; 29 | } 30 | 31 | public static String getEndpoint(PolygonIoEndpoint endpoint) { 32 | String result = null; 33 | 34 | switch (endpoint) { 35 | case Stocks: 36 | result = "stocks"; 37 | break; 38 | 39 | case Options: 40 | result = "options"; 41 | break; 42 | 43 | case Indices: 44 | result = "indices"; 45 | break; 46 | 47 | case Forex: 48 | result = "forex"; 49 | break; 50 | 51 | case Crypto: 52 | result = "crypto"; 53 | break; 54 | } 55 | 56 | return result; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /java/connectors/polygon-io/src/main/java/com/epam/deltix/data/connectors/polygon/PolygonIoForexFeed.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.polygon; 2 | 3 | import com.epam.deltix.data.connectors.commons.CloseableMessageOutput; 4 | import com.epam.deltix.data.connectors.commons.ErrorListener; 5 | import com.epam.deltix.data.connectors.commons.Logger; 6 | import com.epam.deltix.data.connectors.commons.MdModel; 7 | import com.epam.deltix.data.connectors.commons.json.JsonArray; 8 | import com.epam.deltix.data.connectors.commons.json.JsonObject; 9 | import com.epam.deltix.data.connectors.commons.json.JsonValue; 10 | import com.epam.deltix.data.connectors.commons.json.JsonWriter; 11 | import com.epam.deltix.dfp.Decimal64Utils; 12 | 13 | public class PolygonIoForexFeed extends PolygonIoFeed { 14 | 15 | 16 | public PolygonIoForexFeed(final PolygonIoConnectorSettings settings, 17 | MdModel.Options selected, 18 | CloseableMessageOutput output, 19 | ErrorListener errorListener, 20 | Logger logger, 21 | String... symbols) { 22 | 23 | super(settings, selected, output, errorListener, logger, symbols); 24 | } 25 | 26 | public void subscribe(JsonWriter jsonWriter, String... symbols) { 27 | super.subscribe(jsonWriter, symbols); 28 | 29 | JsonValue json = JsonValue.newObject(); 30 | JsonObject body = json.asObject(); 31 | body.putString("action", "subscribe"); 32 | body.putString("params", buildParams(symbols)); 33 | json.toJsonAndEoj(jsonWriter); 34 | } 35 | 36 | private String buildParams(String[] symbols) { 37 | StringBuilder params = new StringBuilder(); 38 | for (String symbol : symbols) { 39 | if (selected().level1()) { 40 | params.append("C.").append(symbol).append(","); 41 | } 42 | } 43 | params.setLength(params.length() - 1); 44 | return params.toString(); 45 | } 46 | 47 | @Override 48 | protected void processPolygonData(JsonArray array) { 49 | for (int i = 0; i < array.size(); ++i) { 50 | JsonObject obj = array.getObject(i); 51 | String event = obj.getString("ev"); 52 | if ("C".equalsIgnoreCase(event)) { 53 | String instrument = obj.getString("p"); 54 | long timestamp = obj.getLong("t"); 55 | long askPrice = obj.getDecimal64Required("a"); 56 | long bidPrice = obj.getDecimal64Required("b"); 57 | String exchange = obj.getString("x"); 58 | 59 | processor().onL1Snapshot( 60 | instrument, timestamp, 61 | bidPrice, Decimal64Utils.ZERO, exchange, 62 | askPrice, Decimal64Utils.ZERO, exchange 63 | ); 64 | } 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /java/connectors/polygon-io/src/main/java/com/epam/deltix/data/connectors/polygon/PolygonIoIndicesFeed.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.polygon; 2 | 3 | import com.epam.deltix.data.connectors.commons.CloseableMessageOutput; 4 | import com.epam.deltix.data.connectors.commons.ErrorListener; 5 | import com.epam.deltix.data.connectors.commons.Logger; 6 | import com.epam.deltix.data.connectors.commons.MdModel; 7 | import com.epam.deltix.data.connectors.commons.json.JsonArray; 8 | import com.epam.deltix.data.connectors.commons.json.JsonObject; 9 | import com.epam.deltix.data.connectors.commons.json.JsonValue; 10 | import com.epam.deltix.data.connectors.commons.json.JsonWriter; 11 | import com.epam.deltix.dfp.Decimal64Utils; 12 | 13 | public class PolygonIoIndicesFeed extends PolygonIoFeed { 14 | 15 | 16 | public PolygonIoIndicesFeed(final PolygonIoConnectorSettings settings, 17 | MdModel.Options selected, 18 | CloseableMessageOutput output, 19 | ErrorListener errorListener, 20 | Logger logger, 21 | String... symbols) { 22 | 23 | super(settings, selected, output, errorListener, logger, symbols); 24 | } 25 | 26 | public void subscribe(JsonWriter jsonWriter, String... symbols) { 27 | super.subscribe(jsonWriter, symbols); 28 | 29 | JsonValue json = JsonValue.newObject(); 30 | JsonObject body = json.asObject(); 31 | body.putString("action", "subscribe"); 32 | body.putString("params", buildParams(symbols)); 33 | json.toJsonAndEoj(jsonWriter); 34 | } 35 | 36 | private String buildParams(String[] symbols) { 37 | StringBuilder params = new StringBuilder(); 38 | for (String symbol : symbols) { 39 | if (selected().level1()) { 40 | params.append("V.").append(symbol).append(","); 41 | } 42 | } 43 | params.setLength(params.length() - 1); 44 | return params.toString(); 45 | } 46 | 47 | @Override 48 | protected void processPolygonData(JsonArray array) { 49 | for (int i = 0; i < array.size(); ++i) { 50 | JsonObject obj = array.getObject(i); 51 | String event = obj.getString("ev"); 52 | if ("V".equalsIgnoreCase(event)) { 53 | String instrument = obj.getString("T"); 54 | long timestamp = obj.getLong("t"); 55 | long value = obj.getDecimal64Required("val"); 56 | 57 | processor().onTrade( 58 | instrument, timestamp, value, Decimal64Utils.ZERO 59 | ); 60 | } 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /java/connectors/uniswap/README.md: -------------------------------------------------------------------------------- 1 | # Uniswap Data Connector 2 | 3 | -------------------------------------------------------------------------------- /java/connectors/uniswap/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':java:commons') 3 | 4 | implementation 'org.finos.timebase-ce:timebase-pub' 5 | implementation 'com.epam.deltix:timebase-messages' 6 | implementation 'com.epam.deltix:timebase-collections' 7 | } -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/ConstantListener.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap; 2 | 3 | import com.epam.deltix.data.connectors.commons.Factory; 4 | import com.epam.deltix.data.connectors.commons.JsonObjectsListener; 5 | import com.epam.deltix.data.connectors.commons.MessageOutput; 6 | import com.epam.deltix.data.connectors.commons.json.JsonObject; 7 | import com.epam.deltix.data.uniswap.Action; 8 | import com.epam.deltix.data.uniswap.Updatable; 9 | import com.epam.deltix.data.uniswap.UpdatableAction; 10 | import com.epam.deltix.timebase.messages.MarketMessage; 11 | 12 | import java.util.ArrayList; 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | public class ConstantListener> 18 | implements JsonObjectsListener { 19 | private final Map state = new HashMap<>(); 20 | private final List actions = new ArrayList<>(); 21 | private Factory entityFactory; 22 | private Factory entityActionFactory; 23 | private MessageOutput messageOutput; 24 | 25 | ConstantListener(final Factory entityFactory, 26 | final Factory entityActionFactory, 27 | final MessageOutput messageOutput) { 28 | this.entityFactory = entityFactory; 29 | this.entityActionFactory = entityActionFactory; 30 | this.messageOutput = messageOutput; 31 | } 32 | 33 | @Override 34 | public void onObjectsStarted() { 35 | actions.clear(); 36 | } 37 | 38 | @Override 39 | public void onObject(final JsonObject object) { 40 | final String id = object.getStringRequired("id"); 41 | 42 | U entity = state.get(id); 43 | if (entity == null) { 44 | entity = entityFactory.create(); 45 | entity.update(object); 46 | state.put(id, entity); 47 | 48 | final A action = entityActionFactory.create(); 49 | action.setUpdatableAction(entity, Action.NEW); 50 | 51 | actions.add(action); 52 | } 53 | } 54 | 55 | @Override 56 | @SuppressWarnings("unchecked") 57 | public void onObjectsFinished() { 58 | if (actions.isEmpty()) { 59 | return; 60 | } 61 | 62 | for (int i = 0; i < actions.size(); i++) { 63 | final A action = actions.get(i); 64 | action.setIndex(i); 65 | action.setLast(i == (actions.size() - 1)); 66 | messageOutput.send((MarketMessage) action); // unchecked 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/ReadUniswapData.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap; 2 | 3 | import com.epam.deltix.qsrv.hf.tickdb.pub.DXTickDB; 4 | import com.epam.deltix.qsrv.hf.tickdb.pub.DXTickStream; 5 | import com.epam.deltix.qsrv.hf.tickdb.pub.SelectionOptions; 6 | import com.epam.deltix.qsrv.hf.tickdb.pub.TickCursor; 7 | import com.epam.deltix.qsrv.hf.tickdb.pub.TickDBFactory; 8 | import com.epam.deltix.qsrv.hf.tickdb.pub.TimeConstants; 9 | 10 | // Remove from the repo OR transform to an integration test 11 | public class ReadUniswapData { 12 | public static void main(String[] args) { 13 | final DXTickDB db = TickDBFactory.createFromUrl("dxtick://localhost:8011"); 14 | db.open(true); 15 | for (final DXTickStream stream : db.listStreams()) { 16 | System.out.println(stream.getKey() + " [" + stream.getName() + "]"); 17 | } 18 | 19 | final DXTickStream stream = db.getStream("uniswap"); 20 | 21 | try (TickCursor cursor = stream.select(TimeConstants.USE_CURRENT_TIME, 22 | new SelectionOptions(false, true))) { 23 | while (cursor.next()) { 24 | System.out.println(cursor.getMessage()); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/UniswapCollectionPoller.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap; 2 | 3 | import com.epam.deltix.data.connectors.commons.Factory; 4 | import com.epam.deltix.data.connectors.commons.GraphQlQuery; 5 | import com.epam.deltix.data.connectors.commons.MessageOutput; 6 | import com.epam.deltix.data.connectors.commons.json.JsonObject; 7 | import com.epam.deltix.data.uniswap.Updatable; 8 | import com.epam.deltix.data.uniswap.UpdatableAction; 9 | 10 | import java.util.function.Predicate; 11 | 12 | public class UniswapCollectionPoller> 13 | extends PaginatingUniswapHttpPoller { 14 | 15 | public UniswapCollectionPoller( 16 | final String graphQlUri, 17 | final GraphQlQuery.Query queryTemplate, 18 | final Factory entityFactory, 19 | final Factory entityActionFactory, 20 | final MessageOutput messageOutput) { 21 | this( 22 | graphQlUri, 23 | queryTemplate, 24 | object -> true, 25 | entityFactory, 26 | entityActionFactory, 27 | messageOutput 28 | ); 29 | } 30 | 31 | public UniswapCollectionPoller( 32 | final String graphQlUri, 33 | final GraphQlQuery.Query queryTemplate, 34 | final Predicate objectFilter, 35 | final Factory entityFactory, 36 | final Factory entityActionFactory, 37 | final MessageOutput messageOutput) { 38 | 39 | this( 40 | graphQlUri, 41 | queryTemplate, 42 | object -> true, 43 | entityFactory, 44 | entityActionFactory, 45 | messageOutput, 46 | true); 47 | } 48 | 49 | public UniswapCollectionPoller( 50 | final String graphQlUri, 51 | final GraphQlQuery.Query queryTemplate, 52 | final Predicate objectFilter, 53 | final Factory entityFactory, 54 | final Factory entityActionFactory, 55 | final MessageOutput messageOutput, 56 | final boolean isUpdatable) { 57 | super( 58 | graphQlUri, 59 | queryTemplate, 60 | objectFilter, 61 | 1_000, // TODO: a system property with a default value? 62 | isUpdatable ? 63 | new UpdatableListener( 64 | entityFactory, 65 | entityActionFactory, 66 | messageOutput) : 67 | new ConstantListener( 68 | entityFactory, 69 | entityActionFactory, 70 | messageOutput) 71 | ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/UniswapConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.commons.annotations.ConnectorSettings; 5 | 6 | @ConnectorSettings("UNISWAP") 7 | public class UniswapConnectorSettings extends DataConnectorSettings { 8 | 9 | private String subgraphUrl = "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3"; 10 | private String uniswapApiUrl = "http://localhost:3001/"; 11 | private int amount; 12 | 13 | public UniswapConnectorSettings() { 14 | super(); 15 | } 16 | 17 | public UniswapConnectorSettings(final String name, final String tbUrl, final String stream) { 18 | super(tbUrl, stream); 19 | setName(name); 20 | setSubgraphUrl(subgraphUrl); 21 | } 22 | 23 | public String getSubgraphUrl() { 24 | return subgraphUrl; 25 | } 26 | 27 | public void setSubgraphUrl(String subgraphUrl) { 28 | this.subgraphUrl = subgraphUrl; 29 | } 30 | 31 | public String getUniswapApiUrl() { 32 | return uniswapApiUrl; 33 | } 34 | 35 | public void setUniswapApiUrl(String uniswapApiUrl) { 36 | this.uniswapApiUrl = uniswapApiUrl; 37 | } 38 | 39 | public int getAmount() { 40 | return amount; 41 | } 42 | 43 | public void setAmount(int amount) { 44 | this.amount = amount; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/subscriptions/BundleSubscription.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap.subscriptions; 2 | 3 | import com.epam.deltix.data.connectors.commons.GraphQlQuery; 4 | import com.epam.deltix.data.connectors.commons.HttpPoller; 5 | import com.epam.deltix.data.connectors.commons.Logger; 6 | import com.epam.deltix.data.connectors.commons.MessageOutput; 7 | import com.epam.deltix.data.connectors.uniswap.UniswapCollectionPoller; 8 | import com.epam.deltix.data.uniswap.Bundle; 9 | import com.epam.deltix.data.uniswap.BundleAction; 10 | 11 | import java.util.Collection; 12 | import java.util.List; 13 | 14 | public class BundleSubscription extends Subscription { 15 | private static final GraphQlQuery.Query QUERY_TEMPLATE = GraphQlQuery.query("bundles"); 16 | 17 | static { 18 | QUERY_TEMPLATE.arguments().withOrderBy("id"); 19 | QUERY_TEMPLATE.withScalar("id"); 20 | QUERY_TEMPLATE.withScalar("ethPriceUSD"); 21 | } 22 | 23 | public BundleSubscription( 24 | final String uri, 25 | final MessageOutput messageOutput, 26 | final Logger logger, 27 | final IdentifiedUniswapSymbol... symbols) { 28 | super(uri, messageOutput, logger, symbols); 29 | } 30 | 31 | @Override 32 | public Collection get() { 33 | return List.of(new UniswapCollectionPoller<>( 34 | uri, 35 | QUERY_TEMPLATE, 36 | Bundle::new, 37 | BundleAction::new, 38 | messageOutput)); 39 | } 40 | } -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/subscriptions/CollectSubscription.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap.subscriptions; 2 | 3 | import com.epam.deltix.data.connectors.commons.GraphQlQuery; 4 | import com.epam.deltix.data.connectors.commons.HttpPoller; 5 | import com.epam.deltix.data.connectors.commons.Logger; 6 | import com.epam.deltix.data.connectors.commons.MessageOutput; 7 | import com.epam.deltix.data.connectors.commons.json.JsonObject; 8 | import com.epam.deltix.data.connectors.uniswap.UniswapCollectionPoller; 9 | import com.epam.deltix.data.uniswap.Collect; 10 | import com.epam.deltix.data.uniswap.CollectAction; 11 | 12 | import java.util.Collection; 13 | import java.util.List; 14 | import java.util.function.Predicate; 15 | 16 | public class CollectSubscription extends Subscription { 17 | private static final GraphQlQuery.Query QUERY_TEMPLATE = GraphQlQuery.query("collects"); 18 | 19 | static { 20 | QUERY_TEMPLATE.arguments().withOrderBy("timestamp"); 21 | QUERY_TEMPLATE.withScalar("id"); 22 | 23 | final GraphQlQuery.Object trx = QUERY_TEMPLATE.withObject("transaction"); 24 | trx.withScalar("id"); 25 | 26 | QUERY_TEMPLATE.withScalar("timestamp"); 27 | 28 | final GraphQlQuery.Object pool = QUERY_TEMPLATE.withObject("pool"); 29 | pool.withScalar("id"); 30 | 31 | QUERY_TEMPLATE.withScalar("owner"); 32 | QUERY_TEMPLATE.withScalar("amount0"); 33 | QUERY_TEMPLATE.withScalar("amount1"); 34 | QUERY_TEMPLATE.withScalar("amountUSD"); 35 | QUERY_TEMPLATE.withScalar("tickLower"); 36 | QUERY_TEMPLATE.withScalar("tickUpper"); 37 | QUERY_TEMPLATE.withScalar("logIndex"); 38 | } 39 | 40 | public CollectSubscription( 41 | final String uri, 42 | final MessageOutput messageOutput, 43 | final Logger logger, 44 | final IdentifiedUniswapSymbol... symbols) { 45 | super(uri, messageOutput, logger, symbols); 46 | } 47 | 48 | @Override 49 | public Collection get() { 50 | long now = System.currentTimeMillis() / 1000; 51 | 52 | final GraphQlQuery.Query query = QUERY_TEMPLATE.copy(); 53 | Predicate filter = object -> true; 54 | 55 | query.arguments().withWhere("timestamp_gte: \"" + now + "\""); 56 | 57 | return List.of(new UniswapCollectionPoller<>( 58 | uri, 59 | query, 60 | filter, 61 | Collect::new, 62 | CollectAction::new, 63 | messageOutput, 64 | false)); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/subscriptions/FactorySubscription.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap.subscriptions; 2 | 3 | import com.epam.deltix.data.connectors.commons.GraphQlQuery; 4 | import com.epam.deltix.data.connectors.commons.HttpPoller; 5 | import com.epam.deltix.data.connectors.commons.Logger; 6 | import com.epam.deltix.data.connectors.commons.MessageOutput; 7 | import com.epam.deltix.data.connectors.uniswap.UniswapCollectionPoller; 8 | import com.epam.deltix.data.uniswap.Factory; 9 | import com.epam.deltix.data.uniswap.FactoryAction; 10 | 11 | import java.util.Collection; 12 | import java.util.List; 13 | 14 | public class FactorySubscription extends Subscription { 15 | private static final GraphQlQuery.Query QUERY_TEMPLATE = GraphQlQuery.query("factories"); 16 | 17 | static { 18 | QUERY_TEMPLATE.arguments().withOrderBy("id"); 19 | QUERY_TEMPLATE.withScalar("id"); 20 | QUERY_TEMPLATE.withScalar("poolCount"); 21 | QUERY_TEMPLATE.withScalar("txCount"); 22 | QUERY_TEMPLATE.withScalar("totalVolumeUSD"); 23 | QUERY_TEMPLATE.withScalar("totalVolumeETH"); 24 | QUERY_TEMPLATE.withScalar("totalFeesUSD"); 25 | QUERY_TEMPLATE.withScalar("totalFeesETH"); 26 | QUERY_TEMPLATE.withScalar("untrackedVolumeUSD"); 27 | QUERY_TEMPLATE.withScalar("totalValueLockedUSD"); 28 | QUERY_TEMPLATE.withScalar("totalValueLockedETH"); 29 | QUERY_TEMPLATE.withScalar("totalValueLockedUSDUntracked"); 30 | QUERY_TEMPLATE.withScalar("totalValueLockedETHUntracked"); 31 | QUERY_TEMPLATE.withScalar("owner"); 32 | } 33 | 34 | public FactorySubscription( 35 | final String uri, 36 | final MessageOutput messageOutput, 37 | final Logger logger, 38 | final IdentifiedUniswapSymbol... symbols) { 39 | super(uri, messageOutput, logger, symbols); 40 | } 41 | 42 | @Override 43 | public Collection get() { 44 | return List.of(new UniswapCollectionPoller<>( 45 | uri, 46 | QUERY_TEMPLATE, 47 | Factory::new, 48 | FactoryAction::new, 49 | messageOutput)); 50 | } 51 | } -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/subscriptions/FlashSubscription.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap.subscriptions; 2 | 3 | import com.epam.deltix.data.connectors.commons.GraphQlQuery; 4 | import com.epam.deltix.data.connectors.commons.HttpPoller; 5 | import com.epam.deltix.data.connectors.commons.Logger; 6 | import com.epam.deltix.data.connectors.commons.MessageOutput; 7 | import com.epam.deltix.data.connectors.commons.json.JsonObject; 8 | import com.epam.deltix.data.connectors.uniswap.UniswapCollectionPoller; 9 | import com.epam.deltix.data.uniswap.Flash; 10 | import com.epam.deltix.data.uniswap.FlashAction; 11 | import com.epam.deltix.data.uniswap.Transaction; 12 | import com.epam.deltix.data.uniswap.TransactionAction; 13 | 14 | import java.util.Collection; 15 | import java.util.List; 16 | import java.util.function.Predicate; 17 | 18 | public class FlashSubscription extends Subscription { 19 | private static final GraphQlQuery.Query QUERY_TEMPLATE = GraphQlQuery.query("flashes"); 20 | 21 | static { 22 | QUERY_TEMPLATE.arguments().withOrderBy("timestamp"); 23 | QUERY_TEMPLATE.withScalar("id"); 24 | 25 | final GraphQlQuery.Object trx = QUERY_TEMPLATE.withObject("transaction"); 26 | trx.withScalar("id"); 27 | 28 | QUERY_TEMPLATE.withScalar("timestamp"); 29 | 30 | final GraphQlQuery.Object pool = QUERY_TEMPLATE.withObject("pool"); 31 | pool.withScalar("id"); 32 | 33 | QUERY_TEMPLATE.withScalar("sender"); 34 | QUERY_TEMPLATE.withScalar("recipient"); 35 | QUERY_TEMPLATE.withScalar("amount0"); 36 | QUERY_TEMPLATE.withScalar("amount1"); 37 | QUERY_TEMPLATE.withScalar("amountUSD"); 38 | QUERY_TEMPLATE.withScalar("amount0Paid"); 39 | QUERY_TEMPLATE.withScalar("amount1Paid"); 40 | QUERY_TEMPLATE.withScalar("logIndex"); 41 | } 42 | 43 | public FlashSubscription( 44 | final String uri, 45 | final MessageOutput messageOutput, 46 | final Logger logger, 47 | final IdentifiedUniswapSymbol... symbols) { 48 | super(uri, messageOutput, logger, symbols); 49 | } 50 | 51 | @Override 52 | public Collection get() { 53 | long now = System.currentTimeMillis() / 1000; 54 | 55 | final GraphQlQuery.Query query = QUERY_TEMPLATE.copy(); 56 | Predicate filter = object -> true; 57 | 58 | query.arguments().withWhere("timestamp_gte: \"" + now + "\""); 59 | 60 | return List.of(new UniswapCollectionPoller<>( 61 | uri, 62 | query, 63 | filter, 64 | Flash::new, 65 | FlashAction::new, 66 | messageOutput, 67 | false)); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/subscriptions/PriceSubscription.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap.subscriptions; 2 | 3 | import com.epam.deltix.data.connectors.commons.HttpPoller; 4 | import com.epam.deltix.data.connectors.commons.Logger; 5 | import com.epam.deltix.data.connectors.commons.MdModel; 6 | import com.epam.deltix.data.connectors.commons.MessageOutput; 7 | import com.epam.deltix.data.connectors.uniswap.UniswapPricePoller; 8 | 9 | import java.util.Arrays; 10 | import java.util.Collection; 11 | import java.util.stream.Collectors; 12 | 13 | public class PriceSubscription extends Subscription { 14 | private MdModel.Options selected; 15 | private int amount; 16 | private int depth; 17 | private Logger logger; 18 | 19 | public PriceSubscription( 20 | final String uri, 21 | final MessageOutput messageOutput, 22 | final Logger logger, 23 | final MdModel.Options selected, 24 | final int amount, 25 | final int depth, 26 | final IdentifiedUniswapSymbol... symbols) { 27 | this(uri, messageOutput, logger, symbols); 28 | this.selected = selected; 29 | this.amount = amount; 30 | this.depth = depth; 31 | this.logger = logger; 32 | } 33 | 34 | public PriceSubscription( 35 | final String uri, 36 | final MessageOutput messageOutput, 37 | final Logger logger, 38 | final IdentifiedUniswapSymbol... symbols) { 39 | super(uri, messageOutput, logger, symbols); 40 | } 41 | 42 | @Override 43 | public Collection get() { 44 | return Arrays.stream(symbols).map(symbol -> { 45 | String name = symbol.token0() + "/" + symbol.token1(); 46 | return new UniswapPricePoller( 47 | uri, 48 | null, 49 | messageOutput, 50 | selected, 51 | amount, 52 | depth, 53 | symbol.token0Id(), 54 | symbol.token1Id(), 55 | logger, 56 | name); 57 | }).collect(Collectors.toList()); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/subscriptions/Subscription.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap.subscriptions; 2 | 3 | import com.epam.deltix.data.connectors.commons.HttpPoller; 4 | import com.epam.deltix.data.connectors.commons.Logger; 5 | import com.epam.deltix.data.connectors.commons.MessageOutput; 6 | 7 | import java.util.Collection; 8 | import java.util.function.Supplier; 9 | 10 | public abstract class Subscription implements Supplier> { 11 | protected final String uri; 12 | protected final MessageOutput messageOutput; 13 | protected final Logger logger; 14 | protected final IdentifiedUniswapSymbol[] symbols; 15 | 16 | protected Subscription( 17 | final String uri, 18 | final MessageOutput messageOutput, 19 | final Logger logger, 20 | final IdentifiedUniswapSymbol... symbols) { 21 | 22 | this.uri = uri; 23 | this.messageOutput = messageOutput; 24 | this.logger = logger; 25 | this.symbols = symbols; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/subscriptions/TransactionSubscription.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap.subscriptions; 2 | 3 | import com.epam.deltix.data.connectors.commons.GraphQlQuery; 4 | import com.epam.deltix.data.connectors.commons.HttpPoller; 5 | import com.epam.deltix.data.connectors.commons.Logger; 6 | import com.epam.deltix.data.connectors.commons.MessageOutput; 7 | import com.epam.deltix.data.connectors.commons.json.JsonObject; 8 | import com.epam.deltix.data.connectors.uniswap.UniswapCollectionPoller; 9 | import com.epam.deltix.data.uniswap.Transaction; 10 | import com.epam.deltix.data.uniswap.TransactionAction; 11 | 12 | import java.util.Collection; 13 | import java.util.List; 14 | import java.util.function.Predicate; 15 | 16 | public class TransactionSubscription extends Subscription { 17 | private static final GraphQlQuery.Query QUERY_TEMPLATE = GraphQlQuery.query("transactions"); 18 | 19 | static { 20 | QUERY_TEMPLATE.arguments().withOrderBy("timestamp"); 21 | QUERY_TEMPLATE.withScalar("id"); 22 | QUERY_TEMPLATE.withScalar("blockNumber"); 23 | QUERY_TEMPLATE.withScalar("timestamp"); 24 | QUERY_TEMPLATE.withScalar("gasUsed"); 25 | QUERY_TEMPLATE.withScalar("gasPrice"); 26 | 27 | final GraphQlQuery.Object mints = QUERY_TEMPLATE.withObject("mints"); 28 | mints.withScalar("id"); 29 | 30 | final GraphQlQuery.Object burns = QUERY_TEMPLATE.withObject("burns"); 31 | burns.withScalar("id"); 32 | 33 | final GraphQlQuery.Object swaps = QUERY_TEMPLATE.withObject("swaps"); 34 | swaps.withScalar("id"); 35 | 36 | final GraphQlQuery.Object collects = QUERY_TEMPLATE.withObject("collects"); 37 | collects.withScalar("id"); 38 | 39 | final GraphQlQuery.Object flashed = QUERY_TEMPLATE.withObject("flashed"); 40 | flashed.withScalar("id"); 41 | } 42 | 43 | public TransactionSubscription( 44 | final String uri, 45 | final MessageOutput messageOutput, 46 | final Logger logger, 47 | final IdentifiedUniswapSymbol... symbols) { 48 | super(uri, messageOutput, logger, symbols); 49 | } 50 | 51 | @Override 52 | public Collection get() { 53 | long now = System.currentTimeMillis() / 1000; 54 | 55 | final GraphQlQuery.Query query = QUERY_TEMPLATE.copy(); 56 | Predicate filter = object -> true; 57 | 58 | query.arguments().withWhere("timestamp_gte: \"" + now + "\""); 59 | 60 | return List.of(new UniswapCollectionPoller<>( 61 | uri, 62 | query, 63 | filter, 64 | Transaction::new, 65 | TransactionAction::new, 66 | messageOutput, 67 | false)); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/subscriptions/UniswapDayDataSubscription.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap.subscriptions; 2 | 3 | import com.epam.deltix.data.connectors.commons.GraphQlQuery; 4 | import com.epam.deltix.data.connectors.commons.HttpPoller; 5 | import com.epam.deltix.data.connectors.commons.Logger; 6 | import com.epam.deltix.data.connectors.commons.MessageOutput; 7 | import com.epam.deltix.data.connectors.commons.json.JsonObject; 8 | import com.epam.deltix.data.connectors.uniswap.UniswapCollectionPoller; 9 | import com.epam.deltix.data.uniswap.UniswapDayData; 10 | import com.epam.deltix.data.uniswap.UniswapDayDataAction; 11 | 12 | import java.util.Collection; 13 | import java.util.List; 14 | import java.util.function.Predicate; 15 | 16 | public class UniswapDayDataSubscription extends Subscription { 17 | private static final GraphQlQuery.Query QUERY_TEMPLATE = GraphQlQuery.query("uniswapDayDatas"); 18 | 19 | static { 20 | QUERY_TEMPLATE.arguments().withOrderBy("date"); 21 | QUERY_TEMPLATE.withScalar("id"); 22 | QUERY_TEMPLATE.withScalar("date"); 23 | QUERY_TEMPLATE.withScalar("volumeETH"); 24 | QUERY_TEMPLATE.withScalar("volumeUSD"); 25 | QUERY_TEMPLATE.withScalar("volumeUSDUntracked"); 26 | QUERY_TEMPLATE.withScalar("feesUSD"); 27 | QUERY_TEMPLATE.withScalar("txCount"); 28 | QUERY_TEMPLATE.withScalar("tvlUSD"); 29 | } 30 | 31 | public UniswapDayDataSubscription( 32 | final String uri, 33 | final MessageOutput messageOutput, 34 | final Logger logger, 35 | final IdentifiedUniswapSymbol... symbols) { 36 | super(uri, messageOutput, logger, symbols); 37 | } 38 | 39 | @Override 40 | public Collection get() { 41 | long now = System.currentTimeMillis() / 1000; 42 | 43 | final GraphQlQuery.Query query = QUERY_TEMPLATE.copy(); 44 | Predicate filter = object -> true; 45 | 46 | query.arguments().withWhere("date_gte: " + now); 47 | 48 | return List.of(new UniswapCollectionPoller<>( 49 | uri, 50 | query, 51 | filter, 52 | UniswapDayData::new, 53 | UniswapDayDataAction::new, 54 | messageOutput, 55 | false)); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/connectors/uniswap/subscriptions/UniswapSymbol.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.uniswap.subscriptions; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collection; 5 | import java.util.HashSet; 6 | import java.util.Set; 7 | 8 | public class UniswapSymbol { 9 | public static String[] collectSymbols(final UniswapSymbol... uniswapSymbols) { 10 | if (uniswapSymbols == null) { 11 | return new String[] {}; 12 | } 13 | final Set result = new HashSet<>(); 14 | Arrays.stream(uniswapSymbols).forEach(uniswapSymbol -> uniswapSymbol.collectTokens(result)); 15 | return result.toArray(String[]::new); 16 | } 17 | 18 | private final String token0; 19 | private final String token1; 20 | 21 | public UniswapSymbol(final String symbol) { 22 | final int delimIdx = symbol.indexOf('/'); 23 | if (delimIdx == -1) { 24 | token0 = symbol.isBlank() ? null : symbol.trim(); 25 | token1 = null; 26 | } else { 27 | final String t0 = symbol.substring(0, delimIdx); 28 | final String t1 = symbol.substring(delimIdx + 1); 29 | 30 | token0 = t0.isBlank() ? null : t0.trim(); 31 | token1 = t1.isBlank() ? null : t1.trim(); 32 | } 33 | 34 | if (token0 == null && token1 == null) { 35 | throw new IllegalArgumentException("Empty symbol '" + symbol + '\''); 36 | } 37 | } 38 | 39 | protected UniswapSymbol(final UniswapSymbol from) { 40 | this.token0 = from.token0; 41 | this.token1 = from.token1; 42 | } 43 | 44 | public String token0() { 45 | return token0; 46 | } 47 | 48 | public boolean hasToken0() { 49 | return token0 != null; 50 | } 51 | 52 | public String token1() { 53 | return token1; 54 | } 55 | 56 | public boolean hasToken1() { 57 | return token1 != null; 58 | } 59 | 60 | public void collectTokens(final Collection to) { 61 | if (hasToken0()) { 62 | to.add(token0()); 63 | } 64 | if (hasToken1()) { 65 | to.add(token1()); 66 | } 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return (hasToken0() ? token0() : "") + '/' + 72 | (hasToken1() ? token1() : ""); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/Action.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | public enum Action { 4 | NEW, UPDATE, DELETE 5 | } 6 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/Bundle.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.data.connectors.commons.Util; 4 | import com.epam.deltix.data.connectors.commons.json.JsonObject; 5 | import com.epam.deltix.timebase.messages.SchemaElement; 6 | 7 | public class Bundle implements Updatable { 8 | // bundle address 9 | private String id; 10 | //price of ETH in usd 11 | private String ethPriceUSD; 12 | 13 | @Override 14 | public String getTbSymbol() { 15 | return "bundle"; 16 | } 17 | 18 | @SchemaElement() 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public void setId(final String id) { 24 | this.id = id; 25 | } 26 | 27 | public boolean updateId(final String id) { 28 | if (Util.equals(this.id, id)) { 29 | return false; 30 | } 31 | this.id = id; 32 | return true; 33 | } 34 | 35 | @SchemaElement() 36 | public String getEthPriceUSD() { 37 | return ethPriceUSD; 38 | } 39 | 40 | public void setEthPriceUSD(final String ethPriceUSD) { 41 | this.ethPriceUSD = ethPriceUSD; 42 | } 43 | 44 | public boolean updateEthPriceUSD(final String ethPriceUSD) { 45 | if (Util.equals(this.ethPriceUSD, ethPriceUSD)) { 46 | return false; 47 | } 48 | this.ethPriceUSD = ethPriceUSD; 49 | return true; 50 | } 51 | 52 | @Override 53 | public boolean update(final JsonObject from) { 54 | boolean result = false; 55 | result |= updateId(from.getString("id")); 56 | result |= updateEthPriceUSD(from.getString("ethPriceUSD")); 57 | return result; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "Bundle{" + 63 | "id='" + id + '\'' + 64 | ", ethPriceUSD='" + ethPriceUSD + '\'' + 65 | '}'; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/BundleAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class BundleAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private Bundle entity; 10 | private Action action; 11 | 12 | public BundleAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public Bundle getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(Bundle entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final Bundle entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "BundleAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/BurnAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class BurnAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private Burn entity; 10 | private Action action; 11 | 12 | public BurnAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public Burn getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(Burn entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final Burn entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "BurnAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/CollectAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class CollectAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private Collect entity; 10 | private Action action; 11 | 12 | public CollectAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public Collect getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(Collect entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final Collect entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "CollectAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/FactoryAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class FactoryAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private Factory entity; 10 | private Action action; 11 | 12 | public FactoryAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public Factory getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(Factory entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final Factory entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "FactoryAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/FlashAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class FlashAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private Flash entity; 10 | private Action action; 11 | 12 | public FlashAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public Flash getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(Flash entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final Flash entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "FlashAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/MintAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class MintAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private Mint entity; 10 | private Action action; 11 | 12 | public MintAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public Mint getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(Mint entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final Mint entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "MintAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/PoolAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class PoolAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private Pool entity; 10 | private Action action; 11 | 12 | public PoolAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public Pool getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(Pool entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final Pool entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "PoolAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/PositionAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class PositionAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private Position entity; 10 | private Action action; 11 | 12 | public PositionAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(boolean last) { 32 | this.isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public Position getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(Position entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final Position entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "PositionAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/PositionSnapshotAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class PositionSnapshotAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private PositionSnapshot entity; 10 | private Action action; 11 | 12 | public PositionSnapshotAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(boolean last) { 32 | this.isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public PositionSnapshot getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(PositionSnapshot entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final PositionSnapshot entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "PositionSnapshotAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/SwapAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class SwapAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private Swap entity; 10 | private Action action; 11 | 12 | public SwapAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public Swap getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(Swap entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final Swap entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "SwapAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/TickAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class TickAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private Tick entity; 10 | private Action action; 11 | 12 | public TickAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public Tick getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(Tick entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final Tick entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "TickAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/TokenAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class TokenAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private Token entity; 10 | private Action action; 11 | 12 | public TokenAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public Token getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(Token entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final Token entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "TokenAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/TokenDayDataAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class TokenDayDataAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private TokenDayData entity; 10 | private Action action; 11 | 12 | public TokenDayDataAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public TokenDayData getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(TokenDayData entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final TokenDayData entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "TokenDayDataAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/TokenHourDataAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class TokenHourDataAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private TokenHourData entity; 10 | private Action action; 11 | 12 | public TokenHourDataAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public TokenHourData getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(TokenHourData entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final TokenHourData entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "TokenHourDataAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/TransactionAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class TransactionAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private Transaction entity; 10 | private Action action; 11 | 12 | public TransactionAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public Transaction getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(Transaction entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final Transaction entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "TransactionAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/UniswapDayDataAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.timebase.messages.MarketMessage; 4 | import com.epam.deltix.timebase.messages.SchemaElement; 5 | 6 | public class UniswapDayDataAction extends MarketMessage implements UpdatableAction { 7 | private int index; 8 | private boolean isLast; 9 | private UniswapDayData entity; 10 | private Action action; 11 | 12 | public UniswapDayDataAction() { 13 | } 14 | 15 | @SchemaElement() 16 | public int getIndex() { 17 | return index; 18 | } 19 | 20 | @Override 21 | public void setIndex(final int index) { 22 | this.index = index; 23 | } 24 | 25 | @SchemaElement() 26 | public boolean isLast() { 27 | return isLast; 28 | } 29 | 30 | @Override 31 | public void setLast(final boolean last) { 32 | isLast = last; 33 | } 34 | 35 | @SchemaElement() 36 | public UniswapDayData getEntity() { 37 | return entity; 38 | } 39 | 40 | public void setEntity(UniswapDayData entity) { 41 | this.entity = entity; 42 | } 43 | 44 | @SchemaElement() 45 | public Action getAction() { 46 | return action; 47 | } 48 | 49 | public void setAction(final Action action) { 50 | this.action = action; 51 | } 52 | 53 | @Override 54 | public void setUpdatableAction(final UniswapDayData entity, final Action action) { 55 | setSymbol(entity.getTbSymbol()); 56 | this.entity = entity; 57 | this.action = action; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "UniswapDayDataAction{" + 63 | "symbol=" + getSymbol() + 64 | ", index=" + index + 65 | ", isLast=" + isLast + 66 | ", entity=" + entity + 67 | ", action=" + action + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/Updatable.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | import com.epam.deltix.data.connectors.commons.json.JsonObject; 4 | 5 | public interface Updatable { 6 | 7 | String getTbSymbol(); 8 | 9 | boolean update(JsonObject from); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /java/connectors/uniswap/src/main/java/com/epam/deltix/data/uniswap/UpdatableAction.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.uniswap; 2 | 3 | public interface UpdatableAction { 4 | void setIndex(final int index); 5 | 6 | void setLast(final boolean last); 7 | 8 | void setUpdatableAction(U entity, Action action); 9 | } 10 | -------------------------------------------------------------------------------- /java/runner/src/intTest/java/com/epam/deltix/data/connectors/reports/ReportGenerator.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.reports; 2 | 3 | import java.io.*; 4 | import java.nio.charset.StandardCharsets; 5 | import java.util.Arrays; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class ReportGenerator { 10 | 11 | public static final String CONNECTION_REPORT = "Connection"; 12 | public static final String VALIDATE_L2_REPORT = "Validate L2 Data"; 13 | public static final String SUPPORTED_MODEL_REPORT = "Model"; 14 | 15 | public static void generate(File outputFile, String title, Map testReports) { 16 | System.out.println("Printing file: " + outputFile.getAbsolutePath()); 17 | List tests = Arrays.asList( 18 | CONNECTION_REPORT, VALIDATE_L2_REPORT, SUPPORTED_MODEL_REPORT 19 | ); 20 | 21 | try (OutputStreamWriter writer = new OutputStreamWriter( 22 | new FileOutputStream(outputFile), StandardCharsets.UTF_8)) { 23 | 24 | writer.append(title); 25 | writer.append("\n\n"); 26 | writer.append("| Exchange | "); 27 | for (String testName : tests) { 28 | writer.append(testName).append(" | "); 29 | } 30 | writer.append("\n| --- | --- | --- | --- |\n"); 31 | for (TestConnectorReports testReport : testReports.values()) { 32 | writer.append("| ").append(prepareName(testReport.connector())).append(" | "); 33 | for (String testName : tests) { 34 | TestReport report = testReport.reports().get(testName); 35 | if (report != null) { 36 | if (report.status() == TestStatus.INFO) { 37 | writer.append(report.message()) 38 | .append(" | "); 39 | } else { 40 | if (report.status() == TestStatus.OK) { 41 | writer.write("\u2705"); 42 | } else { 43 | writer.write("\u274C"); 44 | } 45 | } 46 | } 47 | 48 | writer.append(" | "); 49 | } 50 | 51 | writer.append("\n"); 52 | } 53 | } catch (IOException e) { 54 | throw new RuntimeException(e); 55 | } 56 | } 57 | 58 | private static String prepareName(String name) { 59 | return capitalize(name).replaceAll("-", " "); 60 | } 61 | 62 | private static String capitalize(String name) { 63 | return name.substring(0, 1).toUpperCase() + name.substring(1); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /java/runner/src/intTest/java/com/epam/deltix/data/connectors/reports/TestConnectorReports.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.reports; 2 | 3 | import com.epam.deltix.data.connectors.commons.json.JsonObject; 4 | 5 | import java.util.LinkedHashMap; 6 | import java.util.Map; 7 | 8 | public class TestConnectorReports { 9 | private final String connector; 10 | private final String stream; 11 | private final boolean disabled; 12 | 13 | private final Map reports = new LinkedHashMap<>(); 14 | 15 | public TestConnectorReports(final JsonObject fromJsom) { 16 | this(fromJsom.getStringRequired("name"), 17 | fromJsom.getStringRequired("stream"), 18 | fromJsom.getBoolean("disabled")); 19 | } 20 | 21 | public TestConnectorReports(final String connector, final String stream, final boolean disabled) { 22 | this.connector = connector; 23 | this.stream = stream; 24 | this.disabled = disabled; 25 | } 26 | 27 | public void runTest(String name, Runnable r) { 28 | try { 29 | r.run(); 30 | addTestOk(name); 31 | } catch (Throwable t) { 32 | addTestError(name, t); 33 | throw t; 34 | } 35 | } 36 | 37 | public void addTestOk(String name) { 38 | reports.put(name, new TestReport(name, TestStatus.OK, "Test " + name + " ok")); 39 | } 40 | 41 | public void addTestMessage(String name, String message) { 42 | reports.put(name, new TestReport(name, TestStatus.INFO, message)); 43 | } 44 | 45 | public void addTestError(String name, Throwable error) { 46 | reports.put(name, new TestReport(name, "Test " + name + " failed", error)); 47 | } 48 | 49 | public String connector() { 50 | return connector; 51 | } 52 | 53 | public String stream() { 54 | return stream; 55 | } 56 | 57 | public boolean isDisabled() { 58 | return disabled; 59 | } 60 | 61 | public Map reports() { 62 | return reports; 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return "connector='" + connector + "', stream='" + stream + '\''; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /java/runner/src/intTest/java/com/epam/deltix/data/connectors/reports/TestReport.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.reports; 2 | 3 | public class TestReport { 4 | private final String name; 5 | private final TestStatus status; 6 | private final String message; 7 | private final Throwable error; 8 | 9 | public TestReport(String name, TestStatus status, String message) { 10 | this(name, status, message, null); 11 | } 12 | 13 | public TestReport(String name, String message, Throwable error) { 14 | this(name, TestStatus.FAILED, message, error); 15 | } 16 | 17 | public TestReport(String name, TestStatus status, String message, Throwable error) { 18 | this.name = name; 19 | this.status = status; 20 | this.message = message; 21 | this.error = error; 22 | } 23 | 24 | public String name() { 25 | return name; 26 | } 27 | 28 | public TestStatus status() { 29 | return status; 30 | } 31 | 32 | public String message() { 33 | return message; 34 | } 35 | 36 | public Throwable error() { 37 | return error; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /java/runner/src/intTest/java/com/epam/deltix/data/connectors/reports/TestStatus.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.reports; 2 | 3 | public enum TestStatus { 4 | OK, 5 | FAILED, 6 | SKIPPED, 7 | INFO 8 | } 9 | -------------------------------------------------------------------------------- /java/runner/src/intTest/java/com/epam/deltix/data/connectors/validator/DataValidator.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.validator; 2 | 3 | import com.epam.deltix.containers.AlphanumericUtils; 4 | import com.epam.deltix.containers.DateTimeHelper; 5 | import com.epam.deltix.containers.MutableString; 6 | import com.epam.deltix.containers.interfaces.Loggable; 7 | import com.epam.deltix.timebase.messages.TypeConstants; 8 | import com.epam.deltix.timebase.messages.universal.PackageHeaderInfo; 9 | 10 | public interface DataValidator extends Loggable { 11 | 12 | void sendPackage(PackageHeaderInfo headerInfo); 13 | 14 | static MutableString generateLogMessage(MutableString buffer, CharSequence symbol, 15 | long exchangeId, long timestamp, CharSequence quoteId, short level, 16 | CharSequence message) { 17 | if (buffer == null) buffer = new MutableString(); 18 | buffer.clear(); 19 | if (symbol != "") buffer.append("Symbol: ").append(symbol).append(" "); 20 | if (exchangeId != TypeConstants.EXCHANGE_NULL) { 21 | buffer.append("Exchange Id: "); 22 | if ((int)(exchangeId >>> 60) != 0) { 23 | buffer = AlphanumericUtils.appendAlphanumeric(buffer, exchangeId).append(" "); 24 | } 25 | else 26 | buffer.append(exchangeId).append(" "); 27 | } 28 | if (timestamp >= 0) buffer.append("Time: ").append(timestamp).append(" "); 29 | DateTimeHelper.append(buffer, timestamp); 30 | buffer.append(' '); 31 | if (quoteId != null) buffer.append("QuoteId: ").append(quoteId).append(" "); 32 | if (level >= 0) buffer.append("Level: ").append(level).append(" "); 33 | if (message != "") buffer.append("Message: ").append(message).append(" "); 34 | return buffer; 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /java/runner/src/intTest/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /runner/config/runner.log 5 | 6 | 7 | %date %level [%thread] %logger{10} [%file:%line] %msg%n 8 | 9 | 10 | 11 | 12 | 14 | 15 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /java/runner/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM amazoncorretto:11-alpine3.17 2 | 3 | ENV LANG=C.UTF-8 4 | COPY runner /runner 5 | 6 | ENV JAVA_OPTS=-verbose:gc 7 | ENV SPRING_CONFIG_LOCATION=/runner/config/application.yaml 8 | 9 | WORKDIR runner 10 | 11 | EXPOSE 8055 12 | ENTRYPOINT ["/bin/sh", "-c", "./runner.sh"] 13 | -------------------------------------------------------------------------------- /java/runner/src/main/java/com/epam/deltix/data/connectors/Application.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /java/runner/src/main/java/com/epam/deltix/data/connectors/runner/ConnectorImplementation.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.runner; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnector; 4 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 5 | 6 | class ConnectorImplementation, S extends DataConnectorSettings> { 7 | private final String name; 8 | private final Class connectorClass; 9 | private final Class settingsClass; 10 | 11 | ConnectorImplementation(String name, Class connectorClass, Class settingsClass) { 12 | this.name = name; 13 | this.connectorClass = connectorClass; 14 | this.settingsClass = settingsClass; 15 | } 16 | 17 | public Class getConnectorClass() { 18 | return connectorClass; 19 | } 20 | 21 | public Class getSettingsClass() { 22 | return settingsClass; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return name + " [" + connectorClass.getSimpleName() + "(" + settingsClass.getSimpleName() + ")]"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /java/runner/src/main/java/com/epam/deltix/data/connectors/runner/controllers/DataConnectorsController.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.runner.controllers; 2 | 3 | import com.epam.deltix.data.connectors.commons.DataConnectorSettings; 4 | import com.epam.deltix.data.connectors.runner.ConnectorsRunner; 5 | import com.epam.deltix.data.connectors.runner.model.DataConnectorDto; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.bind.annotation.ResponseBody; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | @Controller 17 | @RequestMapping("/api/v0") 18 | public class DataConnectorsController { 19 | 20 | private final ConnectorsRunner runner; 21 | 22 | @Autowired 23 | public DataConnectorsController(ConnectorsRunner runner) { 24 | this.runner = runner; 25 | } 26 | 27 | @ResponseBody 28 | @RequestMapping(value = "/connectors", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) 29 | public List getConnectors() { 30 | List connectors = new ArrayList<>(); 31 | runner.forEachConnector((connector) -> { 32 | final DataConnectorSettings settings = connector.settings(); 33 | connectors.add( 34 | new DataConnectorDto( 35 | settings.getType(), 36 | settings.getName(), 37 | settings.getStream(), 38 | "UNKNOWN", // todo: get status 39 | settings.isDisabled() 40 | ) 41 | ); 42 | }); 43 | 44 | return connectors; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /java/runner/src/main/java/com/epam/deltix/data/connectors/runner/model/DataConnectorDto.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.runner.model; 2 | 3 | public class DataConnectorDto { 4 | 5 | private String type; 6 | private String name; 7 | private String stream; 8 | private String status; 9 | 10 | private boolean disabled; 11 | 12 | public DataConnectorDto() { 13 | } 14 | 15 | public DataConnectorDto(String type, String name, String stream, String status, boolean disabled) { 16 | this.type = type; 17 | this.name = name; 18 | this.stream = stream; 19 | this.status = status; 20 | this.disabled = disabled; 21 | } 22 | 23 | public String getType() { 24 | return type; 25 | } 26 | 27 | public void setType(String type) { 28 | this.type = type; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public String getStream() { 40 | return stream; 41 | } 42 | 43 | public void setStream(final String stream) { 44 | this.stream = stream; 45 | } 46 | 47 | public String getStatus() { 48 | return status; 49 | } 50 | 51 | public void setStatus(String status) { 52 | this.status = status; 53 | } 54 | 55 | public boolean isDisabled() { 56 | return disabled; 57 | } 58 | 59 | public void setDisabled(boolean disabled) { 60 | this.disabled = disabled; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /java/runner/src/main/java/com/epam/deltix/data/connectors/runner/settings/ConnectorsSettingsProvider.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.runner.settings; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | import java.util.stream.Collectors; 10 | 11 | @Component 12 | @ConfigurationProperties("") 13 | public class ConnectorsSettingsProvider { 14 | 15 | private Map> connectors; 16 | 17 | public Map> getConnectors() { 18 | return connectors; 19 | } 20 | 21 | public void setConnectors(Map> connectors) { 22 | this.connectors = new HashMap<>(); 23 | connectors.forEach((key, value) -> this.connectors.put(key.toLowerCase(), value)); 24 | } 25 | 26 | public Map connectorSettings(String connector) { 27 | return this.connectors.get(connector.toLowerCase()); 28 | } 29 | 30 | public String extractType(String connector) { 31 | return extractString(connector, "type"); 32 | } 33 | 34 | public String extractInstruments(String connector) { 35 | return extractString(connector, "instruments"); 36 | } 37 | 38 | public List extractModel(String connector) { 39 | return extractStringList(connector, "model"); 40 | } 41 | 42 | public List extractModelTypes(String connector) { 43 | return extractStringList(connector, "modelTypes"); 44 | } 45 | 46 | public String extractString(String connector, String key) { 47 | Map connectorSettings = connectorSettings(connector); 48 | if (connectorSettings != null) { 49 | Object value = connectorSettings.get(key); 50 | if (value instanceof String) { 51 | return (String) value; 52 | } 53 | } 54 | 55 | return null; 56 | } 57 | 58 | public List extractStringList(String connector, String key) { 59 | Map connectorSettings = connectorSettings(connector); 60 | if (connectorSettings != null) { 61 | Object value = connectorSettings.get(key); 62 | if (value instanceof Map) { 63 | return ((Map) value).values().stream() 64 | .filter(String.class::isInstance) 65 | .map(String.class::cast) 66 | .collect(Collectors.toList()); 67 | } else if (value instanceof List) { 68 | return ((List) value).stream() 69 | .filter(String.class::isInstance) 70 | .map(String.class::cast) 71 | .collect(Collectors.toList()); 72 | } 73 | } 74 | 75 | return null; 76 | } 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /java/runner/src/main/java/com/epam/deltix/data/connectors/runner/settings/RunnerSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.runner.settings; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.util.List; 7 | 8 | @Component 9 | @ConfigurationProperties("runner") 10 | public class RunnerSettings { 11 | 12 | private List discoverPackages; 13 | 14 | public List getDiscoverPackages() { 15 | return discoverPackages; 16 | } 17 | 18 | public void setDiscoverPackages(List discoverPackages) { 19 | this.discoverPackages = discoverPackages; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /java/runner/src/main/java/com/epam/deltix/data/connectors/runner/settings/TimebaseSettings.java: -------------------------------------------------------------------------------- 1 | package com.epam.deltix.data.connectors.runner.settings; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "timebase") 8 | public class TimebaseSettings { 9 | 10 | private String url; 11 | private String user; 12 | private String password; 13 | 14 | public String getUrl() { 15 | return url; 16 | } 17 | 18 | public void setUrl(String url) { 19 | this.url = url; 20 | } 21 | 22 | public String getUser() { 23 | return user; 24 | } 25 | 26 | public void setUser(String user) { 27 | this.user = user; 28 | } 29 | 30 | public String getPassword() { 31 | return password; 32 | } 33 | 34 | public void setPassword(String password) { 35 | this.password = password; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /java/runner/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ./logs/timebase-connectors.log 5 | 6 | 7 | %date %level [%thread] %logger{10} [%file:%line] %msg%n 8 | 9 | 10 | 11 | 12 | 14 | 15 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /lgtm.yml: -------------------------------------------------------------------------------- 1 | extraction: 2 | java: 3 | index: 4 | gradle: 5 | version: "7.4.1" 6 | java_version: "11" 7 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | import java.nio.file.Files 2 | import java.nio.file.Paths 3 | 4 | def excludingProjects = ['buildSrc'] as Set 5 | 6 | def discoverSubprojects 7 | discoverSubprojects = { File baseFolder, File currentFolder, List toCollection -> 8 | currentFolder.eachDir() { dir -> 9 | 10 | def relative = baseFolder.toPath().relativize(dir.toPath()) 11 | def projectName = relative.toString().replace(File.separatorChar, ':' as char) 12 | 13 | if (Files.exists(Paths.get(dir.getAbsolutePath(), 'build.gradle')) && Files.exists(Paths.get(dir.getAbsolutePath(), 'src'))) { 14 | println "Found project: ${projectName}" 15 | 16 | if (!excludingProjects.contains(projectName)) { 17 | toCollection.add(projectName) 18 | } 19 | } else { 20 | discoverSubprojects(baseFolder, dir, toCollection) 21 | } 22 | 23 | } 24 | return toCollection 25 | } 26 | 27 | include discoverSubprojects(rootDir, new File(rootDir, "java"), new ArrayList()) as String[] 28 | 29 | --------------------------------------------------------------------------------