org.jvirtanen.config.Configs Java Examples

The following examples show how to use org.jvirtanen.config.Configs. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StockTicker.java    From parity with Apache License 2.0 6 votes vote down vote up
private static void listen(Config config, MessageListener listener) throws IOException {
    if (config.hasPath("market-data.multicast-interface")) {
        NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface");
        InetAddress      multicastGroup     = Configs.getInetAddress(config, "market-data.multicast-group");
        int              multicastPort      = Configs.getPort(config, "market-data.multicast-port");
        InetAddress      requestAddress     = Configs.getInetAddress(config, "market-data.request-address");
        int              requestPort        = Configs.getPort(config, "market-data.request-port");

        MoldUDP64.receive(multicastInterface, new InetSocketAddress(multicastGroup, multicastPort),
                new InetSocketAddress(requestAddress, requestPort), listener);
    } else {
        InetAddress address  = Configs.getInetAddress(config, "market-data.address");
        int         port     = Configs.getPort(config, "market-data.port");
        String      username = config.getString("market-data.username");
        String      password = config.getString("market-data.password");

        SoupBinTCP.receive(new InetSocketAddress(address, port), username, password, listener);
    }
}
 
Example #2
Source File: TradeReporter.java    From parity with Apache License 2.0 6 votes vote down vote up
private static void main(Config config, boolean tsv) throws IOException {
    Instruments instruments = Instruments.fromConfig(config, "instruments");

    MessageListener listener = new PMRParser(new TradeProcessor(tsv ?
                new TSVFormat(instruments) : new DisplayFormat(instruments)));

    if (config.hasPath("trade-report.multicast-interface")) {
        NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "trade-report.multicast-interface");
        InetAddress      multicastGroup     = Configs.getInetAddress(config, "trade-report.multicast-group");
        int              multicastPort      = Configs.getPort(config, "trade-report.multicast-port");
        InetAddress      requestAddress     = Configs.getInetAddress(config, "trade-report.request-address");
        int              requestPort        = Configs.getPort(config, "trade-report.request-port");

        MoldUDP64.receive(multicastInterface, new InetSocketAddress(multicastGroup, multicastPort),
                new InetSocketAddress(requestAddress, requestPort), listener);
    } else {
        InetAddress address  = Configs.getInetAddress(config, "trade-report.address");
        int         port     = Configs.getPort(config, "trade-report.port");
        String      username = config.getString("trade-report.username");
        String      password = config.getString("trade-report.password");

        SoupBinTCP.receive(new InetSocketAddress(address, port), username, password, listener);
    }
}
 
Example #3
Source File: Simulator.java    From parity-extras with Apache License 2.0 5 votes vote down vote up
private static MarketData marketData(Config config) throws IOException {
    NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface");
    InetAddress      multicastGroup     = Configs.getInetAddress(config, "market-data.multicast-group");
    int              multicastPort      = Configs.getPort(config, "market-data.multicast-port");
    InetAddress      requestAddress     = Configs.getInetAddress(config, "market-data.request-address");
    int              requestPort        = Configs.getPort(config, "market-data.request-port");

    String instrument = config.getString("instrument");

    return MarketData.open(multicastInterface,
            new InetSocketAddress(multicastGroup, multicastPort),
            new InetSocketAddress(requestAddress, requestPort),
            ASCII.packLong(instrument));
}
 
Example #4
Source File: Gateway.java    From nassau with Apache License 2.0 5 votes vote down vote up
private static UpstreamFactory upstream(Config config) {
    NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "upstream.multicast-interface");
    InetAddress      multicastGroup     = Configs.getInetAddress(config, "upstream.multicast-group");
    int              multicastPort      = Configs.getPort(config, "upstream.multicast-port");
    InetAddress      requestAddress     = Configs.getInetAddress(config, "upstream.request-address");
    int              requestPort        = Configs.getPort(config, "upstream.request-port");

    return new UpstreamFactory(multicastInterface, new InetSocketAddress(multicastGroup, multicastPort),
            new InetSocketAddress(requestAddress, requestPort));
}
 
Example #5
Source File: TerminalClient.java    From parity with Apache License 2.0 5 votes vote down vote up
private static void main(Config config) throws IOException {
    InetAddress orderEntryAddress  = Configs.getInetAddress(config, "order-entry.address");
    int         orderEntryPort     = Configs.getPort(config, "order-entry.port");
    String      orderEntryUsername = config.getString("order-entry.username");
    String      orderEntryPassword = config.getString("order-entry.password");

    Instruments instruments = Instruments.fromConfig(config, "instruments");

    TerminalClient.open(new InetSocketAddress(orderEntryAddress, orderEntryPort),
            orderEntryUsername, orderEntryPassword, instruments).run();
}
 
Example #6
Source File: FIXGateway.java    From parity with Apache License 2.0 5 votes vote down vote up
private static FIXAcceptor fix(OrderEntryFactory orderEntry, Config config) throws IOException {
    InetAddress address      = Configs.getInetAddress(config, "fix.address");
    int         port         = Configs.getPort(config, "fix.port");
    String      senderCompId = config.getString("fix.sender-comp-id");

    Instruments instruments = Instruments.fromConfig(config, "instruments");

    return FIXAcceptor.open(orderEntry, new InetSocketAddress(address, port),
            senderCompId, instruments);
}
 
Example #7
Source File: TradingSystem.java    From parity with Apache License 2.0 5 votes vote down vote up
private static MarketData marketData(Config config) throws IOException {
    String           session            = config.getString("market-data.session");
    NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface");
    InetAddress      multicastGroup     = Configs.getInetAddress(config, "market-data.multicast-group");
    int              multicastPort      = Configs.getPort(config, "market-data.multicast-port");
    InetAddress      requestAddress     = Configs.getInetAddress(config, "market-data.request-address");
    int              requestPort        = Configs.getPort(config, "market-data.request-port");

    return MarketData.open(session, multicastInterface,
            new InetSocketAddress(multicastGroup, multicastPort),
            new InetSocketAddress(requestAddress, requestPort));
}
 
Example #8
Source File: TradingSystem.java    From parity with Apache License 2.0 5 votes vote down vote up
private static MarketReporting marketReporting(Config config) throws IOException {
    String           session            = config.getString("market-report.session");
    NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-report.multicast-interface");
    InetAddress      multicastGroup     = Configs.getInetAddress(config, "market-report.multicast-group");
    int              multicastPort      = Configs.getPort(config, "market-report.multicast-port");
    InetAddress      requestAddress     = Configs.getInetAddress(config, "market-report.request-address");
    int              requestPort        = Configs.getPort(config, "market-report.request-port");

    return MarketReporting.open(session, multicastInterface,
            new InetSocketAddress(multicastGroup, multicastPort),
            new InetSocketAddress(requestAddress, requestPort));
}
 
Example #9
Source File: Simulator.java    From parity-extras with Apache License 2.0 4 votes vote down vote up
private static OrderEntry orderEntry(Config config) throws IOException {
    InetAddress address = Configs.getInetAddress(config, "order-entry.address");
    int         port    = Configs.getPort(config, "order-entry.port");

    return OrderEntry.open(new InetSocketAddress(address, port));
}
 
Example #10
Source File: Gateway.java    From nassau with Apache License 2.0 4 votes vote down vote up
private static DownstreamServer downstream(Config config, UpstreamFactory upstream) throws IOException {
    InetAddress address = Configs.getInetAddress(config, "downstream.address");
    int         port    = Configs.getPort(config, "downstream.port");

    return DownstreamServer.open(upstream, new InetSocketAddress(address, port));
}
 
Example #11
Source File: FIXGateway.java    From parity with Apache License 2.0 4 votes vote down vote up
private static OrderEntryFactory orderEntry(Config config) {
    InetAddress address = Configs.getInetAddress(config, "order-entry.address");
    int         port    = Configs.getPort(config, "order-entry.port");

    return new OrderEntryFactory(new InetSocketAddress(address, port));
}
 
Example #12
Source File: TradingSystem.java    From parity with Apache License 2.0 4 votes vote down vote up
private static OrderEntry orderEntry(Config config, OrderBooks books) throws IOException {
    InetAddress address = Configs.getInetAddress(config, "order-entry.address");
    int         port    = Configs.getPort(config, "order-entry.port");

    return OrderEntry.open(new InetSocketAddress(address, port), books);
}