Example #1
0
        protected void algoStop(IWrite iWrite, string cmdName, object[] cmdArguments)
        {
            if (IsLogged(iWrite))
            {
                //stop and dispose algo
                if (algoMachine != default(Algo.Base))
                {
                    algoMachine.StopGracefull();
                    DataCollector.rezefProducer.RemoveConsumer(algoMachine);
                    algoMachine.Dispose();
                    algoMachine = default(Algo.Base);
                }
                //stop and dispose OrderFSM
                if (rezefOrderFSM != default(FMRShell.RezefOrderFSM))
                {
                    rezefOrderFSM.Dispose();
                    rezefOrderFSM = default(FMRShell.RezefOrderFSM);
                }

                //TODO - test if there is no other users, before calling DataCollector.Stop
                if (DataCollector != default(FMRShell.Collector))
                {
                    DataCollector.Stop(FMRShell.DataType.Rezef);
                }
            }
        }
        protected void algoStop(IWrite iWrite, string cmdName, object[] cmdArguments)
        {
            if (IsLogged(iWrite))
            {
                //stop and dispose algo
                if (algoMachine != default(Algo.Base))
                {
                    algoMachine.StopGracefull();
                    DataCollector.rezefProducer.RemoveConsumer(algoMachine);
                    algoMachine.Dispose();
                    algoMachine = default(Algo.Base);
                }
                //stop and dispose OrderFSM
                if (rezefOrderFSM != default(FMRShell.RezefOrderFSM))
                {
                    rezefOrderFSM.Dispose();
                    rezefOrderFSM = default(FMRShell.RezefOrderFSM);
                }

                //TODO - test if there is no other users, before calling DataCollector.Stop
                if (DataCollector != default(FMRShell.Collector))
                    DataCollector.Stop(FMRShell.DataType.Rezef);
            }
        }
        /// <summary>
        /// Create Algo object and connect it to the data feed
        /// Data feed can be a playback or real-time data feed
        /// </summary>
        protected void algoStart(IWrite iWrite, string cmdName, object[] cmdArguments)
        {
            if (IsLogged(iWrite))
            {
                if (algoMachine != null)
                {
                    iWrite.WriteLine("Stop the algo first");
                    return;
                }

                bool argsRes = true;
            #if USEFMRSIM
                string backlogfile = null;
                double speedup = 1.0;
            #endif
                // parse arguments
                switch (cmdArguments.Length)
                {
            #if USEFMRSIM
                    case 0:
                    case 1:
                        iWrite.WriteLine("Usage: <backlogfile> [speedup]");
                        argsRes = false;
                        break;

                    case 2:
                        backlogfile = cmdArguments[1].ToString();
                        break;

                    case 3:
                        backlogfile = cmdArguments[1].ToString();
                        speedup = JQuant.Convert.StrToDouble(cmdArguments[2].ToString(), 1.0);
                        break;
            #endif

                    default:
                        iWrite.WriteLine("Too many arguments");
                        argsRes = false;
                        break;
                }

                if (!argsRes) return;

                // if i run in simulation mode create playback
            #if USEFMRSIM
                // create Rezef data generator
                TaskBarLibSim.EventGenerator<K300RzfType> dataGenerator =
                    new TaskBarLibSim.RezefDataGeneratorLogFile(backlogfile, speedup, 500);

                // setup the data generator(s) in the K300Class
                TaskBarLibSim.K300Class.InitStreamSimulation(dataGenerator);
            #endif

                // Create data collector if not created already.
                // Do not set internal time stamps, use time stamps from the recorded data log
                if (DataCollector == null)
                    DataCollector = new FMRShell.Collector(this.fmrConection.GetSessionId(), false);

                // create Order FSM
                rezefOrderFSM = new RezefOrderFSM(this.fmrConection);
                rezefOrderFSM.Start();

                // create Algo
                if (algoMachine == null)
                    algoMachine = new Algo.Base(rezefOrderFSM);

                // connect algo to the data feed
                DataCollector.rezefProducer.AddConsumer(algoMachine);

                // start data collector, which will start the stream in K300Class
                DataCollector.Start(FMRShell.DataType.Rezef);

                // start algo - can be also done afterwards, by calling Start
                algoMachine.Start();
            }
        }
Example #4
0
        /// <summary>
        /// Create Algo object and connect it to the data feed
        /// Data feed can be a playback or real-time data feed
        /// </summary>
        protected void algoStart(IWrite iWrite, string cmdName, object[] cmdArguments)
        {
            if (IsLogged(iWrite))
            {
                if (algoMachine != null)
                {
                    iWrite.WriteLine("Stop the algo first");
                    return;
                }

                bool argsRes = true;
#if USEFMRSIM
                string backlogfile = null;
                double speedup     = 1.0;
#endif
                // parse arguments
                switch (cmdArguments.Length)
                {
#if USEFMRSIM
                case 0:
                case 1:
                    iWrite.WriteLine("Usage: <backlogfile> [speedup]");
                    argsRes = false;
                    break;

                case 2:
                    backlogfile = cmdArguments[1].ToString();
                    break;

                case 3:
                    backlogfile = cmdArguments[1].ToString();
                    speedup     = JQuant.Convert.StrToDouble(cmdArguments[2].ToString(), 1.0);
                    break;
#endif

                default:
                    iWrite.WriteLine("Too many arguments");
                    argsRes = false;
                    break;
                }

                if (!argsRes)
                {
                    return;
                }


                // if i run in simulation mode create playback
#if USEFMRSIM
                // create Rezef data generator
                TaskBarLibSim.EventGenerator <K300RzfType> dataGenerator =
                    new TaskBarLibSim.RezefDataGeneratorLogFile(backlogfile, speedup, 500);

                // setup the data generator(s) in the K300Class
                TaskBarLibSim.K300Class.InitStreamSimulation(dataGenerator);
#endif

                // Create data collector if not created already.
                // Do not set internal time stamps, use time stamps from the recorded data log
                if (DataCollector == null)
                {
                    DataCollector = new FMRShell.Collector(this.fmrConection.GetSessionId(), false);
                }

                // create Order FSM
                rezefOrderFSM = new RezefOrderFSM(this.fmrConection);
                rezefOrderFSM.Start();

                // create Algo
                if (algoMachine == null)
                {
                    algoMachine = new Algo.Base(rezefOrderFSM);
                }

                // connect algo to the data feed
                DataCollector.rezefProducer.AddConsumer(algoMachine);

                // start data collector, which will start the stream in K300Class
                DataCollector.Start(FMRShell.DataType.Rezef);

                // start algo - can be also done afterwards, by calling Start
                algoMachine.Start();
            }
        }