org.apache.commons.configuration2.builder.fluent.Configurations Java Examples

The following examples show how to use org.apache.commons.configuration2.builder.fluent.Configurations. 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: BitbankContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test(enabled = false)
public void testOrder() throws ConfigurationException, InterruptedException {

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));
    Key key = Key.builder().site(ID).instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    Set<CreateInstruction> creates = Sets.newHashSet(
            CreateInstruction.builder().price(new BigDecimal("1000000")).size(new BigDecimal("+0.0001")).build(),
            CreateInstruction.builder().price(new BigDecimal("1500000")).size(new BigDecimal("-0.0001")).build()
    );

    Map<CreateInstruction, String> created = target.createOrders(key, creates);
    System.out.println("Created : " + created);

    TimeUnit.SECONDS.sleep(10L);

    Set<CancelInstruction> cancels = created.values().stream().filter(StringUtils::isNotEmpty)
            .map(id -> CancelInstruction.builder().id(id).build()).collect(toSet());
    Map<CancelInstruction, String> cancelled = target.cancelOrders(key, cancels);
    System.out.println("Cancelled : " + cancelled);

}
 
Example #2
Source File: DocumentationTest.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
public void swagger2MarkupConfigFromCommonsConfiguration() throws IOException, ConfigurationException {
    Path localSwaggerFile = Paths.get("/path/to/swagger.yaml");

    // tag::swagger2MarkupConfigFromCommonsConfiguration[]
    Configurations configs = new Configurations();
    Configuration configuration = configs.properties("config.properties"); //<1>

    Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder(configuration) //<2>
            .build();

    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(localSwaggerFile)
            .withConfig(config)
            .build();
    // end::swagger2MarkupConfigFromCommonsConfiguration[]
}
 
Example #3
Source File: ZaifContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test(enabled = false)
public void test() throws ConfigurationException, IOException {

    doCallRealMethod().when(target).request(any(), any(), any(), any());

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));
    Key key = Key.builder().site(ID).instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    System.out.println("AP: " + target.getBestAskPrice(key));
    System.out.println("BP: " + target.getBestBidPrice(key));
    System.out.println("AS: " + target.getBestAskSize(key));
    System.out.println("BS: " + target.getBestBidSize(key));
    System.out.println("MP: " + target.getMidPrice(key));
    System.out.println("AD: " + target.getAskPrices(key));
    System.out.println("BD: " + target.getBidPrices(key));

    System.out.println("LP:" + target.getLastPrice(key));
    System.out.println("TD:" + target.listTrades(key, null));

    System.out.println("IC:" + target.getInstrumentCurrency(key));
    System.out.println("FC:" + target.getFundingCurrency(key));
    System.out.println("FP:" + target.findProduct(key, BTC, JPY));

    System.out.println("P1:" + target.getConversionPrice(key, BTC));
    System.out.println("P2:" + target.getConversionPrice(key, JPY));

    System.out.println("IP:" + target.getInstrumentPosition(key));
    System.out.println("FP:" + target.getFundingPosition(key));
    System.out.println("AO:" + target.listActiveOrders(key));
    System.out.println("EX:" + target.listExecutions(key));

}
 
Example #4
Source File: ZaifContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test(enabled = false)
public void testOrder() throws ConfigurationException, InterruptedException, IOException {

    doCallRealMethod().when(target).request(any(), any(), any(), any());

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));
    Key key = Key.builder().site(ID).instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    Set<Instruction.CreateInstruction> creates = Sets.newHashSet(
            Instruction.CreateInstruction.builder().price(new BigDecimal("1000000")).size(new BigDecimal("+0.0001")).build(),
            Instruction.CreateInstruction.builder().price(new BigDecimal("1500000")).size(new BigDecimal("-0.0001")).build()
    );

    Map<Instruction.CreateInstruction, String> created = target.createOrders(key, creates);
    System.out.println("Created : " + created);

    TimeUnit.SECONDS.sleep(5L);
    System.out.println("Orders:" + target.listActiveOrders(key));
    TimeUnit.SECONDS.sleep(5L);

    Set<Instruction.CancelInstruction> cancels = created.values().stream().filter(StringUtils::isNotEmpty)
            .map(id -> Instruction.CancelInstruction.builder().id(id).build()).collect(toSet());
    Map<Instruction.CancelInstruction, String> cancelled = target.cancelOrders(key, cancels);
    System.out.println("Cancelled : " + cancelled);

    TimeUnit.SECONDS.sleep(5L);
    System.out.println("Orders:" + target.listActiveOrders(key));

}
 
Example #5
Source File: QuoinexContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test(enabled = false)
public void test() throws ConfigurationException {

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));
    Context.Key key = Context.Key.builder().site(ID).instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    System.out.println("AP: " + target.getBestAskPrice(key));
    System.out.println("BP: " + target.getBestBidPrice(key));
    System.out.println("AS: " + target.getBestAskSize(key));
    System.out.println("BS: " + target.getBestBidSize(key));
    System.out.println("MP: " + target.getMidPrice(key));
    System.out.println("AD: " + target.getAskPrices(key));
    System.out.println("BD: " + target.getBidPrices(key));

    System.out.println("LP:" + target.getLastPrice(key));
    System.out.println("TD:" + target.listTrades(key, null));

    System.out.println("IC:" + target.getInstrumentCurrency(key));
    System.out.println("FC:" + target.getFundingCurrency(key));
    System.out.println("FP:" + target.findProduct(key, BTC, JPY));

    System.out.println("P1:" + target.getConversionPrice(key, BTC));
    System.out.println("P2:" + target.getConversionPrice(key, JPY));

    System.out.println("IP:" + target.getInstrumentPosition(key));
    System.out.println("FP:" + target.getFundingPosition(key));
    System.out.println("AO:" + target.listActiveOrders(key));
    System.out.println("EX:" + target.listExecutions(key));

}
 
Example #6
Source File: QuoinexContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test(enabled = false)
public void testOrder() throws ConfigurationException, InterruptedException {

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));
    Context.Key key = Context.Key.builder().site(ID).instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    Set<Instruction.CreateInstruction> creates = Sets.newHashSet(
            Instruction.CreateInstruction.builder().price(new BigDecimal("1000000")).size(new BigDecimal("-0.001")).build(),
            Instruction.CreateInstruction.builder().price(new BigDecimal("+800000")).size(new BigDecimal("+0.001")).build()
    );

    Map<Instruction.CreateInstruction, String> created = target.createOrders(key, creates);
    System.out.println("Created : " + created);

    TimeUnit.SECONDS.sleep(5L);
    System.out.println("AO:" + target.listActiveOrders(key));

    TimeUnit.SECONDS.sleep(5L);
    created.values().stream().filter(StringUtils::isNotEmpty)
            .forEach(id -> System.out.println("FO:" + target.findOrder(key, id)));

    Set<Instruction.CancelInstruction> cancels = created.values().stream().filter(StringUtils::isNotEmpty)
            .map(id -> Instruction.CancelInstruction.builder().id(id).build()).collect(toSet());
    Map<Instruction.CancelInstruction, String> cancelled = target.cancelOrders(key, cancels);
    System.out.println("Cancelled : " + cancelled);

}
 
Example #7
Source File: BtcboxContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test(enabled = false)
public void test() throws ConfigurationException {

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));
    Context.Key key = Context.Key.builder().site(ID).instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    System.out.println("AP: " + target.getBestAskPrice(key));
    System.out.println("BP: " + target.getBestBidPrice(key));
    System.out.println("AS: " + target.getBestAskSize(key));
    System.out.println("BS: " + target.getBestBidSize(key));
    System.out.println("MP: " + target.getMidPrice(key));
    System.out.println("AD: " + target.getAskPrices(key));
    System.out.println("BD: " + target.getBidPrices(key));

    System.out.println("LP:" + target.getLastPrice(key));
    System.out.println("TD:" + target.listTrades(key, null));

    System.out.println("IC:" + target.getInstrumentCurrency(key));
    System.out.println("FC:" + target.getFundingCurrency(key));
    System.out.println("FP:" + target.findProduct(key, BTC, JPY));

    System.out.println("P1:" + target.getConversionPrice(key, BTC));
    System.out.println("P2:" + target.getConversionPrice(key, JPY));

    System.out.println("IP:" + target.getInstrumentPosition(key));
    System.out.println("FP:" + target.getFundingPosition(key));
    System.out.println("AO:" + target.listActiveOrders(key));
    System.out.println("EX:" + target.listExecutions(key));

}
 
Example #8
Source File: BtcboxContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test(enabled = false)
public void testOrder() throws ConfigurationException, InterruptedException {

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));
    Context.Key key = Context.Key.builder().site(ID).instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    Set<Instruction.CreateInstruction> creates = Sets.newHashSet(
            Instruction.CreateInstruction.builder().price(new BigDecimal("1500000")).size(new BigDecimal("-0.001")).build(),
            Instruction.CreateInstruction.builder().price(new BigDecimal("1000000")).size(new BigDecimal("+0.001")).build()
    );

    Map<Instruction.CreateInstruction, String> created = target.createOrders(key, creates);
    System.out.println("Created : " + created);

    TimeUnit.SECONDS.sleep(5L);
    System.out.println("AO:" + target.listActiveOrders(key));

    TimeUnit.SECONDS.sleep(5L);
    created.values().stream().filter(StringUtils::isNotEmpty)
            .forEach(id -> System.out.println("FO:" + target.findOrder(key, id)));

    Set<Instruction.CancelInstruction> cancels = created.values().stream().filter(StringUtils::isNotEmpty)
            .map(id -> Instruction.CancelInstruction.builder().id(id).build()).collect(toSet());
    Map<Instruction.CancelInstruction, String> cancelled = target.cancelOrders(key, cancels);
    System.out.println("Cancelled : " + cancelled);

}
 
Example #9
Source File: DoctorKafkaConfig.java    From doctorkafka with Apache License 2.0 5 votes vote down vote up
public DoctorKafkaConfig(String configPath) throws Exception {
  try {
    Configurations configurations = new Configurations();
    configuration = configurations.properties(new File(configPath));
    drkafkaConfiguration = new SubsetConfiguration(configuration, DOCTORKAFKA_PREFIX);
    this.initialize();
  } catch (Exception e) {
    LOG.error("Failed to initialize configuration file {}", configPath, e);
  }
}
 
Example #10
Source File: Helios.java    From standalone-app with Apache License 2.0 5 votes vote down vote up
private static Configuration loadConfiguration() throws IOException, ConfigurationException {
    Configurations configurations = new Configurations();
    File file = Constants.SETTINGS_FILE_XML;
    if (!file.exists()) {
        XMLConfiguration tempConfiguration = new XMLConfiguration();
        new FileHandler(tempConfiguration).save(file);
    }
    FileBasedConfigurationBuilder<XMLConfiguration> builder = configurations.xmlBuilder(file);
    builder.setAutoSave(true);
    return builder.getConfiguration();
}
 
Example #11
Source File: SettingsConfiguration.java    From Getaviz with Apache License 2.0 5 votes vote down vote up
private static void loadConfig(String path) {
	File file = new File(path);
	try {
		Configurations configs = new Configurations();
		config = configs.properties(file);
		new File(instance.getOutputPath()).mkdirs();
	} catch (ConfigurationException cex) {
		log.error(cex);
	}
}
 
Example #12
Source File: Schema2MarkupConfigBuilder.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
/**
 * Loads the default properties from the classpath.
 *
 * @return the default properties
 */
public static Configuration getDefaultConfiguration() {
    Configurations configs = new Configurations();
    try {
        return configs.properties(PROPERTIES_DEFAULT);
    } catch (ConfigurationException e) {
        throw new RuntimeException(String.format("Can't load default properties '%s'", PROPERTIES_DEFAULT), e);
    }
}
 
Example #13
Source File: Application.java    From swagger2markup-cli with Apache License 2.0 5 votes vote down vote up
public void run() {

        Swagger2MarkupConfig swagger2MarkupConfig = null;
        if(StringUtils.isNotBlank(configFile)) {
            Configurations configs = new Configurations();
            Configuration config;
            try {
                config = configs.properties(configFile);
            } catch (ConfigurationException e) {
                throw new IllegalArgumentException("Failed to read configFile", e);
            }
            swagger2MarkupConfig = new Swagger2MarkupConfigBuilder(config).build();
        }
        Swagger2MarkupConverter.Builder converterBuilder = Swagger2MarkupConverter.from(URIUtils.create(swaggerInput));
        if(swagger2MarkupConfig != null){
            converterBuilder.withConfig(swagger2MarkupConfig);
        }
        Swagger2MarkupConverter converter = converterBuilder.build();

        if(StringUtils.isNotBlank(outputFile)){
            converter.toFile(Paths.get(outputFile).toAbsolutePath());
        }else if (StringUtils.isNotBlank(outputDir)){
            converter.toFolder(Paths.get(outputDir).toAbsolutePath());
        }else {
            throw new IllegalArgumentException("Either outputFile or outputDir option must be used");
        }
    }
 
Example #14
Source File: ArtemisTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void checkRole(String user, File roleFile, String... roles) throws Exception {
   Configurations configs = new Configurations();
   FileBasedConfigurationBuilder<PropertiesConfiguration> roleBuilder = configs.propertiesBuilder(roleFile);
   PropertiesConfiguration roleConfig = roleBuilder.getConfiguration();

   for (String r : roles) {
      String storedUsers = (String) roleConfig.getProperty(r);

      log.debug("users in role: " + r + " ; " + storedUsers);
      List<String> userList = StringUtil.splitStringList(storedUsers, ",");
      assertTrue(userList.contains(user));
   }
}
 
Example #15
Source File: GraphFactory.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private static org.apache.commons.configuration2.Configuration getConfiguration(final File configurationFile) {
    if (!configurationFile.isFile())
        throw new IllegalArgumentException(String.format("The location configuration must resolve to a file and [%s] does not", configurationFile));

    try {
        final String fileName = configurationFile.getName();
        final String fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1);

        final Configuration conf;
        final Configurations configs = new Configurations();

        switch (fileExtension) {
            case "yml":
            case "yaml":
                final Parameters params = new Parameters();
                final FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
                        new FileBasedConfigurationBuilder<FileBasedConfiguration>(YAMLConfiguration.class).
                                configure(params.fileBased().setFile(configurationFile));

                final org.apache.commons.configuration2.Configuration copy = new org.apache.commons.configuration2.BaseConfiguration();
                ConfigurationUtils.copy(builder.configure(params.fileBased().setFile(configurationFile)).getConfiguration(), copy);
                conf = copy;
                break;
            case "xml":
                conf = configs.xml(configurationFile);
                break;
            default:
                conf = configs.properties(configurationFile);
        }
        return conf;
    } catch (ConfigurationException e) {
        throw new IllegalArgumentException(String.format("Could not load configuration at: %s", configurationFile), e);
    }
}
 
Example #16
Source File: BaseSettings.java    From batfish with Apache License 2.0 5 votes vote down vote up
private static Configuration loadFileConfiguration(File configFile) {
  try {
    return new Configurations().properties(configFile);
  } catch (ConfigurationException e) {
    throw new BatfishException(
        "Error loading configuration from " + configFile.getAbsolutePath(), e);
  }
}
 
Example #17
Source File: Version.java    From batfish with Apache License 2.0 5 votes vote down vote up
/** Returns the version corresponding to the specified key, in the specified properties file */
public static String getPropertiesVersion(String propertiesPath, String key) {
  try {
    Configuration config = new Configurations().properties(propertiesPath);
    String version = config.getString(key);
    if (version.contains("project.version")) {
      // For whatever reason, resource filtering didn't work.
      return UNKNOWN_VERSION;
    }
    return version;
  } catch (Exception e) {
    return UNKNOWN_VERSION;
  }
}
 
Example #18
Source File: FuncotatorUtils.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Create a configuration instance from a properties file, where key names are ordered.
 *
 * @param configFile Must be a readable file.
 * @return Configuration instance. Never {@code null}
 */
public static Configuration retrieveConfiguration(final File configFile) {
    IOUtils.assertFileIsReadable(configFile.toPath());

    // Use Apache Commons configuration since it will preserve the order of the keys in the config file.
    //  Properties will not preserve the ordering, since it is backed by a HashSet.
    try {
        return new Configurations().properties(configFile);
    } catch (final ConfigurationException ce) {
        throw new UserException.BadInput("Unable to read from XSV config file: " + configFile.toString(), ce);
    }
}
 
Example #19
Source File: FuncotateSegmentsIntegrationTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void assertEmptyTsvFileHasCorrectHeaders(final File outputFile, final String segResourceFile) throws IOException {
    final Path configFile = Resource.getResourceContentsAsFile(segResourceFile).toPath();
    try {
        final Configuration configFileContents = new Configurations().properties(configFile.toFile());
        final List<String> expectedColumns = Lists.newArrayList(configFileContents.getKeys());
        FuncotatorTestUtils.assertTsvFieldNames(outputFile, expectedColumns);
    } catch (final ConfigurationException ce) {
        throw new UserException.BadInput("Unable to read from XSV config file: " + configFile.toUri().toString(), ce);
    }
}
 
Example #20
Source File: TestClasspathLocationStrategy.java    From commons-configuration with Apache License 2.0 5 votes vote down vote up
/**
 * Tests a successful location of a provided resource name.
 */
@Test
public void testLocateSuccess() throws ConfigurationException
{
    final FileLocator locator =
            FileLocatorUtils.fileLocator().fileName(FILE_NAME)
                    .basePath("somePath").create();
    final URL url = strategy.locate(fileSystem, locator);
    final Configurations configurations = new Configurations();
    final XMLConfiguration config1 = configurations.xml(url);
    final XMLConfiguration config2 = configurations.xml(ConfigurationAssert.getTestURL(FILE_NAME));
    ConfigurationAssert.assertConfigurationEquals(config1, config2);
}
 
Example #21
Source File: BitpointContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test(enabled = false)
public void test() throws ConfigurationException, IOException {

    doCallRealMethod().when(target).request(any(), any(), any(), any());

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));
    Key key = Key.builder().site(ID).instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    System.out.println("AP: " + target.getBestAskPrice(key));
    System.out.println("BP: " + target.getBestBidPrice(key));
    System.out.println("AS: " + target.getBestAskSize(key));
    System.out.println("BS: " + target.getBestBidSize(key));
    System.out.println("MP: " + target.getMidPrice(key));
    System.out.println("AD: " + target.getAskPrices(key));
    System.out.println("BD: " + target.getBidPrices(key));

    System.out.println("LP:" + target.getLastPrice(key));
    System.out.println("TD:" + target.listTrades(key, null));

    System.out.println("IC:" + target.getInstrumentCurrency(key));
    System.out.println("FC:" + target.getFundingCurrency(key));
    System.out.println("FP:" + target.findProduct(key, BTC, JPY));
    System.out.println("CM:" + target.getCommissionRate(key));

    System.out.println("P1:" + target.getConversionPrice(key, BTC));
    System.out.println("P2:" + target.getConversionPrice(key, JPY));

    System.out.println("IP:" + target.getInstrumentPosition(key));
    System.out.println("FP:" + target.getFundingPosition(key));
    System.out.println("AO:" + target.listActiveOrders(key));
    System.out.println("EX:" + target.listExecutions(key));

}
 
Example #22
Source File: SettingsConfiguration.java    From Getaviz with Apache License 2.0 5 votes vote down vote up
private static void loadConfig(String path) {
	File file = new File(path);
	try {
		Configurations configs = new Configurations();
		config = configs.properties(file);
	} catch (ConfigurationException cex) {
		System.out.println(cex);
	}
}
 
Example #23
Source File: GameConfig.java    From 2018-TowerDefence with MIT License 5 votes vote down vote up
public static void initConfig(String configLocation) {
    if (configuration == null) {
        Configurations configurations = new Configurations();

        try {
            configuration = configurations.properties(configLocation);

        } catch (ConfigurationException e) {
            log.error("Unable to initialise configuration, please have a look at the inner exception.", e);
            throw new RuntimeException("Unable to initialise configuration, please have a look at the inner exception.", e);
        }
    }
}
 
Example #24
Source File: Config.java    From bireme with Apache License 2.0 5 votes vote down vote up
/**
 * Read config file and store in {@code Config}.
 *
 * @param configFile the config file.
 * @throws ConfigurationException - if an error occurred when loading the configuration
 * @throws BiremeException - wrap and throw Exception which cannot be handled
 */
public Config(String configFile) throws ConfigurationException, BiremeException {
  Configurations configs = new Configurations();
  config = configs.properties(new File(configFile));

  basicConfig();
  connectionConfig("target");
  dataSourceConfig();

  logConfig();
}
 
Example #25
Source File: Config.java    From bireme with Apache License 2.0 5 votes vote down vote up
private HashMap<String, String> fetchTableMap(String dataSource)
    throws ConfigurationException, BiremeException {
  Configurations configs = new Configurations();
  Configuration tableConfig = null;

  tableConfig = configs.properties(new File(DEFAULT_TABLEMAP_DIR + dataSource + ".properties"));

  String originTable, mappedTable;
  HashMap<String, String> localTableMap = new HashMap<String, String>();
  Iterator<String> tables = tableConfig.getKeys();

  while (tables.hasNext()) {
    originTable = tables.next();
    mappedTable = tableConfig.getString(originTable);

    if (originTable.split("\\.").length != 2 || mappedTable.split("\\.").length != 2) {
      String message = "Wrong format: " + originTable + ", " + mappedTable;
      logger.fatal(message);
      throw new BiremeException(message);
    }

    localTableMap.put(dataSource + "." + originTable, mappedTable);

    if (!tableMap.values().contains(mappedTable)) {
      loadersCount++;
    }
    tableMap.put(dataSource + "." + originTable, mappedTable);
  }

  return localTableMap;
}
 
Example #26
Source File: BitmexContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test(enabled = false)
public void test() throws Exception {

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));

    doCallRealMethod().when(target).request(any(), any(), any(), any());

    Key key = Key.builder().instrument("XBT_QT").timestamp(Instant.now()).build();

    // Tick
    System.out.println("Ask : " + target.getBestAskPrice(key));
    System.out.println("Bid : " + target.getBestBidPrice(key));
    System.out.println("Mid : " + target.getMidPrice(key));
    System.out.println("Ltp : " + target.getLastPrice(key));

    // Book
    System.out.println("ASZ : " + target.getBestAskSize(key));
    System.out.println("BSZ : " + target.getBestBidSize(key));

    // Trade
    System.out.println("TRD : " + target.listTrades(key, null));

    // Account
    System.out.println("IPS : " + target.getInstrumentPosition(key));
    System.out.println("FPS : " + target.getFundingPosition(key));

    // Reference
    System.out.println("COM : " + target.getCommissionRate(key));
    System.out.println("MGN : " + target.isMarginable(key));
    System.out.println("EXP : " + target.getExpiry(key));

    // Order Query
    System.out.println("ORD : " + target.findOrders(key));
    System.out.println("EXC : " + target.listExecutions(key));

}
 
Example #27
Source File: BitmexContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test(enabled = false)
public void test_Order() throws Exception {

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));

    doCallRealMethod().when(target).request(any(), any(), any(), any());

    Key key = Key.builder().instrument("XBJ_QT").timestamp(Instant.now()).build();

    Map<CreateInstruction, String> ids = target.createOrders(
            key, Sets.newHashSet(
                    CreateInstruction.builder()
                            .price(new BigDecimal("1000000"))
                            .size(new BigDecimal("10E-1")).build(),
                    CreateInstruction.builder()
                            .price(new BigDecimal("1000000"))
                            .size(new BigDecimal("0.2E1")).build()
            ));

    System.out.println("NEW : " + ids);

    Thread.sleep(TimeUnit.SECONDS.toMillis(5));

    System.out.println("CND : " + target.cancelOrders(key, ids.values().stream()
            .map(id -> CancelInstruction.builder().id(id).build()).collect(Collectors.toSet())
    ));

}
 
Example #28
Source File: FiscoContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test(enabled = false)
public void test() throws ConfigurationException, IOException {

    doCallRealMethod().when(target).request(any(), any(), any(), any());

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));
    Key key = Key.builder().site(ID).instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    System.out.println("AP: " + target.getBestAskPrice(key));
    System.out.println("BP: " + target.getBestBidPrice(key));
    System.out.println("AS: " + target.getBestAskSize(key));
    System.out.println("BS: " + target.getBestBidSize(key));
    System.out.println("MP: " + target.getMidPrice(key));
    System.out.println("AD: " + target.getAskPrices(key));
    System.out.println("BD: " + target.getBidPrices(key));

    System.out.println("LP:" + target.getLastPrice(key));
    System.out.println("TD:" + target.listTrades(key, null));

    System.out.println("IC:" + target.getInstrumentCurrency(key));
    System.out.println("FC:" + target.getFundingCurrency(key));
    System.out.println("FP:" + target.findProduct(key, BTC, JPY));
    System.out.println("CM:" + target.getCommissionRate(key));

    System.out.println("P1:" + target.getConversionPrice(key, BTC));
    System.out.println("P2:" + target.getConversionPrice(key, JPY));

    System.out.println("IP:" + target.getInstrumentPosition(key));
    System.out.println("FP:" + target.getFundingPosition(key));
    System.out.println("AO:" + target.listActiveOrders(key));
    System.out.println("EX:" + target.listExecutions(key));

}
 
Example #29
Source File: BitpointContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test(enabled = false)
public void testOrder() throws ConfigurationException, InterruptedException, IOException {

    doCallRealMethod().when(target).request(any(), any(), any(), any());

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));
    Key key = Key.builder().site(ID).instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    Set<Instruction.CreateInstruction> creates = Sets.newHashSet(
            Instruction.CreateInstruction.builder().price(new BigDecimal("400000")).size(new BigDecimal("+0.001")).build(),
            Instruction.CreateInstruction.builder().price(new BigDecimal("600000")).size(new BigDecimal("-0.001")).build()
    );

    Map<Instruction.CreateInstruction, String> created = target.createOrders(key, creates);
    System.out.println("Created : " + created);

    TimeUnit.SECONDS.sleep(5L);
    System.out.println("Orders:" + target.listActiveOrders(key));
    TimeUnit.SECONDS.sleep(30L);

    Set<Instruction.CancelInstruction> cancels = created.values().stream().filter(StringUtils::isNotEmpty)
            .map(id -> Instruction.CancelInstruction.builder().id(id).build()).collect(toSet());
    Map<Instruction.CancelInstruction, String> cancelled = target.cancelOrders(key, cancels);
    System.out.println("Cancelled : " + cancelled);

    TimeUnit.SECONDS.sleep(5L);
    System.out.println("Orders:" + target.listActiveOrders(key));

}
 
Example #30
Source File: FiscoContextTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test(enabled = false)
public void testOrder() throws ConfigurationException, InterruptedException, IOException {

    doCallRealMethod().when(target).request(any(), any(), any(), any());

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));
    Key key = Key.builder().site(ID).instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    Set<Instruction.CreateInstruction> creates = Sets.newHashSet(
            Instruction.CreateInstruction.builder().price(new BigDecimal("700000")).size(new BigDecimal("+0.001")).build(),
            Instruction.CreateInstruction.builder().price(new BigDecimal("800000")).size(new BigDecimal("-0.001")).build()
    );

    Map<Instruction.CreateInstruction, String> created = target.createOrders(key, creates);
    System.out.println("Created : " + created);

    TimeUnit.SECONDS.sleep(5L);
    System.out.println("Orders:" + target.listActiveOrders(key));
    TimeUnit.SECONDS.sleep(30L);

    Set<Instruction.CancelInstruction> cancels = created.values().stream().filter(StringUtils::isNotEmpty)
            .map(id -> Instruction.CancelInstruction.builder().id(id).build()).collect(toSet());
    Map<Instruction.CancelInstruction, String> cancelled = target.cancelOrders(key, cancels);
    System.out.println("Cancelled : " + cancelled);

    TimeUnit.SECONDS.sleep(5L);
    System.out.println("Orders:" + target.listActiveOrders(key));

}