Package com.collective2.signalEntry.adapter

Examples of com.collective2.signalEntry.adapter.IterableXMLEventReader


    private void journalTest(C2EntryServiceJournal journal) {
        //starts out empty
        assertTrue(!journal.pending().hasNext());

        //successful addition of one request
        Request request = new Request(Command.Signal);
        journal.append(request);
        assertEquals(request,journal.pending().next());

        //successful removal of one request
        journal.markSent(request);
        assertTrue(!journal.pending().hasNext());

        //successful addition of two requests in order
        Request request2 = new Request(Command.Cancel);
        assert(!request.equals(request2));
        journal.append(request);
        journal.append(request2);
        Iterator<Request> iterator = journal.pending();
        assertTrue(iterator.hasNext());
View Full Code Here


    @Test
    public void timeoutTest() {

        Collective2Adapter adapter = new Collective2Adapter();
        //mock request that does not return actual URL to collective2
        Request mockRequest = new Request(Command.AllSignals) {
            @Override
            public URL buildURL() {
                try {
                    return new URL("file://nofile.nowhere");
View Full Code Here

    @Test
    public void transmitTest() {

        Collective2Adapter adapter = new Collective2Adapter();
        //mock request that does not return actual URL to collective2
        Request mockRequest = new Request(Command.Cancel) {
            @Override
            public URL buildURL() {
                return getClass().getClassLoader().getResource("staticResponse.xml");
            };
        };
View Full Code Here

        int id = 42;
        long time = stop;
        Instrument instrument = Instrument.Forex;
        String symbol = "GG";
        SignalAction action = SignalAction.BTO;
        Integer quantity = 10;
        QuantityComputable quantityComputable = new QuantityComputableFixed(quantity);
        long cancelAtMs = Long.MAX_VALUE;
        Duration timeInForce = Duration.GoodTilCancel;
View Full Code Here

        assertEquals(Integer.valueOf(-quantity),portfolio.position("GG").quantity());
        assertEquals(new BigDecimal("-60"),portfolio.equity(dataProvider));

        //Buy to cover this short position

        SignalAction action = SignalAction.BTC;
        OrderProcessorStop buyProcessor = new OrderProcessorStop(time,symbol,buyBelow);
        order = new Order(null, id,instrument,symbol,action,quantityComputable,cancelAtMs,timeInForce,buyProcessor,null);

        processed = buyProcessor.process(dataProvider, portfolio, commission, order, action, quantityComputable, null);
        expectedCash = expectedCash.subtract(expectedBuy.multiply(new BigDecimal(quantity))).subtract(commission);
View Full Code Here

        int id = 42;
        long time = stop;
        Instrument instrument = Instrument.Forex;
        String symbol = "GG";
        SignalAction action = SignalAction.BTO;
        Integer quantity = 10;
        QuantityComputable quantityComputable = new QuantityComputableFixed(quantity);
        long cancelAtMs = Long.MAX_VALUE;
        Duration timeInForce = Duration.GoodTilCancel;
        OrderProcessorMarket processor = new OrderProcessorMarket(time, symbol);
View Full Code Here

        assertEquals(Integer.valueOf(-quantity),portfolio.position("GG").quantity());
        assertEquals(new BigDecimal("-60"),portfolio.equity(dataProvider));

        //Buy to cover this short position

        SignalAction action = SignalAction.BTC;
        order = new Order(null, id,instrument,symbol,action,quantityComputable,cancelAtMs,timeInForce,processor, null);

        processed = processor.process(dataProvider, portfolio, commission, order, action, quantityComputable, null);

        assertTrue(processed);
View Full Code Here

        int id = 42;
        long time = stop;
        Instrument instrument = Instrument.Forex;
        String symbol = "GG";
        SignalAction action = SignalAction.BTO;
        Integer quantity = 10;
        QuantityComputable quantityComputable = new QuantityComputableFixed(quantity);
        long cancelAtMs = Long.MAX_VALUE;
        Duration timeInForce = Duration.GoodTilCancel;
        OrderProcessorMarket processor = new OrderProcessorMarket(time, symbol);
View Full Code Here

        int id = 42;
        long time = stop;
        Instrument instrument = Instrument.Forex;
        String symbol = "GG";
        SignalAction action = SignalAction.BTO;
        Integer quantity = 10;
        QuantityComputable quantityComputable = new QuantityComputableFixed(quantity);
        long cancelAtMs = Long.MAX_VALUE;
        Duration timeInForce = Duration.GoodTilCancel;
View Full Code Here

        assertEquals(Integer.valueOf(-quantity),portfolio.position("GG").quantity());
        assertEquals(new BigDecimal("-60"),portfolio.equity(dataProvider));

        //Buy to cover this short position

        SignalAction action = SignalAction.BTC;
        OrderProcessorLimit buyProcessor = new OrderProcessorLimit(time,symbol,buyBelow);
        order = new Order(null, id,instrument,symbol,action,quantityComputable,cancelAtMs,timeInForce,buyProcessor,null);

        processed = buyProcessor.process(dataProvider, portfolio, commission, order, action, quantityComputable,null);
        expectedCash = expectedCash.subtract(expectedBuy.multiply(new BigDecimal(quantity))).subtract(commission);
View Full Code Here

TOP

Related Classes of com.collective2.signalEntry.adapter.IterableXMLEventReader

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.