List of usage examples for java.lang Double valueOf
@HotSpotIntrinsicCandidate public static Double valueOf(double d)
From source file:com.irusist.xiaoao.turntable.service.RequestService.java
public void run() { duration = (long) (Double.valueOf(config.get(0)) * 1000); for (int i = 1; i < config.size(); i++) { String[] line = config.get(i).split("\\|"); tokens.put(line[0], line[1]);//from w w w . j a v a2 s . co m } while (true) { Random rand = new Random(); for (Map.Entry<String, String> entry : tokens.entrySet()) { try { Thread.sleep(rand.nextInt(1000)); } catch (Exception e) { e.printStackTrace(); } String account = entry.getKey(); String token = entry.getValue(); execute(pool, account, token); } try { Thread.sleep(duration); } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.nubits.nubot.pricefeeds.BitstampPriceFeed.java
@Override public LastPrice getLastPrice(CurrencyPair pair) { long now = System.currentTimeMillis(); long diff = now - lastRequest; if (diff >= refreshMinTime) { String url = "https://www.bitstamp.net/api/ticker/"; String htmlString;//from w ww .j a v a2 s . c o m try { htmlString = Utils.getHTML(url, true); } catch (IOException ex) { LOG.severe(ex.toString()); return new LastPrice(true, name, pair.getOrderCurrency(), null); } JSONParser parser = new JSONParser(); try { JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString)); double last = Double.valueOf((String) httpAnswerJson.get("last")); //Make the average between buy and sell last = Utils.round(last, 8); lastRequest = System.currentTimeMillis(); lastPrice = new LastPrice(false, name, pair.getOrderCurrency(), new Amount(last, pair.getPaymentCurrency())); return lastPrice; } catch (Exception ex) { LOG.severe(ex.toString()); lastRequest = System.currentTimeMillis(); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } else { LOG.fine("Wait " + (refreshMinTime - (System.currentTimeMillis() - lastRequest)) + " ms " + "before making a new request. Now returning the last saved price\n\n"); return lastPrice; } }
From source file:com.nubits.nubot.pricefeeds.BitfinexPriceFeed.java
@Override public LastPrice getLastPrice(CurrencyPair pair) { long now = System.currentTimeMillis(); long diff = now - lastRequest; if (diff >= refreshMinTime) { String url = "https://api.bitfinex.com/v1/pubticker/btcusd"; String htmlString;//from w ww .ja v a2 s. c om try { htmlString = Utils.getHTML(url, true); } catch (IOException ex) { LOG.severe(ex.toString()); return new LastPrice(true, name, pair.getOrderCurrency(), null); } JSONParser parser = new JSONParser(); try { JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString)); double last = Double.valueOf((String) httpAnswerJson.get("last_price")); //Make the average between buy and sell last = Utils.round(last, 8); lastRequest = System.currentTimeMillis(); lastPrice = new LastPrice(false, name, pair.getOrderCurrency(), new Amount(last, pair.getPaymentCurrency())); return lastPrice; } catch (Exception ex) { LOG.severe(ex.toString()); lastRequest = System.currentTimeMillis(); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } else { LOG.fine("Wait " + (refreshMinTime - (System.currentTimeMillis() - lastRequest)) + " ms " + "before making a new request. Now returning the last saved price\n\n"); return lastPrice; } }
From source file:fuzzy.df.TestLargestOfMaximaDefuzzificationFunction.java
@Test() public void testDefuzzificationEmptySet() { LargestOfMaximaDefuzzificationFunction<Double> df = makeDefuzzificationFunction(); DoubleRange range = new DoubleRange(0.0, 0.0); MembershipFunction<Double> mf = new SigmoidalMembershipFunction(-10.0, 10.0); Double d = df.evaluate(range, mf); assertEquals(Double.valueOf(0.0), d); }
From source file:fuzzy.df.TestSmallestOfMaximaDefuzzificationFunction.java
@Test() public void testDefuzzificationEmptySet() { SmallestOfMaximaDefuzzificationFunction<Double> df = makeDefuzzificationFunction(); DoubleRange range = new DoubleRange(0.0, 0.0); MembershipFunction<Double> mf = new SigmoidalMembershipFunction(-10.0, 10.0); Double d = df.evaluate(range, mf); assertEquals(Double.valueOf(0.0), d); }
From source file:de.tudarmstadt.ukp.experiments.argumentation.sequence.evaluation.helpers.FinalTableExtractor.java
public static void createCrossEvaluationTables(File mainFolder, final String prefix) throws IOException { Map<String, Table<String, String, Double>> domainResults = new TreeMap<>(); File[] crossDomainFolders = mainFolder.listFiles(new FileFilter() { @Override/*from w ww. j a v a 2 s .co m*/ public boolean accept(File pathname) { return pathname.isDirectory() && pathname.getName().startsWith(prefix); } }); System.out.println(Arrays.toString(crossDomainFolders)); for (File crossDomainFolder : crossDomainFolders) { // get the target domain String[] folderNameSplit = crossDomainFolder.getName().split("_"); String domain = folderNameSplit[1]; String featureSet = folderNameSplit[2]; File resultSummaryFile = new File(crossDomainFolder, "resultSummary.txt"); for (String line : FileUtils.readLines(resultSummaryFile)) { // parse the line with evaluation String[] split = line.split("\\s+"); String argumentComponent = split[0]; Double value = Double.valueOf(split[1]); // create a new table if needed if (!domainResults.containsKey(domain)) { domainResults.put(domain, TreeBasedTable.<String, String, Double>create()); } // fill the table Table<String, String, Double> table = domainResults.get(domain); if (includeColumn(argumentComponent)) { table.put(featureSet, argumentComponent, value); } } } System.out.println(domainResults.keySet()); for (Map.Entry<String, Table<String, String, Double>> entry : domainResults.entrySet()) { System.out.println(entry.getKey()); System.out.println(tableToCsv(entry.getValue())); } }
From source file:com.facebook.LinkBench.distributions.ZipfDistribution.java
@Override public void init(long min, long max, Properties props, String keyPrefix) { if (max <= min) { throw new IllegalArgumentException("max = " + max + " <= min = " + min + ": probability distribution cannot have zero or negative domain"); }//from w w w . java2 s . c o m this.min = min; this.max = max; String shapeS = props != null ? ConfigUtil.getPropertyRequired(props, keyPrefix + "shape") : null; if (shapeS == null) { throw new IllegalArgumentException( "ZipfDistribution must be provided " + keyPrefix + "shape parameter"); } shape = Double.valueOf(shapeS); if (shape <= 0.0) { throw new IllegalArgumentException("Zipf shape parameter " + shape + " is not positive"); } if (props != null && props.containsKey(keyPrefix + LinkBenchConstants.PROB_MEAN)) { scale = (max - min) * ConfigUtil.getDouble(props, keyPrefix + LinkBenchConstants.PROB_MEAN); } else { scale = 1.0; } // Precompute some values to speed up future method calls long n = max - min; alpha = 1 / (1 - shape); zetan = calcZetan(n); eta = (1 - FastMath.pow(2.0 / n, 1 - shape)) / (1 - Harmonic.generalizedHarmonic(2, shape) / zetan); point5theta = FastMath.pow(0.5, shape); }
From source file:com.nubits.nubot.pricefeeds.BitstampEURPriceFeed.java
@Override public LastPrice getLastPrice(CurrencyPair pair) { long now = System.currentTimeMillis(); long diff = now - lastRequest; if (diff >= refreshMinTime) { String url = "https://www.bitstamp.net/api/eur_usd/"; String htmlString;/*from w w w .j a va 2s . co m*/ try { htmlString = Utils.getHTML(url, true); } catch (IOException ex) { LOG.severe(ex.toString()); return new LastPrice(true, name, pair.getOrderCurrency(), null); } JSONParser parser = new JSONParser(); try { JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString)); double buy = Double.valueOf((String) httpAnswerJson.get("buy")); double sell = Double.valueOf((String) httpAnswerJson.get("sell")); //Make the average between buy and sell double last = Utils.round((buy + sell) / 2, 8); lastRequest = System.currentTimeMillis(); lastPrice = new LastPrice(false, name, pair.getOrderCurrency(), new Amount(last, pair.getPaymentCurrency())); return lastPrice; } catch (Exception ex) { LOG.severe(ex.toString()); lastRequest = System.currentTimeMillis(); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } else { LOG.fine("Wait " + (refreshMinTime - (System.currentTimeMillis() - lastRequest)) + " ms " + "before making a new request. Now returning the last saved price\n\n"); return lastPrice; } }
From source file:org.esupportail.papercut.domain.UserPapercutInfos.java
/** * Papercut WebService gives balance values like 1.9465000000000003 * Error of epsilon machine is suspected in Papercut ! * -> to workaround, we simply here round the balance ... * /*from w w w .jav a 2 s . c o m*/ * Note that 5 decimals is the max in papercut today, but maybe one day it will be more so here we return with 10 max * * @param balance * @return */ private static String fixRoundPapercutError(String balance) { DecimalFormat df = new DecimalFormat("#.##########"); df.setRoundingMode(RoundingMode.HALF_UP); return df.format(Double.valueOf(balance)); }
From source file:com.nubits.nubot.pricefeeds.feedservices.CoinbasePriceFeed.java
@Override public LastPrice getLastPrice(CurrencyPair pair) { long now = System.currentTimeMillis(); long diff = now - lastRequest; if (diff >= refreshMinTime) { String url = getUrl(pair); String htmlString;/*from w w w . j a va2s . co m*/ try { htmlString = Utils.getHTML(url, true); } catch (IOException ex) { LOG.error(ex.toString()); return new LastPrice(true, name, pair.getOrderCurrency(), null); } JSONParser parser = new JSONParser(); try { JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString)); double last = Double.valueOf((String) httpAnswerJson.get("amount")); lastRequest = System.currentTimeMillis(); lastPrice = new LastPrice(false, name, pair.getOrderCurrency(), new Amount(last, pair.getPaymentCurrency())); return lastPrice; } catch (Exception ex) { LOG.error(ex.toString()); lastRequest = System.currentTimeMillis(); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } else { LOG.warn("Wait " + (refreshMinTime - (System.currentTimeMillis() - lastRequest)) + " ms " + "before making a new request. Now returning the last saved price\n\n"); return lastPrice; } }