/** * Obtains an instance of {@code Money} as the total value of * a possibly empty collection. * <p> * The amounts are added as though using {@link #plus(BigMoneyProvider)} starting * from zero in the specified currency. * All amounts must be in the same currency. * * @param currency the currency to total in, not null * @param monies the monetary values to total, no null elements, not null * @return the total, never null * @throws CurrencyMismatchException if the currencies differ */ public static BigMoney total(CurrencyUnit currency, Iterable<? extends BigMoneyProvider> monies) { return BigMoney.zero(currency).plus(monies); }
/** * Obtains an instance of {@code Money} as the total value of * a possibly empty array. * <p> * The amounts are added as though using {@link #plus(BigMoneyProvider)} starting * from zero in the specified currency. * All amounts must be in the same currency. * * @param currency the currency to total in, not null * @param monies the monetary values to total, no null elements, not null * @return the total, never null * @throws CurrencyMismatchException if the currencies differ */ public static BigMoney total(CurrencyUnit currency, BigMoneyProvider... monies) { return BigMoney.zero(currency).plus(Arrays.asList(monies)); }
public String addOrder(Order.OrderType orderType, BigMoney price, BigDecimal amount) throws UnsupportedEncodingException, JsonProcessingException { String typeStr = Order.OrderType.ASK == orderType ? "ask" : "bid"; String priceStr = MtGoxUtils.getPriceString(price); String amountStr = MtGoxUtils.getAmountString(amount); HashMap<String, String> params = new HashMap<String, String>(3); params.put("type", typeStr); params.put("amount_int", amountStr); // if price <= 0, it's a market order if (price.isGreaterThan(BigMoney.zero(price.getCurrencyUnit()))) { params.put("price_int", priceStr); } String reqId = String.format("order_add:%s:%s:%s", typeStr, priceStr, amountStr); return signedCall("order/add", params, reqId); }
public void calcProfitLoss() { BigMoney equivBTCStartBal = BigMoney.zero(CurrencyUnit.of("BTC")); BigMoney equivBTCEndBal = BigMoney.zero(CurrencyUnit.of("BTC")); BigMoney startBal = BigMoney.zero(CurrencyUnit.of("BTC")); BigMoney endBal = BigMoney.zero(CurrencyUnit.of("BTC")); BigDecimal startRate = BigDecimal.ZERO; BigDecimal endRate = BigDecimal.ZERO;
bidArrow = 0; askArrow = 0; shortSMA = BigMoney.zero(localCurrency); longSMA = BigMoney.zero(localCurrency); shortEMA = BigMoney.zero(localCurrency); longEMA = BigMoney.zero(localCurrency); shortMACD = BigMoney.zero(localCurrency); longMACD = BigMoney.zero(localCurrency); sigLineMACD = BigMoney.zero(localCurrency); Double expLongMACD = Double.valueOf(0); Double expSigLineMACD = Double.valueOf(0); BigMoney sumShortSMA = BigMoney.zero(localCurrency); BigMoney sumLongSMA = BigMoney.zero(localCurrency); BigMoney newBid = null, oldBid = BigMoney.zero(localCurrency); BigMoney newAsk = null, oldAsk = BigMoney.zero(localCurrency); BigMoney newPrice = null, oldPrice = BigMoney.zero(localCurrency); BigDecimal newVolume = null, oldVolume = BigDecimal.ZERO; BigDecimal totalVolume = BigDecimal.ZERO, absVolume = null, changedVolume = null; vwap = BigMoney.zero(localCurrency);