Package whitewerx.com.trapos.model

Examples of whitewerx.com.trapos.model.Rate


    public void onEvent(MarketEvent marketEvent, long sequence, boolean endOfBatch) throws Exception {
        String delmitedRate = marketEvent.getMessage();
       
        if(!translator.canHandle(delmitedRate))
            return;
        Rate rate = translator.translate(delmitedRate);

        marketEvent.accept(rate);
       
        if(l.isInfoEnabled())
            l.info("onEvent: seq:"+sequence + "/" + endOfBatch + " event: "+ marketEvent);
View Full Code Here


        Matcher m = tradeRegex.matcher(delimitedTrade);
        if( !m.matches() )
            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())
View Full Code Here

        amount *= multiplier.factor();
        return new Amount(amount, tradeRate.getBaseCurrency());
    }

    private Rate parseTradeRateFrom(String delimitedRate) throws TranslateException {
        Rate tradeRate = rateTranslator.translate(delimitedRate);
        return tradeRate;
    }
View Full Code Here

        String ccy1 = m.group(CCY1);
        String ccy2 = m.group(CCY2);
        double atRate = Double.valueOf(m.group(RATE));
       
        Rate rate = new Rate(atRate, new CurrencyPair(new Currency(ccy1), new Currency(ccy2)));
        if(l.isTraceEnabled())
            l.trace(delimitedRate +"->" + rate);
       
        return rate;
    }
View Full Code Here

        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

        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

        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

    Mockery context = new Mockery();
   
    @Test
    public void translatesValidEURUSDRate() throws Exception {
        String delimitedRate = "R|EURUSD|1.3124";
        Rate expected = new Rate(1.3124, EURUSD);
               
        RateTranslator rateTranslator = new RateTranslator();
        Rate rate = rateTranslator.translate(delimitedRate);
        assertThat(rate, equalTo(expected));
    }
View Full Code Here

    public void consumesRateEvent() throws Exception {
       
        final String delimitedRate = "R|GBPUSD|1.6324";
        final RateTranslator rateTranslator = context.mock(RateTranslator.class);
        final MarketEvent marketEvent = context.mock(MarketEvent.class);
        final Rate rate = context.mock(Rate.class);
       
        final MarketRateEventHandler h = new MarketRateEventHandler(rateTranslator);
        context.checking(new Expectations(){{
            oneOf(marketEvent).getMessage();
            will(returnValue(delimitedRate));
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);
        assertThat(trade, equalTo(expected));
View Full Code Here

TOP

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

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.