Package com.collective2.signalEntry.journal

Examples of com.collective2.signalEntry.journal.C2EntryServiceLogFileJournal


    private final DataProvider dataProvider = new DynamicSimulationMockDataProvider(start,open,high,low,close,stop);
    private final BigDecimal commission = new BigDecimal("9");

    @Test
    public void  limitBTOTestOpenOpen() {
        RelativeNumber buyBelow = new RelativeNumber("4");//must buy below this price
        RelativeNumber sellAbove = new RelativeNumber("3");//must sell above this price

        BigDecimal expectedBuy = new BigDecimal("3");
        BigDecimal expectedSell = new BigDecimal("3");

        limitBTOTest(buyBelow, sellAbove, expectedBuy, expectedSell);
View Full Code Here


        limitBTOTest(buyBelow, sellAbove, expectedBuy, expectedSell);
    }

    @Test
    public void  limitBTOTestLimitLimit() {
        RelativeNumber buyBelow = new RelativeNumber("2");//must buy below this price
        RelativeNumber sellAbove = new RelativeNumber("4");//must sell above this price

        BigDecimal expectedBuy = new BigDecimal("2");
        BigDecimal expectedSell = new BigDecimal("4");

        limitBTOTest(buyBelow, sellAbove, expectedBuy, expectedSell);
View Full Code Here

        limitBTOTest(buyBelow, sellAbove, expectedBuy, expectedSell);
    }

    @Test
    public void  limitBTOTestTopTop() {
        RelativeNumber buyBelow = new RelativeNumber("1");//must buy below this price
        RelativeNumber sellAbove = new RelativeNumber("7");//must sell above this price

        BigDecimal expectedBuy = new BigDecimal("1");
        BigDecimal expectedSell = new BigDecimal("7");

        limitBTOTest(buyBelow, sellAbove, expectedBuy, expectedSell);
View Full Code Here

    }

    @Test
    public void  limitSTOTest() {

        RelativeNumber sellAbove = new RelativeNumber("3");//must sell above this price
        RelativeNumber buyBelow = new RelativeNumber("4");//must buy below this price

        BigDecimal expectedSell = new BigDecimal("3");
        BigDecimal expectedBuy = new BigDecimal("3");

        limitShortTest(SignalAction.STO, sellAbove, buyBelow, expectedSell, expectedBuy);
View Full Code Here

    }

    @Test
    public void  limitSShortTest() {

        RelativeNumber sellAbove = new RelativeNumber("4");//must sell above this price
        RelativeNumber buyBelow = new RelativeNumber("2");//must buy below this price

        BigDecimal expectedSell = new BigDecimal("4");
        BigDecimal expectedBuy = new BigDecimal("2");

        limitShortTest(SignalAction.SSHORT, sellAbove, buyBelow, expectedSell, expectedBuy);
View Full Code Here

        //starts out empty
        assertTrue(!journal.pending().hasNext());

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

        //stop journal and force reload from disk
        journal.close();
        journal = new C2EntryServiceLogFileJournal(tempFile,4096);

        assertEquals(request, journal.pending().next());

        ///////////////////////////////
        //successful removal of one request
        journal.markSent(request);

        //stop journal and force reload from disk
        journal.close();
        journal = new C2EntryServiceLogFileJournal(tempFile,4096);

        assertTrue("check file:"+tempFile,!journal.pending().hasNext());

        //////////////////////////////////
        //successful addition of two requests in order
        Request request2 = new Request(Command.Cancel);
        assert(!request.equals(request2));
        journal.append(request);

        //stop journal and force reload from disk
        journal.close();
View Full Code Here

            e.printStackTrace();
            fail();
        }
        C2EntryServiceLogFileJournal journal = new C2EntryServiceLogFileJournal(tempFile,50);

        Request request = new Request(Command.Signal);
        Request request2 = new Request(Command.Cancel);

        journal.append(request);
        journal.markSent(request);

        assertFalse(journal.pending().hasNext());
View Full Code Here

    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

TOP

Related Classes of com.collective2.signalEntry.journal.C2EntryServiceLogFileJournal

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.