示例#1
0
        /// <summary>
        /// Reset histsim and simbroker
        /// </summary>
        public virtual void Reset()
        {
            try
            {
                // try unbind, swallow exception
                UnbindStrategy(ref _strategy);

                if (_strategy != null)
                {
                    _strategy.Reset();
                }

                _histsim = new MultiSim(_tickfiles.ToArray());
                _histsim.Initialize();
                _histsim.GotTickHandler  += new Action <Tick>(_histsim_GotTick);
                _histsim.GotDebugHandler += new Action <string>(_histsim_GotDebugHandler);

                _simbroker = new Broker();
                _simbroker.UseBidAskFills                  = _usebidaskfill;
                _simbroker.AdjustIncomingTickSize          = _adjustincomingticksize;
                _simbroker.GotOrderHandler                += new Action <Order>(_broker_GotOrder);
                _simbroker.GotOrderCancelBroadcastHandler += new Action <string, bool, long>(_broker_GotOrderCancel);
                _simbroker.GotFillHandler                 += new Action <Trade>(_broker_GotFill);

                BindStrategy(ref _strategy);

                _isbusy = false;
            }

            catch
            {
                _isbusy = true;
                Debug("Backtest engine initialization failed.");
            }
        }
        /// <summary>
        /// Reset histsim and simbroker
        /// </summary>
        public virtual void Reset()
        {
            try
            {
                // try unbind, swallow exception
                UnbindStrategy(ref _strategy);

                if (_strategy != null)
                    _strategy.Reset();

                _histsim = new MultiSim(_tickfiles.ToArray());
                _histsim.Initialize();
                _histsim.GotTickHandler += new Action<Tick>(_histsim_GotTick);
                _histsim.GotDebugHandler += new Action<string>(_histsim_GotDebugHandler);

                _simbroker = new Broker();
                _simbroker.UseBidAskFills = _usebidaskfill;
                _simbroker.AdjustIncomingTickSize = _adjustincomingticksize;
                _simbroker.GotOrderHandler += new Action<Order>(_broker_GotOrder);
                _simbroker.GotOrderCancelBroadcastHandler += new Action<string, bool, long>(_broker_GotOrderCancel);
                _simbroker.GotFillHandler += new Action<Trade>(_broker_GotFill);

                BindStrategy(ref _strategy);

                _isbusy = false;
            }

            catch
            {
                _isbusy = true;
                Debug("Backtest engine initialization failed.");
            }  
        }
 void UnbindSim(ref MultiSim h)
 {
     h.GotTickHandler -= new Action<Tick>(_histsim_GotTick);
     h.GotDebugHandler -= new Action<string>(_histsim_GotDebugHandler);
 }
示例#4
0
 void UnbindSim(ref MultiSim h)
 {
     h.GotTickHandler  -= new Action <Tick>(_histsim_GotTick);
     h.GotDebugHandler -= new Action <string>(_histsim_GotDebugHandler);
 }