Package com.collective2.signalEntry

Examples of com.collective2.signalEntry.Duration


        Portfolio portfolio = new SimplePortfolioFactory().createPortfolio(new BigDecimal("10000"));
        BigDecimal commission = new BigDecimal("10.00");
        Integer systemId = simulationAdapter.createSystem("first system",password,portfolio,commission);
        simulationAdapter.subscribe(eMail,systemId,password);
        C2ServiceFactory factory = new C2ServiceFactory(simulationAdapter);
        C2EntryService sentryService = factory.signalEntryService(password, systemId, eMail);

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

        Signal msft = sentryService.stockSignal(ActionForStock.BuyToOpen)
                .quantity(10).symbol("msft")
                .stopLoss(base, stopSize)
                .duration(Duration.GoodTilCancel);
        if (isLimit) {
            msft = msft.limitOrder(triggerPrice);
        } else {
            msft = msft.stopOrder(triggerPrice);
        }

        Response openResponse = msft.send();

        Integer signalId = openResponse.getInteger(C2Element.ElementSignalId);

        assertEquals(0,signalId.intValue());


        simulationAdapter.tick(dataProvider,sentryService);

        HashSet<Integer> pending = sentryService.sendAllSignalsRequest()
                                                   .collectIntegers(new HashSet<Integer>(),
                                                                    C2Element.ElementSignalId);

        assertEquals(expectedPendingCount, pending.size());
        Integer id = pending.iterator().next();

        BigDecimal stop = sentryService.sendSignalStatusRequest(id,true).getBigDecimal(C2Element.ElementStop);
        assertEquals(expectedStop,stop);

    }
View Full Code Here


        String eMail = "someone@somewhere.com";
        Portfolio portfolio = new SimplePortfolioFactory().createPortfolio(new BigDecimal("10000"));
        BigDecimal commission = new BigDecimal("10.00");
        Integer systemId = simulationAdapter.createSystem("first system",password,portfolio,commission);
        simulationAdapter.subscribe(eMail,systemId,password);
        C2ServiceFactory factory = new C2ServiceFactory(simulationAdapter);
        C2EntryService sentryService = factory.signalEntryService(password, systemId, eMail);

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

        Signal msft = sentryService.stockSignal(ActionForStock.BuyToOpen)
                .quantity(10).symbol("msft")
View Full Code Here

        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);
        Order order = new Order(null, id,instrument,symbol,action,quantityComputable,cancelAtMs,timeInForce,processor, null);

        //test only the processor and do it outside the order
        boolean processed = processor.process(dataProvider, portfolio, commission, order, action, quantityComputable, null);
View Full Code Here

        Instrument instrument = Instrument.Forex;
        String symbol = "GG";
        Integer quantity = 10;
        QuantityComputable quantityComputable = new QuantityComputableFixed(quantity);
        long cancelAtMs = Long.MAX_VALUE;
        Duration timeInForce = Duration.GoodTilCancel;
        OrderProcessorMarket processor = new OrderProcessorMarket(time, symbol);
        Order order = new Order(null, id,instrument,symbol,sellAction,quantityComputable,cancelAtMs,timeInForce,processor, null);

        //test only the processor and do it outside the order
        boolean processed = processor.process(dataProvider, portfolio, commission, order, sellAction, quantityComputable, null);
View Full Code Here

        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);
        Order buyOrder = new Order(null, id,instrument,symbol,action,quantityComputable,cancelAtMs,timeInForce,processor, null);

        //final quantity is not known until this order is processed
        //this however has the quantity because QuantityComputableFixed is used above
View Full Code Here

        String symbol = "GG";
        SignalAction action = SignalAction.BTO;
        Integer quantity = 10;
        QuantityComputable quantityComputable = new QuantityComputableFixed(quantity);
        long cancelAtMs = Long.MAX_VALUE;
        Duration timeInForce = Duration.GoodTilCancel;


        OrderProcessorLimit processor = new OrderProcessorLimit(time, symbol, buyBelow);
        Order order = new Order(null,id,instrument,symbol,action,quantityComputable,cancelAtMs,timeInForce,processor,null);
View Full Code Here

        Instrument instrument = Instrument.Forex;
        String symbol = "GG";
        Integer quantity = 10;
        QuantityComputable quantityComputable = new QuantityComputableFixed(quantity);
        long cancelAtMs = Long.MAX_VALUE;
        Duration timeInForce = Duration.GoodTilCancel;

        OrderProcessorLimit processor = new OrderProcessorLimit(time,symbol,sellAbove);
        Order order = new Order(null, id,instrument,symbol,sellAction,quantityComputable,cancelAtMs,timeInForce,processor,null);

        //test only the processor and do it outside the order
View Full Code Here

                //use to compute quantity
                QuantityComputable quantityComputable = quantityFactory.computable(request,this);

                //GTC or Day
                Duration timeInForce = (Duration)request.get(Parameter.TimeInForce);

                //cancel at this fixed time
                long cancelAtMs = Long.MAX_VALUE;
                Number cancelAt = (Number)request.get(Parameter.CancelsAt);
                if (cancelAt != null) {
View Full Code Here

                int quantity = order.quantity();
                String symbol = order.symbol();
                BigDecimal limit = order.limit(); //original signal value unless its relative in which case its not available
                BigDecimal stop = order.stop()//original signal value unless its relative in which case its not available
                BigDecimal market = order.market();
                Duration duration = order.timeInForce();
                Integer ocaGroupId = order.oneCancelsAnother();

                queue.add(eventFactory.createStartElement("", "", "action"));
                queue.add(eventFactory.createCharacters(action.toString()));
                queue.add(eventFactory.createEndElement("", "", "action"));

                queue.add(eventFactory.createStartElement("", "", "quant"));
                queue.add(eventFactory.createCharacters(Integer.toString(quantity)));
                queue.add(eventFactory.createEndElement("", "", "quant"));

                queue.add(eventFactory.createStartElement("", "", "symbol"));
                queue.add(eventFactory.createCharacters(symbol));
                queue.add(eventFactory.createEndElement("", "", "symbol"));

                queue.add(eventFactory.createStartElement("", "", "limit"));
                queue.add(eventFactory.createCharacters(limit.toString()));
                queue.add(eventFactory.createEndElement("", "", "limit"));

                queue.add(eventFactory.createStartElement("", "", "stop"));
                queue.add(eventFactory.createCharacters(stop.toString()));
                queue.add(eventFactory.createEndElement("", "", "stop"));

                queue.add(eventFactory.createStartElement("", "", "market"));
                queue.add(eventFactory.createCharacters(market.toString()));
                queue.add(eventFactory.createEndElement("", "", "market"));

                queue.add(eventFactory.createStartElement("", "", "tif"));
                queue.add(eventFactory.createCharacters(duration.toString()));
                queue.add(eventFactory.createEndElement("", "", "tif"));

                queue.add(eventFactory.createStartElement("", "", "ocagroupid"));
                queue.add(eventFactory.createCharacters(ocaGroupId==null?"":ocaGroupId.toString()));
                queue.add(eventFactory.createEndElement("", "", "ocagroupid"));
View Full Code Here

        String symbol = "GG";
        SignalAction action = SignalAction.BTO;
        Integer quantity = 10;
        QuantityComputable quantityComputable = new QuantityComputableFixed(quantity);
        long cancelAtMs = Long.MAX_VALUE;
        Duration timeInForce = Duration.GoodTilCancel;


        OrderProcessorStop processor = new OrderProcessorStop(time, symbol, buyBelow);
        Order order = new Order(null, id,instrument,symbol,action,quantityComputable,cancelAtMs,timeInForce,processor,null);
View Full Code Here

TOP

Related Classes of com.collective2.signalEntry.Duration

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.