Examples of SystemManager


Examples of com.collective2.signalEntry.adapter.dynamicSimulator.SystemManager

    public void tick(DataProvider dataProvider, C2EntryService entryService) {

        //ensure existing requests are submitted.
        entryService.awaitPending();

        SystemManager system = systems.get(entryService.systemId());

        //can not tick and transmit at same moment in order to keep simulator repeatable
        synchronized(lock) {
               //look at ordered list of signals for each system and do all those older than time now.
            this.time = dataProvider.endingTime();
            system.tick(time, dataProvider);
            lastTickDataProvider = dataProvider;
        }

        for(GainListenerManager manager:gainListeners) {
            manager.send(gainExecutor, dataProvider, system);
View Full Code Here

Examples of com.collective2.signalEntry.adapter.dynamicSimulator.SystemManager

    private XMLEventReader simpleTransmit(Request request) {

        logger.trace("transmit "+request.toString());

        synchronized(lock) {
            SystemManager system = null;
            if (request.containsKey(Parameter.SystemId)) {
                system = lookupSystem(request);
                if (system==null) {
                    return new SimulatedResponseError(ERROR,"no system","");
                }
            }

            XMLEventReader xmlEventReader;
            Command command = request.command();
            switch (command) {
                case Signal:

                     long timeToExecute       = extractTimeToExecute(request);
                     int[] signalIdArray      = system.scheduleSignal(timeToExecute,request);
                     int signalId             = signalIdArray[0];
                     int stopLossSignalId     = signalIdArray[1];
                     int profitTargetSignalId = signalIdArray[2];
                     return new SimulatedResponseSignal(signalId,
                                                        stopLossSignalId==SystemManager.NO_ID?null:stopLossSignalId,
                                                        profitTargetSignalId==SystemManager.NO_ID?null:profitTargetSignalId,
                                                        OK);

                case GetBuyPower:
                   //  long lastTickTime = lastTickDataProvider.endingTime();
                     BigDecimal buyPower = system.portfolio().cash().add(system.totalMargin());
                     return new SimulatedResponseGetBuyPower(OK,time,buyPower);

                case Cancel:

                    Integer id = (Integer)request.get(Parameter.SignalId);
                    assert(id>=0) : "DynamicSimulator only uses positive signalIds";

                    system.cancelSignal(id,time);
                    return new SimulatedResponseCancel(OK);

                case CancelAllPending:

                    system.cancelAllPending(time);
                    return new SimulatedResponseCancelAllPending(OK);

                case CloseAllPositions:

                    system.portfolio().closeAllPositions();
                    return new SimulatedResponseCloseAllPositions(OK);

                case FlushPendingSignals:

                    system.flushPendingSignals(lastTickDataProvider);
                    return new SimulatedResponseFlushPendingSignals(OK);

                case AllSignals:
                    //not filled, cancelled or expired!
                    //only for this subscriber
                    String subscriberEmail = (String)request.get(Parameter.EMail);
                    Map<Integer,List<Integer>> allPendingSignals = new HashMap<Integer,List<Integer>>();
                    for(SystemManager sys:systems) {
                        if (sys.isSubscribed(subscriberEmail)) {
                            Integer sysId = sys.id();
                            allPendingSignals.put(sysId,sys.allPendingSignals());
                        }
                    }
                    return new SimulatedResponseGetAllSignals(OK, allPendingSignals);

                case GetSystemEquity:

                    long lastTickTime = lastTickDataProvider.endingTime();
                    Number equity = system.portfolio().equity(lastTickDataProvider);
                    return new SimulatedResponseGetSystemEquity(OK,lastTickTime,equity);

                case GetSystemHypothetical:

                    List<Map<C2Element, Object>> data = new ArrayList<Map<C2Element, Object>>();

                    for(SystemManager sys:systems) {
                        Map<C2Element, Object> map = new HashMap<C2Element, Object>();
                        //populate this map for this system.
                        map.put(C2Element.ElementSystemId, sys.id());
                        map.put(C2Element.ElementSystemName, sys.name());

                        //NOTE: very basic margin calculations where negative cash is margin, should improve some day.
                        BigDecimal sysCash = sys.portfolio().cash();
                        BigDecimal sysEquity = sys.portfolio().equity(lastTickDataProvider);
                        BigDecimal totalEquityAvail = sysCash.add(sysEquity);
                        BigDecimal marginUsed = (sysCash.compareTo(BigDecimal.ZERO)<0 ? sysCash.negate() : BigDecimal.ZERO);

                        map.put(C2Element.ElementTotalEquityAvail, totalEquityAvail);
                        map.put(C2Element.ElementCash, sysCash);
                        map.put(C2Element.ElementEquity, sysEquity);
                        map.put(C2Element.ElementMarginUsed, marginUsed);

                        data.add(map);
                    }

                    return new SimulatedResponseGetSystemHypothetical(data);

                case PositionStatus:

                    String symbol = (String)request.get(Parameter.Symbol);
                    Integer position = system.portfolio().position(symbol).quantity();
                    return new SimulatedResponsePositionStatus(OK,time,symbol,position);

                case RequestOCAId:

                    Integer ocaid = system.generateNewOCAId();
                    return new SimulatedResponseRequestOCAId(ocaid,OK);

                case Reverse:
                    //the same as a signal but its done now and can not be parked
                    Integer reverseId = system.scheduleSignal(time, request)[0];
                    return new SimulatedResponseReverse(OK);

                case SendSubscriberBroadcast:

                    String email = (String)request.get(Parameter.EMail);
                    String message = (String)request.get(Parameter.Message);
                    system.sendSubscriberBroadcast(email,message);
                    return new SimulatedResponseSendSubscriberBroadcast(OK);

                case SetMinBuyPower:

                    Number minBuyPower = (Number)request.get(Parameter.BuyPower);
                    system.minBuyPower(minBuyPower);
                    return new SimulatedResponseSetMinBuyPower(OK);

                case NewComment:

                    Integer signalIdForComment = (Integer)request.get(Parameter.SignalId);
                    String comment   = (String)request.get(Parameter.Commentary);
                    String previousComment = system.newComment(signalIdForComment,comment);
                    return new SimulatedResponseNewComment(OK,signalIdForComment,previousComment);

                case AllSystems:     //lookup the systems here
                    throw new UnsupportedOperationException("Not implemented at this time");

                case AddToOCAGroup:   //lookup existing signalid and add it to this existing oca group
                    throw new UnsupportedOperationException("Not implemented at this time");

                case SignalStatus:

                    Integer signalIdInput = (Integer)request.get(Parameter.SignalId);
                    Integer systemId = SystemManager.extractSystemId(signalIdInput);

                    SystemManager systemForSignal = systems.get(systemId);


                    String signalSubscriberEmail = (String)request.get(Parameter.EMail);
                    boolean isSubscribed = systemForSignal.isSubscribed(signalSubscriberEmail);
                    if (!isSubscribed) {
                        return new SimulatedResponseError(ERROR,"email not subscribed",signalSubscriberEmail);
                    }

                    String subscriberPassword = (String)request.get(Parameter.Password);
                    boolean isSystemPassword = systemForSignal.isPassword(signalSubscriberEmail,subscriberPassword);
                    if (!isSystemPassword) {
                        return new SimulatedResponseError(ERROR,"not system password",signalSubscriberEmail);
                    }

                    Order order = systemForSignal.lookupOrder(signalIdInput);

                    String systemName = systemForSignal.name();
                    String postedwhen = order.postedWhen();
                    String emailedWhen = order.eMailedWhen();
                    String killedWhen = order.killedWhen();
                    String tradedWhen = order.tradedWhen();
                    BigDecimal tradePrice = order.tradePrice();
View Full Code Here

Examples of com.collective2.signalEntry.adapter.dynamicSimulator.SystemManager

        String password = (String)request.get(Parameter.Password);
        Integer systemId = (Integer)request.get(Parameter.SystemId);
        if (systemId>systems.size()) {
            return null;
        }
        SystemManager system = systems.get(systemId);
        if (system.isPassword(password)) {
            return system;
        } else {
            return null;
        }
View Full Code Here

Examples of com.collective2.signalEntry.adapter.dynamicSimulator.SystemManager

    public synchronized Integer createSystem(String name, String password, Portfolio portfolio, BigDecimal commission) {

        Integer systemId = systems.size();

        SystemManager system = new SystemManager(portfolio, systemId, name, password, commission, marginAccount);

        systems.add(system);

        return systemId;
    }
View Full Code Here

Examples of com.collective2.signalEntry.adapter.dynamicSimulator.SystemManager

        return systemId;
    }

    public void subscribe(String eMail, Integer systemId, String userPassword) {
        SystemManager system = systems.get(systemId);
        system.subscribe(eMail, userPassword);
    }
View Full Code Here

Examples of fb.rt.tools.SystemManager

    FBJPreferences.loadPrefs("launcher.ini");
    FileLibrary.initStatic();
    FBELibrarySpec.library = new FileLibrary();
    SystemLogger logger = new SystemLogger();
    SystemManager mgr = new FBenchSystemManager(logger);
    try {
      FBELibrarySpec spec = FBELibrarySpec.load(new FileReader(args[args.length - 1]), true);
      mgr.launch(spec, FBJPreferences.getBounds());
    } catch (Exception e) {
      logger.log(e);
     
      System.exit(-1);
    }
View Full Code Here

Examples of org.apache.avalon.phoenix.interfaces.SystemManager

     * Register embeddor and it's components to <code>SystemManager</code>.
     */
    private void registerComponents()
        throws Exception
    {
        final SystemManager systemManager =
            (SystemManager)getServiceManager().lookup( SystemManager.ROLE );

        final SystemManager componentManager =
            systemManager.getSubContext( null, "component" );

        componentManager.register( ManagementRegistration.EMBEDDOR.getName(),
                                   this,
                                   ManagementRegistration.EMBEDDOR.getInterfaces() );

        for( int i = 0; i < m_entries.length; i++ )
        {
            final ManagementRegistration registration =
                ManagementRegistration.getManagementInfoForRole( m_entries[ i ].getRole() );
            if( null != registration )
            {
                componentManager.register( registration.getName(),
                                           m_entries[ i ].getObject(),
                                           registration.getInterfaces() );
            }
        }
    }
View Full Code Here

Examples of org.apache.avalon.phoenix.interfaces.SystemManager

     * Unregister embeddor and it's components from <code>SystemManager</code>.
     */
    private void unregisterComponents()
        throws Exception
    {
        final SystemManager systemManager =
            (SystemManager)getServiceManager().lookup( SystemManager.ROLE );

        final SystemManager componentManager = systemManager.getSubContext( null, "component" );

        componentManager.unregister( ManagementRegistration.EMBEDDOR.getName() );

        for( int i = 0; i < m_entries.length; i++ )
        {
            final ManagementRegistration registration =
                ManagementRegistration.getManagementInfoForRole( m_entries[ i ].getRole() );
            if( null != registration )
            {
                componentManager.unregister( registration.getName() );
            }
        }
    }
View Full Code Here

Examples of org.apache.avalon.phoenix.interfaces.SystemManager

            throw new ManagerException( message );
        }

        // get from list if possible
        final String key = contextKey( name, type );
        SystemManager subcontext =
            (SystemManager)m_subcontexts.get( key );

        // otherwise create and add to list
        if( subcontext == null )
        {
View Full Code Here

Examples of org.apache.avalon.phoenix.interfaces.SystemManager

     *  TODO: context should probably be passed in by reference from the kernel
     */
    private SystemManager getManagementContext()
        throws ManagerException
    {
        final SystemManager appContext =
            m_systemManager.getSubContext( null, "application" );
        return appContext.getSubContext( m_metaData.getName(), "block" );
    }
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.