Package whitewerx.com.trapos.model

Examples of whitewerx.com.trapos.model.Trade


            DomainEvents.registerFor(PositionChangeEvent.class, this);

            if (!marketEvent.isTradeEvent())
                return;

            Trade t = marketEvent.getTrade();
            portfolioPosition.add(t);

        } finally {
            DomainEvents.unregisterFor(PositionChangeEvent.class);
        }
View Full Code Here


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

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

        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);

        return trade;
    }
View Full Code Here

    }
   
    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

    }
   
    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

    }

    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

    public void consumesTradeEvent() throws Exception {
       
        final String delimitedTrade = "T|S|2.3m|R|GBPUSD|1.6324";
        final TradeTranslator tradeTranslator = context.mock(TradeTranslator.class);
        final MarketEvent marketEvent = context.mock(MarketEvent.class);
        final Trade trade = context.mock(Trade.class);
       
        final MarketTradeEventHandler h = new MarketTradeEventHandler(tradeTranslator);
        context.checking(new Expectations(){{
            oneOf(marketEvent).getMessage();
            will(returnValue(delimitedTrade));
View Full Code Here

    @Test
    public void shouldUpdateThePositionForATradeEvent() throws Exception {
       
        final PortfolioPosition portfolioPosition = context.mock(PortfolioPosition.class);
        final MarketEvent tradeEvent = context.mock(MarketEvent.class);
        final Trade trade = context.mock(Trade.class);
       
        context.checking(new Expectations(){{
            oneOf(tradeEvent).isTradeEvent();
            will(returnValue(true));
           
View Full Code Here

    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

    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);
        assertThat(trade, equalTo(expected));
    }
View Full Code Here

TOP

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

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.