Package com.collective2.signalEntry.implementation

Examples of com.collective2.signalEntry.implementation.RelativeNumber


    }

    @Test
    public void  stopSTOTest() {

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

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

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


    }

    @Test
    public void  stopSShortTest() {

        RelativeNumber sellAbove = new RelativeNumber("2");//must sell BELOW this price
        RelativeNumber buyBelow = new RelativeNumber("2");//must buy ABOVE this price

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

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

    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

                }

                Order signal;
                //convert everything to relatives, should have already been relatives?
                RelativeNumber limit = (RelativeNumber)request.get(Parameter.RelativeLimitOrder);
                if (limit != null) {
                    OrderProcessor limitProcessor = new OrderProcessorLimit(timeToExecute, symbol,limit);
                    signal = new Order(this, id, instrument, symbol, action, quantityComputable, cancelAtMs, timeInForce,limitProcessor,conditionalUponOrder);
                else {
                    RelativeNumber stop = (RelativeNumber)request.get(Parameter.RelativeStopOrder);
                    if (stop != null) {
                        OrderProcessor stopProcessor = new OrderProcessorStop(timeToExecute, symbol,stop);
                        signal = new Order(this, id, instrument, symbol, action, quantityComputable, cancelAtMs, timeInForce, stopProcessor,conditionalUponOrder);
                    } else {
                        //market
                        OrderProcessor marketProcessor = new OrderProcessorMarket(timeToExecute, symbol);
                        signal = new Order(this, id, instrument, symbol, action, quantityComputable, cancelAtMs, timeInForce, marketProcessor,conditionalUponOrder);
                    }
                }

                Integer ocaId = (Integer)request.get(OCAId);
                if (ocaId!=null) {
                    signal.oneCancelsAnother(ocaId);
                    //add this signal to the group under this ocaId
                    ocaMap.get(ocaId).add(signal);
                }
                order = signal;
            }

            //must be done before adding the all-in-one stop or target because they must also be added
            archive.add(order);//needed for long term lookup by id order
            scheduled.add(order);//needed for processing by time order

            Integer ocaId = null;

            RelativeNumber stopLoss = (RelativeNumber)request.get(Parameter.RelativeStopLoss);
            RelativeNumber profitTarget = (RelativeNumber)request.get(RelativeProfitTarget);

            Integer forceNoOCA = (Integer)request.get(ForceNoOCA);
            if ((forceNoOCA==null || forceNoOCA.intValue()!=1) && (null!=stopLoss) && (null!=profitTarget)) {
                ocaId = generateNewOCAId();
            }
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

TOP

Related Classes of com.collective2.signalEntry.implementation.RelativeNumber

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.