Package com.collective2.signalEntry

Examples of com.collective2.signalEntry.C2ServiceException


                        break;
                    case 'B': //postive
                        number = new BigDecimal(stringValue.substring(4));
                        break;
                    default:
                        throw new C2ServiceException("Unable to parse "+stringValue,false);
                }
                break;
            default:
                prefix = ' ';
                number = new BigDecimal(stringValue);
                if (BigDecimal.ZERO.compareTo(number)>0) {
                    throw new C2ServiceException("Absolute limit values must not be negative.",false);
                }
        }

    }
View Full Code Here


          //  System.out.println(new Date(openTime)+"  ->  "+new Date(time)+" quantity "+quantity+" gain "+totalCost+" price "+openPrice+" to "+price);

        } else {
            if (quantity==0 && totalQuantity==0) {
                throw new C2ServiceException("Can not open position in "+symbol+" of zero quantity", false);
            }
           
            //if (Math.abs(totalCost.doubleValue()) > 1000000) {
            //    throw new C2ServiceException(totalCost+" bad cost "+price+"  "+quantity+" "+commission,false );
            //}
           
            openTime = time;
            if (BigDecimal.ZERO.compareTo(price)>=0 && quantity>0) {
                //this can really happen but it would be expected to be rare, confirm this with a secondary source
                logger.warn("Lost 100% of position due to zero price data for "+symbol+" on "+new Date(time));
            }

            //logger.trace("open new {} position of {} existing "+totalQuantity,symbol,quantity);
        }


        totalQuantity =  totalQuantity + quantity;

   //TODO:off while testing for optimals
//        //watch for big loss/gain
//        BigDecimal pctFlag = new BigDecimal(".5");   //NOTE: hardcoded to only look for losses now
//        if (0==totalQuantity.intValue() && totalCost.doubleValue()<0 && totalCost.abs().compareTo(initialCost.abs().multiply(pctFlag))>0) {
//            System.err.println("LARGE CHANGE:"+symbol+" Gain:"+totalCost+" Invest:"+initialCost+" closing:"+isClosing+" price:"+price+" quantity:"+quantity+" commission:"+commission+" DATE:"+new Date(time)+" openPrice: "+openPrice+" openDate:"+new Date(openTime));
//        }

       // if (verbose) {
       //     System.err.println(new Date(time)+" update portfolio "+symbol +" quantity:"+totalQuantity+" gain:"+totalCost+" flow:"+adj+" "+isClosing);
       // }
        simplePortfolio.updatePortfolio(symbol, totalQuantity, totalCost, totalSellPrice, this, isClosing, duration);

      
        if ((0 == totalQuantity.intValue()) || null == openPrice) {
            openPrice = price;
        }
       
        //TODO: no transactions should ever be this big must track down how this happened.
        if (Math.abs(totalCost.doubleValue()) > 1000000) {
            throw new C2ServiceException(totalCost+" bad cost "+price+"  "+quantity+" "+commission+" init "+initialCost+" totalSale "+totalSellPrice+" date "+new Date(time),false );
        }
        /*
         * WARNING: stats gathering
com.collective2.signalEntry.C2ServiceException: -1661142.6100 bad cost 39.7200  706 10.00 init -1633090.2900 totalSale -28052.3200 date Tue Mar 18 15:00:00 CDT 2008
    at com.collective2.signalEntry.adapter.dynamicSimulator.portfolio.SimplePosition.addTransaction(SimplePosition.java:127)
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

        Portfolio portfolio = new SimplePortfolioFactory().createPortfolio(new BigDecimal("1000.00"));

        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;
View Full Code Here

        Portfolio portfolio = new SimplePortfolioFactory().createPortfolio(new BigDecimal("1000.00"));

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

        Portfolio portfolio = new SimplePortfolioFactory().createPortfolio(new BigDecimal("1000.00"));

        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;
View Full Code Here

TOP

Related Classes of com.collective2.signalEntry.C2ServiceException

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.