Package com.collective2.signalEntry.adapter.dynamicSimulator.portfolio

Examples of com.collective2.signalEntry.adapter.dynamicSimulator.portfolio.Portfolio.position()


        dataProvider = dataProvider.incTime(timeStep,new BigDecimal("13"));
        simulationAdapter.tick(dataProvider,sentryService);

        updateSetWithPendingSignalIds(sentryService, pendingSignalIdSet);

        assertEquals(10, portfolio.position("msft").quantity().intValue());

        assertTrue(pendingSignalIdSet.contains(newCloseSignalId));

        //get signal details
        assertEquals(Integer.valueOf(10),sentryService.sendSignalStatusRequest(newCloseSignalId,true).getInteger(C2Element.ElementQuant));
View Full Code Here


            assertEquals(1,pendingSignalIdSet.size());
        }

        dataProvider = dataProvider.incTime(timeStep,new BigDecimal("9"));
        simulationAdapter.tick(dataProvider,sentryService);
        assertEquals(0, portfolio.position("msft").quantity().intValue());

        //for oca orders the other order will get cancelled when the first is triggered.
        //for non oca orders there will be one closing order however it should not be valid
        //because its a close against something closed.
View Full Code Here

        validateStartingBalances(systemId, sentryService);

        BigDecimal stopLoss = new BigDecimal("20.50");
        BigDecimal profitTarget = new BigDecimal("120.50");

        assertEquals(0, portfolio.position("msft").quantity().intValue());

        Response openResponse = sentryService.stockSignal(ActionForStock.BuyToOpen)
                .marketOrder().quantity(10).symbol("msft")
                .stopLoss(stopLoss).profitTarget(BasePrice.Absolute,profitTarget,noOCA)
                .duration(timeInForce).send();
View Full Code Here

        dataProvider = dataProvider.incTime(timeStep,new BigDecimal("121"));
        simulationAdapter.tick(dataProvider,sentryService);

        //these tests do not work for DayOrders because all the signals have already expired
        if (timeInForce==Duration.GoodTilCancel) {
            assertEquals(10, portfolio.position("msft").quantity().intValue());

            updateSetWithPendingSignalIds(sentryService, pendingSignalIdSet);

            assertTrue(pendingSignalIdSet.contains(newCloseSignalId));
            if (noOCA) {
View Full Code Here

            } else {
                assertEquals(1,pendingSignalIdSet.size());
            }
            dataProvider = dataProvider.incTime(timeStep,new BigDecimal("161"));
            simulationAdapter.tick(dataProvider,sentryService);
            assertEquals(0, portfolio.position("msft").quantity().intValue());

            //for oca orders the other order will get cancelled when the first is triggered.
            //for non oca orders there will be one closing order however it should not be valid
            //because its a close against something closed.
View Full Code Here

        C2ServiceFactory factory = new C2ServiceFactory(simulationAdapter);
        C2EntryService sentryService = factory.signalEntryService(password, systemId, eMail);

        validateStartingBalances(systemId, sentryService);

        assertEquals(0, portfolio.position("msft").quantity().intValue());
        Response openResponse = sentryService.stockSignal(ActionForStock.BuyToOpen)
                                        .marketOrder().quantity(10).symbol("msft")
                                        .duration(Duration.GoodTilCancel).send();

        Integer signalId = openResponse.getInteger(C2Element.ElementSignalId);
View Full Code Here

        },C2Element.ElementTotalEquityAvail,
          C2Element.ElementCash,
          C2Element.ElementEquity,
          C2Element.ElementMarginUsed);
        assertEquals("expected to check 4 elements",4,checkedElements.size());
        assertEquals(10, portfolio.position("msft").quantity().intValue());

        ///////////////////
        //market order sell test
        ///////////////////
        Response marketOrderResponse = sentryService.stockSignal(ActionForStock.SellToClose)
View Full Code Here

        simulationAdapter.tick(dataProvider,sentryService);

        ////////////////////
        //confirm values
        ///////////////////
        assertEquals(0, portfolio.position("msft").quantity().intValue());
        buyPower = sentryService.buyPower();
        assertEquals(9980d,buyPower.doubleValue(),DELTA);

        systemEquity = sentryService.systemEquity(); //10 * 80.43 = 804.30
        assertEquals(0d,systemEquity.doubleValue(),DELTA);
View Full Code Here

        simulationAdapter.tick(dataProvider,sentryService);

        ////////////////////
        //confirm unchanged values
        ///////////////////
        assertEquals(0, portfolio.position("msft").quantity().intValue());
        buyPower = sentryService.buyPower();
        assertEquals(9980d,buyPower.doubleValue(),DELTA);

        systemEquity = sentryService.systemEquity(); //10 * 80.43 = 804.30
        assertEquals(0d,systemEquity.doubleValue(),DELTA);
View Full Code Here

        simulationAdapter.tick(dataProvider,sentryService);

        ////////////////////
        //confirm changed
        ///////////////////
        BigDecimal entryPrice = portfolio.position("msft").openPrice();
        assertTrue(entryPrice == null || entryPrice.compareTo(successLimit)<=0);

        BigDecimal shares = new BigDecimal("10");
        assertEquals(shares.intValue(), portfolio.position("msft").quantity().intValue());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.