Package whitewerx.com.trapos.model

Examples of whitewerx.com.trapos.model.Amount


            throw new TranslateException("Failed to translate trade.", delimitedTrade);

        TradeType buyOrSell = parseTradeTypeFrom(m.group(TRADE_TYPE));
        Rate tradeRate = parseTradeRateFrom(m.group(RATE));
        TradeMultiplier multiplier = parseTradeMultiplierFrom(m.group(MULTIPLIER));
        Amount tradeAmount = parseTradeAmountFrom(m.group(AMOUNT), multiplier, tradeRate);
       
        Trade trade = new Trade(buyOrSell, tradeAmount, tradeRate);
        if(l.isTraceEnabled())
            l.trace(delimitedTrade +"->" + trade);
View Full Code Here


    }

    private Amount parseTradeAmountFrom(String parsedAmount, TradeMultiplier multiplier, Rate tradeRate) {
        double amount = Double.valueOf(parsedAmount);
        amount *= multiplier.factor();
        return new Amount(amount, tradeRate.getBaseCurrency());
    }
View Full Code Here

        buy5mEURUSD = create5mEURUSDTrade();
        sell3mEURUSD = create3mEURUSDTrade();
    }
   
    private static Trade createSimpleEURUSDTrade() {
        Amount fivePointOneThousand = new Amount(5.1 * 1000, CurrencyProvider.EUR);
        Rate atEURUSDRate = new Rate(1.3124, EURUSD);
        return new Trade(TradeType.BUY, fivePointOneThousand, atEURUSDRate);
    }
View Full Code Here

        Rate atEURUSDRate = new Rate(1.3124, EURUSD);
        return new Trade(TradeType.BUY, fivePointOneThousand, atEURUSDRate);
    }
   
    private static Trade create5mEURUSDTrade() {
        Amount amount = new Amount(5 * ONE_MILLION, CurrencyProvider.EUR);
        Rate atEURUSDRate = new Rate(1.3150, EURUSD);
        return new Trade(TradeType.BUY, amount, atEURUSDRate);
    }
View Full Code Here

        Rate atEURUSDRate = new Rate(1.3150, EURUSD);
        return new Trade(TradeType.BUY, amount, atEURUSDRate);
    }

    private static Trade create3mEURUSDTrade() {
        Amount amount = new Amount(3 * ONE_MILLION, CurrencyProvider.EUR);
        Rate atEURUSDRate = new Rate(1.3160, EURUSD);
        return new Trade(TradeType.SELL, amount, atEURUSDRate);
    }
View Full Code Here

     */
    @Test
    public void translatesATradeMessage() throws Exception {
        String delimitedTrade = "T|B|5.1t|R|EURUSD|1.3124";
       
        Amount fivePointOneThousand = new Amount(5.1 * 1000, new Currency("EUR"));
        Rate atEURUSDRate = new Rate(1.3124, EURUSD);
        final Trade expected = new Trade(TradeType.BUY, fivePointOneThousand, atEURUSDRate);
       
        TradeTranslator t = new TradeTranslator();
        Trade trade = t.translate(delimitedTrade);
View Full Code Here

    @Test
    public void translatesATradeMessageWithNoMultiplier() throws Exception {
        String delimitedTrade = "T|S|5.1|R|EURUSD|1.3124";
       
        Amount fivePointOne = new Amount(5.1, new Currency("EUR"));
        Rate atEURUSDRate = new Rate(1.3124, EURUSD);
        final Trade expected = new Trade(TradeType.SELL, fivePointOne, atEURUSDRate);
       
        TradeTranslator t = new TradeTranslator();
        Trade trade = t.translate(delimitedTrade);
View Full Code Here

   
    @Test
    public void translatesATradeMessageMillionsMultiplier() throws Exception {
        String delimitedTrade = "T|S|2m|R|USDCAD|1.0012";
       
        Amount twoMillion = new Amount(2000000.0, new Currency("USD"));
        Rate atUSDCADRate = new Rate(1.0012, USDCAD);
        final Trade expected = new Trade(TradeType.SELL, twoMillion, atUSDCADRate);
       
        TradeTranslator t = new TradeTranslator();
        Trade trade = t.translate(delimitedTrade);
View Full Code Here

TOP

Related Classes of whitewerx.com.trapos.model.Amount

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.